Monday, December 20, 2010 2010

The 10th and sadly last took place this week in Bangalore. I was there for all three days of the conference and it was great. This time around we were 6 students from my college. In addition, at the last minute a lot of KDE developers did turn up, including Vishesh Handa, Pradeepto, Abhishek and Sujith.

Danese Cooper’s opening talk about the architecture of Wikipedia was inspiring. That one of the top 5 websites in the world, is powered by just 450 servers and 60 people is an inspiring tale of open source skill and passion. Danese was here to consider a possible server location in India to serve Asia. Wikimedia was also kind enough to give t-shirts as part of the delegate kit. The calendar in the delegate kit also has stunning wildlife photography. lunches are always delicious so that came before any talk. With Nokia being one of the sponsors, Meego was being pushed heavily with 2 days of talks and workshops. Nokia is already pushing QML as a… but I’m getting ahead of myself.

So yes, on day 1, Aditya Bhatt had a talk on libface which by the way, will identify anything as a face. Rahul Sundaram’s talk about Fedora’s early mistakes was good learning for other FOSS projects. But I was distracted by this time by the announcement that Nokia was giving away two or three N900s!

To those who don’t know, the N900 is a hand held computer powered by Maemo, with complete root access and lots of developer friendly features. At the same time it gives any smart-phone the run for its money. Nokia has been agressively pushing the N900 to developers so that the Meego platform can start getting application support. Since Qt applications run directly on Meego, KDE developers are a particularly strong N900 market. Now it was my chance to get one! The catch was to make a QML/Qt based program and submit it on the third day of the conference.

I’ve had QML in my sights for quite some time, but never took out the time to actually try it out. Here was an opportunity. So I made Solarwolf in pure QML and JavaScript. QML’s state concept is very interesting and makes sense if you’ve read Computation and State-machines. Of course there are certain areas where it was much easier to write imperative code in JS. The code itself was written sprint style and is not the neatest or most refactored. What QML really needs is something similar to inheritance so that certain common properties (for example all Sprites have movement deltas) can be factored out. In addition it is odd that all Qt properties and classes have not been exposed in QML’s scripting environment. Things like QRect::intersects() would have been very useful.

Day 2 had Abhishek Patil’s talk about scripting Kate which was insightful and shows what an awesome piece of software Kate is. Anand Mitra’s talk about ZFS was the best technical talk in my two years at He clearly had a good understanding of ZFS (seeing that I had nothing) and made everyone aware of the challenges of porting such core programs like filesystems. Leveraging the Git Object Store by Ramkumar Ramachandra was a good way to know how dumb git is. After that I skipped all the talks to hack on Solarwolf, so I’m not aware of the others. Fahrenheit did do a good show however.

By that night my game was pretty much done, it was working on Dinesh’s N900 and so with a bit of polish the next morning I was ready for submission. But with that, and talking to a few people about various things I missed all the talks, including CouchDB and QtWebkit’s graphics layer.

Aanjhan Ranganathan’s “A Hacker’s Apology” was a brilliant end to the final The point about preaching Hacker Culture, and not politics or philosophy is the most important thing today. Encouraging everyone in the world to be curious about their surroundings and always asking why should be encouraged, rather than fighting about whether its Linux or GNU/Linux :). The slides aren’t up yet, but everyone should see them when they are available.

Following some moments of nostalgia by Atul Chitnis, The Raghu Dixit Project brought the house down with their superb music!

I won!

That’s right. I have a brand new N900. With a high-quality Bluetooth headset too. This chronologically goes in on the last day at around 5:00 pm, but I thought it deserved a seperate section. It’s a great phone except for the lack of STK support. Some of the little UI touches and shortcuts are especially heartening. They lend true geekiness to the phone. The camera is more than good enough for me, it plays virtually everything I throw at it, and it has inbuilt UPnP support! Now its time to play Angry Birds.

Me, Aditya, Dinesh, Mohit, Viranch and Nirmal.

Posted via email from nikhil's posterous

Wednesday, December 15, 2010

Introducing Mugshot

There is a certain fun in hacks, little projects you do on a whim and finish in a few days. And then you go and buy a domain for it and launch it. That's Mugshot.

Mugshot is a web service which offers face-detection. It uses the libface library which was implemented mainly as a Google Summer of Code project for KDE. So one day I was thinking that services like Facebook and Flickr allow you to upload images and then tag them. But why not let the faces be detected automatically. So I hacked out Mugshot. It doesn't wrap the entire libface api for node.js, but only one function to detect the faces. Further details can be found on the website, including the documentation.

At the moment libface can stumble on some faces, but when it works, the results can be quite interesting! That image is by Pierre Tourigny and is under the Creative Commons Share-alike Attribution license. Its used to avoid uploading any real faces.

Are there plans to add recognition support and other advanced services? I don't know, maybe if I have a whim. Meanwhile, go fork it.

Posted via email from nikhil's posterous

Thursday, December 09, 2010

Synapse 2011: Behind the website

Synapse 2011 Homepage

The Synapse website undergoes a over-haul every year to stay in sync with the theme for that year. Since the last year, I’ve been the webmaster and programmer for the website. Which means I do all the HTML/CSS/JS/PHP/SQL dirty work.

This year’s theme for Synapse is “Silver Screen”, having to do with legendary movies and so on. Their is always the need to bring something new to the website, something that differentiates it from a normal website. At the same time it has to:

  • degrade on older browsers
  • be standards compliant
  • have clean URLs
  • readability
  • look good in 1024x768

The last requirement is a by product of the maximum screen resolution in our computer labs. Finally, I’m the kind of person that develops kinesthetic memory about websites and like things to happen fast. If I’ve to wait for a navigational element to load before I can click on it, that just annoys me.

The Synapse website team is listed on the contact page. We started working in October. I don’t remember how, but we had agreed to use horizontal scrolling. It was either that or a 4 way grid like NoFrks. I had seen it in action at Join the Game and it looked good if executed well.

Platform choices

Our website is powered by: * CodeIgniter * MySQL

The backend is virtually untouched from the 2010 version. CI uses great url –> filename mappings, and I took full advantage of that to create a very dynamic website. Helpers are another use advantage. For an example, quite a lot of events require registration. Manually going to every page and adding an event specific link seemed like too much effort. Instead I inserted a common function in every page, and the function consults a table to see if the event actually requires registration or not, and returns the appropriate link. Given a choice I’d liked to use Python, but our server does not support it, and this way was probably better in time savings.

On the client we use: * jQuery * jCarousel * simplemodal * tinyTips * easing * lightbox * scroll * Some CSS3 for rounded corners and WebFonts when available

CI also allows clean URLs using routing and so that problem was solved. With a ready backend, we had much more time to work on the frontend.

