Delete all files starting with ._
Written on the 4th of September, 2008
For some reason Textmate seems to be littering my file system with ._* files where the * are is replaced with the actual file name. I’m guessing this is just Textmate trying to make a backup file or keep a lot of what edits have been made, or what have you but it’s annoying. This is how I’ve been deleting them:
find ./ -name "._*" -type f -print0 | xargs -0 rm
That basically searches the current directory and any subdirectory, calling rm on any matching file whose name starts with ._
Javascript needs an optimized testing suite.
Written on the 26th of August, 2008
Javascript has been around for a while, but it finally feels like it’s come into its own. With the plethora of libraries available to developers that ease the pain of cross-browser coding, building an enterprise level dynamic web application doesn’t feel taboo. An even better sign is the large number of Javascript testing suites that are being published. JSUnit and JSSpec are the two most prominent I’ve used, but I’ve heard of quite a few others (though have no experience with them).
The problem with these test suites is that they are sometimes stuck executing large blocks of repetitive script. That’s not so much the problem as is the fact that Javascript is single threaded and ties up the entire interface while the test runs. One solution to this problem could be a test suite that implements Google Gear’s WorkerPools to run each test and then return the result of the test to the interface. “But it’s a test!”, you say. “Who cares about the interface while you’re running a test?”, you ask. Well, I do for one. I hate loosing control of my interface, and sometimes my entire browser if a long running Javascript test is trying to complete. Also, if I have a suite of 200 tests which takes a few minutes to complete, I’d like to be able to start reading about the errors as soon as they happen, not after the tests have completely finished and I’ve regained control of my interface.
Another suggestion that would help improve Javascript test suites: standard mock interfaces for the most popular Javascript libraries like Prototype, jQuery and mootools. I’m constantly overwriting $.ajax or $.post in jQuery with simple return methods either fire a callback or return an error result. Having a mock library would hopefully make that process even simplier. All credit for this idea belongs to my coworker Nick who suggested it last week.
If you know of implementations of either of these ideas, don’t keep it a secret! Let us know!
RSpec and Rails
Written on the 16th of April, 2008

Early morning light,
my tests fail on each attempt.
Should I use mocks here?
Random Alphanumeric Generators
Written on the 3rd of March, 2008
[ruby]
def random_alphanumeric(size=16)
space = ‘0123456789abcedfghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’
(1..size).collect {space[Kernel.rand(space.size)].chr}.join
end
[/ruby]
I’m always impressed by people’s incredibly beautiful and terse bits of ruby code. This one isn’t super special, but I figured I’d share it for anyone who might need something similar.
[python]
import string, random
random.seed(12)
def random_alphanumeric(size=16)
return “”.join([random.choice(string.letters + string.digits) for x in range(size)])
[/python]
… talk about svelte.
Voice Urban Dictionary
Written on the 16th of February, 2007
A friend, k7lim, recently released a voice app that uses voice xml (VXML) to allow you to call in and receive information about the BART system. I decided to have my own go at creating a voice app and in about 45 minutes had a working demo which randomly chooses a word from the Urban Dictionary and then speaks its definition. If you’re interested in having a go, just dial
415-912-1586 and simply listen to the random definition pulled out of the dictionary! (There are no associated charges with this call, other than what your telephone provider charges you for making a typical phone call)
The urban dictionary tends to include some fairly R rated or X rated material. If you’re easily offended this might not be for you.
VXML and this app in general is exceedingly simple. It’s basically a PHP script that uses Urban Dictionary’s SOAP based API to request a random word. The PHP script then formats the output in VXML which the text to speech app can understand and deliver it over the phone wire. All that in about 20 lines of PHP + XML!

