Archive for May, 2006

onEnterFrame vs. setInterval

2006.05.31, Wed

Which one is better for code that should repeat at at intervals, onEnterFrame or setInterval?

(more…)

Skewing random numbers towards 0

2006.05.29, Mon

A quick way to skew random numbers towards 0 is to raise them to some powers – the higher the power, the higher the skew.

var num:Number    = Math.pow( Math.random(), 2 );

My del.icio.us bookmarklet

2006.05.15, Mon

I like Alan Marklet's Maker, the tool that let you create bookmarklets to add links to del.icio.us. But I wanted something that let me either use some text I highlighted in the page, or else the description meta-tag. So I hacked the original bookmarklet and made it my own. Shame that WordPress won't let me publish in a useful format.
(more…)

Finding files on the command line and doing something with them

2006.05.11, Thu

find a_directory -iname “*.zip” -exec unzip -d another_directory {} \;
This will unzip all files from a_directory into another_directory

find a_directory -iname ‘*.gif’ -or -iname ‘*.jpg’ -exec cvs add -kb {} \;
This add all image files inside a_directory to CVS as binary.

The Joys of COUNT

2006.05.10, Wed

COUNT has actually two forms: COUNT(*) counts the number of rows in a table; and COUNT(expr) counts the non-null occurrences of expr. This is very useful for generating reports, e.g.:

SELECT COUNT(*) AS ‘Total’, COUNT(ID_winner) AS ‘Claimed’

Referring to a parent object from within an XML event handler

2006.05.02, Tue

The mx.utils.Delegate class in Actionscript 2.0 is the only way I have found so far to refer to a parent object from within an XML event handler.

(more…)