The site works in IE > 7 and any relatively new Firefox and Chrome. It was never tested in IE6 because we didn’t have access to one. Finally, most visitors are engineering college students who are quite likely to use modern browsers.


For a website like Synapse, which has 3 level events, the navigation can be a make or break. I wasn’t so happy with last year’s attempt which had too much hover, and the users had to search three levels deep if they forgot where the event was.

An initial attempt at a better navigation was made using SpaceTree. It is a really good navigational tool, and significant effort was invested in trying to make it fit the Synapse event model. The plan was that on the Events landing page, the SpaceTree would be the main content, and clicking on a event, would open the event details in a modal dialog. But that just sucks. I wanted to remove as many click’s as possible. The next option was to shift the SpaceTree a bit to the left and fit the content to the right. But with the 1024px constraint, that wouldn’t work. Meanwhile I was facing some issues with the spacetree, it requires a special script to work in IE, was causing graphic glitches in a Chrome beta, and wasn’t behaving nicely in terms of firing events. The Javascript Visualization toolkit is really good, but it didn’t cross over well to navigation.

We decided to remove an entire level by showing the navigation in a modal dialog. So all the Technical events get shown together, all the Cultural together and so on. This still means two clicks to get anywhere, but gives users a very obvious heirarchy, while at the same time not requiring them to remember anything except the name and the category (which is usually quite obvious). The current representation is of course dependent on the theme, but I’ve to stick to a certain order in this article. Chronologically the theme plan came after the SpaceTree idea and before this one. We had two iterations even in the current situation. The first one was to push each navigation ‘card’ to the top left, over the green of the joker’s head. That would leave us with more space for content. But it clashed horribly, and was too small. Also our site is such that my cursor is much more likely to be to the right of the screen, so it went to the right.

The Theme

Agreeing on a design to represent the theme was the hardest part of the entire endeavour (the second hardest was getting it to work in Internet Explorer). The Synapse website has 4 main areas:

  • Landing
  • Events
  • Sponsors
  • Contact

Registration can usually be put in a separate window or per event. We had four characters also finalised.

  • Gabbar from Sholay
  • Amitabh Bacchan from ? ( yes I don’t know my Bollywood films )
  • King Leonidas from 300
  • The Joker from The Dark Knight

The first plan was to have a movie projector on the landing, with the Synapse logo embossed into it. Each navigation pane would be film-strip like. But that is a cliche cliche. I distinctly remember ideas involving, flowers and 4 coloured sarees. Then somebody stumbled upon Lucuma. Oh, by the way:

The secret to creativity is knowing how to hide your sources. — Albert Einstein

That was it, we had the motivation and the final vision. Merging the scenes from one to another was a very good idea. In addition, if you notice the Synapse website carefully, certain parts of the background are shown only while changing the page. It was a bit tricky to get jCarousel to play nicely with that, but I got it working in the end. The Tree to Joker transition remains my favourite part of the site.

That week of 25th-31st October, we had a 109 commits in total (out of the overall 154 till now). So the team did work their asses off.

The rest was pretty spartan. A very simple black and white theme. The top navigation font is Neucha. Incidentally, we use Sans Serif fonts all over, including the main copy, because we don’t have much to read, and dropping the serif means more ‘white’ space. The character on each page adds a distinctive look. The top edge has a frayed look, but the bottom edge doesn’t. This is because while top margin positioning works across all browsers, the same doesn’t hold for bottom. It varies a lot with screen resolution and browser version and none of us had that good an understanding of the box model, or the arsenal of tricks more seasoned web-devs have to make this work.

The little things

Clicking on any events takes you to a event page, where all the top links scroll, except ‘Home’, which will refresh the page. This is intentional. The hash tag and jCarousel do not play well together. jCarousel has problems with indexing the right spots in the element list. So a hashtag couldn’t be used. Leaving the landing page their would mean a delay or click to get to the main content. But reordering the landing page on all the event pages would break consistency. With caching the home click should be almost instantaneous. So it was a compromise, and one that we should plan for next time.

The sub-headings in events and contacts are generated with javascript. The actual thing is just some

s, but scrolling in that tiny area can become tedious. So a domready hook collects all the h2s and create’s ‘tabs’ out of them. jQuery is good for these kind of things.

The registration page tries to be nice. If you’ve already registered before, details like your name, and phone number get filled in automatically. For students inside the college this is instantaneous, and a major time-saver. Since more than half of our participation is from within college, this is a very good usability improvement.

The second usability issue in the registration form is quite subtle. If you enter the wrong password, focus is immediately drawn back to the password field. But if you focus on a different field again, it won’t pull you back the second time. This is because it is quite possible that I want to fix the username instead of the password, and always pulling focus to the password again wouldn’t allow that. So alert the user once, but give up after that. Of course, the values are double checked upon submission, so security is not compromised.

Finally by asking DA-IICT students for 9-digit IDs we can always contact them while ensuring uniqueness, while also auto-filling the institute name and removing the option for accomodation, ensuring that people are only shown what is required.

The horizontal partition puts a physical differentiation between common fields and per-event fields. In fact, we can even add custom fields for events which require them, by simply making entries in the events details and the page will automatically include them.

In summary, the Synapse website is a pretty good architecture, and quite well thought out. There are certain improvements that are visible in hindsight, but which we looked over inthat one week of crazy work. The result is quite stunning though.

Posted via email from nikhil's posterous

Semester 5

Its been ages since I’ve got a post up, but I have my excuses. I have been working on a static site for myself, self-hosted and with my own domain name. I thought I would only resume blogging once that was done, but it is going to take some more time. Now with December a week old, it is time for my customary brain dump about the entire semester. In many ways these posts are highlights of the semester according to me. The short version: It was busy.

Last time, it was summer and I was in GSoC euphoria, and since then I’ve had a couple of posts about it and KDE, but I left out all the human bits.

The fifth semester is an important stepping stone in DA-IICT. It is the first time that you are free to chose half of the courses depending on your interests. It meant I could give up Communications, which had always hit me hard when it came to grades. So I had Introduction to Algorithms, Embedded Hardware Design (EHD), Database Management Systems (DBMS), Computer Networks (CNS), Introduction to VLSI and Approaches to Science Fiction (SF).

EHD was a course which was very interesting and very boring. The interesting part was programming Atmel micro-controllers in C. I. Loved. It. We even made a wicked cool one-way chat that used two Atmel boards. Typing messages to the serial port on one computer, would send it to the board, which would Huffman encode it, send it across the SPI bus, where another board would decode it and send it to the second computer. The SPI bus can be swapped with any system for longer range communication, it was only that our board didn’t support it. The boring part was the second half, when we were programming FPGAs using Verilog. FPGAs are the kind of technology that tries to think too much. It also makes programming the simple things on them extremely convoluted, with pin assignments on the massive board and using the god-awful slow Xilinx ISE environment. Write to Run time is a crucial parameter of programmer happiness. When you can finish a large ice-cream scoop in the time it takes to burn changes to a board, something is wrong.

