Page 14 of 28
Amazon's Kindle Comparable to a Hardcover?
Morgan Webb made a comparison between Amazon’s new Kindle eBook reader and a hardcover book. Though she was simply trying to liken the Kindle to the nearest priced physical book product, this is a false comparison. Someone buying a hardcover book is looking for something more than just the words and content of the story; they enjoy the physical representation of a fine work. A more accurate comparison for the Kindle is a regular old paperback, whose purchaser is simply looking for the cheapest representation of the book’s content. At less than $15 for the average paperback, the Kindle doesn’t look like such a good deal, since they charge $10 per book for the $400 device.
Time Machine for Linux
Since Apple’s recent release of Leopard, which comes with the wonderful backup solution Time Machine, I’ve seen more than a few articles explaining how those with Linux/Unix machines can create there own incremental backups using rsync
. This is great and, short of hard-linked directories, exactly like Apple’s Time Machine backend. Furthermore, this has always been possible on systems with rsync
available and filesystems that support hardlinks. I’ve been doing incremental backups for years but, unlike all of the recent articles in question, I didn’t roll my own solution: I use ‘rsnapshot’ to do all of the hard work for me.
There are a number of tutorials for setting up rsnapshot
and the process is really quite simple. First, install rsnapshot
; if you’re using a system with a good package manager, then this is a trivial operation:
~$ sudo aptitude install rsnapshot
Next, you must edit the rsnapshot.conf
file which, in most Linux distributions, resides in /etc
. Note that the key/value pairs in this file must be tab delimited. The file is well commented; the major things that need to be changed are:
snapshot_root
- where the backups will be stored- backup intervals - how many of each interval to keep around (I do 7 dailys, 4 weeklys and 3 monthlys)
- backup points - what to backup
The last point requires some elaboration, as this is what rsnapshot
will be backing up. for a server that is only backing up it’s own stuff this can be fairly simple:
backup /etc/ servername/ backup /var/lib/svn/ servername/ backup /home/ servername/
Which tells rsnapshot
to backup /etc
, /home
and the subversion repository and place them in the directory servername
under the snapshot_root
directory. rsnapshot
is also capable of backup up remote hosts via ssh:
backup root@remote:/etc/ remote/ +rsync_long_args=--bwlimit=120 backup root@remote:/home/ remote/ +rsync_long_args=--bwlimit=120
As above, this will backup the contents of the specified directories under the remote_host
directory in your snapshot_root
directory. This also gives an example of passing arguments to rsync
for that host. I use this to backup my home machine to my server; since I’m on a residential internet link, I tell rsync
to limit its bandwidth usage to 120 kilobytes per second when it is backing up this host to keep from saturating the pipe.
Parkour on ESPN
ESPN had a spot on Parkour this past week; sounds like the sport is actually gaining some traction. Time to gather up my cold weather gear and get back out there.
Programming is Impressive
When you program you tend to have an impressive (or confusing, take your pick) looking screen, particularly if you consider vim an IDE:
Dulce de Leche Ice Cream
My dad made up a bunch of dulce de leche a while back; if you’re going to boil one can, you might as well fill the pot. For those who don’t know, the easiest way to make dulce de leche, a caramelized milk product popular in South and Central America, is to boil a can of sweetened condensed milk for two to three hours. At the shorter end of that range, you’ll end up with viscosity similar to a caramel syrup; longer and it turns into a thick, spreadable paste, not unlike Nutella.
I have seen numerous references on the internet of people not wanting to boil a can for fear of it exploding, but this trepidation is unfounded - boiling is a normal part of the canning process. The contents of the can are put in, the can is sealed and then it is brought to 100°C or even hotter to sterilize the elements within. Leaving a can in boiling water on the stove is perfectly safe, assuming the pan doesn’t run dry, the water will keep the system, can included, from breaking the boiling point. That’s just basic thermodynamics. As mentioned previously, it’s worthwhile to boil a few cans at once, since the energy expenditure of keeping a pot simmering on the stove is nearly identical.
To make the ice cream, combine these ingredients and toss it into your ice cream maker:
1 can sweetened condensed milk 1 can dulce de leche 1 cup heavy cream 2 cups milk Vanilla to taste (1-3 teaspoons)
I used thick (3 hour) dulce de leche, which lends a very strong flavor and skim milk, because it was in the fridge. To get everything to combine, I had to stir it on the stove for about 10 minutes. Don’t just let milk sit on the stove unstirred, however; it grows a nasty skin quite quickly. If you don’t have another can of sweetened condensed milk, it can be replaced by another cup of cream, a half cup of milk and a cup of sugar.
Code Golf
I stumbled across a code golf earlier this week that offers numerous problems. The specific challenge I came across was the fizz buzz problem that I had been introduced to a few weeks ago.
My initial attempt in Perl was this:
for (1..100) { $a = ""; $a = "Fizz" if !($_ % 3);
1 2 3 4 5 6 7 if (!($_ % 5)) { $a .= "Buzz" } elsif ($_ % 3) { $a = $_ } print "$a\n"}
Nothing special at all, just some fairly tight, clean code. Aside from the broken apart if
block and the use of bad variable names ($a
, $_
) it wouldn’t look out of place in a normal program. After exhausting my knowledge of esoteric Perl, I whittled it down to this:
for (1..100) { $a = ($_ % 3) ? "" : "Fizz"; $a .= "Buzz" if !($_ % 5);
1 2 3 $a ||= $_; print "$a\n"}
With a bit of digging, I found that I could use the +
and ,
operators as part of print
to get rid of that $a
assignment:
for (1..100) { $a = ($_ % 3) ? "" : "Fizz"; $a .= "Buzz" if !($_ % 5);
1 print + $a || $_, "\n"}
But you certainly don’t need most of the parenthesis, and Perl deals with barewords just fine:
for (1..100) { $a = $_ % 3 ? "" : Fizz; $a .= Buzz if !($_ % 5);
1 print + $a || $_, "\n"}
Finally, after reading through perlvar
I found that the input record separator, which defaults to “\n”, can take the place of that four-character newline:
for (1..100) { $a = $_ % 3 ? "" : Fizz; $a .= Buzz if !($_ % 5);
1 print + $a || $_, $/}
101 characters, but you can go a step further, drop the $a assignment and condense those statements down below:
for (1..100) { print + ($_ % 3 ? "" : Fizz) . ($_ % 5 ? "" : Buzz) || $_, $/ }
Finally, since this is now a single Perl statement, the curly braces can be eliminated by placing the loop control at the end (thanks to Fotios for that tip). After you beat the whitespace out, you end up with 56 characters:
print+($%3?"":Fizz).($%5?"":Buzz)||$_,$/for(1..100)
What Are You Worth to Facebook?
It was widely reported yesterday that Microsoft bought a 1.6% stake in Facebook for $240 million, thereby valuing the company at $15 billion. Sure getting in on such a huge cache of advertising-ready eyeballs and consumer data is worth a lot, but the bid puts a price of $357 on each of Facebook’s 42 million accounts. Marketplace’s coverage put that number at $300 dollars, which takes into account Facebook’s projection of 50 million accounts by the end of the year. Beyond that, however, is the fact that an account doesn’t necessarily mean a user; nothing stopped me from creating a Facebook page for the Pope and I know that Jesus isn’t actually my friend. Furthermore, not all registered users regularly use the site. I would bet that more than a quarter of my friends use facebook less than once a month, and even then only for a handful of page views (no, I don’t want to be your super-best-buddy). If we take my brash generalization at face value, leaving 30 million active users, they are each worth $500. Do you really think you see $500 worth of ads on Facebook?
Data::Dumper
Data::Dumper is one of the most useful Perl modules when developing code, providing quick and easy access to the contents of data structures. Are you unsure whether you’re setting the values of a hash correctly? Don’t understand how someone has organized an object that you’re ‘use'ing? Data::Dumper to the rescue.
use Data::Dumper; my %foo; $foo{'bar'} = 'This is bar'; $foo{'baz'}{'foo'} = 'This is foo, stored under baz in %foo'; $foo{'qux'} = 'This is qux'; print "The hash '%foo' looks like this:\n"; print Dumper(\%foo);
When executed:
The hash '%foo' looks like this: $VAR1 = { 'bar' => 'This is bar', 'baz' => { 'foo' => 'This is foo, stored under baz in %foo' }, 'qux' => 'This is qux' };
Note that I passed Dumper() a reference to the 'foo’ hash by using a backslash, which is what you will want most of the time with anything other than a scalar. Passing a reference causes Dumper() to print the entire variable’s contents in the same scope. If you pass 'foo’ directly, instead of its reference, you end up with this:
The hash '%foo' looks like this: $VAR1 = 'bar'; $VAR2 = 'This is bar'; $VAR3 = 'baz'; $VAR4 = { 'foo' => 'This is foo, stored under baz in %foo' }; $VAR5 = 'qux'; $VAR6 = 'This is qux';
Which doesn’t make it clear that 'foo’ is a hash.
Homemade Carbonator
After reading this instructable I was very excited because I’ve recently started drinking a lot of seltzer water and I felt silly paying for something so simple. I collected parts from eBay and some online distributors as follows:
- 15lbs. CO2 tank (eBay, $80 shipped)
- Regulator (BeverageFactory.com, $45)
- Carbonator cap (MoreBeer.com, $15)
- Tubing and adapters (hardware store, $5)
- Filled CO2 tank (Robert’s Oxygen, $25)
It’s a pretty simple arrangement, in the end. Just hook the regulator up to the tank along with the tubing to the carbonator cap, adjust the pressure to 50PSI and then fizzy up a bottle of cold water.
Perceptions Are Not Reality
I watched some music videos on YouTube today and found that Ska-P do not look at all as I imagined them. Yum!Yum!ORANGE, however, look exactly like my mind pictured.