Abhi Yerra

Rants of lunatic

Archive for April 2006

Python XML Oddities

without comments

I finally figured out how to use xml.dom and create xml documents in Python, but all is not well. For one thing as I was trying to implement the GoogleCalendar API it just became way too verbose. Lots of typing to achieve very little. Although I must say the doc.toprettyxml() that resulted was pretty nice, but it just wasn’t worth all the trouble.

So what am I to do? I have been coding for the last hour instead of doing math homework like I should be. Most of the time making THREE elements for the document. Time for Plan B. Since I already know what the document looks like it should be good if I just use something to load the ready made text instead of creating it from scratch. Once I do that I can manipulate the text at will.

I can also use something like xmltramp to achieve this. Well what’s the moral of this story? Plan out the estimated time it will take to implement things before actually doing it. That way you avoid lots of work refactoring. Also think of the different options before going foward. Also, if you have to study for quizes that is more important then coding!

Written by abhiyerra

April 26, 2006 at 2:27 am

Posted in all

Revision Control

without comments

I have been using Subversion quite a bit recently. I put all my code in the repository and it is nice knowing that the code is there and not worrying about losing changes. Its a great discovery that has made development quite a bit easier. I write a deploy script and voila it automatically deploys the version onto the server. I feel like a kid talking about candy, so I will stop. I made a new link above called Coding that points to the repository. Enjoy!

Written by abhiyerra

April 24, 2006 at 9:05 pm

Posted in all

Googie the Python GoogleLogin

without comments

The code for the GoogleLogin authentication and Google Calendar API. This is still under development, but I added the ability to add an event to the calendar. I will add more code as I have more time.

Current TODO includes:

  1. Time so you don’t have to manually enter the time each time.
  2. Query events in a given range.
  3. The other events in the Calendar API.

This should work well and is made under BSD License. Enjoy!

I’d like to thank matt poepping whose code I sort of based this on.

Written by abhiyerra

April 23, 2006 at 7:48 pm

Posted in all

Berkeley Zen Center Experience

without comments

Yesterday I went to the Berkeley Zen Center. It was not my first time, but I went with my Zen Buddhism 130 class. Once there a priest named Raul gave us Zazen instruction it was interesting and I learned a few new things. However, I have trouble keeping my eyes open as he instructed. I need to close my eyes since my eyes either take everything in and get distracted or they keep bouncing which doesn’t give me any concentration.

After he gave instruction we sat for about five minutes. I was sitting in full lotus, and I started getting extreme pain in my legs. So much so that I wanted to move. However, I didn’t because I thought, “What if this is it?” That is my new mantra, “What if this is it?” Everything just fades away, we are going to die we are going to feel pleasure and pain. But what if that pain is all that you feel, or what if that pleasure is all that you feel? I realized that while that pain is there let it be there, when it’s gone it’ll go away on its own accord. So I sat in that position holding onto the pain.

After that while everyone else left I stuck around for the sitting. During the sitting I made the mistake of not facing the wall. Thankfully a person told me to face the wall, at which point I turned around. Mistakes are done, we have to learn sometime. Then after the meditation there was the bowing to the Buddha and chanting of the Heart Sutra.

After that was done I was supposed to bow to my seat and to the sanga, unfortunately I bowed to the sanga both times. Mistakes happen like I said. It is how we learn and the people there were nice so I didn’t feel totally bad, I just fix my mistakes the next time around.

After that I headed back to my dorm and that was my experience at the Zen Center.

Written by abhiyerra

April 21, 2006 at 2:00 pm

Posted in all

Backing Up Directories to Gmail

without comments

I know that I am horrible at backing up data. I never do it! I find it boring and I rather repeat something then backup stuff. However, backing up is important, especially as I found out when you’ve been working on something for six months and in a second all that disappears. So I wrote a script to do this.

Initially I wrote it in Python, but then later moved it to Shell Script. Why did I do this? Well Python is powerful and all, but for a trivial task as backing up a directory it is better to just do it in Shell Script as it is quicker. If you compare the two scripts the shell script is much smaller then that of Python. However, the shell script requires that you have mutt installed.

Alright first thing first. In the script change the BACKUP_DIR and TO variables to the directory to backup and the recipient of the file at GMail. Move the file to something like $HOME/bin. After that’s done you have to enter a new cronjob. To enter it on my system I type: crontab -e at the shell. Once I have entered crontab I add this, which backups at 5am everyday:

0 05 * * * $HOME/bin/backup.sh

Once that is done go to the recipient gmail account and we are to create a filter.

  1. Go to Create Filter at the top.
  2. In the Create a filter view, in the subject type: Schiess Backup
  3. Click next step.
  4. Check the Apply Label checkbox and create a new label backups. Also I recomend that you check the first option: Skip the Inbox. That is unless you want to get the backups in your inbox everyday.

