updated rails from .13.1 to .14.3
The update went very smooth with this guide
All my work thus far has been on the database side, mapping incoming xml documents to my model. But there have been some significant performance increases in active record. My unit tests were taking on average 78 seconds on a 3.4 ghz pentium box running FreeBSD 5.3. That time has now been cut to 62 seconds on the same box. And that is with transactional fixtures turned off and instantiated fixtures turned on. Not too shabby!
Great work guys! I can’t praise you enough.
obfuscated mailto – ruby one liner
I have always been annoyed at having to write email addresses online such as codefoo at bar dot com/code. Damn the spambots!
I recently ran across this technique for obfuscating email addresses on web pages so that it appears normal to the user, but not something which could be easily parsed by a spambot.
You convert the link text and href to html characters.
becomes (added line breaks for readability)
Just a little bit more cryptic. The core method for converting a string to an html character string is just a one line ruby method, of course.def string_to_htmlc(s) s.strip.unpack(“C*”).map{|ch| “#” + ch.to_s + “;” }.to_s endA couple of things are going on here. codes.strip.unpack(“C*)/code We first remove any leading or trailing whitespace with the strip method. The unpack method on string is used for decoding a string (possibly with binary data in it) into an array. The argument code”C*"/code is an instruction that the next 0 to many characters should be turned into an unsigned integer, i.e. the number which represents the the ascii character. We now need to convert our array of integers into the html code for each character. The html code for a character is simply the ascii integer value for that character preceded by code#/code and ending with a code;/code. The ruby map mehtod takes care of this for us. Array#map invokes the block for each element in the array. Finally we convert the array back into a string with the code.to_s/code for our html pleasure. The code.to_s/code method on array is the same as calling codearray.join/code All you have to do now is just put some code in your rails helper module to output a full href.module MyHelper def to_html_email(address) email = string_to_htmlc(address) “a href=\”#{string_to_htmlc(‘mailto:’)}#{email}\“#{email}/a” end def string_to_htmlc(s) s.strip.unpack(“C*”).map{|ch| “#” + ch.to_s + “;” }.to_s end endNow it should be safe to display an email address on a webpage.
another great thing about ruby – the unit testing
The more I use ruby, the more I love it. I ran across this today – the ability to run individual unit tests.
You can run an individual test method within a test case by providing the -n switch after the ruby file containing the tests. the -n argument accepts either an absolute test method name or a regular expression which will run all the tests which match the expression.
codepre
ruby test/foo_test.rb
/pre/code
This runs all the tests within foo_test.rb.
codepre
ruby test/foo_test.rb -n test_bar
/pre/code
This runs the individual test method named test_bar within foo_test.rb
codepre
ruby test/foo_test.rb -n /bar/
/pre/code
This runs all the test methods within foo_test.rb which contain the string “bar”.
new ride
I finally got a bike! I picked up a 1999 Suzuki Intruder VS1400 with only 4200 miles at a very reasonable price.
The bike came with windshield, saddle bags, engine crash bar and some Vance Hines pipes (very loud). It’s a blast to ride. I’ve put about 350 miles on it since I picked it up on Tuesday (4 days ago).
I got it a tuneup yesterday, changed all the fluids, etc. and it’s running pretty well. The carb needs to be re-jetted b/c it was never done by the guy I bought it from when he put the bigger pipes on. And the mechanic set the idle too high. We had to increase the idle because the engine was cutting off sometimes when slowing.
Well, I know what my primary mode of transportation will be for some time to come. Thankfully Charleston has mild winters.

identity 2.0 – great presentation
One of the best presentations from OSCON given as a keynote by Dick Hardt has been published online. It’s a must see. I was blown away when I watched this at the conference. It’s an incredibly entertaining and interesting presentation.
Identity 2.0 – OSCON 2005 Keynote
office revenge – aluminum foil desk
When I first started at my current job, I was out sick for a couple of days and came back to my office totally re-arranged as a practical joke. Pictures were upside down, glasses taped to the desk, shoes hanging from the ceiling, and about 100 other small re-arrangements.
It took a while to get back at one of the instigators, but the opportunity finally arrived :) Deanna went on vacation last week!
A while back I had seen an email where someone’s desk was “foiled” and really liked the result. Total project time about 2 1/2 hours. So here it is: (all picts at flickr)


Interesting app – the semantic web
A friend of mine pointed me to an interesting app this afternoon. Piggy-Bank
The description from the site is
bq. Piggy Bank is an extension to the Firefox web browser that turns it into a “Semantic Web browser�
It seems to take the various website data (via screen scrape) create an RDF document out of it. That information is stored in a central location which can be queried by the said application. For instance, one of the pieces of data it collects is location. So it could collect the location of all the apartments for rent from the apartment rental website. It would also collect the location from the bus terminal website. Ultimately you could do a query to find apartments within a given radius of all the bus terminal in you location and display it on a google map.
It’s a very interesting concept. I have looked at semantic web stuff before and understood the basic concepts of the underlying technology, but did not get what it could be used for. This app makes it fall into place a little more than before.
One of the things I still fail to understand about the semantic web stuff is how to go about using the data that is published. Nobody would publish the RDF/OWL model in the same way, just as to developers would come up with a slightly different database structure. It all stores the same data, but in a different way.
Using the apartment for instance. Two different property management companies publish an RDF document for the web.
Propery Management site 1 comes up with a model like this
codepre
Apartment:
Address:
line1
line2
city
…
Specs:
square_footage
number_of_bedroooms
…
/pre/code
And Property Management Site 2 comes up with a model like this:
codepre
Apartment:
addressLine1
addressLine2
city
…
squareFootage
numberOfBedroooms
…
/pre/code
They both have exactly the same data, just modeled differently. One is more normalized than the other and the attributes/elements of the document are are slightly different.
Perhaps I am missing something but it seems that if you wanted a central storage location for semantic web stuff, you would have to do alot of mapping between one document and another. This would seem to limit the number of sites you could query because of the time and labor involved in mapping.
I really want to believe in widescale use of this technology, but I fail to see it right now.
new toy
It was time for a new toy… Since the old digital camera was old and busted, it was time to bring in the new and shiny.
I wound up getting a Nikon Coolpix 4800
I really like this camera. They did a good job with controls on the camera. You don’t have to push too many buttons to do what you want and it’s pretty intutive.
And to christen the camera, I put created a flickr account
There is supposed to be a flickr feed on the sidebar, but it does not seem to be working now. Ah… something else to get working.
new server
My host has moved locations and everyone is now running on new hardware.
The move was painless. For me atleast. Everything was working just fine when I tested it out a little while ago.
Hopefully the combination of new hardware and hosting facility will fix the downtime problems I (they) have been having.
From textdrive’s flickr account…

Switched from Fedora to Ubuntu
I switched from Fedora to Ubuntu last week on my computer at work and I could not be happier.
Setup was simple. I really like the apt-get, gentoo portage and BSD ports model. RPM is just too much of a pain.
One interesting thing about Ubuntu is that there is not a standard root account. Just like you do with OS X, you have to sudo everything. That’s fine with me. And if you really, really need root, all you have to do is sudo bash and you are root.
This biggest annoyance is that I can not find a postgresql 8.0 package for ubuntu. I really don’t want to have to maintain all the startup scritps myself.
Otherwise, I’m very happy with it so far. Hopefully it will stay that way.