Speaking of ice-cream cones, for the first time ever, I bought an entire pack worth of ice-cream (Baskin Robbins) and ate it all. It was delicious! It was great. It just got a bit boring towards the end. The 24th was incidentally the coldest day of November in Gandhinagar, and at 1pm in the afternoon, I was shivering, it was raining and it was the middle of final exams. It’s good I wasn’t thinking about the probability of getting sick.

VLSI was my most challenging subject. The professor was top-notch, and I loved the course. The look at how ALUs and memory is made using CMOS gates — that was truly full-stack knowledge. It was calculating the delay that seemed really tough for first two exams, but by the third exam I had it down well and managed to get a 7/10 overall.

DBMS was a fiasco. I disliked the course, I disliked the teaching assistants, I disliked the boring stuff we had to do in the labs. CNS labs on the other hand were very interesting, we did a lot of Wireshark inspection and set up BGP/OSPF routers. Very hands-on. The lectures were another matter. I attended 3 out of the 40 odd that happen in a semester.Algorithms was pretty normal, some very interesting things like O(n) median finding in an unsorted array and dynamic programming is a wonderful technique for solving problems, although not easy to get your head around.

Which brings me to the final course, Science Fiction. It was brilliant! We watched influential movies from the last fifty years, and I plan to review all of them in another post. It gave me a chance to review Stephen Baxter, analyze time travel and opened my eyes to this whole idea of SF being influenced by the society in which it was written. We had a very questioning professor, who introduced all these ideas. For all my life I’ve read novels pretty cursorily. The deeper themes and clues were lost as I spread through them. But that course brought all these things out. I’ve learnt to appreciate writing — the subtlety of language, the thorough research, the names — everything has to come together to create that perfect book.

With that course, and Entelechy bringing out 3 editions in one semester, I’ve written tonnes of articles in those 4 months, and it has spurred a certain love of writing. I need to work more on my description, and emotion more though.

Football always proceeds in fits and starts at DA-IICT, and this semester was more of fits. First I got a nasty ankle sprain, there went two weeks. Then my new pair of studs/cleats tore. Fortunately, the showroom didn’t have a replacement, so they gave me better ones! Neck-deep in work, I also had to forgo the tournament in IIT Kanpur.

As October approaches, Synapse preparations start. After last year’s series of disasters with a bad looking website and a server fire during the actual fest, we needed to strike back. So check out this year’s website. In fact, a full post about its making seems to be in order. This was done in one week, with two very late nights and taking advantage of the superb back-end code from last year. It has reinforced my belief that for something to be successful and worth doing, that initial idea has to be top-notch, a vision that provides very strong motivation. A mediocre idea will often lead to lack of perseverance in the team. Also I shamelessly request all readers who are college students to take part in Apps Dreamer

There was Hackfest of course, and I’m going to this year too. With an extremely busy four months, I’ve realised that its time to start saying no. I had a lot of mandatory tasks plus some others I took on voluntarily, but it proved a bit too much. So I’ve been really relaxing this month. That doesn’t mean I’ve stopped programming or learning. It means that I don’t do too much and the moment I feel tired, I stop. Next semester will again have a few projects, and I’ll be attempting the GRE, so I need to recharge this month.

Overall, semester 5 was good. Not enough academic learning, but lots of non-academic learning, and very busy days. Something I don’t want to repeat again :) The weather all throughout was magnificent though. The rains decided that 4 months was too short a time, and continued almost till the beginning of November. That coupled with winter felt just great.

Posted via email from nikhil's posterous

Sunday, October 17, 2010

UPnP MediaServer KIO Slave is OUT!

I’ve released the first version of the UPnP MediaServer KIO slave which allows KDE applications to seamlessly browse UPnP devices on the network, and access their files. An outcome of my Google Summer of Code, this is the first step towards getting UPnP Collection support into Amarok. For now, the slave is meant for application developers since dolphin & co. in KDE 4.5 do not directly know how to launch it.

The recommended way to detect UPnP devices and invoke the slave is with Cagibi. To browse the device, run konqueror with the URL “upnp-ms://” where UUID is something like


which has been retrieved from Cagibi

Full release announcement is at

Download v0.8.0:

I request early adopters and developers to test this out. Bugs and feedback is welcomed at

Posted via email from nikhil's posterous

Wednesday, October 06, 2010

Hackfest 2010

The usual convention in open source is that new developers get into a project by themselves. They follow online documentation and get into IRC channels and find their way around by themselves. Its not often that we get the chance to meet new guys and teach them the ‘tricks of the trade’. But that is exactly what happened at Hackfest @ Shaastra 2010

Hackfest got together mentors from various projects to introduce students to contributing to open source projects. We had Yuvi Panda for GNOME, Pratul Kalia for Android, and also Minix, and the Linux Kernel, and me for KDE. We also had the t3rmin4t0r for an excellent talk about the state of the Web.

KDE had 8 students. On day 1 (30th September) the computer systems weren’t set up, so we covered basic signals and slots, and I discussed the KDE architecture and useful libraries and then walked them through some sample code. After that the students found a Junior Job each that they would like to fix.

On day 2 we got KDE trunk compiled successfully and wrote a basic Hello Qt Application, following which I walked through a simple tweet fetcher to explain configuration, and creating basic GUIs. By the end of day 2, Anirudh S had got a simple menu entry bug fixed. I also fixed this Okular wish live, starting from scratch to demonstrate how to approach a bug. I will reviewboard it soon.

On day 3, three of the participants fixed a kwin Junior Job and we tried to take a shot at adding something like a ‘tick mark’ to the Notes plasmoid, although that didn’t succeed completely. After that everybody was pretty tired and so we stopped coding and we the mentors shared some stories of how we got into open source and so on with the crowd, Pratul being particularly good at that sort of thing. With that the actual event was done, and since my flight had been advanced to 5:30 in the morning I left.

The customized Shaastra distro made for the event!

The entire event was excellent, with the Hackfest coords and volunteers Subhashini, Sarthak, Kashyap, Kirtika and others did a great job with making us feel comfortable. I’ve never had someone send a taxi to the airport for me before :)

Posted via email from nikhil's posterous

Thursday, September 09, 2010

tmux and vim configuration

I’ve now been on tmux for quite a few months since migrating from screen.

aterm + tmux + zsh + vim makes a super command-line combination.

