Watford kung fu club

May 4, 2006
2 comments Kung Fu

Pen Rance, who wrote the book Martial Arts that I mentioned about a month ago has now set up a kung fu club in Hertfordshire. It's called FWC Herts

If you live in the Herfordshire Watford area, I genuinely recommend that you give it a try if you want to get fit or you're already fit but bored with the local gym.

UPDATE

This club is now run by instructor Carlo Fernandes

Mobile-review.com

May 2, 2006
3 comments Misc. links

Mobile-review.com In the process of buying a new mobile phone? And possibly extra curious on the phone's camera capabilities? Then check out Mobile-review.com I just discovered it today. It's got really lengthy, detailed and comparative reviews not only in specs but with plenty of pictures and the authors "personal impressions" too.

Sadly no review of my phone, the Treo 650 but from this page I count about 75 reviews just of various Nokia phones.

Nice websites like this are hard to find. Keep up the good work [Russian] guys!

Private functions in Javascript?

April 29, 2006
3 comments Web development, Python

In Python you indicate whether a function/method is private by naming it so that it starts with an _ underscore like this:


def _thisIsPrivate():
    return 'a'

def thisIsPublic():
    return 'b'

It means that if you have these two functions in a file called dummy.py and you do something like this:


>>> from dummy import *
>>> thisIsPublic()
'a'
>>> _thisIsPrivate()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name '_thisIsPrivate' is not defined

Seems fair doesn't it. Now is there such similar naming convention and functionality in Javascript?

Truncated! Read the rest by clicking the link below.

type - Writing shell scripts

April 28, 2006
1 comment Linux

I've started skimming through the lovely Writing shell scripts tutorial and even though I'm just in the beginning of it I've already learnt one very useful thing: the type program. With it you can find out "what type of command it is". This is useful because sometimes you want to know where some command is coming from. I'll let this example explain its usage:


peterbe@trillian:~ $ type jed
jed is /usr/bin/jed
peterbe@trillian:~ $ type cvs_commit 
cvs_commit is /home/peterbe/bin/cvs_commit
peterbe@trillian:~ $ type alias
alias is a shell builtin
peterbe@trillian:~ $ type sjed
sjed is aliased to `sudo jed'

I'll read more of this after the weekend.

Helpdeskshow - a quick review

April 26, 2006
0 comments IssueTrackerProduct

I just got back from the Helpdesk & IT Support Show in Olympia (Kensington, London). My main impression is: there are many, big players in this industry.

My pet project, the IssueTrackerProduct is very basic in comparison to some of these companies products. Although it's often used in help desk situations the kind of help desk solutions I've seen today are way different. For many of them, it's all about integrating various systems such as asset management, call logging, configuration management, knowledge management, etc. It seems that the actual help desk apps seems to have to be low priority compared to getting all pieces to fit together.

Truncated! Read the rest by clicking the link below.

Interesting float/int casting in Python

April 25, 2006
21 comments Python

Casting is when you convert a variable value from one type to another. This is, in Python, done with functions such as int() or float() or str(). A very common pattern is that you convert a number, currently as a string into a proper number.

Let me exemplify:


>>> x = '100'
>>> y = '-90'
>>> print x + y
100-90
>>> print int(x) + int(y)
10

That was the int() function. There's also another very common one which is float() which does basically the same thing:


>>> print float(x) + float(y)
10.0

Truncated! Read the rest by clicking the link below.

Best bicycle locks

April 22, 2006
1 comment Misc. links

The Kryptonite NYFU This is a great article about the best bicycle locks that this guy can find. He buys a bunch of different cable locks, U-locks and chains. (Sometime U-locks are called D-locks but I think it's the same thing)

He then pursues to lock up his bike and then tries to break the lock with a set of different hand tools such as hacksaw, bolt cutters, crowbar etc. Every lock is judged by security, ease of use and value in price but security is a 20 point scale whereas ease of use and value is a 10 point scale.

I like this article because A) I can learn something about what lock to buy for my bike and B) it's nice to see when someone puts his efforts in to put together a nice little article like this.

Thank you Scott Elder for the review!

Date formatting in Python or in PostgreSQL (part II)

April 19, 2006
0 comments Python

This is an update on Date formatting in python or in PostgreSQL where the test wasn't done very well. The solution using Python for the formatting created a new DateTime object each time for each formatting because the time_stamp extracted from the database was a string. That would be beneficial to the Python formatting alternative but that's not the whole point. I suspect that the way I did the experiment last time (code is lost by the way) was wrong and didn't focus on the correct benchmark.

In this, my second attempt, I've done a more correct test and tried it on 500 selects. 500 formatted in SQL and 500 formatted in Python. The results are even more outstanding for PostgreSQL than last time.

Here are the results:


times1 (python formatted)
0.113439083099
times2 (sql formatted)
0.00697612762451

That means that doing the date formatting in SQL is 16 times faster!!

Bare in mind that this is optimization and you always have to be careful when doing optimization. For example, the SQL database shouldn't get involved in the presentation and if you need to use a different locale you might to change your application in two places which is risky.

Careful when dealing with options in IE

April 14, 2006
2 comments Web development

If you have a drop down that looks like this:


<select name="name"
 onchange="alert(this.options[this.selectedIndex].value)">
  <option>Bill</option>
  <option>Gates</option>
</select>

you'll get a different alert message in Firefox and IE6. Try it here

Firefox will understand that if you don't have a value attribute on a option tag, it takes the content of the option tag as the value. IE doesn't. On the above code it returns blank (aka. empty string) in the alert.

Truncated! Read the rest by clicking the link below.

Case insensitive list remove call (part II)

April 11, 2006
1 comment Python

Yesterday I blogged about a simple algorithm for removing a string from a list of string case insensitively. I was happy to see that several people joined in with suggestions just a few hours after I published it. I have now thought about it a bit more and to honour those who commented I've done a little benchmark to find out which one is the best.

What both my own solution and some peoples suggestions forgot was to raise a ValueError if it fails just like this would: list("abc").remove("d")

So, I've tidied up the suggestions and where need be I've added the exception throw. This is not the first time list comprehension in python impresses me. The winner in terms of performance is Andrews list comprehension suggestion. Here are the timeing results:


f1 0.704859256744
f2 1.5358710289
f3 1.37636256218
f4 0.468783378601
f5 0.475452899933
f6 0.666154623032

Truncated! Read the rest by clicking the link below.