Wednesday, August 11. 2010Mythbuntu upstart job to set channel 3I switched to digital cable recently, which means that there is now an external cable box for tuning. That means the analog tuner on my mythbox must be set to channel 3 to receive the input from the cable box. Unfortunately, ivtv-tune has a quirk that made it difficult to get the PVR-250 tuned to channel 3. The problem is that ivtv-tune needs the HOME environment variable to be set, and it needs there to be a ~/.ivtv-tune file there. Finally I got it working with this upstart script: # Ensures the PVR 250 card is set to channel 3 so that the cable box works. description "Ensures the PVR 250 card is set to channel 3" author "Matt Hughes Now the ir-blaster can do it's thing and everything works. As a side note, if your remove control stops working, you should replace the batteries be for messing with the LIRC configuration, even if you just updated your kernel. !$!@#$@# Linux. Thursday, March 4. 2010The super easy way to use Emacs and Slime with ClojureI recently became interested in Clojure, a (mostly) functional lisp that runs on the JVM. While reading the documentation and watching the screencasts, I wanted to start trying out some of the stuff I was seeing. I use Emacs for code, on Windows, Linux, and Mac OS, and it is particularly nice for dynamic languages that provide a REPL. Here's the super easy way to get started with Clojure on Emacs.
; SLIME 20091016 user> user> For more information about how Slime works, see this post by Bill Clementson. This Emacs+Slime+Clojure video on Vimeo may also be interesting, although dated. Sunday, February 28. 2010Releasing Phred... finally.Today I've posted Phred, the 3d FDTD program I wrote for my M.A.Sc, to Google code. In some ways it is very simple: it only supports uniform grading for instance. The way the updates are handled is not very flexible. The testing is pretty primitive. Other things about it are still really cool: it runs on a variety on super-computers, or at least it did five years ago. It uses Python as a scripting language for problem set-up. It implements the Drude model for modelling some kinds of metal. It's a good example of my skills as they were five years ago. Despite cringing at some of this code, I'm still pretty proud of it. You can find the Phred Google Code project page here. Cool stuff about Phred:
I ran the majority of my large simulations on Nexus and Glacier, and smaller simulations on Debian Linux, so those are the best tested. However, things have come along way in five years, and I'm not sure if everything would still compile given various software updates than may have been rolled out. There are a lot of rough edges and unfinished things in the code. I was experimenting with template meta-programming for the updates, for instance. Template meta-programming is interesting, but because it's a side-effect of a language feature designed for something else it is hard to use. The error messages are particularly unhelpful. My goal in releasing this is mostly just to preserve it for my own reference, to ensure that it is not lost when the hard drive it was on is disposed of or dies. Open source is more than just the code. It takes a lot of work to build up a community, get people interested, accept patches, and so on. I don't have time to give this project that kind of love. Perhaps someone else will be interested in picking it up and taking it over, but that seems unlikely. There are already many other actively maintained open source FDTD packages out there. Tuesday, February 16. 2010XTerm and metaI'm using Cygwin and X11 on Windows 7, and I'm pretty happy with it so far. The newest version of Cygwin integrates nicely, and 7 seems pretty polished and much nicer overall than XP (I never really used Vista). The one problem I've been having is related to the meta key in XTerm. I'm a heavy user of the Emacs movement keys, so M-b, M-f, M-a and friends see heavy use. However, in the default configuration, I get garbage and strange behaviour. I finally found the fix in an old blog post from 2005. To summarize, the fix is to ctrl-left click and make sure that "meta sends escape" is selected. This can be made permanent by adding this to your .Xresources file: XTerm*metaSendsEscape: true To load that change without restarting X, run xrdb -override .Xresources. Now to figure out what is wrong with X11 on Snow Leopard! UPDATE: If adding the above your your .Xresources file does not work, try adding it to .Xdefaults instead. Alternatively, add xrdb -merge ~/.Xresources to your .xinitrc file. Sunday, June 21. 2009AFP server on Ubutnu for Leopard clientsI 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. Saturday, April 4. 2009Installing Leopard, part III 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. Monday, March 9. 2009Bootcamp, Tiger, and Leopard oh my!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:
thunderstorm:~ mch$ sudo fdisk /dev/rdisk0
Disk: /dev/rdisk0 geometry: 9729/255/63 [156301488 sectors]
Signature: 0xAA55
Starting Ending
#: id cyl hd sec - cyl hd sec [ start - size]
------------------------------------------------------------------------
1: EE 0 0 2 - 1023 254 63 [ 1 - 156301487]
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. Saturday, November 1. 2008Some greasemonkey action for the Calgary Public LibraryThe "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.
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! Saturday, January 26. 2008Lines of code... useful metric?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.
find . -name "*.cc" -or -name "*.hh" -exec wc -l "{}" ";" | gawk '{nlines = nlines + $1} END {print nlines}'
Thursday, January 3. 2008Installing GRUB on a USB driveIf you want to have multiple OS's on your USB drive, you can install GRUB. I haven't actually installed multiple OS's, but GRUB does work:
Thursday, December 27. 2007Creating a bootable USB drive with FreeDOSIt 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.
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... Monday, December 24. 2007Crashes can be entertaining...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. Saturday, December 22. 2007Watch sports for the crashes?Short track speed skating is entertaining because it's fast, and sometimes there are spectacular crashes. Riding in a velodrome is no different.... Dumb passing maneuver by #3. Sunday, October 14. 2007Line by line processing with BashI 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. Thanks electricmonk!.
(Page 1 of 20, totaling 296 entries)
» next page
|
Friends with webpagesCalendar
QuicksearchThings of importanceCategoriesSyndicate This BlogTop Exitsspacemonkeys.ca (25)
imdb.com (16) en.wikipedia.org (10) www.apple.com (10) www.coffeecats.ca (10) bash.org (8) gallery.spacemonkeys.ca (8) rantastic.spacemonkeys.ca (7) www.gnu.org (7) clojure.org (6) Creative Commons |
|||||||||||||||||||||||||||||||||||||||||||||||||