That’s it! Backups everyday!

Written by abhiyerra

April 20, 2006 at 3:39 am

Posted in all

Misunderestimated Email Backup Script

without comments

Another email backup script to rival EvilCoder’s script. So have fun and use it with a cronjob to make it easier. And please change the information in the file so I don’t get a bunch of your backups.

Written by abhiyerra

April 20, 2006 at 3:21 am

Posted in all

Forwarding Email in UNIX

without comments

If you want to forward email to another email address then this should be changed. That is add it to .procmailrc.

:0
* ^TO.*
! your_logname@other.domain

Written by abhiyerra

April 19, 2006 at 12:50 am

Posted in all

Message Sent to Chris Young

without comments

This is a reply I sent in response to my two comparisson posts. If anyone else was offended this is for you too. Thank you.

I’m sorry if I came out too strong in my blog. I didn’t mean to say that they were wrong in anyway. Because the teachings adapted to the place they went. Like Chan/Zen when it went to China and Japan adapted to the rituals and it works and that’s what’s great about Buddhism.

Different traditions of Buddhim are like differnent icings of the same cake. So I agree that we shouldn’t waste arguing. My entries were not meant to be against or for the differnt traditions, much more they were supposed to be for me to differentiate why I choose Theravada instead of the other traditions.

But I believe that the different traditions provide something great by themselves. Zen focused mostly on zazen, Mahayana focused on compassion, Theravada focused on simplicity. Each provide something or the same thing, just said differently.

I agree fully that I should write less about these pointless comparisons and just sit. After all comparing different chocolate cakes with different icings isn’t as fun as eating them. Along the way people prefer different icings or a little differences in the way things are taught.

And yes I agree that the Buddha taught to question authority. I am not an authority in anyway and you are totally right to question me. And I wholeheartedly thank you for that. After all why the hell should you listen to me?

But in my posts I wasn’t comparing the teachings as much as the history of where each tradition came from. It does not matter to me much what tradition people follow as long as they are practicing.

So once again sorry about these comparisons. Thank you.

Written by abhiyerra

April 14, 2006 at 1:21 pm

Posted in all

Python Email Backup Script

without comments

EvilCoder’s Perl Email Backup script now has competition!


import os
import smtplib
import tarfile
from email import Encoders
from email.MIMEBase import MIMEBase
from email.MIMEMultipart import MIMEMultipart

SENDER = 'sender@mailplace'
RECIPIENT = 'reciever@mailplace'
BACKUP_DIR = '/path/to/backup'
BACKUP_FILE = 'backup.tar.bz2'
SERVER = 'localhost'

tar = tarfile.open(BACKUP_FILE, 'w:bz2')
for name in os.listdir(BACKUP_DIR): if not name == BACKUP_FILE: tar.add(name)
tar.close()

msg = MIMEMultipart()
msg['From'] = SENDER
msg['To'] = RECIPIENT
msg['Subject'] = 'Backup of %s' % BACKUP_DIR

part = MIMEBase('application', 'octet-stream')
part.set_payload(open(BACKUP_FILE, 'rb').read())
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="%s"'
% os.path.basename(BACKUP_FILE))
msg.attach(part)

smtp = smtplib.SMTP(SERVER)
smtp.sendmail(SENDER, RECIPIENT, msg.as_string())
smtp.close()

os.remove(BACKUP_FILE)

Written by abhiyerra

April 12, 2006 at 2:55 pm

Posted in all

Theravada Buddhism

with one comment

As I have studied Buddhism more and more I find that Theravadan Buddhism is what makes the most sense to me. I have looked into the Mahayana tradition and it does not have the same appeal as that of Theravada.

About six centuries after the Buddha reached parinirvana there started to be a division among Buddhism with a new sect called Mahayana (Large Vechicle) that called everyone else Hinayana (Small Vechicle). This is because in the Mahayana tradition people are supposed to hold off their full enlightenment and follow the path of the Bodhisattva. That is a person who holds off their enlightenment so they can out of compassion help others attain enlightenment as well.

So far I do not see any problem and later on Theravada forms from one of the Hinayana schools trying to be as orthodox as possible to the original Buddha’s teachings. Mahayana however comes up with an elaborate system of new teachings on emptiness, new sutras and etc. Although the teachings may have merit, they should not have been given as high an authority as the Buddha’s words in the Tipitaka.

So then why is Theravada any better? Theravada is as close orthodox Buddhism as possible since it does not add any new text that were not part of the Buddha’s words. That is the traditions of Theravada are what the Buddha did in his time without these new additions that give a different interpretation to what the Buddha taught.

Some may argue that Theravadan Buddhism has not evolved with the times like Mahayana. It is true to a certain extent, but things are improving as Theravada is gaining a footing in the West.

Written by abhiyerra

April 12, 2006 at 1:36 pm

Posted in all