YuviSense Codin Kid

An 18 year old guy from Chennai, India who codes, photographs & has fun More...

Cheese 2.31.1 Released

If you had read my Cheese GSoC proposal, it would've stressed on one major point - make Cheese sexy.

Two days ago, one of my classmates spent 5 minutes on the bus using Cheese and trying out different effects (and poses!). Today, my brother spent 20 minutes trying to get the perfect combination of style and vagueness for his Facebook profile picture - using Cheese. He then asked me to create an account for him in Ubuntu (he was an exclusively Win7 user till then) before leaving.

I'm still not where I want to be (the girls haven't gone gaga over it...yet!), but I know very well that I am on the right path.

And a major milestone in that path is the release of Cheese 2.31.1. The 'release' means that the code is now stable enough to be actually shown off. The major features (rewrite in Vala, use Clutter, user defined Effects and most importantly, Live Previews) are in working condition. We are no longer walking through a minefield of segfaults. You can build it and show it off. When something breaks and you tell us, we'll most probably not reply with 'yeah, we know that. We'll fix it when we get to it'. The road to Cheese 3.0 has begun.

So, what's all in this release?

  1. Rewrite of the UI code. We removed the entire old src/ folder, and rewrote everything from scratch. Using Vala. Why? Because ~7000 lines of C code is now ~1500 lines of Vala code. And the Vala code has more features (Live preview, for one!). The Vala compiler is pretty mature - only one 'real' bug so far (rest have been mostly binding bugs, fixed with single line of code changes). And #vala has been incredibly helpful too! And we are re-using most of the 'backend' code (Camera detection, pipeline linking, etc) - it is still in C, and writing Vala bindings was incredibly simple.

  2. Move from Gtk to Clutter for display. Means I can do stuff like overlay semi-transparent text on top of the effects. Or have animated page transitions. Or (in the future), use OpenGL effects without having to do an extra to-fro copy from memory. Have drop shadows for everything. Make the effects tilt and rotate around when hovered over. Etc, etc, etc. Clutter is the major contributor to the 'sexy' part.

  3. User created effects. Effects are no longer hardcoded. A simple 4 line text file and enthusiasm for reading documentation is all that is required to create your own effect. The effects are based on GStreamer, and are very flexible - you can create something as simple as monochrome + hue, or something as complex as face detection + extra limb addition to specific people :P

  4. Live Streaming - biggie. All effects are arranged in grids of 3x3 in multiple pages that you can swipe through. Simply clicking one will activate it pretty much instantaneously. No more 'select effect, apply, no-it-sucks, let's go back and do it again' games :)

I made a quick screencast to show the new Live preview stuff to those of you too lazy to actually get the source and compile. And the subject is a pink+green teddy bear sitting on my white netbook. (And the weird stuff that turns up after I exit fullscreen is a bug in RecordMyDesktop - and is an incentive for you to actually get the source and check it out :P)

These are the four major features that are new. All the other parts of previous Cheese UI have also been implemented (preferences, thumbnail viewer, fullscreen, wide mode, device detection, etc.)

As for the next release - keep looking out for it, it will land soon! It will primarily be a bug fix and code cleanup release - fixing crashes, UI inconsistencies and making sure everything works as intended.

A lot of late night hackery (mostly because my college takes up 10 hours of 'regular' time) has gone into this release - so check it out here and tell us what you think. Especially about the parts that suck. Especially useful would be if you can get someone non-technical to sit in front of Cheese, observe where all they fail (and succeed) and then report your observations back to us.

My GSoC 2010 Proposal

I used gist to publish my GSoC proposal. Diffs, easy to show off, and Markdown support - made gist perfect for me to make modifications and get feedback easily.

It is the first 'real' document I've written - it actually had a tangible effect.

Now that I don't need to make any modifications, I've moved it to my site.

Vala, GTKBuilder and Autoconnecting Signal Handlers

Note: I'm not an expert on Vala, GTK+, or anything else for that matter. If I am off base someplace, comment.