But there can be certain issues with the key bindings with vim. Since moving to tmux I’ve avoided using vim tabs since I couldn’t figure out the right key bindings to switch them using C-PgUp and C-PgDn when in tmux. But today with a little help on #tmux and kerneltrap I finally got things working. So here are my .tmux and .vimrc files for posterity.

# start a new session on tmux att if no existing session is running new  # screen prefix key set -g prefix C-a  # large history set-option -g history-limit 100000  # swap on C-a C-a bind-key C-a last-window bind-key k confirm-before kill-window bind-key r source-file ~/.tmux.conf bind-key v split-window -h #similar to vim's vsplit bind-key h split-window  set-option -g default-terminal "screen-256color"  # status bar customisation set-option -g status-bg default set-option -g status-fg green  # highlight status bar on activity set -g visual-activity on  # change foreground-background for the current window setw -g window-status-current-attr reverse setw -g monitor-activity on  # for vim setw -g xterm-keys on  # load average, battery, and date + time set -g status-right "#[fg=magenta] #(cat /proc/loadavg|awk '{print

$1 \“ \” $2 \“ \” $3}‘) #(acpi|awk ’{print $4;}‘) #[fg=cyan]%d-%m


# put the programs to start by default here # one $SHELL is always started at 0  # todo/bugtracker neww -n yokadi -t 10 yokadi  # focus on first window select-window -t 0  set status-left-attr reverse


syntax enable filetype on filetype indent on filetype plugin on  " Fast editing of the .vimrc map e :e! ~/.vim_runtime/vimrc  " When vimrc is edited, reload it autocmd! bufwritepost .vimrc source ~/.vimrc  " indent related set backspace=indent,eol,start set smarttab set expandtab set sw=4 set tabstop=4 set softtabstop=4  " other view settings, some redundant set t_Co=256 set number set autoindent set smartindent set showcmd set showmatch set ruler set tw=0 set hlsearch set incsearch set magic  " I don't like swap files set noswapfile :highlight Pmenu ctermbg=238 ctermfg=white gui=bold  " for tmux set mouse=a set ttymouse=xterm  " following taken from set hidden runtime macros/matchit.vim set wildmenu set wildmode=list:longest set title set visualbell  "mappings " fast saves " fast quit " and tag/tree toggling :nmap  :w :nmap  :wall :map  :qall :map  :TlistToggle :map  :NERDTreeToggle :map  :FuzzyFinderFile  :let NERDTreeQuitOnOpen = 1  " ignore case when searching :set ignorecase " but if any character is typed uppercase, respect the case :set smartcase  :set wildignore=*.o,*.pyc set completeopt=menuone,menu,longest,preview  :set scrolloff=8  :set wm=4  " use ack instead of grep for vimgrep :set grepprg=ack  " abbreviations " useful iab xauthor Nikhil Marathe <> iab xdate =strftime("%d/%m/%y %H:%M:%S")  let g:GetLatestVimScripts_allowautoinstall=1  " Tell vim to remember certain things when we exit "  '10 : marks will be remembered for up to 10 previously edited files "  "100 : will save up to 100 lines for each register "  :20 : up to 20 lines of command-line history will be remembered "  % : saves and restores the buffer list "  n... : where to save the viminfo files set viminfo='10,\"100,:20,%,n~/.viminfo  " when we reload, tell vim to restore the cursor to the saved position augroup JumpCursorOnEdit au! autocmd BufReadPost * \ if expand(":p:h") !=? $TEMP | \ if line("'\"") > 1 && line("'\"") <= line("$") | \ let JumpCursorOnEdit_foo = line("'\"") | \ let b:doopenfold = 1 | \ if (foldlevel(JumpCursorOnEdit_foo) >

foldlevel(JumpCursorOnEdit_foo – 1)) |

\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 | \ let b:doopenfold = 2 | \ endif | \ exe JumpCursorOnEdit_foo | \ endif | \ endif " Need to postpone using "zv" until after reading the modelines. autocmd BufWinEnter * \ if exists("b:doopenfold") | \ exe "normal zv" | \ if(b:doopenfold > 1) | \ exe "+".1 | \ endif | \ unlet b:doopenfold | \ endif augroup END  :runtime! ftplugin/man.vim  vnoremap  * :call VisualSearch('f') vnoremap  # :call VisualSearch('b')  " Smart way to move btw. windows map  j map  k map  h map  l  " Allow Ctrl+PgUp/PgDn in tmux set t_kN=[6;*~ set t_kP=[5;*~  " reduce vi compatibility for more usefult stuff set nocp

Posted via email from nikhil's posterous

Sunday, August 29, 2010

Knocked out of Node Knockout

(This is one of those you-don’t-really-have-to-read-it kind of posts)

I was very excited about Node Knockout. I had a great idea for an IRC bouncer + websocket based client called Ircsome using node, qooxdoo and a couple of other things.

I knew that I would only get 24 hours since Sunday had higher priority events, but I believed I could get the basic app working in 24 hours. Until things went downhill from last week. First my brand new shoes tore, and since Adidas has an idiotic replacement policy (even in their centralised, computer based inventory systems) where-in you’ve to go to the same store you bought it from, I lost about 3 hours of my time at home ( although I managed to pick up Erlang Programming. Then in the train home, I rebooted my cell phone and my SIM card just gave, it refused to work. There went my internet connection, no frequent push-pulls. Still I managed to get the client and server atleast talking to each other and logging onto IRC when the user filled in the details in the browser. I pushed out the changes over my home connection, and the push to Joyent succeeded, yet my server didn’t seem to be running, atleast my home internet configuration couldn’t manage to connect to it on any of the expected ports (even though push to the same server worked). By this time I was really annoyed, and had to sleep to, so I stopped. Knockout!

I plan to continue on Ircsome though, so I can deploy my own home brewed bouncer on my (coming soon) VPS and access IRC and logs from anywhere. Qooxdoo is a pretty great toolkit, but lacking certain kinds of documentation and being very heavy in size. Its almost like Qt, though I dislike the Java getter naming convention.

Posted via email from nikhil's posterous

Saturday, August 21, 2010

Final Evaluations results processed for Amarok and KDE UPnP Integration

Hi Nikhil Marathe,

We have processed the evaluation for your project named Amarok and KDE UPnP Integration with KDE.

Congratulations, from our data it seems that you have successfully passed the Final Evaluations. Please contact your mentor to discuss >the results of your evaluation and to plan your goals and development plan for the rest of the program

Greetings, The Google Open Source Programs Team


Posted via email from nikhil's posterous

Saturday, July 31, 2010

Whats up doc?

Pardon me for the excessively cliche title, I was short on time :P

Its been a week now since college began, and already I feel the
extreme busy-ness that occurs trying to squeeze every activity into 24
hours. The vacations were comparatively totally empty.

The UPnP collection support in Amarok is concluding pretty well. Today
I committed the fix that considerably shortens the amount of data
transfer required over the network for subsequent queries once the
local cache is relatively filled. With a relatively small share on
miniDLNA, I got near native performance, with the tracks being
populated as soon as I opened up a tree. The kioslave too has had some
additions that allow applications using it to bypass many of the
user-friendly features (required for browsing via Dolphin or
Konqueror) and get blazing fast results instead.

With another Amarok release coming up, I want to get some time to fix
bugs, but it has been hard to come by, even on a weekend.

My other pet KDE project has been Rekonq, more specifically Chrome
extension support. I can't remember the last time I blagged about it,
but just so it doesn't get buried as defunct project, let me give a
status update. Work is slow but not stalled. I have extension
installation working. I have figured out how to interface the C++ and
JS parts, although it is a bit hacky. The Chrome Tabs API is mostly
implemented, (localization and script injection and message passing
are not), including the captureVisibleTab() method. Now that I have
some experience, it should be much easier to implement the rest of the
APIs. I still have to figure out how to implement background pages
(most likely a WebTab not added to the UI), implement safe message
passing and so on. A nice UI to manage extensions would also be
required, and it would be great if others are interested in jumping in
to the project.
I would be glad to explain the architecture ( I have a IRC log lying
around, thanks to Rohan Garg :P )

I don't know about 1.0, but extension support will get there in the
end, so lets not remove my name from the Credits :)

