Come.. Let’s Dance
Just another sketch to break the monotony of my life. (Somehow felt good no matter how bad this turned out)
(My scanner sucks)
Just another sketch to break the monotony of my life. (Somehow felt good no matter how bad this turned out)
(My scanner sucks)
This happens to me all the time, especially when running programs that takes hours to complete.
Start the code
Go out for some tea or movie.
When you come back, you find that the program had decided to piss you off by crashing 2 seconds after you went away from the keyboard.
The amount of cuss words thrown at the code/program is directly proportional to the silliness of the cause of the crash or error. Even more, if its a typo. Now that twitter allows tweets to be sent to Bharti AirTel (Boohoo others) numbers, and add Python + python-twitter + konsole (Terminal emulator from KDE) to the mix, you can get a very rudimentary notification system which can DM you when konsole activity changes.
To do this, First Enable ‘Monitor for Silence’ in ‘View’ Menu
Then ‘Settings’ –> ‘Configure Notifications’. In the dialog that pops us, configure the notifications such that it executes a python script. The dialog should look something like this,
The real deal is in the script. It uses the python-twitter module to send a DM from a dummy account to whatever account you want the notifications to go to.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
Thats it! Simple but useful ;p (Of course, change the message according your needs)
Recently I had to make use of Google’s translation engine to translate phrases at work. Given the lazy big bum I am, I found using the Google’s web UI a bit tiresome to use. I thought “heck, why not write a little jabber bot to make things a bit easier..”. (Agreed, writing a bot is nowhere near to the best solution.)
Writing a Jabber bot is incredibly easy with python. You will need the JabberBot package, which offers a really really simple and straightforward way to write bots. The little script below proves how easy it is.
The bot translates phrases/sentences using the python-pygtrans package. I had to name the script something and Nai Sekar seemed to be a good idea. Apologies if you just went ‘WTF?!’. (I am quite lame when it comes to naming code/function/classes)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
Oh yeah!. With the power of DBus and libpurple APIs it is possible to give your boss the illusion of managing you. Just run the following script (under WTFPL). Tested with jabber accounts in a live office environment :P.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
When it comes to fitness, I am one of those nerdy couch potatoes with a rather rotund tummy. Burning away calories has become an important priority now and boy, do I miss those Lays and the local Iyengar Bakery Bun Butter Jam and Puffs. For the last week, I have been waking up early and jogging for 30-40 minutes (I also got a good pair of running shoes). Should increase the workout time as weeks progress.
Oh, I also got a new job :D….
Ever had that feeling of insignificance? The feeling that your very existence is a microscopic peanut in the grand scheme of things. By grand, I mean the Whole Sort of General Mish Mash. I am going through that right now. We are, according to our own theories an extremely smart species, yet for every answer we discover, 10 more questions creep up like one of those annoying LOLCATS shouting ‘OH HAI’. What the hell is the purpose of life? Why do we exist? What is our place in this infinite Cosmos (See the embedded video)? Its incredibly creepy even to think that our entire life is just a mega-complex probability equation, which most likely is too complex for our puny brains to comprehend.
Yeah, so basically what I am coming at is simple. Party now, Life is too short to be spent over unnecessary complications. Or in other words Frigging Use Python!!!!
Brainfuck is one of those turing complete languages that has no apparent use in the real world. But hey, being very very simple with a limited grammar, writing an interpreter should be easy. So here it is, under WTFPL. The code works (I hope so) with the examples from the Wikipedia article.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
2-3 back came a sad and shocking news (atleast to me) that Openmoko has sacked/let go of 50% of its work force and has ceased all developments for GTA03. Furthermore Openmoko has stopped funding FSO. Both of which were grim developments to hear.
On a brighter note, FSO has started work on the Vala/C implemention of the reference Python implementation named cornucopia, which mainly aims at the general defragmentation of all the middleware code out there for handheld devices. Whats more, the first subsystem to be ported to this new codebase will be odeviced, which happened to be my project for the Google Summer of Code 2008.
For more, check this recent blog entry by Mickey.
Patches all the way :D…
I know I am pretty late but finally I got myself a new Yamaha FZ. A nice revvy pickup and wide tyres is making me go ‘whee’ over long sweeping curves.
Drinks about a litre every 40-45 kilometres
Pics soon :)
About 10 minutes ago, my brain switched from neutral to first gear and started pondering about ways to teach someone how to program (Not that I am particularly good at programming in the first place :D).
For example, how would you explain the concept of variables, references, names. etc, which seemingly form the corner stone of programming language syntax. Sometimes this can make you struggle a bit when you are switching languages.
Consider the following,
1 2 3 4 5 6 |
|
One teency weency thing I learnt the hardway was the fact that when the interpreter evaluates ‘a = 10’, it creates a “box”, slaps the label ‘a’ on it and puts the integer 10 in it. Consequently, something like swapping of two numbers becomes as easy as,
1
|
|
This is actually emphasised on most, if not all Python tutorials I have come across. This didn’t sound all that important when I learnt Python for the first time.
Then I found C to be doing things differently (Am I even right?), Take this for example,
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Gives the following output, where x and y are named on different boxes and yet have the same values.
1 2 |
|
Hmm, This is where I hit it. Suddenly realisation dawned. Sun shone again. Birds twittered. The darkness was gone. I suddenly found myself telling “Its called the pointers.. stupid!”
Now, to mirror the the Python “box” analogy (not exactly) well, a in a language like C, we have to our disposal the good old pointers.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
This would give me,
Value of x = 5, Address of x is c07ec844
Value of y = 5, Address of y is c07ec844
where ‘*’ and ‘&’ are the de-reference (value-of) and reference (value-at) operators.
So folks, Is it right to think along the lines of “a box at c07ec844 is labelled ‘x’ with the integer value 5” when I see something as mundane as “int x = 5” . It did help me to understand pointers better, but are there any better analogies when speaking about variables, references etc. than say, picturing a row of shelves with lots of boxes, each of which can have multiple sticky notes with names at a given point of time.