Stop Being Carbon

Icon

acts_as_geocodable in tests

The last few days I wrote some unit tests for a project I’m currently working on (and which, by the way, should be released to public in a few weeks time). To easily be able to change attributes of my models and not rely on fixtures, I’m using the fixture_replacement plugin and actsasgeocodable to easily deal with address translations and that stuff (it introduces various attributes, like street, country, postal code,…). The last one comes with a nice option, normalized_address, which will update the information in your model with the information it got from the geocoding service (and thus will correct invalid postal codes, etc.).

Well, again, this feature is really handy but can lead to problems if you forgot that you activated it and just want to change the postal code of one of your models. Because the geocoder will still find the right address (mainly because the street name is the same) and actsasgeocodable will correct the invalid postal code for you. And you gonna have no clue why it won’t take the postal code you’ve used in fixture_replacement’s helper methods.

A simple fix for that is to add the following setup method into your unit tests:

def setup
  # This ensures that we can set individual attributes of our model
  # without being overridden by acts_as_geocodable.
  Property.acts_as_geocodable_options[:normalize_address] = false
end

Wildcards for phone numbers

Working for quite a big company has the disadvantage that you cannot now all the people there and their respective telephone numbers (especially when you were lucky enough not to get one of those Blackberry things). I’m pretty bad at remembering telephone numbers – which is actually not quite true, I still know all the numbers of my primary school friends – so for me it would be quite useful if my Nokia phone would support wildcards for phone numbers. So that I could even tell that the call is coming from within my company, even if I don’t have the exact name of the caller.

I always knew that coffee is my lifesaver

I guess every Mac users know the problem: You’re talking with your friends, showing them some drawing, snippet of code or website, talk even more with them and your Mac activates its screensaver and locks down the Keychain. For me that results in entering my password three times (one for login, one for iScrobbler and one for Safari’s Keychain access). Annoying.

But I discovered (or merely googled) a small tool which prevents your Mac from activating the screensaver, dimming down the screen or even going to sleep: Caffeine. Trust me, you need this tool.

Strange module error with Hpricot

I got some strange error today when I tried to deploy one of my rails projects to my slice at slicehost. The problem was that I had a newer version of Hpricot running on the slice (0.6.161) versus 0.6 on my local machine. The following line failed:

Hpricot::XChar::PREDEFINED_U.merge!({" " => 32})

Ahm, okay. I didn’t see any changes made to the overall layout of Hpricot so I suspect that line should work. Any ideas?

(If anyone is interested in the meaning of the above line, check this ticket).

Color profile me

…and I’ve never dealt with them, but today I found some small glitch on Vimeo. If you’re running Safari, you will notice that the color of the corners of the different sections does not match the surrounding background color.

I guess the problem lies within the color profile, which is some self configured one and not sRGB (well, at least that’s what I found out while doing some 2-minute research).

Links for rainy days

For pretty long I thought that YouTube is a pretty useless and time-eating monster. Things have changed since I discovered some pretty interesting channels (and clips). A short primer:

  • The Google Channel I really like their Tech Talk clips, featuring Linus Torvalds talking about git, the Google maps clips, etc.
  • Sketchup Channel That software is amazing! Its so easy to use and yet you can make such good models (I can remember the time when I started learning Blender).
  • Randy Pausch – Last Lecture That lecture is really a must-see. It’s so moving and positive.

Reading osm files with Python – python-osm

A few days ago I experimented with some data files from the Open Street Map Project. Because I do most of my quick’n'dirty prototyping with Python, I looked for a Python module which would read osm files (which is, to be fair, really no problem because it’s clean XML).

I stumbled over Rory McCann’s python-osm lib over at Github. His version was missing the relation feature of the osm data structure but it was a one minute walk to implement it.

You can access the forked project @Github.

Possible bug in Lightbox (and fix)

I’m currently working on some Rails project which makes use of the great attachment_fu plugin by Technoweenie (which led to my first bugfix for an Open Source project).

Yesterday I stumbled over some glitch with Lightbox (or Script.aculo.us, I’m not really sure) which results in a mal-sized picture. For the sample, go here. The fix is quite simple, you have to explicitly set the width of the image (that should be around line #260):

imgPreloader.onload = (function(){
    this.lightboxImage.src = this.imageArray[this.activeImage][0];
    // The following line will fix the glitch:
    this.lightboxImage.width = imgPreloader.width;
    this.resizeImageContainer(imgPreloader.width, imgPreloader.height);
}).bind(this);
imgPreloader.src = this.imageArray[this.activeImage][0];

5 reasons why real estate sites suck (in Austria)

  • Their design looks so 1999 (and their markup is even 1994)
    What’s one of the reasons why Google’s search is so successful? Because it doesn’t offer any distractions. You have a search box. That’s it. Simplicity is the key.

  • It’s time for RSS
    When I’ve clicked through all the search criterias (you do not need to refresh the page as soon as I’ve select one district of ten) I want to store these results, and, just to be able to keep an eye on the thing, get a link to an RSS feed. So I can quickly see if there are new offerings.

  • Ads all over the place
    I don’t know how they make money (I guess they take fees from the estate agents) but distracting ads all over the place are a thing which are common for every site I’ve found.

  • I really wanna do search for all attributes
    You can search for price and area but then you can’t search for the number of rooms. Or you can search for the district but can’t tell them that you wanna have an eat-in kitchen.

  • Pictures? Yes, resized, unreadable and low quality
    Okay, bad quality pictures are often the fault of the estate agent. But badly scaled images which become unreadable (floor plans) are really not necessary. Not resizing them at all and just setting the size of the image container is really bad practise.

  • Prices? All included, please
    Just yesterday I’ve stumbled over a site which didn’t let you enter an all-included price but instead just considered the rent (without taxes and service charges). Really helpful, thanks. When you’re looking for a flat which costs 700 Euros you will get rents as high as 900 Euros.

SharpMap modifications

Wow, nearly three weeks since my last blog post (but I do post some updates more frequently on Twitter).

[Warning: tech stuff follows] Anyway, I’m doing quite fine. My bachelor project is slowly taking shape. Currently I am modifying SharpMap for our needs (adding a dynamic layer for our data, adding some events to know what’s going on inside of SharpMap,…).

I’ve also touched the clipping function, which really sucked. I replaced it with Sutherland-Hodgman’s polygon-clipping algorithm which works like a charm. This move was necessary because GDI+ has some problems rendering invalid data (meaning data which is far outside of the viewport). The process doing the drawing will block all others and your system will come to a halt – no moving cursors, no task manager, no nothing.

Because SharpMap is released under the LGPL, I will post the .diff patches as soon as the major work is finished.

Flickr

delicious

Asynchronous Google Analytics for WordPress plugin powered by WordPress Expert at minilibra.com.