Posted via email from nikhil's posterous

Saturday, July 17, 2010

UPnP Searching

I’ve been pretty quite about GSoC progress. But I had a great time at aKademy and forgot all about blog posts. So the current status is thus. If programming was just about getting things done, I am done! But its not, which means although everything I was supposed to do is done in a big picture way, the next few weeks will see bug fixes, optimization and ensuring that certain things can be done faster, more accurately or in a more user-friendly manner. I also have to port the code over to use Solid, now that fellow GSoCer Paulo Romulo has improved UPnP support in it.

Last time I gave a glimpse of the Browse based collection. UPnP MediaServers have two methods of accessing their content. Browse() is similar to going through your hard-disk directory by directory. As you can see, this can be quite inefficient for a Collection since it has to keep track of a large number of tracks. The other method is Search(), wherein users can query the MediaServer to give tracks/media matching certain criteria, such as belonging to a specific artist, or containing a certain pattern in the name. This is much more efficient because all the work is done by the server and we just need to handle the results.

That has been the crux of my work this past month. Due to the restricted format of the UPnP search standard, it required a bit of work to handle more complex queries. In addition, due to the way the Amarok Collection and QueryMaker code works, I have to always ask the server for tracks rather than telling it to return on Artists or Albums. It took quite a bit of experimenting to understand these two things. But two days ago the collection started working with actual searching for simple patterns.

Here is the Search based collection with no search.

Here it is with a search term.

I should point out that the code is intelligent. It will contact the server and ask it if it supports Searching, or only Browsing and use the appropriate collection.

Other than that there are several bug fixes in the slave and in Amarok and support for reference IDs to prevent duplicate items ( every FOSS software server I tried still doesn’t support refID properly though ).

By the way, I passed mid-term evaluations. Yay!

Posted via email from nikhil's posterous

Friday, July 16, 2010

Fogged goggles

It is my habit to go swimming daily in the summer. This is the time when I am home from college, but the poor Mumbai University chaps are trapped in exams. The swimming pool as an habitat is a fascinating picture. And with no distractions it proves to be an ideal ground to pay attention to the human species, not to mention overhear conversations. I’ve come to the conclusion that swimmers can be categorized and a taxonomy is not far off.

First up are Blubbers. Physical characteristics: men, past their prime, pot-bellies. It is undoubtedly easy to identify a Blubber. A lone Blubber is not so interesting. A tendency to not take effort leads him to float on his back. Since fat people float without effort, he can enter a state of quiet contemplation.

It is when Blubbers congregate that things can get interesting. If you ever have the opportunity to stand next to a Floogie ( a group of Blubbers ), watch them try to out do each other every time they talk. You will notice that all those ‘achievements’ are always in the past. Exploits of swims attempted in rivers in their youth, or nephews and sons who have reached heights come up often. But mostly it is the banter of how the country is going to hell and how every politician should be burnt and what they would have done in the same situation. I should mention that it is quite common for them to also plan the next drink-guzzling afternoon where-in each will try to increase his beer-belly more than others. Warning: It is dangerous to expose children to Floogies. Make sure you are strong minded and get far away at the first moment of light-headedness.

We now turn to Ladies. Their count is lower due to a lack of time or often devotion to other things. I should remark that swimming seems to bring their words-per-minute down by about 80%. Owing to the awkwardness involved in getting close to one, Ladies are quite an under-studied species. Some female readers might be interested in expanding upon this, the US military is always looking for ways to spend money on completely pointless things.

Kids. Don’t you wish you could be one. Kids are extremely easy to identify. They are small.

Some tend to morbidly afraid of the water and will not go in until forced by a Moleskein guardian ( see below ). Once they take to the water they immerse in their own world, unaware that they are about to kick a swimmer. Groups of kids often avail of trivial pursuits like throwing a coin into the water and rushing to get it. This is encouraged, it is known to lead many to become Swimmers later. Interoperatability between the sexes is best at this point, after all ignorance is bliss. The ease of swimming is inversely proportional to the number of kids in the water, as normal traffic rules do not apply to them ( Lack of rules has also been observed in Blubbers ).

The author feels no qualms when he puts himself in the species called Swimmers. They are the alpha males of the pool, strong, lithe and confident of their ability in the water. Their aim is to exercise, to push themselves to do as many laps as possible. It is quite unfortunate then, that every other class conspires to block them, hit them and more generally just piss them off by mere presence. In densely populated pools, Swimmers have been known to demonstrate extreme reaction times. It is my inference that this is due to the need to grind to a halt when a Kid comes in the way.

Moleskeins. Mostly harmless.

A major cause of concern in my pool is the lack of a species called Beautiful Girls. Taxonomically perfectly named with the English word ‘beautiful’ denoting physical appearance and ‘girl’ meaning ‘young of female gender’. Extremely rare species in these parts of the world, swimologists have laboured to collect information about them. Your author has had the bad luck to observe only one in his 3 month sojourn. It is unfortunate that she could swim a bit. This immediately discounted the species Damsels in Distress. This is bad because it has led to my inability to be called “my hero” which is important for a Swimmer’s confidence.

