University of Moratuwa has been able to top the Google Summer of Code program, yet again. With 22 participating students university of Moratuwa was far ahead from the second place, University of Campinas Brazil which had 12 participating students. I’m glad i was a part of this success. Here are some stats of GSOC 2009.
University of Moratuwa tops GSOC 2009
September 17, 2009 · 3 Comments
→ 3 CommentsCategories: IT · Programming · Randoms
Tagged: gsoc, university of moratuwa
Debugging in Python
September 7, 2009 · 1 Comment
Python has a simple yet powerful builtin module for debugging called pdb. Using this module you can debug your python code easily even without any IDE.
1. First step is to import the pdb module
2. Next step is to mark the entry point where the debugger would be called in. We use the set_trace() method for that.
pdb.set_trace()
3. When the program is run the execution would stop at the set_trace() method and would wait for debugging commands.
4. To run the next statment enter ‘n’ or ‘next’
5. To print a variable enter ‘pp variable_name’
6. To run until exit enter ‘c’ or ‘continue’
7. To display the current location enter ‘l’ or ‘list’
This would display an appropiate part of the source code with a pointer to the current statement.
8. To step into a method enter ’s’ or ’step’ when debugger is met with a method
9. To insert a break point enter ‘b filename:linenumber’
10. You can also dynamically assign values into variables.
Let’s assume there is a variable called num initialized to 10. You want to see what would happen when that variable is initialized to 20. You just do this. (pdb) num = 20 and then enter ‘n’ to execute next statement or enter ‘c’ to execute program until the end.
An example would look like this
import pdb
def method():
i = 10
name = ‘kasun’
last_letter = name[-1]
last_num = ord(last_letter)
print ‘last_num is’, last_num
if __name__ == ‘__main__’:
pdb.set_trace()
method()
→ 1 CommentCategories: Journey into Python · Programming
Tagged: debugging, pdb, Programming, python
When Linux crashes
August 27, 2009 · Leave a Comment
Yes Linux been another piece of software, gets crashed once in a while. Once I used to work with a Ubuntu machine that after 10 hours of work would always get stuck when trying to shutdown. Luckily for Linux users there are some options before reaching for the power button.
You can use a sequence of <alt + sysreq(Prnt Scrn) + key> to issue commands straight into the kernel even when the system is in a total non responsive state.
For example the following sequence of commands can rescue you from a crash and would execute a safe reboot.
ALT + SysReq + r
ALT + SysReq + s
ALT + SysReq + e
ALT + SysReq + i
ALT + SysReq + u
ALT + SysReq + b
Here you can find what each command actually does.
For the easiness of remembering the commands, the idiom, ‘Raising Skinny Elephant Is Utterly Boring’ is used.
Remember that the above commands would only work when the system is in a non-responsive state. Otherwise it would just throw a bunch of print screen windows at you.
→ Leave a CommentCategories: IT · Randoms
Tagged: linux, magic commands, recover
What if by Ron Paul
June 21, 2009 · Leave a Comment
Ron Paul is one of those rare politicians who make sense more often than not but find it hard to make a big enough impact to actually change the status-quo. Why? I don’t know, maybe this whole democracy thing is a delusion, maybe you always need some special interest group behind you to win an election.
I found this speech by Ron Paul, a very thoughtful speech indeed.
These are the most interesting points I found in the speech.
- What if we wake up one day and realize that terrorist threat is a predictable consequence of our meddling in the affairs of others.
- What if conservatives who preach smaller government wake up and realize that our interventionist foreign policy provides the greatest incentive to expand the government.
- What if we as a nation came to realize that the quest for empires eventually destroys all great nations.
- What if Christianity actually preaches peace and not preventive wars of aggression.
- What if diplomacy is found to be superior to bombs and bribes.
→ Leave a CommentCategories: politics
Tagged: interventionism, politics, Ron Paul, special interests
Ahmadinejad’s win
June 14, 2009 · Leave a Comment
Contrary to the hopes of West and anyone like me who would not mind a saner regime anywhere in the world that maybe, Ahmadinejad have won the Iranian presidential election and in a landslide too. There are stories of vote rigging and many malpractices but you should always think twice when Western media report on Iran. Whatever the malpractices that were supposedly took place, the win is convincing enough for me.
What I was thinking was actually who would welcome Ahmadinejads win?Of course other than the public of Iran. Ultra nationalist Zionists of Israel could keep using Iran’s nuclear threat to come to power and keep refusing any reasonable middle ground regarding the problems of Palestinians. Neocons in USA who don’t want to see any dialog between USA and Iran would find a very good excuse. Then of course is the religious conservative, terror loving, ruling elite of Tehran, who could keep ignoring reforms and modernity for Iranians and continue on their imaginary revolutions and destabilization of their neighbors. It is very interesting how hardliners in opposite sides of the line could rely on each other for their survival.
The bright side of story? Looks like the majority behind the reformist opposition had been youth and students. Would the next generation be able to take Iran, a country with a wonderful History that had done so much for the human civilazation on a more secular, modern path? Time will tell.
→ Leave a CommentCategories: politics
Tagged: Ahmadinejad, elections, Iran, politics
I am on GitHub
June 13, 2009 · Leave a Comment
Github is a web based project hosting service based on git that has social networking concepts embedded into it. They call it Social Coding. Apart from standard version control facilities github includes social networking features like RSS feeds and followers. Currently I have the GSOC 2009 project hosted in github and hopefully many more in the future.
You can follow my social codings at http://github.com/kasun.
→ Leave a CommentCategories: IT · Programming
Tagged: git, github, gsoc, social-networking
My silly quotes – 4
June 11, 2009 · 1 Comment
Democracy is the biggest delusion of our time.
→ 1 CommentCategories: quotes
Tagged: delusions, democracy, quotes
Journey into Python
May 10, 2009 · Leave a Comment
As I said earlier I am in the process of moving into python. I am in love with the beast at the moment and thought I would write down what I find interesting in python. Pros and cons, both. This is my journey into Python.
The first thing that I found of interest is the python interactive shell. It allows you to run python statements and expressions in the console. This is really handy when you are learning python or testing a python module. How many times have you skipped checking out some feature while learning a language like Java because writing a whole class and then running it to test a small feature is not worth all the trouble? I do it all the time. That is where the python interactive shell comes in.

