Bitten by twitter

It was recently that I decided to check out this cool microblogging site thanks to geekandpoke and my friend Swaroop . Twitter has this concept that, when you 'follow' someone, you get know by minute updates on the things that they do. When you 'tweet' it means that you just update what you are doing now. So if I was tweeting now, I would something like 'blogging about twitter'. To know more -> twitter help.


Twittering with python

Twitter is a cool micro blogging site, with many people updating their day to day activities on a minute by minute basis. So what if we could get as well as post updates in a neat way. The possibilities are endless. One possible scenario would be, If you have a firewall, your firewall could 'tweet' every time it is targeted by an attacker. So people around the world( who follow you) would get to know the attack process in real time !!!

Now lets try to programmatically read and then post a few tweets using python.

So lets get started,

The first site would ofcourse be the python section of twitter api library - http://apiwiki.twitter.com/Libraries#Python

In the next 4 steps, lets see how we could post a tweet in twitter

1. First download the wrapper python twitter.

2. Run > cmd. Go to the folder where you have downloaded python twitter( as mentioned in step 1 ) and Fire up python

3. Type
>>> import twitter

4. If you want to get latest tweets of someone, then the type the following

>>> client = twitter.Api()
>>> latest_posts = client.GetUserTimeline("yourusername")
>>> print [s.text for s in latest_posts]

5. If you want to post your own tweets, then type the following

>>> client = twitter.Api(username='yourusername', password='yourpassword')
>>> update = client.PostUpdate('The Twitter API is easy')


Other cool twitter api wrappers

Hang on buddies, more updates coming soon.

Labels:

News aggreagator in Python

Hi,
Following are some of the links I came across while trying to make a python based rss aggregator. Although the following resources(links) can guide to some really cool stuff, my plan is to have a python based rss aggregator customized to present information in some really cool ways like depending on my usage, tell me which news i like the most and present those and so on. If they are really nice info, I should be able to send it to my news group > uit_tvm, by just a click of a button. I will keep you guys updated on the status of the project.

As per current requirements, the project has 2 parts
1. Python parser - which fetches rss feeds from sites
2. Email the feeds to uit_tvm - either I need to run my own email server(which is really cool ) or I need to access GMail/Yahoomail using python API provided by yahoo.

So the following links to point to the above mentioned ideas.

Email APIs
Send email in python
http://www.daniweb.com/forums/thread136280.html

Accessing your Gmail inbox with Pythonhttp://www.holovaty.com/blog/archive/2004/06/18/1751
libgmail — Python binding

SendYmail
http://sendymail.sourceforge.net/

About BBauth required for yahoo mail APIhttp://www.isolani.co.uk/blog/web/LondonHackdayBbauthAndYahooMail

for Google's Gmail service
http://libgmail.sourceforge.net/

Running your own server
Apache emal serverhttp://en.wikipedia.org/wiki/Apache_James Comparison of mail servershttp://en.wikipedia.org/wiki/Comparison_of_mail_servers

Misc
PyDigg - A Python Toolkit for the Digg API
http://neothoughts.com/2007/04/30/pydigg-a-python-toolkit-for-the-digg-api/







Accessing Yahoo Mail withtout POP
http://bytes.com/forum/thread521242.html

Yahoo! Mail Web Service Code Samples
http://developer.yahoo.com/mail/code/

Labels: , , , ,

Another exciting project

(Now its all starting to fit together - The compiler project I had in my mind for years)


Its a been a dream of mine, for a quite a long time, to write a compiler of my own. Rather than the sheer joy of creating, and getting invovled with such a cool project, my foremost aim was to get to know, more about how one language gets "magically" transformed to another, using a "special software" that we call the compiler. All these thoughts lay in my mind for quite some time.

And whenever i wanted to write a compiler, the first thought that came to my mind was that, I must learn assembly language and parsing and all those complicated stuff.


Now it so happened that, 2 weeks back, one of my friends Nandu had come to my home and we discussed about these things, that is compiler design, operating systems and so on(One of the best things i like about his visit) He asked me if it was possible to write a new programming language, but with an easier, yet powerful syntax, compared to Java. He also told me that the compiler could be written in Java, to compile this new programming language.

The idea really did strike me. After he left my place, I started to think about it, and this is the end result of that thought process.
For identification puprose, the new programming language shall be called Neo(if any of you guys have copyrighted that name, please contact me and I will be glad to change the project name!)

(The compilation process)


