February, 2009
21
Feb 09
Backing things up a la Crashplan
Backing things up is very important… your hard drive will fail one of these days, and when it does you will lose everything (trust me, my laptop hard drive failed once…).

You are backing important things up right? Oh…
Enter Crashplan. It seems like a simple way to set up your important things to be backed up elsewhere, either on another hard drive, another computer (maybe a family member’s or maybe even on their servers (don’t worry… it is encrypted quite well).
The first thing you have to do is get it (down in the right corner):

Then you have to chose the version you want to get (Linux for me obviously):

Unzip it and install it:

You will notice that I am installing as root, that is because of this notice:
NOTE: You are apparently not installing as root. While it is recommended to
install as root it is not required. If you continue to install as seanja
then Crashplan will only be able to back up files readable by seanja.
You can install it as a non-root (admin) user if you only want to backup files that are yours, but I have files that I would like to backup elsewhere. I just installed it using the defaults:

Ah… I had to install this twice because I messed it up the first time… make sure that you are in the directory that you unzipped crashplan to so that you can just run:
sudo ./install.sh
Then start Crashplan (which will auto start at the end if you told it to), and signup for an account:

And if it all went well, you will now have Crashplan up and running, you can now install it on another computer using the same account, and it will recognize it as another one of your computers and let you backup to it for free.

20
Feb 09
Damn-it PHP
Run this, I will wait
<?php $items = array('name'=>'blah1', 0=>array('blah2')); $name = 'name'; foreach($items as $key=>$value){ var_dump($key); var_dump($name); var_dump($name==$key); print "\n"; } ?>
…
…
…
…
…
…
…
Probably not what you would expect from that is it?
Well, the first one should be:
string(4) "name" string(4) "name" bool(true)
But the second one seems a little odd… at least for a moment anyway:
int(0) string(4) "name" bool(true)
But then, you should probably rtfm:
If you compare an integer with a string, the string is converted to a number. If you compare two numerical strings, they are compared as integers. These rules also apply to the switch statement. The value is given by the initial portion of the string. If the string starts with valid numeric data, this will be the value used. Otherwise, the value will be 0 (zero). Valid numeric data is an optional sign, followed by one or more digits (optionally containing a decimal point), followed by an optional exponent. The exponent is an ‘e’ or ‘E’ followed by one or more digits.
Doh! Not really a wtf… more like a gotcha. Change the last comparison to check if they are Identical and you will be fine.
<?php $items = array('name'=>'blah1', 0=>array('blah2')); $name = 'name'; foreach($items as $key=>$value){ var_dump($key); var_dump($name); var_dump($name===$key); print "\n"; } ?>
Stupid weakly typed languages… well… at least… stupid PHP, Ruby works fine:
x = rand(36**9).to_s(36) y = 2 puts x puts y puts(x == y) #false