Thanks Tod!

May 31st, 2005 : bangladesh, featured, php

Tod Maffin wrote about my OPML project for on his blog, iloveradio.org. Let’s see how long it takes to for Tod’s entry to be the top item when you google “rasheq rahman”

(As of this writing, his original post is #10 on the results page.)


A new design again …

May 26th, 2005 : themes, wordpress

If you are regular at my blog, you know I have this almost bi-monthly fascination with changing the layout of my blog. This is largely due to my rapidly expanding knowledge of WordPress, css, and elements of good web design. I readily admit to suffering from “Gee that’s cool, why don’t I make my site look like that” syndrome. This incarnation was borne of the realization that my previous theme, while aesthetically beautiful, was hard to read comfortably. As I started hunting for a replacement WordPress theme my focus turned towards finding something that was simple. I googled for lists of wordpress themes and came across Emily Robbins’ exhaustive list of WordPress Themes.

I literally began clicking through this list until I came across a design called Conestoga Street by Theron Parlin. The theme caught my eye because it is very simple using a white background with black texts and selective coloring to highlight post titles, links and meta data. I also liked the fact that a single vertical bar separated the posts from the menu information on the right. I knew that I wanted to use a few WordPress plugins to display information on the right but I didn’t want it to look to cluttered by having the side bar boxed in.

Tweaking the design took a few hours of fiddling with the Theme editor but I think I have something usable and easily skinnable. Once I have some time I might investigate writing a script which would allow me to change the css stylesheet depending on the time of day so a visitor would see a different color scheme as the day wears on.

That is unless I get bored with this design and find something else.


My fifteen minutes of fame (or how to get OPML into HTML)

May 26th, 2005 : opml, php

A few days back as I was skimming through my plethora of rss feeds on Bloglines I came across a post from Tod Maffin looking for a programmer to write a simple script which would parse an OPML file of podcasts into HTML which could be included in a web page. The task was straightforward enough and given the ubiquity of OPML in RSS readers, I knew someone else would have at least written a basic parser in PHP that I could start with. I wrote back to Tod telling him that I was the man for the job and set about working on the script. I offered to do the script pro-bono as a way to help spread the word about public-radio podcasts which keep me entertained and amused throughout the day.

A quick google search brought me to Joe Grossberg’s PHP script for including his OPML Bloglines subscription list as an HTML un-ordered list on his blog. His code was very straightforward and well writen so I decided to use it as a base.

My first task was to strip out all the code that was particular to Bloglines OPML format and customize the script to the format of Tod’s OPML file (you can find an example here). This proved to be more difficult than I originally anticipated and I had to consult the PHP manual to understand how the PHP function, xml_parse_into_struct function worked in order to make sure I was pulling out the parsed podcast feed title and URL. However, after a few hours of trial and error, I was able to parse the OPML file correctly into an ordered list. I even added a small bit of code to ignore the first entry in his OPML file which is a link to add new podcasts. (Tod had hardcoded that link into his website and he only provided the link in the OPML file so that it could be used in the Ipodder directory to have podcast listeners contact him about new podcasts).

With the parsing complete, I turned to the task of displaying the podcast information in an HTML table. I took my cue from Tod’s orginial page which he had been manually updating as new podcasts were added. In that layout, podcasts were organized by categories and alternating categories had the same color so that it was easy to distinguish between categories. I wanted my script to generate the table entirely using PHP so I had to reaquaint myself with the process of writing code by hand because my script would have to add the table tags dynamically depending on how many podcasts were in the OPML file. After a few hours of tweaking the code and a night’s worth of sleep I finally had it generate a basic table which I could include in another PHP file.

In order to make the table a little easier to read, I used the trick of alternating colors for table rows that’s become popular around the Net and in applications like Apple’s iTunes. The easiest way I found to do this was to keep track of the number of podcasts in each category. Every time my script would go to write out the table cell definition for a podcast it would check to see if the podcast number was divisible by two meaning that it was even. Even numbered podcasts would be colored using one color and odd numbered podcasts would use a different color. To make things even more interesting, I kept track of the category number as well and wrote code to create two sets of even/odd color pairs – one for even numbered categories and other for odd-numbered categories. You can admire the results at http://todmaffin.com/feeds/ . http://publicradiofeeds.com.

With Tod’s permission I’m releasing the source code for my file under GPL so that others might benefit and improve on it. The file is called ipodder.opml.class.php. To use it, you’ll need to add the following code snippet as a table row in another .php file:

In addition you’ll want to set the color values for even/odd podcasts and categories using the following four variables:

Anyways here is the link to the ipodder.opml.class.php file.

I hope you find it useful in and of itself or as a point of departure for building your own OPML parser. Please email me with any feedback you might have at projects@rasheqrahman.com.


Code to determine the user’s offset from GMT

May 13th, 2005 : bangladesh, featured


The joy of open source

May 8th, 2005 : open source, php

I was first drawn to open source by the promise of free software. Blogs I read and respected would suggest a GPL’d app which I would download, use and not think twice about as long they worked. Open source apps were like any other piece of software – the only difference was they didn’t cost me anything.

However, now that I’ve been learning PHP, I have begun to appreciate open source apps in a completely different way. For me, taking apart a PHP program, tracing functions and variables across different include files, has taught me more than any book about how to write proper PHP scripts. The fact that I can “look under the hood” to see how a program is constructed is fascinating and has inspired me to do some tinkering myself.

Scuttle, my bookmark manager has a great feature which allows you to mark a bookmark public or private. This is most often done when the bookmark is first added but can be amended later by editing the bookmark on another page. By default, new bookmarks are publicly viewable which means that you don’t have to log in to access them. This is great for most uses but for personal bookmarks I would have to either remember to set my bookmark to private when I first added or click on the edit link which would take me to a separate page where I would have access to edit all fields (URL, description, tags, etc) related to that bookmark. All I wanted was a simple link on the page which would allow me to mark something as private or public without having to edit the entire boomark record. However, I noticed that beside the “edit” link there was another link called “delete” which allowed me to directly delete a link without having to go to another page.

Harnessing the power of open source, I was able to learn that the delete function worked quite simply and elegantly by parsing a URL which contained the id number of the boomark to be deleted. This boomark id was used by a php script to construct a DELETE query in MYSQL which removed the bookmark from the list of visible bookmarks. Knowing that making my bookmarks private or public was just a matter of executing an UPDATE query to set the bookmark status to either (0) for public or (2) for private, I easily copied the php file used for the delete action and modified the SQL script to UPDATE instead of DELETE. In the main bookmarks file, I also added two links to the script that created the bookmarks list which would allow me to mark boomarks public or private. Voila !! Without having to put in a feature request to the author I was able to customize scuttle to suit my work style.

Simply put, that’s really cool …


All about folksonomies

May 7th, 2005 : blogs, folksonomies, wordpress

I just installed Cat2tag a wordpress plugin to add folksonomies to WordPress. Though I’m not yet a power blogger (i.e. I don’t blog multiple times a day or for that matter multiple times a week), as a power del.icio.us and scuttle user, I can immediately appreciate the value of being able to create tags on the fly.

My only gripe is that I would love it if Edmundo could make tags comma separated instead of space separated. I like the multi-word categories names without underscores.