Carbon XEmacs installed

March 14, 2006
0 comments macOS

Finally I have a sensible editor installed on my Intel iMac. It's called Carbon XEmacs (aka. just emacs :)

All thanks to Andrew Choi. He's prepared two patches that makes this possible. The version I got was XEmacs-21.5.23 plus two additional patches from Andrew for Intel support and proper "Quit Application" connection with the OS. Thankfully nothing was difficult because everything went smoothly without any error messages anywhere. I did have to do some reading, searching and downloading. The hardest task was to find Andrews Carbon XEmacs site to just get started. If you also have an (Intel) mac os x and want to install XEmacs too, here are some notes on what I did:

Truncated! Read the rest by clicking the link below.

Quick PostgreSQL optimization story

March 11, 2006
1 comment Work

There are several ways to do case insensitive string matching in SQL. Here are two ways that I've tried and analyzed on a table that doesn't have any indices.

Option 1:


(
 LOWER(u.first_name) = LOWER('Lazy') OR 
 LOWER(u.last_name) = LOWER('Lazy') OR
 LOWER(u.first_name || u.last_name) = LOWER('Lazy')
)

Option 2:


(
 u.first_name ILIKE 'Lazy' OR 
 u.last_name ILIKE 'Lazy' OR
 u.first_name || u.last_name ILIKE 'Lazy'
)

A potentially third option is to make sure that the parameters sent to the SQL code is cooked, in this case we make the parameter into lower case before sent to the SQL code

Option 1b:


(
 LOWER(u.first_name) = 'lazy' OR 
 LOWER(u.last_name) = 'lazy' OR
 LOWER(u.first_name || u.last_name) = 'lazy'
)

Which one do you think is fastest?

Truncated! Read the rest by clicking the link below.

Squeezebox + Pandora

March 8, 2006
3 comments Misc. links

Where I live we have a stereo in the living room with decent sound that I often use when cooking (assuming I'm home alone). Since I'm too modern to still use those blank things called CDs I have to rely on MP3 through my Treo 650 on which I've got an SD card filled with 1gb of MP3. This works but limits me. I love Pandora and have always wanted to be able to get Pandora into my livingroom stereo. It's not been possible until now. The solution is called Squeezebox and costs $300 (£170).

I've just finished this article on NYTimes.com and it seems to be the answer to all of my problems. It's a lot of money for something I only use a couple of minutes per day but I think I'm ready to spend it just because it can do Pandora as well as play the MP3 I have on my linux and my mac over the wireless home network. Now let's hope we'll see these on the UK market soon at decent prices. Wish me luck :)

parentElementsByTagName(doc, tagname, classname)

March 6, 2006
3 comments Web development

I've just written a little javascript function that I have myself found extremely valuable when doing DOM scripting. It's called parentElementsByTagName() and even if it's name isn't great it really does work and has proven very useful for my app.

At any starting point in a DOM tree (first parameter) it goes "up the tree" by looping over "currentelement.parentNode". The second parameter is the tag name (eg. "div") and the third parameter is optional and it's a class name that that tag name needs to have.

I wrote this because I found myself writing this.parentNode.parentNode.parentNode... in my Javscript code and thought I'd stop that sillyness.

Truncated! Read the rest by clicking the link below.

tightVNC and Chicken of the VNC

March 4, 2006
0 comments macOS

Here's what I had to do to get VNC working between my mac and my ubuntu linux machine here on this home network.

On the mac tiger, I went to http://sourceforge.net/projects/cotvnc/ and downloaded and installed the latest Chicken of the VNC.

On the ubuntu linux, I had to do this:


$ sudo apt-get update; sudo apt-get install tightvncserver
$ xset -q | less # look for the list of font paths and copy
$ sudo jed /etc/vnc.conf
# set $fontPath = what-you-copied-from-the-last-command
$ xrandr -q 

You can use xrandr -q just to find out a) what your current screen resolution is in Linux and what your alternatives are. With all this ready, then start the server.

Truncated! Read the rest by clicking the link below.

Why Linux is better

March 1, 2006
0 comments Linux

Manu Cornet of the Ubuntu team has created a simple yet effective site called Why Linux is better which I thought was pretty good.

Microsoft spend million$ on their "Get the facts" campaign where they get "independent" companies (affiliated with Microsoft if you read the fine print) to say that Windows is better than Linux. Sure enough, there are some points where Windows is better but far more where Linux is better than Windows. Anyway, this is what Manu is up against and still his delivery is much better than the Get the facts campaign. All he has to do is to be honest.

Keep up the good work Manu!

Martial Arts by Pen Rance

February 27, 2006
0 comments Kung Fu, Books

Martial Arts - A book about Kung fu films Got my copy today! I'm excited to read it.

Martial Arts is a book about martial arts films such as Enter the Dragon and Crouching Tiger Hidden Dragon etc. written by my "kung fu sister". Within the club you sometimes refer to other people in club as brothers and sisters. Pen and I train both train with Dave in Islington.

Have you seen Crouching Tiger Hidden Dragon? Do you understand it all or are you, like me, just watching for its fascinating effects, scenery and swordplay? Apparently, all the questions that you've always wanted to know is in the book. I remember asking Pen once: "Why does she jump off the bridge in the end?" To which Pen replied: "Buy my book and you'll find out". So I did. Can't wait!

Apple Store or Micro Anvika

February 26, 2006
1 comment

I really like the Apple Store (UK) website so that's where I went to find out how much a pair of speakers cost. £129 apparently.

Not bad but a lot of money for a 2.1 speaker set after all. For once I was clever and did a comparison before I got my wallet out. I went to Micro Anvika's online webstore and found exactly "the same speakers for £110":http://www.microanvika.com/MAC/product.asp?TXT=INFO&PNO=HRM19611. That's a "£19":http://www.google.co.uk/search?q=19+british+pounds+in+us+dollars difference.

Keep that in mind the next time you carelessly buy your next accessory from the Apple Store.

In writing this up I notice another nuisance about the Apple Store site. You can't copy-and-paste the URL to products because the URL becomes invalid when your session expires. Sort it out Apple!

UPDATE

My friend Ben Mason points out that you can get the same speakers from Ebuyer.com for £94+£5 shipping

Dynamic image replacement technique

February 24, 2006
6 comments Web development, Python

I've been playing with PIL's ImageDraw to create images from text. This isn't anything new but I thought I'd combine it with some Web 2.0 technology. The page is marked up like before in valid and accessible XHTML, then a javascript kicks in to automatically replace the plain text headers with image generated ones.

The benefit of this is that the image replacement stuff happens AFTER the page has been loaded for snappier response times. The page looks better with image headlines because you're not font-limited there (see apple.com for example). And most importantly: you want images for headlines but you also want to be found on Google.

Go to the demo page to see it in action.

Truncated! Read the rest by clicking the link below.

Google and Python code

February 22, 2006
14 comments Python

After reading Matt Harrison's notes about Python at Google I noticed something which I couldn't add up.

"Python programmers at Google must follow a strict style guideline (based on PEP8 with 2 spaced indenting). When engineers are first granted commit access to their SCM system, they must pass a style test."

"based on PEP8" but rejecting such an important part as indentation really is.

From PEP 8 Style Guide for Python Code

"Use 4 spaces per indentation level."

Truncated! Read the rest by clicking the link below.