The rarety can be comprehended by the fact that only once in this time was the BG close enough to attempt communication. Alas, I was checked in my attempt by the arrival of a Blubber who attempted to teach the BG the right stroke. Considering that Blubber’s are incapable of coming within 50 yards of the right stroke, I think he must have read it in a book. This has led to my lifelong hatred of that species. It is the wish of me and my colleagues that Beautiful Girls increase in number, and that is the reason why I’m all for feminism.

( this is meant to be an anecdote, my first attempt at writing one. I will not apologize for any Politically Incorrect behaviour. I do not believe in PC in jokes. Enjoy :) )

Posted via email from nikhil's posterous

Friday, July 09, 2010

Akademy Day 5/6

Day 5 of Akademy was spent hacking too. Then I had a great meal at Plevna), Tamperelainen, which was mashed potatoes + lingonberry jam + Tampere’s famous blood sausages. Well it lived up to its expectations, the sausages were definitely good, but different. It was kind of like sabudana vada.

Unfortunately Germany lost :( The final will still be a good watch though.

Once again, I would like to raise my fictional hat to COSS and all the volunteers for the excellent organisation of this year’s Akademy.

The day trip was spectacular.

We were treated to Finland’s natural beauty in abundance. Merunlahti Centre for Nature Tourism has this camp like area right next to lake Höytämöjärvi with canoeing, slacklining and other activities.

The first thing to do was to jump in the lake, which was pretty cold. I have never properly swum in fresh water before ( which says something about India’s screwed up Nature ) so it was great. And unlike the sea, a lake actually has a reachable ‘other side’. So I swam across and back about 150 m or so. Give a human a log in the water and he is transformed to a 5 year old. KDE developers spent half the time trying various things like standing on the log, getting everyone on without falling off and other stunts, which was really funny and great ‘community bonding’. Maybe day trips should be done at the beginning of Akademy :)

I tried my hand at a bit of darts, but I am bad at it. Archery was more my thing. Slacklining was not. Canoeing was great though. I got a feel of the boat immediately, although it was my first time ever, I think I’ll be trying it again when I get the opportunity.

The food was great too. We had bread and fruits and BBQed corn and potatoes, sausages we could cook ourselves over a fire and marshmallows!

Now a sauna isn’t really my thing, but they had a great sauna house and so I took a few spins. When in Finland, do what the Finnish do. Get out of the sauna and jump into the lake!

Tomorrow is the last day of Akademy, and I will miss this place and all the fascinating people. I wish I had a hackspace like Demola, fast internet, food, no disturbances. Kudos to the organizers again.

Posted via email from nikhil's posterous

Wednesday, July 07, 2010

Akademy Day 3/4

Akademy just keeps getting better and better, and this year's location
couldn't have been more perfect.

The Demola office, if it could be called that, is the perfect
hackspace. Lots of tables strewn over the place, no partitions, sofas
to relax on and even a retro arcade game!

Yesterday and today and the rest of the week will be hackdays and
BoFs, so there isn't really much to report.
But at the end of today I just took a random walk across Tampere, and
its a beautiful city as you can see.

Tomorrow I plan to take the free walking tour that takes place everyday in Tampere, any other KDE
hackers planning to go?

Posted via email from nikhil's posterous

Monday, July 05, 2010

Akademy Day 2

Today was the day of fluffy, hands down! Frederik Gladhorn gave a
super lightning talk introducing his quite serious pet project

Other than this I attended Lubos' performance talk, and Milian and
Aleix's great KDevelop feature promo. I mean if Ctrl+Space can give a
complete program, why am I even learning C++? :) In addition Casper
gave a very nice talk about getting KDE to work on windows, and hats
of to the KDE-Windows team for there efforts.

The show-stealer was of course Aaron Seigo's keynote, exhorting all of
us to strive for 'elegance' now that KDE has achieved a great
technical base. The simple brush paintings, which I assume are done
with Krita, complemented it perfectly. So here's to more elegant

I spent the rest of the day tracking down a pretty annoying bug in the
UpnpSearchCollection and then find out that UPnP has no way to group
searches to clarify precedence. So I have to think about that
tomorrow. The thing with the first two days of Akademy has been that
by the time you settle in to do some coding, there is an interesting
talk :) So with that done, I am planning to get quite some work done,
not only with the GSoC but a few kwin and Amarok things too.

I will also attempt the Qt certification to see if I'm good enough.

The most important thing is that we had free icecream today, thanks to
the basyskom guys.

Unlike yesterday's party, today was a relaxed evening, with the TOAS
sauna running. I attempted it, but my body's capability to produce
sweat is very high and I had to get out in 5 minutes. I did some
random stuff, met some more people and figured out where the laundry
room is!

Posted via email from nikhil's posterous

Sunday, July 04, 2010

Akademy Day 1

Into the sea of existing akademy posts enters another one.

Technically its my second day in Finland. I arrived on the 2nd with Pradeepto from mumbai. We met seele and Justin at Schiphol itself, while blauzahl and Mek were on the same flight! If that wasn’t enough, the bus from Helsinki to Tampere found aseigo and Hans Chen on it too, making it the Akademy bus.

The Student House TOAS city is an awesome place to live in, with rooms just like in college, a bit better :)

The Finlayson area hack room was really cool too, and yesterday I spent a few hours there getting to know quite a few people, including Vishesh Handa. I also bought my KDE shirt. At 8:30, the sun was still high up in the sky, at 11, its like evening in Mumbai which was bizarre. Akarsh and Prakash also caught up after a delayed flight.

Today was even better. The keynote was pretty good, its great to see KDE going deeper into the mobile space. Meanwhile (Qt made sure to give us all a rubber duck)[].

I met a lot of people who have been mentors, helpers and friends over IRC – Martin Grasslin, Leo Franchi, Nikolaj Nielsen, Friedrich Kossebau, Martin Sandsmark, Lydia Pintscher and many many more, whom I have to talk too about various topics.

Thomas Thym’s talk about principles in open source communities was very interesting while both Nikolaj and Leo conveyed social music capabilities and Amarok’s role in it very well. During the few talks I didn’t attend, I tried to do a bit of work, but it was a little hard due to all the excitement :)

Now Martin had written a plugin for the match, but I couldn’t stand not watching it and missed his talk. I wasn’t alone. It was great fun to travel 9000 km to watch football with other KDE developers. And since KDE has a large number of Germans you can guess who was supported. Germany were amazing with a 4 goal trouncing of Argentina, and with this form they can easily win the Cup.

With all the talks out of the way, me, kstar and pinocchio went to the downstairs supermarket. I had a strawberry-pineapple bread and rajma-chawal for dinner :) followed by liquorice sticks.

