HTML5 Canvas

I have been playing around with animation in Javascript/Canvas off and on for a while. Given that whatever programming I get to do at work is typically some kind of system script or automation tool, it’s nice to do something with a bit of visual feedback. It is also very frustrating because the interactions between actual real world things that I can see and touch often confound me.

Anyway, this is what I have managed thus far.

Boundary detection. The circles change direction when they hit the container boundary and fade when they cross each other’s area. The line between the two was just to help me verify the distance was being calculated from the center.
New window.
[iframe src=”” width=”630″ height=”610″]

Reverse direction on collision. Added a visible border for the container boundary too.
New window.
[iframe src=”” width=”630″ height=”610″]

Every time the circles collides, the larger one steals a bit of mass from the smaller one.
New window.
[iframe src=”” width=”630″ height=”610″]

The larger on steals mass and color on collision.
New window.
[iframe src=”” width=”630″ height=”610″]

Perl password masking in Linux

Most solutions for this seem to point you to Term::ReadKey, which looks something like this:
ReadMode( noecho => STDIN );
my $pass = <STDIN>;
ReadMode( restore => STDIN );

However, I did not have that module on my servers, and the Linux admins get fussy about installing new ones. Fortunately, it does not seem that great of a loss, as system calls via Perl are not really more complicated – the code to hide the password looks nearly identical, and character substitution would still require a loop. It looks like this is geared towards making scripts more portable.

Anyway, here is some code.

Method 1 : Turns off echo so you don’t see anything as it is typed.
system("stty -echo");
system("stty echo");

Method 2 : Turns off echo and buffering. This lets you read one character at a time and write an asterisk instead of echoing the character to the terminal. To get the full password, you just concatenate the characters as they are read in. In this case, you check for the end of input using ord() – you are looking for something like CR or LF, but really anything below ascii 32 should not be in a password.
system ("stty -echo -icanon");
while (sysread STDIN, $a, 1) {
if (ord($a) < 32) { last; } $pass .= $a; syswrite STDOUT, "*", 1; } system ("stty echo icanon");