As show in the figure ^^ ,the input to the compiler will be the Neo programming language source and the output will be source code in java(yeah, our plain old .java file)Now clearly, 2 challenges lay ahead of me.

  1. Designing a new language - Neo.
  2. Designing a compiler for this new language.

If you seem to feel any of the section highlighted below to be too technical pleae feel free to Google for the same and learn more about it. I bet you wont be sorry for that ;)



1)Designing a new language - Neo

A lot of questions arose in my mind. On the basic level I had to tackle :

  • What syntax must I follow ?(basic structure of the project)
  • Should it be loosely styped and strongly typed
  • What about functions?

Okay, so to keep up with the KISS methodology(KISS - Keep it Simple Stupid) I decided to make a prototype version first, then tackle more complicated issues.

I wanted something, like a mix of Python and Java.(Yeah i know Jython exists, but getting your hands dirty by creating your own compiler is something different)

So first thing i wanted was that in order to print a simple hello world, You must type print. Thats all. No more classes and pubilc static void main (syntax used in java) and all



2) Compiler

The compiler must be in Java, although I have plans to port it to python later on. But anyway currently I will stick on with java. The ouput of the program will be a java file that could be compiled using the normal javac compiler provided by Sun .


Let the coding begin


With a basic idea and some thoughts initiated by Nandu, i decided to start coding. I fired up jcreator and started to code. As the project progressed(in a span of couple of days) I got a lot of great feedback from Nandu and also by looking up in the web; thus the initial prototype version was completed, And i decided to release it, as an open source project.

You can get the complete documentation, along with the full source code for the project here. I want to polish it a bit further by adding more syntax, but still keeping it as simple as possible. If you like to contribute to this project, you can post your modified version as reply to the thread in the group where I posted the source code.

Your precious feedback is welcome, as to how this project should be continued. I have posted my vision here, and if you like to make use of this idea in someother place, do post it here


All the best guys

with regards
Justin

Labels: , , ,

Emacs touch



I recently came across a thread in
comp.lang.python namely The Modernization of Emacs which stressed the need for changing emacs to "appeal to the masses" I actually clicked the thread just because of the sheer number of replies to thread - 269 last count. But upon reading, I found it really interesting. I had almost given up learning emacs, after I felt it was not worth it, but this reply by Bjorn Borud made me start thinking.
I am quoting his reply here and I bet these, are worth a read.

Sometimes it is better than what you had before, but often it is not really better, just different. a good example is the web and the applications we implement in terms of the web. take forums for instance. in a strict technical sense, web-based forums are inferior to NNTP-based forums.for my uses, web forums are a huge step back from NNTP.

There are two types of "user friendly". there's "user friendly" and then there is "beginner friendly" which is often mislabeled. the latter is more important for applications which are to be used casually. like utilities you only use once or twice per year -- those need to be "beginner friendly".

for applications you are likely to use for prolonged periods of time (like programming, video editing, music production etc), it does not make sense to optimize for "beginner friendly". at least not at the cost of making the application less "user friendly".

applications you spend a lot of time using are worth an investment in learning how to use them. what creates friction in an application you know reasonably well is when common tasks are fiddly. for instance, while menus are often good for casual use and lower the initial threshold for absolute beginners, depending heavily on menu navigation becomes too fiddly if you are performing a certain task 2-3 times per minute. it is not _user_ friendly.

Emacs is rather "user friendly", but not very "beginner friendly". when I was first confronted with it, the sort of text editors I was used to were Wordstar and derivatives of it. I was rather annoyed that it didn't do what I expected, so I just used a different editor.

a few years later I bemoaned the fact that Emacs was so hard to use during a conversation with a friend. he asked me if I had actually made an effort to learn Emacs, which of course I hadn't. so I figured I might as well give it a shot.

following the tutorial that comes with Emacs (and which is referred to in the startup message) I spent a couple of hours one afternoon learning the basics. already the next day I started using Emacs for programming. the week after I had progressed to using it as my newsreader (which I still do to this day) and eventually I started reading my email in Emacs. perhaps two months after I had sat down to learn Emacs I wrote my first Emacs extensions in Emacs Lisp. mostly simple stuff to make common programming tasks easier.

After all these I decided to give emacs another try(In windows XP), this time, a more dedicated one. I went to this site(The site contains detailed instructions on installing emacs on windows) and downloaded the latest emacs from the gnu site(Its a 13 mb download).

so I hope, no I think i WILL become an emacs Pro some day

:)

Bye

Labels: , , ,