Page 18 of 28
Fast Downloads with Metalink
Reading the Slashdot thread about PC-BSD someone mentioned that there was a VMWare image pre-installed for playing around with it. On the download page, in addition to being able to select mirrors, as one expects with a large file, there was a Metalink. Not to be confused with Oracle’s worthless support website, Metalinks are files that describe methods for obtaining a file, in this case, HTTP and FTP locations where it is available and hashes for pieces of the file. After first trying a couple of mirrors and only getting ~60Kb/s I grabbed the Metalink file and installed Aria2, a command-line Metalink downloader. I simply pointed aria2 to the Metalink file (it can also take the URL of the Metalink) and it started downloading from 15 of the servers in the list simultaneously. Needless to say, this resulted in a much faster download. More information about Metalinks, including projects that employ them, can be found at the Metalink website.
Caps Lock to Control on Ubuntu
If you’ve ever used a Sun workstation, you know the joys of having a control key where most keyboards position the caps lock key. If you’re an experienced user of the Interweb, you know that there is nary an occasion that calls for the caps lock. The fact that you have to hold down the shift key is a good moment to reconsider any yelling. Though I don’t use the console often, it is endlessly annoying to find that I don’t have a properly positioned control key when I do. I went searching for the right way to change the keyboard’s layout, since I hadn’t ever bothered to do it previously. I found this how-to by Gary Vollink which describes how to replace the worthless caps lock with the useful control key in all operating systems anyone ever uses.
For Ubuntu’s console, it’s a simple change in /etc/console-setup/boottime.kmap.gz
, which can be edited directly with vi
; no need to un-gzip it first. Keycode 29 is the left control key and #58 is the caps lock. If you want another control, just copy the contents of 29 to 58 and if, for some reason (lots of SQL?) you care to swap the two rather than be rid of caps lock entirely, simply swap the values after the equals signs.
In X, I had previously used Gnome’s keyboard preferences to change the caps lock setting, but the above-mentioned howto showed that it could be done by adding the following option to the ‘InputDevice’ section of one’s xorg.conf
:
Option "XkbOptions" "lv3:ralt_switch, ctrl:nocaps"
Malted Milk Ice Cream
A Google search for ‘malted milk ice cream’ only turns up a single recipe, that from A Perfect Scoop. I used that as the basis for my ice cream but only very loosely. I’ve been cooking long enough what changes can be made to a recipe without screwing it up completely and so took the liberty of omitting the eggs. I usually make ice cream without eggs mainly because I’m lazy and if you use eggs you have heat your mixture to cook them. Also, without eggs ice cream is considerably healthier, containing much less fat and cholesterol. Finally, ice cream made with eggs is technically a custard. That final stipulation is the one I pull out when I don’t want people to think I’m lazy. My recipe is as follows:
1.5 cups half & half 1.5 cups whole milk 1 cup malted milk 1/2 cup skim milk powder 1/2 cup sugar 1.5 teaspoons vanilla
I use more vanilla and malted milk because I really like those flavors. The amount of vanilla is perfect, but if you’re not into the malt as much, you should first ask yourself why you are making malted milk ice cream and then only use ½ or 2/3 of a cup. I used whole milk and half & half in the quantities specified because I wanted 3 cups of liquid total and that’s how much half & half I had that needed to be used up. The original recipe calls for cream, as many ice cream recipes do; this will certainly make a more luscious ice cream, but I’ve found whole milk + half & half to do a fine job. My normal ratio is 1 cup half & half and 2 cups milk, which makes a very good ice cream with much less fat than cream-based ice cream. I guess I really am making ice milk, but no matter, it’s good stuff.
Creating Encrypted Backups with GPG
With large hard drives becoming cheap and external enclosures easy to find, many people are finally beginning to perform backups of their data. While an external drive is a good step that will mitigate the risk of the main drive’s failure or an accidental deletion, it doesn’t protect from the worse, albeit more rare risks of fire and theft. I say this and now I’m about to delve into some Linux jazz that doesn’t apply to normal users. Oh well.
I keep regular backups (I’m actually lucky enough to have an offsite location to put them) but want to keep my most important data in another place as well and to do so, I occasionally burn a DVD with said data. My only concern with this is that if I, say, leave it in my car now my potentially private data is even more susceptible to theft. In order to make this a non-issue, I use the following command to create encrypted and gzipped tar archives:
tar -chf - foo/ | gzip - | gpg -e -r Drew > foo.tar.gz.gpg
Quite simple, really.
Smoking
Smoking food is great; the only downside is that if you want it ready for an afternoon barbecue, you have to get up early to put the meat to the heat. Alton Brown’s recipe for pulled pork is what I use; it simply consists of brining a pork shoulder overnight and then smoking with a simple rub. If you’ve got the smoker running, you might as well toss on other stuff as well.
Installing VMware Workstation on Ubuntu Feisty (7.04)
I found a new, easy process for installing VMware on Ubuntu, having updated the kernel on my Feisty machine since the last time I used the virtual machine. Whenever the kernel changes, VMware needs to rebuild it’s kernel module to suit, via the script vmware-config.pl
. This involves a few steps such that VMware can correctly build it’s module against the kernel you’re running. First, you need to grab the headers for your running kernel and set them up to support building:
~$ sudo -i ~# aptitude install linux-headers-`uname -r` ~# cd /usr/src/ /usr/src# ln -s linux-headers-2.6.20-16-`uname -r` linux /usr/src# cd linux /usr/src/linux# cp /boot/config-`uname -r` .config /usr/src/linux# make oldconfig && make prepare0 && make scripts
The above installs the kernel headers for your current kernel (uname -r' gives the running kernel's version), gets the
.configfor said kernel and preps the headers per the
.config`. Now, on to the VMware part of things.
Installing VMware is really easy, thanks to this patch. You simply need to get the patch, untar and run it; the script included invokes the VMware configurator automatically.
/usr/src# wget http://ftp.cvut.cz/vmware/vmware-any-any-update109.tar.gz /usr/src# tar zxf vmware-any-any-update109.tar.gz /usr/src# cd vmware-any-any-update109 /usr/src/vmware-any-any-update109# ./runme.pl
Follow the directions provided by the VMware configuration script (the defaults are safe, but read the information) and you’re done.
Why Oil Companies Support Carbon Caps
Amongst all of the recent news about climate change, I started hearing about large corporations, even oil and car companies, who were backing legislation such as carbon caps. The most notable of these groups is the US Climate Action Partnership which includes companies like BP America and PG&E that are throughly tied to fossil fuels. Why are these companies supportive of legislation that will create wholesale changes in the manner in which their industries operate?
First and foremost, these companies aren’t stupid and realize that, given the current political climate where human-induced global warming has become accepted as truth, their best move is to mitigate the effects of legislation that changes the way their businesses operate. The best way to run any business is to simply keep on trucking; if you can sell the same product or service without having to change what you deliver or the manner in which you create it, your operating costs will be very low. A cap-and-trade system would certainly change the way any carbon-producing industry must operate, but it probably wouldn’t require as much change in facilities and production methods as more specifically defined legislation. Cap-and-trade simply states, “Either release less carbon or buy the right to pollute more from someone else.” This gives companies a lot of options.
The more sinister reason that carbon producers support cap-and-trade legislation is that they know the world is changing. Alternative fuels are gaining momentum as gas prices soar and hatred of pollution and high prices adds to the animosity towards carbon-based fuels. Tempering this hatred with pseudo-green initiatives like supporting carbon-control legislation may help fossil-fuel dependent companies stand up to other energy sources. This also has the side effect of possibly convincing some rainy-day environmentalists that oil companies aren’t so bad after all.
Setting IzPack's Default Target Directory
IzPack is a great installer written in Java and configured with XML files, though the documentation can be a little bit lacking. This OK because the variables are all named well so one can easily look to an existing installer (such as that for IzPack itself or 7-zip) and copy needed bits of code. One thing that I found elusive was how to set the default install directory to something other than “C:\Program Files<product name>”. The <info> element provides an <appsubpath> element that allows you to specify something other than <product name>, but you’re still limited to something within the default Windows installation directory. Alas, mailing lists to the rescue! This post describes declaring a resource in the install.xml and after a bit of fiddling I came up with the following.
First, create a file TargetDir.txt with nothing more than the path you want to install at, for me that file simply contained “C:\foo”. Next, point to the resource in the install.xml:
<resources>
<!-- Set the default installation directory shown in the TargetPanel -->
<res id="TargetPanel.dir" src="TargetDir.txt" />
</resources>
Rebuild the installer and you’re set.
Finding Perl Module Dependencies
So you’ve written a Perl program and want to give it to someone else. The only problem is, like any good Perl program, you’ve made good use of modules, some of which may be non-standard. The person in question may not be able to install modules on the machine they’re going to be running your script on, or maybe you just don’t want to hassle them with that. The easy way is to give them the modules in the proper directory structure right alongside your program; they simply toss the group of modules in the same directory as the script and when it’s run the Perl interpreter searches . (the current directory) for the modules, finds them and goes about its merry way.
The only hiccup, some of the modules you’ve used depend on other modules…which may have further dependencies. Rather than suffer through dependency reminiscent of Red Hat (even the newest version…), you can use the Devel::Modlist module which will tell you which modules are required to run the program. Invoked with the ‘nocore’ option, Devel::Modlist will ignore standard modules, which ought to be installed with any Perl distribution. Here is an example from a program I wrote; the only module I invoke directly is XML::SAX.
~/code$ perl -d -MDevel::Modlist=nocore merge.pl foo.xml bar.xml
Loading DB routines from perl5db.pl version 1.28
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
XML::NamespaceSupport 1.09
XML::SAX 0.14
XML::SAX::Base 1.04
XML::SAX::DocumentLocator
XML::SAX::Exception 1.01
XML::SAX::ParserFactory 1.01
XML::SAX::PurePerl 0.90
XML::SAX::PurePerl::DTDDecls
XML::SAX::PurePerl::DocType
XML::SAX::PurePerl::EncodingDetect
XML::SAX::PurePerl::Productions
XML::SAX::PurePerl::Reader
XML::SAX::PurePerl::Reader::Stream
XML::SAX::PurePerl::Reader::String
XML::SAX::PurePerl::Reader::URI
XML::SAX::PurePerl::Reader::UnicodeExt
XML::SAX::PurePerl::UnicodeExt
XML::SAX::PurePerl::XMLDecl
~/code$
tar over SSH (part 2)
In our last episode we used tar to move a file structure across the network. This time, to create a tarball directly onto another machine the following command can be used:
tar czf - foo/ | ssh user@host "cat > /path/to/foo.tgz"
This is useful if the machine you’re taring from doesn’t have enough disk space to hold the tarball. Furthermore, it’s probably faster because the tarball is only being written once, directly to its final location.