I spent quite a some time today trying to get GTKBuilder to automagically connect all my signals to their handlers. I tripped up at a few places, and so recording them here for posterity.

  1. If you are using instance methods (like most of us are), you've to decorate your handler function with the attribute [CCode (instance_pos=-1)]. This makes sure that the function is passed the this pointer as last argument, rather than first. You've to do this because Builder.connect_signals passes the instance as last parameter (user_data), and by aligning your this pointer with user_data, you make sure the correct instance is called.

  2. Make sure your handler function signature matches what is expected. Ignore the user_data parameter of most signals - it is used internally by Builder.connect_signals (see above point).

  3. Make sure you pass --pkg gmodule-2.0 to your valac. If you're using Autotools, this means you pass it to VALAFLAGS.

  4. sure your C compiler is called with -dynamic-export. I'm told this enabled support for dlopen in the binary produced.

  5. Mangle your names properly. Cheese.MainWindow.on_quit() becomes cheese_main_window_on_quit on C, and that is what GTKBuilder expects. If you are not sure how your function name is mangled by valac, checkout the generated .c file.

If you do all these 5 things right and you're still having trouble, turn up on #vala at irc.gimp.net and ask the helpful folks there :)

My First Accepted Patch!

As part of my GSoC preparations, I wrote a few patches for Cheese. One of them (a one liner to fix a crash) has made it to GNOME 2.30.1 - the other two (1 and 2) are slightly more significant and involve UI changes, and so will be integrated later.

Free beer to everyone who can catch me in a bar! Free Pepsi/Sprite/Egg Puff to anyone who can catch me in the College Stores ;)

P.S. Obligatory thanks to _ke and fargiolas for guiding me through the difficult bits :)

Dokuwiki plugin to easily embed Gists

I love Gist.

I recently started a project that required me to embed gists in Dokuwiki. I hunted around and found no plugins, so created my own. Needs the superawesome command plugin too. Released under the 3 clause BSD License.

PyCon India 2009

Warning: Rambling, unedited, 7 month old recollection ahead. Proceed at your own risk.

Ah, PyCon India 2009. My first solo bit of travel outside Chennai. What fun it was :) Though it was almost 7 months ago, most of the memories are still fresh. Compare that to college, where I struggle to remember what happened last week...

Anyway, it was fun. I went off by bus with the rather interesting Anirudh - a profitable startupeer and someone I met when working with Busroutes.in. He has a finances related degree and his startup deals with (rather cool) car electronics. He was also a KDE contributor, and is a very interesting travel partner for reasons too numerous to mention here.

I spent some time at Lalbagh, roaming around by myself (and texting classmates with my legs hanging off a cliff-type place). Was fun! I'd definitely do that again - the place was extremely peaceful.

I stayed at Sudar's place. Staying at a bachelor's place was fun - guess that was how my room would look like if I was left all to myself. It was, however, definitely too organized for my tastes - you could actually walk without accidentally stepping on stuff ;) He's grown up too fast - he actually dragged me to a food place and forced me to have breakfast!

