Minor Annoyances

One of my minor annoyances is when I log onto my Hackintosh and try to copy something to one of the network shares on my FreeBSD machine, only to discover that the share isn’t mounted.  I know, it’s not a big deal, I can just select Finder, type K, pick the share from my favorites and it’s mounted.  But I’d rather not have to do that.

AppleScript,” I thought. “I can create an AppleScript app that runs on login and mounts the shares I want.”  In fact, I’d written such a script a couple years ago:

try
    set myIPAddress to do shell script "ifconfig -a inet 2>/dev/null| perl -ne 'if (/inet (\\d+.\\d+.\\d+).\\d+/) {print qq{$1
} if ($1 ne q{127.0.0});}'"
end try
if myIPAddress is "192.168.8" then
    try
        mount volume "smb://daffy.local/packy"
        mount volume "smb://daffy.local/mp3"
    end try
end if

I’d written it to do pretty much the same thing on my laptop. First, it queried the IP address of my laptop to see if I was on my home network (not many people set their internal class C network to 192.168.8.0/16, most use 192.168.0.0/16 or 192.168.1.0/16), and, if so, it mounted both my home directory and the MP3 share from my home server.

Well, I could ditch the first part, since this was for my desktop and I knew it was always going to be on my home network. And I also didn’t want to have to fire up the AppleScript editor every time I wanted to change which network shares were mounted. So I fired up the AppleScript help utility, did some reading on how to read files in AppleScript (since I’m not a frequent AppleScript coder, I frequently have to refer to the docs) and reworked the script into this:

set myHome to (path to home folder) as string
set rcFile to myHome & ".NetworkShares"
set Mounts to read file rcFile as text using delimiter ASCII character 10
repeat with share in Mounts
    try
        mount volume share
    end try
end repeat

This script reads a .NetworkShares file in my home directory, which contains one remote volume URL per line:

nfs://gogo/usr/media
smb://newlennon/Music

Now, when I want to change which shares are mounted, all I have to do is fire up Emacs and edit .NetworkShares.

Eureka!

I think I’ve found the solution to a problem I’ve had at work for ages: Win32::Exe.

I would love to examine the PE version information of a Windows file that’s been uploaded to a Linux server. For a long time, I’ve punted on this problem, and waited until I had the file back on a Windows machine before examining this information, mostly because it’s much easier to get this info using Windows’ API calls to get the data than manually parsing the PE header info.  However, just tonight just stumbled across this perl module mentioned in a stackoverflow post, and it doesn’t depend on modules that we don’t already use.

Now this problem will stop bugging me, and I can go to sleep!

Update: Unfortunately, the files I need to examine are large (> 200MB), and Win32::Exe (via Parse::Binary) seems to load the entire file into memory.  This causes an out of memory error.  But maybe I can use this code as a launching point for a different solution.

I’m embarrassed this took so long…

I got home from work yesterday, and I discovered that my Hackintosh had rebooted itself and was sitting there with a black screen showing nothing but a forlorn cursor blinking at me.  Oh, dear, I thought, something’s gone wonky.

Something usually does go wonky with my hackintosh; it’s nowhere near as stable as the other computers I use (it’s nowhere near as stable as the Mac laptops I own), but I keep using it because… well, it’s an adventure. I mean, if I need something that’s going to work all the time, I have my old 17″ Powerbook (bought new in 2005) and my newer 13″ Macbook (purchased used in 2010).  But I wanted to have a desktop again, and I wanted it to have some oomph. So, last June, I got myself an ASUS P7P55D-E Pro motherboard, an Intel Core i7-870 Lynnfield 2.93GHz CPU, a GeForce 9500 GT graphics card, 8GB of RAM, a 2TB hard drive, and Crucial M4 64GB SSD.  I followed all the instructions on the tonymacx86 blog, and I was up and running.

Anyway, last night I set about trying to figure out what had gone wrong with my setup.  I tried reinstalling the bootloader, but that didn’t work.  I was able to boot a bootloader from a recovery CD and boot into my system on the SSD, but then my system would only work for a little while and then it would hang.  I went googling for other people having problems booting hackintoshes from SSDs, and then I thought to look for problems specifically with my model SSD.  This was when Google’s autocomplete actually led me in the correct direction; I pasted “M4-CT064M4SSD2” into the search bar (copied directly from the System Profiler), and Google suggested “firmware”.  I took the suggestion, which led me to Crucial’s website and the following entry in the change log for the latest firmware upgrade:

Correct a condition where an incorrect response to a SMART counter will cause the m4 drive to become unresponsive after 5184 hours of Power-on time. The drive will recover after a power cycle, however, this failure will repeat once per hour after reaching this point. The condition will allow the end user to successfully update firmware, and poses no risk to user or system data stored on the drive.

This was the point at which my wife came home from the performance of Cyrano that she’s  performing in, and I had to stop for the night.  I picked up work again this afternoon; I downloaded the firmware update, applied it, and crossed my fingers.

