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.

CSSViewer - new promising Firefox Extension

February 20, 2006
0 comments Web development

I only noticed this new Firefox Extension today. It's 1.0 version was released yesterday only. You install it, add it to your toolbar and then you can use it to inspect elements to get the complete rundown of the CSS declaration for a chosen element.

I've haven't tested it fully yet but it looks really promising. If you're a web developer, this is a must. It's much better than the Firebug CSS inspector but someone more clever than me can probably point out that they serve different purposes.

Get it here

waiting for your guidance

February 19, 2006
2 comments

This arrived at my inbox a couple of days ago:


hi
iam manish kaushik
an indian
iam doing btech in IT
can you help me
idon't know nothing about hacking
i want learn from you
and iam waiting for your guidance

At least he wants to learn, but what an (pardon my french) stupid way of asking. Why not try to read something like a book or a webpage/article about hacking.

Perhaps it's cultural thing. Or a social thing maybe, similar to what you say to someone who speaks a different and interesting language "If you teach me Swahilii, I'll teach you Swedish". But that's just a manner of speech.

By posting about this, guys in India, please keep sending these funny emails. Sorry for not replying to any of them. I particulary enjoy those who think I'm a kung fu master and that I can teach them kung fu via email.

How to fold t-shirts, with a "machine"

February 13, 2006
0 comments Misc. links

Saw this a while ago but was hoping not to link to it before I've tried it myself. The instructions are really simple so all I actually really need is a big cardboard box now.

The show step by step how you can make a machine out of cardboard that can fold t-shirts. Check it out!