Monthly Archives: January 2007

Simple BBCode To HTML Function In PHP

January 22, 2007 » Geek

While working on a “secret” project I needed a simple BBCode to HTML converter. I’m sure there are a number of them out there, but I wanted to build my own. Here it is, a quick and dirty regex filled function.

In other news this is post #99 since I started the blog. Here’s to hoping #100 is stellar.

Update (01/23/07)
I just realized that PHP lets you use arrays in preg_replace, so a ‘better’ version would be…

Linux Multiple File Search And Replace

January 21, 2007 » Geek

This is something I’ve needed to do occasionally and always have to look up. The one I like best is located at this post but I’m going to repeat it here for posterity and so I can find it again easier.

perl -pi -w -e 's/search/replace/g;' *.php

So easy, thats why Perl rocks. Thank you Bob Fulkerson for introducing us.

Other options include the frickin sweet looking ruby app SearchAndReplaceGlobal by the same guy who wrote the editor I first learned to do HTML with, Arachnophilia. I say sweet looking because I never actually got it running. I didn’t try very hard though.

New prototype.js Website

January 21, 2007 » Geek

My favorite js library has got itself a new home at The new site is much better than the old stuff and the API is very handy. Check it out if you want a super handy lib.

Cleaning Up E-Books

January 19, 2007 » Geek

I have a large number of ebooks in Microsoft’s .lit format. My Nokia 770 doesn’t have any software to read a .lit format book. In fact, I can’t say I’ve ever seen a .lit reader other than Microsoft’s own.

What I have seen is the nifty and very usefull ConvertLIT which I use to down convert the files into plain HTML. I don’t even bother with the images. The problem is, they tend to come out formatted in a hideous fashion. I came up with a nice combo of HTML tidy and a perl script.

Here’s my command line for tidy, beware, this will modify your original copy!

Here is my perl script, it just runs the file through some regex’s and writes to the same filename with “NEW” appended. I also made a nice little progress bar because I was bored.

You can download it here, but be careful with it.

Update (01/21/07)
That perl script has a line $_ =~ s/ //mi; which doesn’t really make that much sense looking at it now. I’m thinking $_ s/\s\s+/ /mi; for a replacement. Also, for some reason the server throws up a 500 error on trying to get that file, I’m working on it.

Tags: ,

Further DK421 Development

January 14, 2007 » Geek

After a lengthy break from DK421 development I started up again this evening. My primary purpose tonight was to learn how to program my arduino and to learn the basics of serial communication with javax.comm. I wrote a led blinker that also sent some data over the serial connection. 0 when it turned the light on, 1 when it turned it off. and yes, I know that seems backwards.

After a short battle I hacked up the config and a sample program to print my data. It’s not printing the right values, but it is printing the wrong ones consistently. I think it has to do with my function to convert a byte array to an integer. It also has a small runtime exception that I didn’t work out. Regardless, it’s working. I’ll install Eclipse on this machine and maybe get it working even further soon. Next step is to get some piezo’s and learn to read them.

On that front I was thinking about using the velocity of an impact to handle the volume it plays back. Maybe something of a code, like if a strike is registered with a strength of 100 on pin 0 it could send 0_100 or something. Thats in the future though. I am worried about the fact that there are only 6 analog pins though. That means 6 drums without adding another board.