Unfortunately, the system still wouldn’t boot on it’s own.  I could boot into the recovery CD’s bootloader and then finish the boot off my SSD, but that wasn’t a long-term solution.  So then I tried reformatting the drive.  No luck.  I thought that maybe the drive was just unbootable and tried swapping it out for the SSD I was holding onto for my FreeBSD machine.  That didn’t work either.  Finally, I went through my BIOS settings extremely carefully.

That’s when I noticed it.  The boot order for the machine was the DVD drive, then the ST32000641AS drive, then removable media (I’m guessing that’s USB).  But wait… the ST32000641AS isn’t the SSD, that’s the 2TB drive I’ve got mounted as /Users.  I then poked around in the BIOS settings until I found where the “primary drive” was the 2TB drive and my “secondary drive” was the SSD.  I swapped their order there, and when I came back to the boot order selection screen, it said that I was booting off the DVD, then my M4-CT064M4SSD2, then removable media.  I saved the settings and rebooted.

It worked.  The BIOS settings had probably gotten screwed up while I was moving the SSD off one of the SATA III ports to one of the first four SATA II ports so the firmware update could see it.  If I’d noticed it had changed, I probably would have had my afternoon to play with my FreeBSD server.

Oh, well. There’s always tomorrow.  🙂

RAM!

The two 4GB DIMMS I bought from Newegg on Tuesday for my home server just arrived (I thought about blowing the extra money to get four of them, ditch the two 2GB strips I currently have, and push my server up to its max of 16GB RAM… but I decided I didn’t need THAT much RAM yet).  I’m going to spend this weekend stuffing that, the 96GB flash drive, and the two 2TB drives I’ve had sitting around since last June into my server.

I was encountering really sucky performance when writing to the server over the network (I tried using AFPSMB and NFS; all sucked equally); after doing some reading online, I discovered that there were two possible sources of my performance problems.  First, it could be the cheap Western Digital WD20EARS drives I bought reporting that they have 512-byte to the operating system when they really have 4K sectors.  Second, it could be that ZFS/NFS performance really sucks when you don’t have a ZFS Intent Log (ZIL) on a high-speed device.  However, the older version of FreeBSD I was running at the time had an older version of ZFS, and in that version of ZFS once you added a log device to a storage pool, you couldn’t remove it–you could only replace it.  I didn’t want stick myself in a situation where I couldn’t undo what I’d done (in case it made things worse), so I needed to wait until I could get a version of ZFS later than version 19.

Fortunately, FreeBSD 9.0 contains ZFS version 28.  I’ve updated the server to FreeBSD 9.0 my ZFS pool to version 28 last month. However, I wanted to wait until I had some time before I stuffed any new hardware into my server.  This weekend is it.

Musical Overtones

I’m starting to play with a new tool I heard about on a FLOSS Weekly episode: Overtone. It’s an open-source audio environment for programmatically generating music.  Now, I’ve got a decent grasp of musical theory, and I can sing very well, but my weak spot as a musician has always been that I don’t put in the time/effort into learning a musical instrument necessary to become proficient at it.  It’s not just musical instruments, though: I don’t put in the time/effort necessary to develop the hand-eye coordination necessary to be proficient at video games, so I find them difficult and frustrating.

Overtone, on the other hand, leverages a skill set that I’ve spent years upon years honing: programming.  If I could write programs that play music, then I could finally produce musical output some other way than singing. By myself. A capella.

So far, I’ve managed to get Overtone (and all its requirements like Clojure and SuperCollider) installed and producing sound.  Now I’m setting out to find more documentation on how Overtone works so I can hack out some music with it.  It’s an interesting exercise, learning a programming language solely to be able to produce music. Fortunately, Clojure is a dialect of Lisp, and I had a class back in college that covered Lisp, so I’m already familiar with the basic concepts.  Unfortunately, the way Lisp works, where everything is an expression and all operators are postfix, is very foreign to my raised-on-procedural-languages mind.  I’m looking forward to some frustrating hours ahead as I wrap my brain around it.

Why you should never make the Administrative Contact for an internet domain a non-technical person…

This morning I sat down to look over my new email, and a message with a subject line containing “FINAL NOTICE” caught my eye.  When I opened it, I saw something that had every appearance of being a bill telling me I needed to respond by February 6:

It's very carefully worded, isn't it?
A painstakingly worded request for me to complete my domain’s “search engine registration”.

I found myself reading it very carefully, even though it turned out to be exactly what I thought it was: a spear phishing attempt.  The sender wanted me to sign up for “search engine registration” for my domain.  Failure to do so would “make it difficult for my customers to locate me on the web.”

Baloney. My site is already well-indexed by all the major search engines; I don’t need to pay someone $75 per year ($295 for 10 years or $499 for a lifetime subscription) to periodically submit my domain name to the search engines’ “Add URL” page.

However, this is exactly the kind of thing that, as the administrative contact on my domain, that I get all the time.  Sometimes people registering domains make the mistake of making the administrative contact for a domain a person who isn’t technical.  I did this myself about 15 years ago, and it came back to bite me.