python interactive shell
Importing modules, instantiating variables and running statements can be done right in the console by using the python interactive shell.
→ Leave a CommentCategories: Journey into Python
Tagged: Journey into Python, python, python interactive shell
I am selected for summer of code 2009
April 21, 2009 · 8 Comments
I am so happy to announce that I am selected for Google Summer of Code 2009. Over the next 4 months close to 1000 students from over 70 countries would work with close to 150 open source projects to make the world a little better place.
I am selected to work with Maemo and will be using Python. After programming all this time with Java I was planning to move to Python. This will be a great chance for me to learn Python while contributing to an open source project and on the process getting paid by Google.
Thank you very much Google for this wonderful program.
→ 8 CommentsCategories: IT · Programming
Tagged: google, gsoc, python
Time for privatization again
March 9, 2009 · Leave a Comment
We have a popular government at the moment. A government that keep on repeating that it doesn’t believe in privatization and that privatization is bad in general but a government that doesn’t believe in any of that. Those are just rhetoric to come into power and to stay in power. I firmly believe that when the need arises and when the hard reality hits these malfunctioning brains they will start with privatization. That is what should happen, and by looking at recently passed CEB bill and negotiations with the IMF for a whopping Rs 210 billion it seems like that is exactly what is happening.
Privatization is not bad. It amuses me when some people tell that private enterprise is good and the engine of growth is the private sector but that privatization is bad. How come that be? If private enterprise is good, handing the ownership of state enterprises to private sector should also be good. Having said that government retaining the ownership of some enterprises is ok. It should be case by case rather than privatizing all and everything or the complete opposite. If the ownership of the government doesn’t make any sense privatize them, those that have a direct impact on the public, retain the ownership but make them independent corporations. Have the Ceylon Petroleum Corporation (CPC) which is managed by the government had any positive impact on the public? No. Have the State Pharmaceutical Corporation (SPC) had any positive impact on the public? Indeed yes. Have the privatization of Sri Lanka Telecom had any positive impact on the public? Of course. So why can’t we come into an agreement that corporations such as SPCÂ would not be privatized by any means but something like the petroleum sector would be liberalized and more competition be attracted and if the CPC cannot compete let it go bust. That should be one objective of privatization, getting inefficient businesses out of the market.
This government is in a historic position to challenge popular beliefs and take the country in a new path. If they have the will, they can convince the public that privatization is not so evil (as they also painted it some time back), open economy is the only way forward for a tiny market as ourselves, economic reforms are a must for an economic revival, our state sector is way too big and those cheap talks about an agriculture based economy were not very serious. They can declare they will privatize these institutions because of these reasons and they will not privatize these ones for these reasons. I see no better time for that than this. So gentlemen in the government, my vote is always open, dare to grab it?
→ Leave a CommentCategories: economy · politics
Tagged: economy, politics, privatization