Hung around mostly with mech-yet-wannabe-geek Kausik (who once famously said that he 'doesn't want to use LaTeX for resumes because most people ask for docx or pdf'), Anirudh and Sudar (who was there only for Day 1). Had a longish talk with Kenneth, who I later found out was quite a celebrity on IRC/Mailing Lists. Meeting people you knew onlyine online IRL is unsettling at first.

The event itself went well. I was inside only for a couple of major talks - the one about waffle by cnu is the only thing I could remember. I was mostly out in the corridors, typing out code in (one of the many) laptops that Sudar has. The lightning talks were way more fun - because they were only 15 mins or so long and packed a lot of tech (I particularly remember the one about Python internals by artagnon and one about a GAE app by ideamonk. I gave one too - the last one, so I had no projector, no working laptop, no mic, oh and Kausik who was supposed to present with me ditched me in the last minute :P It still went exceedingly well - it was my first time ever talking on a stage of any stage outside college and the practice I had from giving them in college (Thanks to Dorai and the iCell) helped a ton. I even cracked quite a few jokes that was recieved well. Fun times - and I guess it finally killed the last remaining bits of my 'shit, you aren't really expecting me to go up there and talk, are you?' feelings developed from school days :)

Before I left, I visited planemad at NID. Awesome place. Someday, I hope someone established a National Institude of Programming at such a scenic place, where people can come together and learn about programming rather than engineering (which is just college-management-speak for IT Industry Zombie Production Factory)

There you go! That's a rambling account of my PyCon India 2009 experiences. Next one is probably going to be in Chennai - looking forward to that!

The Python Workshop

We had a python workshop at college a week back.

One hellova workshop it was! Kausik conducted it, and about 14 people turned up (We picked 15, one girl had to miss it 'coz of fever). Every single one of them was there because they wanted to be there. This happened during semester holidays, so they came to college just for this. And from the feedback (and the actions that followed it) I got, it was worth their while.

Teaching Python

Kausik did all the hard work, with me just going around helping people get unstuck. Watching people when they suddenly get it is a really amazing feeling.

The hardest part for many people was not the significant whitespace (most intuitively got it, we didn't even have to repeat it once). It was the concept of explicit self. And the biggest (though not exhaustive) selling points were, in no particular order: Lack of the semicolon, no boilerplate code (type declarations, etc) and support for arbritarily large numbers. pointers are conspicous by their absence.

So, what did you guys cover?

Day 1

  • "Hello World!"
  • Conditionals, Looping constructs
  • Functions
  • Lists, Dictionaries and Tuples
  • Basics of OOP (Classes, Objects, and explicit self)

Day 2

  • Using Google to find docs
  • The datetime module
  • Using easy_install to install external libraries
  • Exploring docs of python-dateutil module

Pretty much zero time was spent lecturing, and most time was spent actually doing things. Just as how things should have been :)

Following up

The best thing about this workshop was it did not end at closing time Day 2. It went on. We are now planning on a weekly programming competition at college, with cash prizes (sponsored by the college and Mr. Dorai Thodla). And several people have taken up solving problems on Project Euler, and we have a working game done by one of the students. That isn't the end - one team is hoping to replace the antiquated VB6-ish management system in our library with one built in django, while another is trying to automate attendence systems using SMS.

Inspiration

So, how did it all get started? The inspiration? Hackfest. Huge thanks to vimzard, kstar and the rest of the Hackfest team who were our inspiration. I hope there is a Hackfest next year too, and that some (a lot!) of our students are more than good enough to attend and make meaningful contributions. It changed me this year, and it should continue to shape and change more people throughout the years :)

And ofcourse, no small thanks to Dorai Thodla, who helped get this entire iCell thing off the ground, and Ms. Sumathi Poobal & Mr. Ramanayagam from our college, without whose participation the iCell would've died a silent death. (What's this iCell thingy anyway? A post for some other time :) )

I didn't happen to forget someone whose name began with a K, did I?

Anatomy of an impromptu hackathon (Git vs SVN)

One of the (good) things that came out of the IIT Hackfest was me hanging out on the #hackers-india IRC channel. It is wild, swingy and usually fun. Usually.