Periodically, I get postal junk mail from a sketchy domain registrar called “Domain Registry of America” that does it’s best to appear that it’s a branch of the US government.  The junk mail informs me that my domain registration is about to expire and that it’s necessary for me to renew it–with them. Naturally, I toss these solicitations in the shredder with the rest of my junk mail.  Unfortunately, at this time, I was volunteering as the webmaster for a non-profit group, and I’d registered the domain name and put the person in charge of that group down as the administrative contact (for the purposes of this story, let’s call this person “Martin”).  My rationale was that, if I ever got hit by a bus, it would be easier for Martin to regain control of the domain and pass it along to my successor.

Well, one day, I got an email saying that the new registrar for this domain was DRoA, and Martin’s name was all over the email.  I called up Martin and asked what was going on. “Yeah, I got a bill saying that the website was expiring, so I paid it.  Did you forget to do something?”  After going back and forth over what happened, it finally came out that Martin had gotten one of these DRoA notices, thought it was a bill, and paid it.

I scolded Martin appropriately and made him promise not to pay any more “bills” that came in the mail without first consulting me.  I then tried to get the money Martin had paid refunded.  It turned out that I couldn’t.  Even though Martin hadn’t read the solicitation completely, it was carefully worded to explain that this was not, in fact, a bill, and that sending money to Domain Registry of America would transfer the domain’s registration to them.  Fortunately, all I had to do was pay for an additional year’s registration with our original registrar and our registration was transferred back.  I told Martin that paying DRoA’s exorbitant prices for a year’s worth of domain registry (twice what we were currently paying) was his personal penance for not carefully reading something before giving away his credit card number.

Flashing back to the present, I find that this notification also contained a block of small print disclaiming that it was a bill:

By accepting this offer, you agree not to hold DS liable for any part. Note that THIS IS NOT A BILL. This is a solicitation.  You are under no obligation to pay the amounts stated unless you accept this offer. The information in this letter contains confidential and/or legally privileged information from the notification processing department of the DS.  This information is intended only for the use of the individual(s) named above. There is no pre-existing relationship between DS and the domain mentioned above.  This notice is not in any part associated with a continuation of services for domain registration.  Search engine submission is an optional service that you can use as a part of your website optimization and alone may not increase the traffic to your site.  If you do not wish to receive further updates from DS send an email to unsubscribe@sesubmission.com and in the subject line only put remove to unsubscribe.  If you are not the intended recipient, you are hereby notified that disclosure, copying, distribution or the taking of any action in reliance on the contents for this letter is strictly prohibited.  * 100% satisfaction guaranteed, you may request a refund within 30 days.

Fortunately, I’m the intended recipient, so my “disclosure, copying [and] distribution” of the contents of this letter aren’t strictly prohibited. 🙂

Posted in Web

Keeping track of when I need to leave work…

One of my big problems with working in NYC and living in NJ is there are “departure windows” where I can catch the right subway to get the right PATH train to catch the right bus in NJ to get me home. Otherwise, I get stuck cooling my heels somewhere in Jersey City waiting for the next bus. I coded myself up a tiny webapp using a jQuery countdown plugin to help me keep track of when my departure windows are.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>BMC Departure Countdown</title>
<style type="text/css">
@import "jquery.countdown.css";

#homeA, #homeB, #homeC, #homeD, #homeE { width: 240px; height: 65px; margin: 10px}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.countdown.js"></script>
<script type="text/javascript">
$(function () {
	var toDay   = new Date();
	$('#today').text(toDay.toLocaleDateString());

	var home804 = new Date(toDay.getFullYear(), toDay.getMonth(),
	                       toDay.getDate(), 18, 57, 00);
	$('#homeA').countdown({ until: home804,
                                description: 'Leave @ 6:57, Home @ 8:04 pm'});

	var home849 = new Date(toDay.getFullYear(), toDay.getMonth(),
	                       toDay.getDate(), 19, 51, 00);
	$('#homeB').countdown({ until: home849,
                                description: 'Leave @ 7:51, Home @ 8:49 pm'});

	var home934 = new Date(toDay.getFullYear(), toDay.getMonth(),
	                       toDay.getDate(), 20, 27, 00);
	$('#homeC').countdown({ until: home934,
                                description: 'Leave @ 8:27, Home @ 9:34 pm'});

	var home1019 = new Date(toDay.getFullYear(), toDay.getMonth(),
	                        toDay.getDate(), 21, 18, 00);
	$('#homeD').countdown({ until: home1019,
                                description: 'Leave @ 9:18, Home @ 10:19 pm'});

	var home1104 = new Date(toDay.getFullYear(), toDay.getMonth(),
	                        toDay.getDate(), 21, 59, 00);
	$('#homeE').countdown({ until: home1104,
                                description: 'Leave @ 9:59, Home @ 11:04 pm'});
});
</script>
</head>
<body style="text-align: center">
<h1>BMC Departure times for<br><span id="today">today</span></h1>
<center>
<div id="homeA"></div>
<div id="homeB"></div>
<div id="homeC"></div>
<div id="homeD"></div>
<div id="homeE"></div>
</center>
</body>
</html>

Hello world!

I’ve finally decided I need to set up my own dedicated blog.  Writing blog entries about tech things on Livejournal just doesn’t seem right, and I’ve got a lot more control if I host my blog myself.

So here it is!