thoughts, ideas, code and other things...

Sunday, February 21, 2010

Better than stealing...

Remember way back when your were that kid whose only tools of trade in teh bag o' tricks were pencil and crayons and stuff like that, ah the small bricks of water colors, the cheap blue color box or color bricks where you'd brush the watery brush and ... blah ends here.
So, yes, better than even copy pasting, not caring about copyrights, etc why not trace the stuff you like as in the old school days :). After all there's no harm/copyright violation in getting inspired from an artform. So for (crap this is 3rd day in making and its not yet out)... I needed some logos, some cool graphics for gmail, twitter and Lenny itself. Here's how I got it done -

1. Load original image/photo into ArtRage or MyPaint (on linux)
2. Start drawing... draw ... draw... draw some more
3. Resize into iconic/useful proportion, and smile.

Lol I might just have mislead you... but hey this obviously sounds like a safer practice than outright copy pasting media content from here and there.

Anyways so this is what I could get out of it (zoom to see brush strokes) -

and finally ->

Labels: , , ,

Friday, February 19, 2010

Minor 'ascii' codec issues when using urllib

Two times in my life I've come across something like this -
>>> d = {'data' : u'\u2013'}                                                                    
>>> urllib.urlencode(d)
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.6/", line 1268, in urlencode
v = quote_plus(str(v))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 0: ordinal not in range(128)

And now that I've a generic solution this this issue (thanks to Jarret Hardie and Grego), I would like to pin it here so that I know where to look for it in future.

# gets rid of ascii codec shite
def sanitize_codec(fooDict,charset):
return dict([(k, v.encode(charset)) for k, v in fooDict.items()])

weird_data = sanitize_codec(weird_data,'utf-8')

Pretty useful when you've to pass on some chunk of an rss feed to some other webapplication, say from gmail feed to twitter rest api.

Labels: , , ,

Monday, February 15, 2010

Nincompoop goes Linux

Ah! more than a year ago I wrote this yet to be finished 2d sidescrolling game with very crappy collision detection and pretty poorly programmed, blah blah called NinCompoop - The Unfinished Quest.

I felt like porting it to linux today. The good news is that allegro is already in the Ubuntu repository, so all I needed to do was a sudo apt-get install liballegro4.2.-dev

Porting again, was dead simple, just change the windows styles slashes to linux style slashes - \\ to /

So here we are, time for a demo -

Fork it here -, a request plz don't complain about ze lameness of teh code.

Labels: ,

Sunday, February 14, 2010

Threading mess at Hackfest@Directi // #24Camp

But seriously a big +1 to Directi its awesome to find such a place to work.

The reason why you can't see anyone there -

Argh! Even after feeling the elephant for 20hrs and almost completing the functionality we landed in a threading mess. more laters...

Labels: , , ,

Saturday, February 13, 2010

प्रोमोटस्य लोलस्य प्रतियोगिता

अगर आप की वेबसाइट पर २५० बटा २५० का कोई खली स्थान है. या फिर आप उन तीन निन्जाओं से इतना प्रभावित हैं की उनके लिए कुछ करना चाहते हैं.

तो रुकिए मत, कुंजीपटल पर आ जाइये, और इन में से किन्ही इश्तेहारी तस्वीरो को अपनी वेबसाइट पर चिपका लें.

यदि आप इनका टट्टू बना कर माथे पर चिपका सकते हैं तो और भी अच्छा रहेगा. अप्रैल तक जो भी इनके टट्टूओं को सबसे अधिक समय तक माथे पर चिपका के रखेगा उसे मेडटूकिल की तरफ से एक ईनाम मिलेगा.

Labels: , , ,

Sudo weirdness with QProcess and Python interpreter

Working with PyQt4, trying to do some cheap hacks to get console output in the UI, I stumbled upon QProcess and landed in a weird situation -
Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt4 import QtCore
>>> process = QtCore.QProcess()
>>> process.start("sudo ls")
>>> [sudo] password for ideamonk: mk48d

Notice the "mk48d" there. Well that's not my password, but they are some of the keys that somehow got filtered out and got printed by the interpreter. Indeed this situation wont come up in real life, but its a point to ponder upon as to why do both the processes - sudo and python interpreter split the user input amongst each other.

anyways laters!


Wednesday, February 03, 2010

Hackfest @ Directi #1 – 31st January, 2010

It all started with this, when Manish DM'd me for a small hackfest. We were looking for a small space where we could sit together, access internet and write some code for straight 5-6 hrs. Thanks to folks at Directi and @codechef, we no longer have to wander / crib about it.

Here is a late recollection of the first event -

This time 4 of us could make it - Manish, Rohan, Ishan and I. We were joined by Mr. Sandeep and Naresh from Directi. Though the initial plan had 9 people, many couldn't make it due to exams, other personal commitments, etc

Ishan's talk was pretty in-depth and eye-opening for any Computer Science student. I think we should've recorded it. The talk dealt with problems that Geolocation based Search faces these days and his focussed on Geolocation disambiguation. He discussed some ways to solve it, ways to store and query your data efficiently (tries, ternary trees), ways to quickly find nearby places (quadtree decomposition), and even few new algorithms (bloom filter, etc).

It was eye opener in the sense that one could actually see the application of Data Structures and Algorithms apart from the only kind of good exposure we get in our college life - Programming Contests.

Then Manish gave an Introduction to Codeigniter, a popular, powerful yet simple mvc framework written in PHP. Though this was meant to be an intro, it actually went in-depth and all of us who had merely tried out Codeigniter once in a while came to know about even more features that it has. The discussion extended to various other issues pertaining to mysql, php, unit testing, etc

It was 2pm already and we were quite hungry by then. Rohan also wanted to give a short talk on his own project on centralized authentication, but we couldn't schedule that along with lunch and work to be done.

By 4pm after lunch the headcount was 3 - Rohan, Manish and I. We started working on apt-offline, in order to make a gui for it in PyQt4. I gave a quick walk-through to what apt-offline does, what it is built upon, and how to use it. Then we saw the code in order to figure out best way to proceed with the task. Manish drew some mockups and discussed on how to make the ui more user friendly and he actually KISSified the current UI into something much straightforward and easy to use.

So far we started designing the new looks in QT Designer, while Rohan shared his in-depth knowledge on Qt (C++) time to time.

As it was 8:30pm already and everyone had college or office to attend to on Monday, we had to leave by then. But boy we wished to stay more.

I think as even folks at Directi suggested, a Saturday would be better time to organize the next hackfest. A night-out is pretty much possible on Saturday as it does take time start working along with everyone on a project.

Last but not the least, the Directi office is a perfect hangout for such weekend coding and geek get-togethers. While meetups do happen in Bangalore, but they mostly comprise of talks and discussions, for instance the bangpypers and ilugb meetups. But a hackfest with such great flexibility and freedom is a totally different learning experience.

Here's Manish's detailed account of the day.

Labels: , , , , ,