PHPthrowdown 2007 retrospective

The PHPthrowdown, a 24 hour php programming contest that happened from 27th to 28th of January 2007, has come to an end. Together with Anant Narayanan I formed the "cookie eaters" team. All we knew before the categories were announced was that we wanted to use PHP-Gtk to create our application.

When the categories (php-gtk, inventory management, game, open category) we posted on the phpthrowdown website, we knew what to do: Create an offline frontend for blogs, utilizing the Services_Blogging package.

The only other competitors in our php-gtk category we know of were the GtkMerryWizards and Mistress (also merry) that were Elizabeth, Leon, Bob and a "fjace". Knowing that there were over 100 teams competing, it was a pretty familiar bunch of people.

A problem, before we even started

On Wednesday 24th Anant told be that his talk on the Gnuify conference had been accepted. After congratulating him, he told me that the date is exactly when phpthrowdown took place. I told him to enjoy the conference, we won't compete on the throwdown, but he still wanted to try since there should be Wifi on the conference.

Preparation

Since Anant sits in India and I in Germany, we needed to communicate somehow. Jabber instant messaging has been used and proven to work for years, so this was tool number 1.

Talking is however much faster than typing, so we tried out some VoIP packages: Kopete, Ekiga and TeamSpeak. Skype will never see my harddisk since I read the news article about how skype has been reverse engineered, understanding that Skype is not only a security hole, but a whole door and you don't even know which data is transferred from or to your computer. Ekiga works, but is too laggy for proper communication around the globe. Since my server runs some TeamSpeak server processes anyway, we chose this - voice was transmitted fast and in good quality.

The next software we needed was some collaborative whiteboard, e.g. to draw class diagrams or visualize things. There are many proprietary apps, but few working open source programs that also were in portage, Gentoo's package manger. Inkscape, my favorite vector drawing program got collaborative whiteboard support through Google's summer of code. The Gentoo package did not have support for this configure flag, but some older version did. It works really nice; the best thing is that it uses the jabber protocol - we could use our existing accounts on the server and didn't have to care about opening new ports in the firewall at all.

The last piece of collaborative software I found to be useful was Gobby, a text editor that allows multiple users to connect and edit the same document at the same time. If you know the unix command talk: It's the same but with syntax coloring, multiple documents and with everyone moving his cursor on the same text, not split screen.

On Friday I prepared myself by setting up some demo blog installations we could use to test our program with and checking that Services_Blogging worked with them. The test turned out to be a good idea since it a) revealed a tiny bug in the PEAR blogging package that threw an E_NOTICE and b) I saw that Serendipity does not have the XML-RPC plugin installed by default.

Another thing was that I set up the svn repository and tried to commit some test file. It turned out to always want the password (we used svn+ssh) and the server did not allow to use authorized_keys. Bill, the server admin was very fast changing the configuration so that in the end checkouts and commits could be done really fast, without typing passwords over and over.

24 hours

We had decided to go on the 6 o'clock UTC timeslot, so at 7:00 am I was sitting on my desk, laptop and all programs running, music playing. Anant wasn't online yet, so I started with the task you need to when starting a new program: Setting up directory structure and creating the first files. After this I began with the configuration class that was to hold the account data and offline/online state.

At 8:25 a small balloon appeared; Anant finally was online - the wifi network there used WPA, and he first had to setup wpa_supplicant.. Next problem was that Wifi there was not accessible from everywhere and he had to stand (not sit) beneath a window to be online.

We needed to decide who does which task; Anant would create the frontend and I was responsible for the backend which holds the blog posts, saves them on disk so that you still have them when closing and starting your application and sending them out to the blog servers. It was 9:02, more than two hours after the contest begun and we just decided who does what. Anant told me he understandably couldn't stand at the window all day and would come back in three hours.

Some hour later he was back; a chair at the window solved the wifi problems for now. We had normal chats asking each other implementational questions until he had his talk at 12:30. When coming back online after his talk, he had bad news: The conference was over, and Wifi would be shut down in half an hour. We quickly needed to decide how front- and backend work together and which signals need to be exchanged.

In the meantime

After Anant went offline 14:07, each of us was on his own. We both had our tasks, and I was quite confident everything would work out well. At about 15:00 my settings GUI was done, settings were saved into a ini file using the PEAR config class.

Next was the Queue implemention that would be used when a blog post has been written and needed to be stored before sent out. This should work during sessions, that means you ought to be able to close your app after writing the post, and start it up and send out all queued posts when you're online again.

