Technology

You are currently browsing the archive for the Technology category.

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.

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).

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.

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];

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.

Ruby sum

def sum(enum, &block)
  sum = 0
  enum.each do |value|
    v = block.call(value)
    sum = v ? v + sum : sum
  end
  sum
end

I played around a little bit with script.aculo.us the last few days and came up with some small Flickr photo browser called Folaroids.

It’s based on Ruby and JavaScript (Prototype and script.aculo.us). It’s the first time that I’ve done some real word application with erb and script.aculo.us (whose effects and support is just awesome).

Check it out (and leave comments).

Here’s the requested .plist file, insert your username (or the path where you’ve put the Apple Script) and save it to /Library/LaunchAgents/com.apple.tm-notification.plist. Then do

launchctl load /Library/LaunchAgents/com.apple.tm-notification.plist

Here’s the .plist file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>  
	<key>Label</key>
	<string>com.apple.tm-notification</string>
	<key>ProgramArguments</key>
	<array> 
		<string>/usr/bin/osascript</string>
		<string>/Users/[user]/Public/tm.scpt</string>
	</array>
	<key>LowPriorityIO</key>
	<true/>
	<key>Nice</key>
	<integer>1</integer>
	<key>StartInterval</key>
	<integer>300</integer>
</dict>
</plist>

Time machine is really a fine piece of software. The only thing which is missing is some kind of notification when a backup was done (you can open the preferences, but that’s not really satisfying).

So I crafted some little Apple Script:

set console_text to do shell script "syslog -F '$Message' -k Sender /System/Library/CoreServices/backupd -k Time ge -5m"
 
if console_text is not "" then
	tell application "GrowlHelperApp"
		set the allNotificationsList to {"Notification"}
		set the enabledNotificationsList to {"Notification"}
 
		register as application ¬
			"Time Machine Notification" all notifications allNotificationsList ¬
			default notifications enabledNotificationsList ¬
			icon of application "Time Machine"
 
		notify with name ¬
			"Notification" title ¬
			"Time Machine" description console_text ¬
			application name "Time Machine Notification"
 
	end tell
end if

Copy it to some folder and register a cronjob, something like this: */5 * * * * /usr/bin/osascript /Users/[username]/Public/tm.scpt

Here is the compiled script: Time Machine Notification

If you want to have a shorter/longer interval you need to change the cron line accordingly and the script (it’s the last parameter in the first line, now saying ‘5m’).

Edit: I did what a reader suggested, here is the .plist file.

WTF of the day

Can anybody tell me why I get “Ho Chi Minh City (VN)” as the first suggestion in a webform when the first (and only) letter I’ve typed is “S”? A colleague suggested that it might be phonetical suggestion, which I doubt for “Ho”, even for local language. And I also doubt that “Jekaterinburg” and “Lamezia” have an “S” as their first letter.

Webform suggestion

« Older entries