Planet WordPress Plugin Released

I love the Planet feed aggregator, but I hate managing it via a text configuration file. I created a WordPress plugin that automatically creates a Planet configuration file from the links that are stored in a WordPress database. Every time a link is updated, deleted, or created, a new planet configuration is generated.

For more information on how to install and configure the plugin, visit the plugin’s homepage. The source code for the plugin is hosted at wordpress.org.

DataIO

A few weeks ago my employer helped the NY State Senate parse the MTA budget information into a machine searchable format. (The MTA originally published the budget as a PDF.) To parse the PDF I used a utility called pdftohtml to first convert the PDL into an XML document. I then used the python library lxml to convert the document into a set of csv files. The results of this labor can be seen on TOPP’s data site.

Soon after I published this data, however, I was told by a number of people that the data would be more useful if presented in another format. At first I just started creating a bunch of command line python scripts that would suck in these csv files, and spit them out in different formats. I quickly realized that I could accumulate these scripts and create a quick and dirty web application.

Over a few train rides I created an application called DataIO, and today, I finally got a chance to upload it to Google App Engine. The application is pretty simple to interact with; instructions are located on its front page.

Continue reading

New Years Resolutions

Inspired by a friend I am going to create list of new years resolutions:

  • Learn a functional programming language. Any suggestions on which one to try out first?
  • Make fewer mockups and write more code. Web frameworks these days allow for such quick development that I think I would be more productive if I just skipped the Omnigraffle/Photoshop step.
  • Learn how to engage in effective Test Driven Development. I have heard of the benefits, but I have never seen a good tutorial on how to do this effectively. Maybe I just need to look a bit harder.
  • Don’t think about work while I am playing and don’t think about playing when I am working. Focus is always good. I am sure at least one person will be happy with this resolution.
  • Make a daily to do list with no more than three items. This was suggested by some lifehacker post and it seems like a great idea.
  • Recycle more at home. I recycle consistently at work because we have containers for different type of containers, but since I do not at home, I get lazy more often.
  • Contribute more back to the open source community. I have written a bunch of code recently that I haven’t yet checked in to a public repository. I have to make contributing back a higher priority.

Exporting Posts from WordPress 2.5

Recently I tried exporting some posts from one WordPress 2.5 blog to another WordPress 2.5 blog. The import worked perfectly, but then I realized that I had forgotten to import one of the posts. Rather than doing to the whole import again, I decided to just import the post that I had forgotten. Unfortunately, WordPress brought over all of my categories again, leaving me with duplicates of all of my categories. Ugg.

I wrote a small python script that takes a wordpress export file and strips out information about categories and tags. It’s a pretty simple script, but I will share it anyway: script

Adding Meta Information to a Blogroll

I found a useful blog post on how to add text fields to the “link management” admin menu in WordPress:  http://planetozh.com/blog/2008/02/wordpress-snippet-add_meta_box/

But how do you save this information into your database?  This is a three step approach.

1.  Add the fields to you database:

add_action('activate_geo_blogroll.php','geo_blogroll_update_db');

function geo_blogroll_update_db(){
   global $wpdb;
   $wpdb->query("ALTER TABLE $wpdb->links ADD COLUMN link_city varchar(255);");
   $wpdb->query("ALTER TABLE $wpdb->links ADD COLUMN link_state varchar(255);");
}

2. Add text fields to the link admin screen:

add_action('admin_menu', 'add_geo_meta_to_links');

function add_geo_meta_to_links() {
   add_meta_box ('geo_link', 'Link Geography', 'geo_blogroll_form', 'link');
}

function geo_blogroll_form () {
  global $link;
?>

<table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5">
  <tr class="form-field">
       <th value="top" scope="row"><label for="blog_city"><?php _e('City'); ?></label></th>
       <td>
           <input name="blog_city" type="text" id="blog_city"
                  value="<?php echo $link->link_city; ?>" style="width: 95%" />
       </td>
  </tr>
  <tr class="form-field">
    <th value="top" scope="row"><label for="blog_state"><?php _e('State'); ?></label></th>
    <td>
      <input name="blog_state" type="text" id="blog_state"
             value="<?php echo $link->link_state; ?>"  style="width: 95%" />
    </td>
  </tr>
</table>

<?php } ?>

3. And finally save this information to the database every time someone saves a new link or updates an old link:

add_action('edit_link', 'geo_blogroll_save_meta');
add_action('add_link', 'geo_blogroll_save_meta');

function geo_blogroll_save_meta ($link_id){
  global $wpdb;
  $sql_statement =  "UPDATE wp_links SET link_city='".$_POST['blog_city'].
                              "', link_state='".$_POST['blog_state'].
                              "' WHERE link_id =".$link_id.";";
  $wpdb->query($sql_statement);
}

Developing Alt Law on Mac OS X

There is a neat project that I have wanted to get involved with for a while called AltLaw. AltLaw is a free open source project developed by the Columbia Law and Technology program. Resources for the project are located at the Law Commons Trac Page.

I am trying to get the AltLaw “stack” working on my Mac OS X machine. So here we go:

Continue reading