It was 22:something when that worked as it should: Publishing the queue, transparently storing and loading the queued posts from the harddisks. My task was done, and ideally I would have started integration with the frontend now if only Anant have had network access at this time.

I surfed around the other group's blog and read their feature list; the wizards were to build an image/photo management app with rudimentary image manipulation functions. The phpthrowdown blog showed me that our group also had a blog, just that Anant failed to communicate that he set it up and tell me the account data - I had time to write, but couldn't blog it...

With all the time left, I decided to write a progress dialog that pops up when publishing posts since Anant would a) not think about programming one and b) I had the Queue code and was familiar with it. After introducing some new signals and coding for some time, we had a progress window that magically pops up when sending out either the whole queue, or sending a single post and hide when work is done.

At about two o'clock I thought that my Iterator implementation in the Queue class was not optimal and would suffer from data inconsistency when not used properly enough. I replaced my index variable by using php's array functions current(), next(), key() and reset(). While tweaking the Queue a bit more, I discovered that it didn't send out all of the posts anymore. I debugged a bit and became aware that you shouldn't use unset() together with next() on an array. So I reversed it to the old code..

IRC was very quiet ad three am, and since my work was done or on hold, I watched some episodes of Grey's Anatomy until it was 4:45 and I had to wake up Jana since she had early morning duty.

Now it was nearly half past five and still no Anant in sight - I was getting nervous since 7:00 was deadline.

The end or the desaster

The end begins with a "ping" message from Anant at 6:05. Kopete did not show me that he was online, and according to Anant I wasn't visible for him, too. He had already been waiting for half an hour - damn Jabber presence protocol.. we would have needed this time so badly.

I checked out from svn, expecting some 10 changed and new files. It was three. Three updated files. I started the program and got Glib errors. Glib errors from a freshly checked out piece of code? Was my Gtk installation broken? Did I do something wrong?

No. It was Anant's try to create a model for a GtkComboBox that failed. It failed althought he had 12 hours to get it working! I really do not know if he didn't have the manual handy because he was offline, but since he contributed to the manual he should have had the PHP-Gtk manual sources on his laptop. With examples. With an tutorial about exactly this. So I copied some of my settings code that also created a dropdown and it worked within 30 seconds.

As my next step I tried out the toolbar buttons: New, View Queue, Settings, About, Exit. Guess what? Settings showed up when I clicked them. That was all. Four of that damn five buttons did not do anything, not even the exit button! Did I tell you that there ought to be an online/offline button in the status bar? It was an image with a hard-coded "online" text next to it. After investigating I found out that this label did not even have its own class variable! It was locally defined in the method that created it - as if it was never meant to be changed again.

The write-a-blog-entry tab was there, now with a working blog account selection. It has two buttons on the bottom, one to publish the entry directly, and one to put it onto the queue. I clicked both of them, and they also did not do anything. When fixing this I saw there wasn't even a method that put title, text and blog account name into a blog post object that could be put onto the queue, although we had decided before that we would have an add-queue signal. And even that GtkTextView/GtkSourceView did not have a class variable I could use to get the text from.

Time was running out, it was about 6:49. 11 Minutes unti deadline. The new button did not work, although that did not require any of the backend features I programmed and Anant had no access to. The About button did not work! Is it really such hard brainwork to get a simple about button work? It actually was supposed to call some static about method in the main gui class, but Anant had commented that out, and the static method was missing.

I did tell you that we planned to have a queue to put all posts in, didn't I? The toolbar actually had a "View queue" button, but it - surprise - did not do anything. There wasn't even a class for it. Not a single hint that such a thing was planned to be in our app.

My last action as captain on the sinking ship was packaging the PEAR package of our application and checking it into svn. Originally I had planned to write that package.xml when we're done integrating our two parts of the program, but luckily I did it at night when I had nothing to do. So I uploaded a program that worked somehow, but had only 1/3 of the features we planned. It behaves a bit strange when seen from outside, you don't see how many entries are in the queue, you cannot see or edit the queue, you have to manually erase text and title if you want to write a second blog post.

After the end

I was pissed. I was really pissed, and if my knowledge of english swear words would be better, Anant would have heared lots of them. I know him as a quite good and reliable programmer, but at this contest it was - so bad my vocabulary is not big enough to express it. Instead I shut down and went to bed.

So, all in all, the first 4/5 went well and I was amazed how much you can accomplish in 24 hours. I am a bit proud of my code, but not of the application that we had to deliver.

Screenshots

All people want to see screens, and here they are:

Main window Publishing Settings window

Written by Christian Weiske.

Comments? Please send an e-mail. Or Reply or Like.