So yesterday night, ideamonk casually mentioned that he was working on something called pymos. It was a python script that made mosiacs. Now that was something I was totally interested in - I tried making a similar 'script' a long time back (in C#), and totally utterly failed, simply because I was so caught up with the part that downloaded pictures from flickr that I didn't do the part that generated the actual Mosaic. Since ideamonk's code already generated the mosaics (and since it was in Python), I forked it, and began to work on the to do items.

Note that ideamonk and I don't know each other (we were apparently sitting next to each other at PyCon India '09, but that doesn't count!). We were on the channel, he's commented on my blog once, and that's about it. But still, we worked together all night fixing code. I could bore you with details of the work that was done within the next five or so hours (1 AM - 6 AM), but I will just point you to to this commit graph generated by GitHub. There was a flurry of commits, and there should be a tagged version up for download (and on PyPI) soon.

If not for github...

Let us, for a moment, assume that this code was on, say, Google Code instead of GitHub. How could I have contributed?

  1. Checkout the code via SVN
  2. Fix one thing
  3. Send ideamonk a patch file (I can't commit anything anywhere!)
  4. Wait for him to: 4a. Open up his mail client 4ai. Get lost in proggit (or FaceBook) 4b. Grab the patch file 4c. Apply patch 4d. Test things to make sure I didn't break things 4e. Wonder if the code is good enough to be merged in 4f. Commit code with my patch in it 4g. Notify me that my patch is in, so i can do an svn up
  5. Go to 2

No code gets committed, simply because step 4 is a huge involvement for ideamonk. Knowing that step 4 is a huge involvement for ideamonk is a huge block for me too. Obviously, he'd rather be coding than dealing with patches. Who wouldn't? Being a developer > Being a maintainer. One of the reasons I respect maintainers of projects a lot.

Now, how does it work with github?

  1. I fork it (1 click)
  2. Fix one thing
  3. Commit, Push to my repo
  4. If there is something significant in, notify ideamonk to pull from me. Else go to 2.

Much simpler, and note that all four are things I could do myself. Nothing depends on ideamonk. Maintainence works is almost zero. Nobody has keys to the cathedral, since this is not one.

Please put your code on GitHub

It has the least amount of friction for developers looking to contribute, and the least amount of work for you as maintainer. Thanks!

Why I got rid of my fork of Waffle

For those of you who didn't know, Waffle is a schemaless storage layer that sits on top of SQLAlchemy. Something that I was initially very interested in.

Not anymore.

Why?

Because I found MongoDB.

And fell in love.

Yes, I do know they both are different, but MongoDB has the things that attracted me to Waffle (very flexible schema, great querying, indexes) and is just as easy to set up (maybe not as easy as Waffle over SQLite, but only slightly less easier).

I <3 MongoDB. Let's see how long this lasts!

What I learnt from the Hackfest at IITM

I was about to just type a list of stuff here, but that doesn't do the topic justice. So here I am, at 3:30 in the morning, sleep cycle screwed up by the Hackfest, typing out a post on what all I learnt from there. I spent pretty much my entire awake-time at the IIT, so it helped me a lot.

Your college doesn't matter much

IIT Envy. Every non-IITian has that. I spent a lot of time at IITM during the Hackfest, and while my IITEnvy did go up during the first few hours, it initially came down well below normal as I got to know the people better. What was cool about them was not where they were studying, but what they were doing. I could do what these guys were doing. Anyone can do what these guys were doing - there is nothing special about the IIT except maybe for the fact that it aggregates naturally dedicated people into pools. You don't need an IIT for that - IRC will do :) I'm from a teeny college that nobody has heard of - that would have been a problem when people judged people by where they studied, rather than by what they did. Should not be a problem for me now :)

Real C isn't hard

I was utterly clueless about GTK+ when I landed up at the IIT. The first thing I told Arun was that I was clueless about C and maybe would like to hack on something in C# or Python.

I thought I was clueless about C. All I had done was TurboC - which I had not really considered as real C till that point. However, an hour into the hackfest, I realized something - Pointers and Structures are all you need! Read the docs, read some good code, and you are done. I will probably do what I usually do to learn a new language - write a significant amount of useful code in it - in C very soon.

Code talks

I don't have any patches against my name. The only significant piece of code I think I have written so far is this blogging engine you are reading. That needs to change.

Doesn't mean I have to churn out code like a copier machine - I just have to have enough things to point to and be able to proudly say 'I did that'. Great Documentation, proper deployment options and a little evangelism helps too. None of my code has any of that. That has to change too.

Know tools well

I use Emacs. But not to its fullest potential. Same thing for pretty much all of my tools - Bash/Powershell, Build Tools, etc. Heck, I can't even write a shell script to save my life! That has to change, and change fast. I smell perl.

People on IRC are friendly

I've always been a lurker on IRC, just listening and not daring to speak. That changed drastically once I actually met these really nice people in person - so I can see my IRC usage going way up! It has also expanded my horizons quite a bit - meeting new people, getting to know people better, constantly being challenged to actually get off my ass and write some stuff, etc.

TODO

  • Read more code. File bugs. Try to fix bugs.
  • Learn Perl. Learn C. Learn C++. Get much better at Python.
  • Go through my code, document all the necessary parts, create home pages for the significant ones.
  • IRC more. I have been - the last two days have seen my IRC usage skyrocket.
  • Stop cribbing about my life and get on with it!

Hackfest '09 - Expectations

I'm going to participate in Hackfest at IITM's Shaastra, starting tomorrow. Will hopefully be a lot of fun - and may I be able to contribute my first ever patch during the event ;) Got permission to not get back home - but wondering, where would I stay? Probably pass out in front of the computers :)

