Monthly Archives: November 2006

Watermarking Photos using Ruby

The task: take a source photo of any size and overlay transparent text atop it. This is useful for asserting to the world that the image is yours (which it sometimes is).
Before:

After:

First, some configurables:

IMAGE_FILE_NAME = ‘/usr/home/mike/pictures/c4rt.jpg’
OVERLAY_FONT = ‘/usr/X11R6/lib/X11/fontsbitstream-vera/Vera.ttf’
OVERLAY_ANGLE = 1
OVERLAY_STRING = "Copyright #{Date.today.year} Mike Burns"

For this task I used the GD library. [...]

STI and Multiple Databases in Rails

I admit, I believed it when DHH said that Rails apps should communicate via REST if they want access to a shared database. I bought into the hype and even wrote a plugin to make this easier.
Well, it’s slow. I don’t have real numbers, of course, because I’m not the type of person to write [...]

Truncating HTML in Ruby

Update: You should read the comments, then check out the extended verion of truncate_html that uses Tidy.
For the blogging Web site we wanted snippets of blog post for the front page and search results. This wasn’t a problem at all for our test blog posts, which we made by pasting lorem ipsum into a text [...]