The KDE Akademy party was at the Love Hotel on Hameenkatu and it was fun meeting a lot of people and talking non code stuff and enjoying the Spain-Paraguay match. But now I’m really tired and have to crash if I want to be attentive tomorrow, particularly with performance, UX and cloud talks.

Posted via email from nikhil's posterous

Saturday, June 26, 2010

A new kind of happiness

The Apple marketing machine created a tribe, giving to the rise of superfans whose identity/self-image hinges on being one of the first to own a new product. I don’t know if it’s Apple you should really blame, though. You should blame our culture for allowing the media to manipulate us, brainwashing us, shaping the behavior to work jobs we hate so we can buy things so we can be happy.

Posted via email from nikhil's posterous

Thursday, June 24, 2010

Saturday, June 19, 2010

Notification madness

Planet, my slave went awry :(
I terminated the processes, but is there a way to kill all the notifications at once.

Friday, June 11, 2010

GSoC Week 4: Experimenting with Collections

I didn't write a post last week, and it looks really bad in my form completion :) but I didn't have any user visible updates at all. This week is much better. First the visual then the text.

That's cover art fetched from the UPnP device when the Content Directory has it available!

Other updates include smoother full and incremental scanning of the Collection. This is one area which needs a lot more improvement. The kio slave is now threaded and continuously monitors the UPnP device for updates. This is used by the Collection to mirror the actual contents whenever possible. The slave is also now fully normally evented, without pesky internal event loops and blocking. I learned a lot about how signals and slots work in the mean time, and uniqueness and disconnections. Certain thread related things have been sorted so that the slave is much more bug free, although Bart Cerneels still made it crash :)

Now today I'm stopping work much earlier, because its time for the World Cup to begin, and I'm supporting Germany! I hope my excuse is good enough.

Oh, by the way:
Here's to meeting a lot of KDE devs soon...

Saturday, May 29, 2010

GSoC Week 2: Experimenting with Collections

Another week is already gone, and although it didn't see much progress feature wise, I've been working a lot on the project. Three days were spent on a nasty little hard to produce bug, one that would only occur 4 levels deep into the Content Directory, and not always in that case either. Finally with a lot of debug statements, many hours talking to Tuomo Penttinen of HUpnp we fixed a little bug in his library.

The reason the bug was present - MediaTomb was disconnecting my slave for connecting multiple times very very quickly. When it rejected the request, two slots were fired in the HUpnp code which caused multiple access's to certain data which should be modified only once... I'll spare the details.

Once that was fixed, I spent half a day getting the DLNA recommended meta-data being reported by the slave using custom UDSEntry fields. That was pretty easy.

That pretty much finishes the slave's Browse() API, since fetching file's is delegated to the HTTP slave. The next step is Search().

But I took a little break and started experimenting with Amarok's Collection code, which is HUMONGOUS and complicated. I still haven't figured it out completely. Like why Collection::queryMaker() has too return a new instance of a QueryMaker sub class everytime, or how the Capabilities system works, but I'll get there in the end. The result for today is manually inserting a track into the collection. Ah, I do like seeing progress:

Friday, May 21, 2010

GSoC Week 1: Kioslave is shaping up

(This post was published on Friday, but I put in a wrong tag and I didn't get aggregated, so, republished)

Although I've been hacking on my GSoC project for quite a while, doing little experiments and getting my mind around various factors involved, this week was my first official coding period, since that was what I had in my timeline.

The first piece to implement is the kioslave to browse UPnP MediaServers. This involves writing a parser for the DIDL-Lite XML format used to describe directory structures. The parser I developed this week can now parse containers and items and their titles and pass them on to the slave. Meta-data and extra tag handling isn't done yet, but I have time :) The slave scheme is upnp-ms and right now you have to pass the UUID. But once the network:// slave is modified, it should be seamless for normal users

Their are a few issues I have to take care of in the slave. UPnP identifies all objects merely by a numeric ID. Now it wouldn't be fun to have the user deal with IDs. So the kioslave uses names just like normal file browsing. This involves reconversion back to the ID whenever I have to talk to the server. If the user manually types a URL to jump to some other point, I have no information about the IDs leading up to that location. So I've to implement some resolving. This is what I did this week. It is still a bit buggy, but I haven't figured out if the bug is in my code or HUpnp ( most likely my code ).

Tuesday, May 11, 2010

This semester was... LEGEN-wait for it-DARY

It's been a week since the summer holidays, and that means another semester is behind me. Reflecting on the past two years of engineering, I would say that this semester has been the best 6 months of my life ever. I have changed (read: improved) in a hell of a lot of ways. I also dumped some of my inclination to always plan out the day and introduced some spontaniety. Just before the sem there was December, which meant and the rural internship. Both thrust me into the public all alone, resulting in an eye-opening experience. was a collection of geeks where for the first time I could talk to other people all day about technology and computers and meet lots of coders from around the country. From a wi-fi enabled, air-conditioned environment to a laid-back village in the middle of nowhere in 3 days. That was the beginning of my rural internship. Those 4 days in the village were quite boring, yet it also opened my eyes to what India was. It doesn't mean I am going to go and use ICT in a socially responsible manner -- It isn't as much fun as programming.

Next up was Synapse. For the first time any piece of my code was being interacted with by hundreds of people, as my backend powered the registration and site navigation for the fest. I knew my code was very good ( definitely better than some code I had to look at for some events with specific websites ), and it felt good when the amount of junk IDs were a very small percentage of the total number of registrations.

Then just a day before Synapse was to begin, we had a 'Bazinga!' moment. The server room air conditioner caught fire, rendering the entire DA-IICT network infrastructure down for about a week. No Synapse website, no updates to do in the dead of the night, which meant I had 3 days off to enjoy :-). This also meant I finally had time to give my laptop for repairs.

Enjoy I did. This Synapse was and will remain a very memorable one. We had a blast decorating the SAC for D-lounge. This involved hanging flags on the awnings by climbing a shaky ladder up to the first floor, then leaving both hands to unravel and hook up the flag. Next up was putting up a installation in the middle of the lotus pond. This required calling in a special-ops team as the pond was full of water. Which reminds me, someone has photos of the entire drama. That same rickety ladder was placed flat and one person sat on the end to keep it from toppling into the water. Then about five of us walked across to the first stage of the pond. Then the ladder was pulled across to the next level. Then me and tanmay passed over. After that the ladder was pulled back, and the artwork was passed over. Time for the final jump. The ladder was brought up all the way to the centre, and we literally pushed the canvas across it, hoping it wouldn't end up tearing or going in the water. Then we repeated the entire sequence to get back out. Fortunately, no one fell in, although two poor souls had to stand barefoot in the dirty water all this while.


