Sunday, August 19, 2012

Updated My Twitter Script Today To Run In Python

Sunday evening and not much to watch on the telly, so I thought I should go back to a few of the Java programs I wrote years ago and bring them into the 21st century. Wel, if you are not currently programming in Python or Django, I consider that as someone who is still hiding in a cave in the 20th century :-)

So, what better way to bring them up to date than to give then a full rewrite in Python. For me, the flexibility, syntax and power of Python is what really made me rewrite it. I love Python - having used it on many projects in the last few years, it's quite easy for me to introduce new developers into programming with Python.

However, today, the Java program I rewrote today was a Twitter program that ran from a shell. Taking search input from the user, connects to remotely to Twitter website, and collect the 10 most recent tweets containing the terms. It then goes ahead and prints the time, user name, the tweet containing our search term.

Today I added a few more features. It's now possible to configure it run continuously using your keyword, when a new tweet comes in containing the keyword, it can either send them a reply tweet, send you an SMS, email you or simply log all the tweets into a database which you can later analyse.

The cool thing about the latest script is that everything is run from a shell. Supply the necessary parameters and away you go. I got these ideas from oDesk when I used to take on on the side programming gig there. So, if you have a few hours in the evenings and on weekends, check them out for some cool and exciting quick programming task.

If anyone wants to poke around the code and probably help in polishing is a bit more or add new features, please let me know.

Now, I'm going for a Sunday evening bike ride I've been indoors since Friday night.

Sunday, August 05, 2012

How To Check Your Django Version In Ubuntu

If you have been working with Django for sometime, you will have noticed how fast the framework development has been going. So, once in a while you need to check that you are not using a very old version.

It is quite easy to upgrade, but believe me, some people never bother at all. There are different reason for not upgrading, - either you have some production code that rely on specific packages in that version - and upgrading means that you will need to rewrite all those code, or you are simply just too lazy to do it.

But if however, you want to know what version is running on your server, simply running this command should do the trick.

helen@helen-server:~$ python
Python 2.7.3 (default, Apr 20 2012, 22:44:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> import django
>>> django.get_version()
'1.4'
>>>

As you can see from the output above, our current version is 1.4, which at the time of this blog post was the latest version.

If you see that your version is a bit older, then simply upgrade by using this command.
This is best simply because it is short and easy to remember for beginners out there.
% sudo apt-get upgrade django


Enter your root password and the upgrade will commence.

On a different note though:

This is for starters - but if you are interested, then see the Free GitHub Tutorial Videos here. But please mind the photos of the naked ladies :) You might also want to check oDesk as for freelancing opportunity if you have free time and would like to earn yourself some income in the process.

You may want to make some cool cash right now as a developer on oDesk simply by helping people with the programming problems. If Java is not your thing, then check out Python or any other programming languages.

Update: it is interesting that since 2012 when this post was first published here, a number of people have found it useful enough that the amount of traffic to this post is fourth on the list of the highest read post on this blog. It goes to show that even a small tip on how to accomplish something can be quite useful.

I guess you can also check the version of your installed Django on any platform with the command above - it doesn't necessarily have to only be on Ubuntu. I was primarily working on Ubuntu back then when this post was written so simply checking your Django version on any platform should work regardless.
Related Posts with Thumbnails