Notes


Canvas rotation

2013-02-21 01:31:07

To paint an image rotated properly, first translate the canvas to the center of where the image will be painted. Then apply the rotation. Then either translate the inverse of what you just translated (just same values, negative), or paint the image a...


Fresh 12.04 todos

2012-10-10 20:31:52

Just (finally) upgraded my ubuntu to 12.04 today. My machine had been flying in semi-upgraded state for a few weeks now (won't go into that) and it prevented me from updating specific stuff because the update list contained a zillion items, with no a...


Getting object properties

2012-10-02 11:14:50

There are various ways of getting a set of properties of an object. I'd like to list them and explain what set they actually gather. Getting the list of properties is handy when you use an object as a hash and want to iterate over all the elements of...


Intersection between two lines

2012-09-11 20:47:04

Simple way of getting the point of intersection between two lines (A-AA and B-BB) on a (2d) plane. Pass on the xy coordinates for all end points of the lines and you'll either get an object with x/y back or the falsy valu...


Determine pos of a vector with distance

2012-09-05 15:08:07

Say you have an origin and a bearing/heading (in radians). Say you want to determine the target position if you would move some distance into that direction. How would you do it? I can't explain this but I can tell you the simple way of doing it: ...


Determine position of angle relative to another

2012-08-23 11:03:45

Searching for this problem is not easy. Even though the solution is very, very short. I wouldn't say simple, but I'm fine with that. So this problem is about having two angles (vectors) with the same origin. I needed to know whether one angle was ...


Get bearings in JS

2012-08-21 15:14:49

Simple script to get the bearings (the angle) of a line relative to a starting point. You can use this for your maps voodoo, or just like me, in a game. The script is utterly simple, as long as you understand the concepts of atan2 ;) ...


Fix slow DNS in Ubuntu

2012-06-28 21:32:58

Out of the blue my computer started to be sluggish as hell. I'm still not sure why this suddenly became a problem, but it did. This post concerns a slow dns problem in Ubuntu 11.04, although I suspect you could apply this to other versions as well...


Gnome js interface

2012-06-26 22:05:54

alt+f2 then lg and you'll get into a nice interactive JS shell where you can apply your js voodoo too gnome. I'm loving it :) (Works at least in Gnome 3.2, dunno about anything else but it seems to be older than that)...


Simple ajax get

2012-05-28 19:41:59

Here's a very simple Ajax get. No attempt at edge casing, escaping, or cross browser fixes. Just xhr with a GET. js var get = function(url, callback){ var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function () { if (...