I was trying to set up netatalk to serve files off my linux box to my macs, but Leopard was giving a cryptic error message whenever I tried to connect to the server. Turns out the that the default netatalk package that comes with Ubuntu doesn't have SSL support enabled, which Leopard requires. I finally found a blog entry that shows how to build an SSL enabled netatalk package. Works like a charm now!
AFP replaces SSHFS and Macfuse for me, as I couldn't get the volumes to mount read/write after upgrading to Leopard. AFP is really more suitable anyway.
I wrote a program to completely remove the FAT partition table
entry from the GPT, which meant learning about CRC-32 and messing up
with the dd command, which was... fun. All this effort didn't pan out however.
Ultimately, I ended up installing Leopard to an external drive,
migrating my backup into the new install, then formatting my internal
drive before using SuperDuper! to copy the new Leopard install to the
internal drive. After I had been running Leopard off of the external
drive for a while, a box popped up that told me that my internal drive
was now available for use in a limited capacity. Turns out Leopard
had been silently running fsck_hfs on the file system, and that it
turned up errors in the drive. That's probably the reason I couldn't
get the Leopard installer to recognize the drive. I just wasn't
patient enough. If I had waited for the installer to finish the fsck,
it probably would have shown up.
The error fsck_hfs found was "Incorrect number of thread records
found." Apparently this is not something that can be fixed in HFS+
file systems. Or at least, the built in tools can't fix it.
I've been trying to upgrade my MacBook Pro to Leopard for the last few
days. The trouble is, the installer refuses to detect any of the
partitions on my hard drive. It doesn't even show the drive with a
exclamation mark and tell me I need to repartition, which seems to be
fairly common. The Disk Utility and command line tools in the
installer don't see the partitions either, so it seems to a problem at
a more fundamental (kernel?) level. Tiger works fine, as does the
installer for Tiger. From searching the inter-tubes, it appears that
the problem is related to my bootcamp partition. The Leopard
installed seems to require a specific partition layout in order for it
to detect the partitions, which seems massively stupid. Especially
when bootcamp installations are probably fairly common on Tiger
machines.
I tried a couple of things already, such are resetting the protective
MBR to contain only the EFI protection partition, but that had no
effect. Since I have rEFIt installed, I wasn't
worried about trashing the MBR, since rEFIt can recreate it from the
GPT.
A guy on this thread about the Leopard
Installer disk detection problems suggests that the installer
requires the GPT itself to be set up in exactly the right way. It
requires either a single HFS+ partition of any size, or a single HFS+
partition followed by a "basic data" partition, as long as the sum of
the two partition sizes is exactly the size of the disk. My disk
appears to fit the second case... Except it doesn't, because
there is a gap between the HFS+ and FAT32 partitions, which can be seen
with the gpt tool:
thunderstorm:~ mch$ sudo gpt -r -v -v show /dev/disk0
gpt show: /dev/disk0: mediasize=80026361856; sectorsize=512; blocks=156301488
gpt show: /dev/disk0: PMBR at sector 0
gpt show: /dev/disk0: Pri GPT at sector 1
gpt show: /dev/disk0: Sec GPT at sector 156301487
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 6
40 409600 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
409640 102760448 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
103170088 262144
103432232 52869216 3 GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
156301448 7
156301455 32 Sec GPT table
156301487 1 Sec GPT header
So, there is a 6 sector gap between the table and the HFS+
partition, and a 262144 sector gap between the HFS+ partition and the
FAT32 partition. That second gap is probably what is messing up the
Leopard installer.
Here's what diskutil has to say about the disk:
thunderstorm:~ mch$ sudo diskutil list disk0
/dev/disk0
#: type name size identifier
0: GUID_partition_scheme *74.5 GB disk0
1: EFI 200.0 MB disk0s1
2: Apple_HFS Thunderstorm 49.0 GB disk0s2
3: Microsoft Basic Data HELL 25.2 GB disk0s3
Yes, my Windows partition is named HELL. Here is my MBR, after I
trashed it so that it only contains the protective GPT partition:
The next step is to back up my boot camp partition before taking
the FAT32 partition out of the GPT... I'm hoping that that will let
me install Leopard, after which I can attempt to restore the GPT
entry for the FAT32, and hopefully everything will work.
The "My account" page on the Calgary Public Library site uses your library card number and a pin number to authenticate you. However, both form fields are of type "password", which means that Firefox won't save the username / password information. Since the site seems to randomly log you out, it becomes a pain in the ass to get out the library card over and over again to type it in by hand.
This Greasemonkey script simply changes the library card barcode number field from a password type to a text type, which allows Firefox to remember the contents. Unfortunately, when Firefox fills the form, it places the "password" (your pin) in the first password field it finds... since the autofill happens before the Greasemonkey script runs. The barcode isn't autofilled anywhere, so it is necessary to embed it in the script itself. Or you can type the first number in the barcode field and it will autofill it then.
NOTE: after using the CPL website a while, I noticed that the original version of this script was filling in random form fields. It needed to be modified to look for some unique characteristic of the sign in page. Since the CPL website uses a single JSP and GET URL parameters to navigate all the pages, one can't use the greasemonkey include/exclude URL thing.
// ==UserScript==
// @name Calgary Public Library Login fixer
// @namespace http://spacemonkeys.ca/greasemonkey
// @description Changes the password box to a text box so
// that firefox can remember the form fields.
// @include https://catalogue.calgarypubliclibrary.com/ipac20/*
// ==/UserScript==
var inputFields = document.getElementsByTagName('input');
var barcode = inputFields[9];
var barcodeLabel = barcode.parentNode.parentNode.childNodes[0].childNodes[0];
var pin = inputFields[10];
var pinLabel = pin.parentNode.parentNode.childNodes[0].childNodes[0];
var mycardNumber = "xxxxxxxxxxxxxx";
// Firefox autofills the pin into the barcode field, probably because
// that is the first password field it sees. The barcode itself is lost.
if (pin.name == "sec2"
&& barcode.name == "sec1"
&& barcodeLabel.data.search("Library Card Number:") != -1
&& pinLabel.data.search("Last 4 numbers") != -1)
{
var temp = barcode.value;
barcode.value = mycardNumber;
pin.value = temp;
// Make the barcode number a text field, so that Firefox will be able
// to remember the barcode/pin combo.
barcode.type = 'text';
}
It looks like the CPL is in the middle of overhauling their site, so maybe the need for this script will go away.
If anyone can tell me how to get Firefox to redo the autofill after changing the barcode field to text, that would be great!
I'm often asked how many lines of code there are in some project I'm working on. I think it's the least useful metric of any codebase, but people always seem interested in knowing. I'm not sure if they are more impressed by a small number or a large number...
Since it comes up, here's a one liner to count the number of lines of code.
It is sometimes necessary, even in this day and age, to use DOS or
some other simple operating system to directly access hardware to
perform tasks such as BIOS upgrades. Floppies, the traditional boot
media for quick and dirty tasks such as this, are almost extinct. CD's
are cumbersome to use and change. It is therefore handy to use
some other portable external bootable media for jobs such as
this. Enter the bootable USB key.
FreeDOS is a handy open source alternative to
MS-DOS, but it only comes as a CD image that must be burned to a CD
and then installed to a hard drive in order to be usable. This makes
it a bit cumbersome to install on a USB key.
I took a somewhat circuitous route to arrive at these
instructions, which included installing FreeDOS in a VMware Fusion
virtual machine, copying that virtual disk to a flat image file,
moving that image file into a Ubuntu virtual machine, byzantine
manipulations of a USB flash drive with dd, and learning more
about FAT and MBR than I ever wanted to know. Hopefully the distilled
instructions below are a little easier.
I assume that you have a Linux capable of running QEMU (there is a version of QEMU for OS X). You don't need
to use QEMU... but it makes it easier to try different things are
repeat the process while still doing other things, since you don't
have to reboot all the time.
Download the FreeDOS installer ISO from FreeDOS.org.
Partition your USB flash drive as you please. You should have at
least one FAT32 primary partition on which you will install
FreeDOS.
Run qemu-launcher. Set it to boot from CD-ROM, and set the CD-ROM
path to point to the FreeDOS ISO you just downloaded. Set hard disk
path to point at the raw flash device (something like /dev/sdb... find
out from dmesg).
Launch qemu. It should boot the FreeDOS installer. Install FreeDOS
on the "hard drive". I recommend installing just the base set of
packages, unless you want to experiment with networking, etc in FreeDOS.
If you don't need multiboot, you are done.
Close QEMU, unplug the flash drive, and try to test it on a real system. If you have trouble, like it says that no OS is found, it may be necessary to run QEMU again in the same way as before, except instead of using the installer, use the live CD and run fdisk /mbr and sys c: to make sure the drive is fully bootable.
If you want to use multiple OS's on the flash drive, then you can
install grub and set it up to boot each one. But that's for a later
post...
but is thinking that one of the drivers you are cheering for just died entertainment?
Urgh. Yay safety innovation. Concussion and a sore (broken?) ankle. Wow.
Crashes are entertaining when you don't know who is involved, but it's pretty dramatic when it happens to someone you are cheering for. Which is part of watching sports I guess... experiencing the lows is just as much a part of it as the highs. Of course you alway want more points and less crashes in that case.
Montreal was perhaps the most entertaining race of the season, and that's because a lot of unexpected stuff happened, not because anyone drove particularity well.
I often tried to use bash's for loops to do line by line processing, but it's alway been a pain in the ass. An example. I have a list of files in a text file, and I want to copy each file to some other location. The naïve method:
for F in `cat names.txt`; do cp $F /new/path; done
Unfortunately, names.txt looks like this:
This filename has spaces 1.txt
This filename has spaces 2.txt
...
This filename has spaces N.txt
Bash breaks each line on the space, so the for loop doesn't copy each complete filename. If there are no spaces or tabs in the filenames, then the for loop works ok. The right solution is to use the read command and a while loop:
cat names.txt | while read FILENAME; do cp "$FILENAME" /new/path; done
Update per comment below: added quotes around $FILENAME.
Apple recently released a new version of the iWork office suite, which now includes a spreadsheet application, Numbers. One thing that annoyed me about Numbers was the data and time formats. I like to use ISO 8601 (YYYY-MM-DD) because I can never remember which is the month and which is the day in the MM/DD/YY or DD/MM/YY format, which is different between the US and Europe. Numbers doesn't have the ISO 8601 format, and doesn't allow you to specify a custom format. Which is kind of annoying, but it is the first release.
Fortunately, someone figured out how to do it. Here is how to do custom date formats in Numbers. . I Haven't tried it out yet though.
Now if only I could figure our how to add functions.... I need WORKDAY() for my schedules....
I replaced this keyboard from Tamara's iBook this morning with one I got off of eBay. All three screws that hold the body to the frame in the battery compartment fell out when I took the battery out, which was a little surprising. Makes me wonder how many other screws have worked themselves loose. The memory shield screws were still nice and snug though.