Finally at 3am the task was done, or so we thought.

Synapse Day 1 - 10:30pm I had just finished the last lecture of the day, and wanted to go to Ahmedabad and get my laptop back. But a gust of wind had caused the installation to collapse. Which meant going back in again, this time much more easily and confidently, and sticking it into the ground using bamboos and nails.

Of course this isn't a post about Synapse, so I am going to jump ahead to day 2, which was all about Indian Ocean.
There is a secret to getting the best view at the Pro Nites in Synapse. Get into security, and know a lot of people. The concert was just a treat, well worth all the effort put into Synapse. It was mindblowing and perhaps only the video can capture most of it. They played some never before played songs which are to be released in movies soon. Yet Ma Rewa and Kandisa stole the show as usual. But the most important part is at the end. Once the concert was done we formed a cordon to let the guys get to their room. Now we weren't allowed in, but in an act of spontaneity I took of my Synapse T-shirt (right there!) and threw it in to the coordinator so he could get it signed. And then I *ran*, to the nearest bathroom which was still some 100 metres away :o Well it definitely paid of. In my closet is now a T-shirt signed by Amit Kilam from Indian Ocean. Finally there was the D-Lounge treasure hunt and the late night pool-playing. Ah... those were the days.

Ok, enough about Synapse. The other thing I do in DA-IICT is play football. This year has been a record in terms of the number of tournaments we've played. In the 3rd semester we went to Patan and had our very own Concours. Then we won the IPTG Petro Cup. And in March we went to BITS Pilani, Goa. I've been in top form ( if I should say so myself ) and improved tremendously in ball control and dribbling this semester. Although we lost in the first round, I was happy to hold my ground and not make any mistakes.

And finally there was of course the Google Summer of Code result. I hadn't got in last year. But this time I had put in a *lot* of effort and would have been really disappointed if I didn't make it. But fortunately I did

Now I just got my results, and I got an 8 out of 10 SPI, my lowest yet :-( All thanks to CT and EL, although it was my fault... Well you can't have everything.

Tuesday, April 27, 2010

Success! Google Summer Of Code

Well after all the micro-blogging at night and the IRC chat, and writing an exam, here is a really good post!

The proposal is Amarok and KDE UPnP Integration. I'll be working with mentor Bart Cerneels. This news was awesome! Last year I didn't get in for kwin-tiling, but I participated in Season of KDE and did a few other contributions all year and it paid off. This year I started of quite early and worked hard on the proposal. When the ideas list went up, Amarok UPnP integration seemed the most interesting to me. Since then I was in talks with Bart and started a discussion on the Amarok mailing list, that much to my surprise, was very responsive :-)

Now with the result out of the way, its time to start working as soon as my final exams get over this week. This will involve choosing a UPnP library and daemon for device discovery. The next step is to implement a KIO slave which can browse UPnP media servers like any other folder. The final thing will be to write an Amarok Collection which can index music on UPnP servers on the network. This involves filtering and sorting and also making the server play music when in the playlist :-), can't forget that. So its going to be a very eventful 3 months, with lots of commits, a T-shirt and lets not forget the money. Right now I'm waiting for the invitation to the private mailing list.

It was great to hear some stats. KDE got 50 slots, 11 Indians got into KDE, and 3 from DA-IICT got into KDE. Which is awesome! Sai Dinesh will be working on getting mobile phones working nicely with KDE. Aditya Bhatt will be working on Digikam face recognition. Others I know are Varrun Ramani, working on Amarok too, implementing Distributed Collections. Vishesh Handa will be working on Nepomuk, and finally the one and only :) Shantanu Tushar on Gluon. Happy hacking everyone...

Monday, April 26, 2010

KWin tiling is merged

I'm glad to announce that yesterday the kwin-tiling branch was merged into kwin trunk by commit 1118677!. It will be available in KDE SC 4.5. Please keep in mind that it is an experimental feature with rough edges. Bug fixes are already on the way, but some things, like session saving and so on are absent. Please do add feature requests and bugs to the KDE bug tracker.

This screencast should show off a few things. Apparently xvidcap produced really bad video, so I will have to do it again, watch out for updates here.

Thanks to Martin Graesslin for being my mentor during Season of KDE, and all the others who bugged me with emails about when tiling would be integrated into KWin :)

GSoC results now 13 hours away...

( Mamma, I'm not stressed out :-) )

Thursday, April 22, 2010

Quick and dirty Instant Messaging with Redis

(Aside: Yes this is a post after a zillion years, but I have a few more lined up, and waiting for some important stuff in about a week)

Redis is a wicked cool NoSQL database, in that storing stuff is not the only thing that it does. Mathias Meyer already has a collection of Redis use cases, but this great idea is mine. Like all good ideas it emerged in the shower :) ( I was not aware of Pieter Noordhuis' MUC when I did this, in either case mine deals with one-to-one IM )

Using the new publish-subscribe commands and a bit of node.js code, here is a tiny instant messaging server. An explanation follows, refer to the code while reading it, Blogger sucks for publishing code.

Here is how it works. For every client, the server maintains two connections to redis. This is because a subscriber is not allowed to invoke other commands. So we have a subscriber connection and publisher connection. Consider two clients are now connected, Alice and Bob.

When Alice connects ( NICK Alice ), we insert her nickname into 'mclarens:inside', a Redis set. This allows us to have a WHO command to list online members. Bob to does the same. To start chatting with Alice, Bob initiates a conversation ( TALKTO Alice ). The node server does none of its own client management. Instead each client just maintains subscriptions to two channels/classes. Each client is always subscribe to '[nick]:info', where it is notified of talk initiations and exits etc. When Bob wants to talk to Alice, he sends a 'start Bob' to Alice's info channel, 'Alice:info'. Then both Alice and Bob subscribe to the class 'Alice:Bob', using alphabetical order to decide the name. When either of them wants to talk to the other, they do MSG [nick] [message]. The connection uses the publish redis connection to send a message to the channel, resulting in both sides being notified of the incoming message.

To terminate the chat, one side just has to send a 'STOP [nick]'. That unsubscribes the user from the class so that he no longer receives messages. It also sends a 'stop [nick]' to the other side, so that he/she can also unsubscribe.

On QUIT, we simply remove ourselves from the mclarens:inside set, unsubscription is handled automatically by Redis!

That's it, simple Instant Messaging! Now this lacks any kind of security and ignore lists and status but proves the point. In fact I'm thinking of using this as the backend for the IM part of the XMPP server I'm hacking on. At this point it is in no shape to have this feature just yet, but it should some day.

(Thanks to roidrage and tnm on #redis for pointing out that I had to use two Redis connections for PubSub.)