Posted in code
06/21 2010

Drupal and Memoization

Memoization is a way to cache the results of calling a function with a specific set of parameters. This can be very useful in Drupal if you need to call a function that does some kind of complex computation or database queries, but is in a part of the code you don’t want to modify. Here is a function I wrote for a recent project that allows you to utilize this technique:

And here are some examples of how you might use it:

Be warned, however. You only want to do this if you know for sure that you are going to call a function more than once. Otherwise it’s just added overhead with no benefit.

Posted in code
05/31 2010

Adobe AIR 2 and jQueryUI Datepicker

As of version 1.8.1, the jQueryUI Datepicker does not work in Adobe AIR. The issue and more details can be found here: http://dev.jqueryui.com/ticket/3945.

The problem is that Adobe AIR does not support dynamically loading strings as code after the load event. Version 1.8.1 of the jQueryUI Datepicker uses this method to add onclick handlers to the various Datepicker controls. The patch to fix the problem can be found here: http://github.com/csnover/jquery-ui/blob/b8d8e1e4a6e405c62ded6dd5ab4065ad10cd1225/ui/jquery.ui.datepicker.js

Posted in code
05/11 2010

Jsonify

On one of my current Drupal projects I found I needed to load nodes via javascript. To make the whole thing easy peasy I created Jsonify, a dead simple Drupal module that provides you with javascript methods for loading nodes and comments.

Posted in code
05/2 2010

Creating .dmg Files with Adobe AIR 2 and OSX

Recently I needed to develop a method for creating password protected backups of my application’s data. The original idea was to create a password protected zip file which I could just do using /usr/bin/zip. Unfortunately, the OSX archiver utility cannot open password protected zip files, making it very difficult for users to actually open the zip files.

So after a bit of research I came across http://github.com/andreyvit/yoursway-create-dmg. This guy has created an awesome little shell script that allows you to create .dmg files with pretty backgrounds and all sorts of other things. I forked it here so that I could add the ability to set a password. And then I just execute the shell file using the NativeProcess API built in to Adobe AIR 2. Here is the javascript:

Posted in code
02/2 2010

Kodak W820 Media RSS Feed

I recently bought my dear mother a Kodak W820 digital photo frame. It’s wireless and supports several ways of reading media from the web, one being RSS. I don’t have much experience with RSS so when I wanted to create my own RSS feed for the frame, I had a little trouble. Here is the markup for the feed that ended up working for me: