How to encode accents in an ascii sql file


Sometimes when you want to send a sql file to someone and it contains accents things go … bad.
To circumvent this in oracle sql files you can escape these with compose(unistr(‘CHARACTER + ACCENT’)).
This way your sql file remains ascii encoded and accents don’t go the way of the dodo.

-- The most common combining characters in ANSI are:
-- U+0300: grave accent (`)
-- U+0301: acute accent (´)
-- U+0302: circumflex accent(^)
-- U+0303: tilde (~)
-- U+0308: umlaut (¨)

compose(unistr('a\0300')) as "grave accent",
compose(unistr('a\0301')) as "acute accent",
compose(unistr('a\0302')) as "circumflex accent",
compose(unistr('a\0303')) as "tilde",
compose(unistr('a\0308')) as "umlaut"

How to combine multiple videos


Vlc has a command line interface that enables all sorts of video editing actions. One of those is to stitch together multiple videos. This is how it works on a mac:

/Applications/ -I ncurses 1.ts 2.ts 3.ts --sout "#gather:std{access=file,dst=full.mp4}" --sout-keep

Switching to Mac


I’ve recently switched from windows and linux to mac. Pretty much everything is different. Here are the shortcuts I can’t live without:

On Windows, I used to… On my Mac…
Home Cmd+Left
End Cmd+Right
Delete fn+Backspace
Ctrl+Left Alt+Left
Ctrl+Right Alt+Right
Cut Ctrl+X Cmd+X
Copy Ctrl+C Cmd+C
Paste Ctrl+V Cmd+V
PrintScreen Cmd+Shift+3: print full screen to file on desktop
Cmd+Shift+4: print selected region to file on desktop
Cmd+Shift+4 Space Click: print selected window, including shadow, to file on desktop
Cmd+Ctrl+Shift+3: print full screen to clipboard
Cmd+Ctrl+Shift+4: print selected region to clipboard
Cmd+Ctrl+Shift+4 Space Click: print selected window, including shadow, to clipboard
Cmd+Space grab Cmd+Shift+W Click Click Cmd+S: print selected window, without shadow, to file
pipe | Alt+Shift+L
tilde ~ Alt+N Space
Ctrl+Alt+Del Force quit unresponsive application Cmd+Alt+Esc Click
Cmd+Alt+Shift+Esc (hold for three seconds)
Ctrl+Shift+Esc Task Manager Cmd+Space Activity Monitor
F2 rename file Enter
Enter open file Cmd+Down
Windows+Left install ShifIt and then Cmd+Alt+Ctrl+Left
Windows+Right install ShifIt and then Cmd+Alt+Ctrl+Right
Del to delete a file Cmd+Backspace
Windows+D to show desktop fn+F11
Insert to select a file in midnight commander Ctrl+T

See also Apple Support: Switching PC Habits.

Optimizing JavaScript is harder than ever


We’ve all got our favorite browser. And while developing for the web we test in that one browser first. Optimizing JavaScript for one browser only is a tempting idea. I mean … how much difference could there be between browser engines anyway?

Let’s use the Fibonacci sequence as an example. I wrote six different versions to calculate it. Obviously the naive, recursive way of calculating it is the slowest, but that is where similarities between browsers end. Internet explorer seems to be faster at looping than rounding numbers. And Chrome seems to favor local variables over global ones so much it doesn’t mind doing a lot more calculations.

Internet Explorer Platform Preview randomness is biased


After installing Internet Explorer Platform Preview 1.9.7745.6019 the first thing I did was check out its javascript performance on my own scripts. It turns out to have a very wierd output for Math.random. Test your browsers Math.random() function and see for yourself.

Update: This seems to be fixed in Explorer Platform Preview 1.9.7766.6000.

Custom model binder to avoid decimal separator problems


I bumped into an issue while trying to get the open source ASP.NET MVC project NerdDinner running on my laptop. The Create action in the DinnersController just wouldn’t work. This was due to Latitude and Longitude values being set with a different decimal separator than my server expected. It got "0.0" instead of "0,0" which the Double.parse function didn’t understand. A client-side JavaScript wrote these values into hidden fields, so it was a bit difficult for me to understand at first. I wrote a custom model binder to solve this for all fields of type double at once.

As I’m still learning ASP.NET MVC, my solution may not be the optimal one.

Read the rest of this entry »

IE8 aggressive caching fix


Apparently Internet Explorer 8 has a more aggressive caching mechanism than any other browser I’ve ever met. To fix it I’ve added the following to almost every dynamic page on my server.

// prevent caching (asp classic jscript)
Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "no-cache");
Response.Expires = -1;
' prevent caching (asp classic vbscript) '
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
// prevent caching (php)
header('Cache-Control: no-cache');
header('Pragma: no-cache');
header('Expires: ' . gmdate(DATE_RFC1123, time()-1));
// prevent caching (C#)
//Response.AddHeader("Cache-Control", "no-cache");
//Response.AddHeader("Pragma", "no-cache");
//Response.Expires = -1;


More information here: How to prevent caching in Internet Explorer

Silverlight vs Flash Chess


After seeing the Silverlight Chess sample I immediately started work on a flash version. It needs a lot of optimizing, not a single variable type was set, so it’s not a very fair fight. Anyway … flash is about 10x faster than the ie7 js engine on my machine. But still a lot slower than silverlight.

Read the rest of this entry »

Generate Excel files in ASP Classic


Generating Excel files in ASP Classic is not as easy as I thought. I hope someone finds use in this little piece of code that shows a way to export data to csv and to xls.

Read the rest of this entry »

Selecting a random employee with adjacency tables


In my previous blogpost I mentioned a way to retrieve the entire tree from a hierarchy stored with adjacency tables. Now I’ve got a way to retrieve a random employee in an organisation.

I use ORDER BY NEWID() to randomize the order and TOP 1 to get only one result.

WITH Bosses (id, boss_id, name, depth, hierarchy)
AS (
	, boss_id
	, name
	, 0
	, name
	FROM People
	WHERE boss_id IS NULL
	, People.boss_id
	, Bosses.depth + 1
	, CONVERT(VARCHAR(50), Bosses.hierarchy + ' > ' +
	FROM People
	, Bosses
	WHERE People.boss_id =
FROM Bosses
WHERE depth >= 2