*coder

thoughts = rand()

Thursday, November 18, 2010

The Daily Status

One of the ongoing frustrations for me at work is this:

Dilbert.com

Multi-core programming with Python

I had given a talk on multi-core programming with Python at http://in.pycon.org/2010/. Here is my talk: http://in.pycon.org/2010/talks/65-multi-core-programming-with-python.

I illustrated a multi-core merge sort using Python's multiprocessing module. Couldn't cover Stackless Python though!

Saturday, February 20, 2010

College students bitten by Python

The Python India community (esp. the bangpypers) had organized for a PyCon last year: http://in.pycon.org/2009/. Being the first of its kind in India, it had attracted a good amount of Python people from colleges!

It is interesting to see that these college students are becoming charming Pythonistas. These are the people who are going to join the startups in Bangalore and will spread Python virulently :)

I had gone there to deliver a talk on IronPython: http://in.pycon.org/2009/talkfull/40/. I was the odd man out talking about Microsoft(.NET) in a conference where a majority of them were open source purists. Some of the attendees were even bashing people who were using proprietary software during presentations. I think it is just moot. As long as you either buy proprietary software or use a freeware, you are good. Using proprietary software without legally buying them or using open source software without adhering to their licensing terms are both bad.

Anyway, it was a good event, and they have even posted a video of my talk: http://pyconindia.blip.tv/file/2714649/

Great work bangpypers!

Wednesday, February 6, 2008

Python aha moment #1 - cruising through a text file

I am planning to write a series of blogs documenting all my "aha" moments with Python. The "aha" moments are those times at which I come across some piece of Python code and murmur to myself - "Python seems to be really cool!"

So here is my first aha moment - cruising through a text file:

for line in file("C:\\Windows\\System32\\drivers\\etc\\hosts"):
     print line

The above lines of Python code will:

a) open the 'hosts' file
b) print every line of that file to the console, and
c) close the file after all the lines are read.

This is a really productive way of parsing text files!

Friday, January 25, 2008

Good programming practices

Sometime back in life - precisely 2003, I came across a nice article in the web describing a gross list of good programming practices. I read it, found it amusing, took a print out of it, filed it and just forgotten about it.

I was cleaning up my room after a very very long time and got noticed of that old print out that I took in 2003. Now, after 5 years with the eyes of experience I looked at it again. To my astonishment I found that the list is indeed a really really good list of programming practices. After fair amount of Googling, located the original version of it!

Monday, September 24, 2007

IronPython - My .NET Exploration Tool

Whenever I need to try out little things in .NET or find out how a .NET API works, I wrote C# files, compiled and executed them. Many a times I felt the compile-execute-recode cycle to be too much for experimenting. I wanted an interactive console where I can type code and see how it works. IronPython seems to be an answer for me. The advantage of IronPython over other Python implementations supporting .NET is that IronPython has been embraced by Microsoft. I think they have hired the IronPython creator too.

So this is what I did with IronPython when trying to explore the Security classes in .NET:

>>> from System import *
>>> from System.IO import *
>>> from System.Security.Cryptography import *
>>>
>>> stream = FileStream("C:/report.txt", FileMode.Open, FileAccess.Read)
>>> sha1 = SHA1Managed()
>>> Convert.ToBase64String(sha1.ComputeHash(stream))
'2jmj7l5rSw0yVb/vlWAYkK/YBwk='
>>>

Well if you are still wondering what the above code does, it just computes the SHA1 of a file called 'report.txt' in my C: drive. It prints the SHA1 as a Base64 formatted string (Base64 is a human readable formatting of binary data).

I believe Windows Power Shell enables one to do such .NET explorations too. I don't want to jump into that until I get Vista.