I'll be hackin on GNOME Apps - hopefully Banshee (since that's one app I love), or write a newish, smallish app with PyGTK. Anything would do but :)

Will be blogging more - Sadly, no camera, so no pictures :(

Anyone else coming along?

Code I've written so far

Code I have written so far:

  1. HiSlain: A static blog publishing system (NOT A DJANGO BLOG!). Runs this blog
  2. wtfimb: The code that powers Busroutes.in
  3. frailgrey: Markov Chain based page generator (pretty lame, actually)
  4. GoodFather: Collection of utils for web data scraping and storing
  5. reappy: A Twitter Search Application Framework
  6. SadIvy: A pure WSGI URL Shortener

Now, I've been doing a shit job of documenting them - none exists. Nor of writing tests - none exists. That should hopefully change soon :)

HiSlain and reappy are where I'm going to concentrate my efforts on for the next month or so.

Task List for HiSlain

  • Refactor code, clean it up so it doesn't look like proof for the Infinite Monkey Theorem
  • Add support for raw, unmanaged pages
  • Port a decent looking, simple theme to HiSlain
  • WRITE DOCUMENTATION!
  • Write some tests, and refactor the code to make it more testable
  • WRITE MORE DOCUMENTATION!

Task List for reappy

  • Write a real application with it, so bugs can be fixed in the process
  • DOCUMENTATION!
  • Write some tests and refactor the code to make it more testable
  • MORE DOCUMENTATION!
  • Examples.

And ofcourse, new sub-pages over here for both of them (atleast). Stay tuned!

3 hours of code & 1 blog post per day

Those are my new goals.

I've got a mechanism to track the code accomplishments (will make that public soon), and maybe I'll write a widget for HiSlain for the blog post/day accomplishment.

I'm liking it so far - 7 hours of code yesterday, along with 2 blog posts. Couldn't hit my code target today - but am hitting my blog target. I should figure out more ways to make this work better.

Let's see how much I could stick to it.

AutoKrish: Because we don't get enough jilpa

I dig KrishAshok's writing. Been lurking there for a long time.

Only problem is, he doesn't write often. Nor does he tweet often.

Only solution is, ofcourse, to create a bot that writes like him, and another bot that tweets like him.

UPDATE: Some of my favorites: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, etc. Too many to list :)

UPDATE 2: Absolute Ripper

The Automatic Quote Generators (aka AutoPeople)

An Automatic Quote Generator - generates sound bites that almost sound like someone else, and are somtimes funny as hell:

A few of them (@AutoLG & @AutoMona) also have twiwtter bots for them, posting short tweets once every seven minutes.

And ofcourse, I open sourced the code for all this - and made it available on github :)

Code Highligting Plugin for HiSlain

I've been hacking 'round with HiSlain, and wrote a syntax highlighting plugin for it. Nothing fancy - just uses Pygments, but the process of modifying the plugin architecture to support this has been an awesome ride. I'll probably open up a new GitHub project just for HiSlain Themes and Plugins.

And since I've to test out Syntax Highlighting,

print "I kinda like Python :)"

Progress on HiSlain #1

Small status update on my blogging platform's progress.

I've got the plugin infrastructure (mostly) in. Google Analytics Plugin and the RSS link plugin are working :)

Next Step is to make DISQUS a plugin too, and then I can start on porting themes!

My involvement in Novelrace

It started when @msnarain pinged me one day and asked if I could help out with a small project involving twitter. I asked how small - and he described what would later on become http://novelrace.in. It ended up being pretty small - about 150 lines of code, excluding styles and stuff. Not bad, eh?

Oh, and if you have no idea what novelrace is - this post should clear things up. And yeah, I too tried participating (story 1, story 2, both written late at night), but I write crap :( Maybe some other time...

Update: According to this, the worth of 150 lines of Py code is ~4,000$! That much for a few days of coding? SERIOUSLY?

View complete archives