Disclaimer: I am not an investment advisor. When I describe my own trading activities, it is not intended as advice or solicitation of any kind.

13 May 2012

Happy 1989

It is 1989 in the Year-a-Month project, but really this month is all over the place. Black Sabbath released Headless Cross this year, but I'm having some trouble getting it; maybe I'll include it next month. It was a light year otherwise, with Accept and Overkill being the only bands on my list releasing any metal albums in 1989. So I used the light month as an opportunity to catch up with the early Motorhead albums I missed.

Also worth mentioning is that Nine Inch Nails released their debut Pretty Hate Machine. You won't ever see NIN on this list, because I already own every studio album that Trent Reznor ever recorded under this band name. My college roommate picked up a copy of Pretty Hate Machine over the summer of 1990 and left it with me while he spent a term in Scotland. I think I nearly wore that CD out that fall, and when we went our separate ways after graduation a couple of years later, I picked up my own copy. Even now, 23 years later, it remains one my favorite albums.

Accept: Eat the Heat - Accept's sound continues to evolve. I can't believe this is the same band I thought sounded like AC/DC just a few months ago. After reviewing Wikipedia, I see why this one sounds so much different: it's the only Accept album on which Udo Dirkschneider wasn't the lead singer.
Overkill: Years of Decay - Overkill is starting to sound like a real band. The raw semi-produced sound of the last couple of albums is gone, and the riffs are all tight and precise. I was surprised to realize that the rhythm guitar sounds quite a bit like Anthrax, but that's where the similarity ends.
Motorhead: Bomber (1979) - This album has the original version of Stone Dead Forever, which is a song that I've been listening to Metallica cover on their album Garage, Inc. for many years. It was one of Motorhead's bigger songs from this album, but I didn't even know its origins until now.
Motorhead: Ace of Spades (1980) - Like most Motorhead albums, Ace of Spades sounds just like all the others. I was listening to Bomber while I did some other things, and then looked to see when Ace was due to play... I was on the last song.
Motorhead: Iron Fist (1982) - Wikipedia talks about a video made with the band in leather armor with swords. Lemmy described the experience as "prancing about in the woods" with armor on. Try as I might, I cannot picture this scene.

02 May 2012

JavaScript, Perl, IRC, and FourSquare

This week I wrote a script to check myself into foursquare venues. Being a C++ programmer for whom every microsecond counts, I don't get much opportunity to play around with scripted languages or internet services. So to accomplish this task, I had to teach myself enough JavaScript including using jQuery and JSON to interact with foursquare's API.

(By the way, I was going to put a foursquare logo here, but I read the trademark page and was so disgusted that I don't think I will)

Foursquare uses OAuth 2.0 to let a user give an application access to their foursquare account. This requires registering the application to get a ClientID, which is as simple as coming up with a name, and then using that ClientID in conjunction with the user's cooperation to generate an authentication token, which can then be used indefinitely to access the user's account. To reduce the risk of the application being spoofed, foursquare also requires a URL during registration, which it calls back during the authentication process.

Because of this callback model, I have to have a real web page on a publicly-available server. I have my markmccracken.net domain hosted primarily for email and this blog, and it does allow HTML-serving, but no server-side scripting like PHP. So that means all the authentication work has to be done in client-side scripting like JavaScript.

The beautiful and media-rich page I whipped up to accomplish the authentication is here. I've had spotty results using this from IE, but it seems pretty reliable under Chrome and Firefox (presuming you have JavaScript turned on, of course). Including the authentication, this page accomplishes a few one-time tasks:
  1. Authenticate, as mentioned, getting an access token I can use indefinitely.
  2. Search the user's lists on foursquare for one called "My Favorites".
  3. Iterate all the venues in that list, putting them and some other helpful defaults into a text box that can be copy/pasted to prime a configuration file.
I like having my long-running scripts talk to me via IRC, because I can passively monitor them from anywhere, and even interact with them in a rudimentary manner. For this project, I used Bot::BasicBot from CPAN, which I've used before to hook a Perl script up to IRC. It's a nice Perl library in the form of a base class where most of the interaction is done in an event-driven manner via the use of callbacks. The two main callbacks for my purposes are tick() and said(). tick() gets called when a timer expires, and said() gets called whenever anyone says anything on the IRC channel. With a little state management and content filtering/parsing, the bot can do pretty much whatever it needs to do with these two callbacks. It can also speak onto the IRC channel by using the say() method.

CPAN is far less scary than The FoursquareTM Site

The only thing left is the meat of the task, which is to check myself into a foursquare venue, wait for a while, and then repeat on the next venue. Since all the venues are pre-loaded into the configuration file, the Perl script just has to iterate them at extremely low speed (one checkin an hour) and make a POST request for each one that actually accomplishes the checkin. For that request, I used the HTTP::Tiny package, because it's usually pre-installed and is very easy to use. Since foursquare requires that POST request to be over https, the IO::Socket::SSL package must also be available.

If you want to try this thing yourself, follow the instructions below for your operating system. I actually have Windows instructions this time because I helped some POWs (Prisoners Of Windows) get it working in their cells. Either way before you begin, create a list on your foursquare account called "My Favorites" and put into it whatever venues you want to automatically check into.

Linux
Perl is probably already installed, but you'll probably need some or all of the extra packages. The cpan utility comes with Perl (at least on Arch), so use it to install the required packages.

sudo pacman -S cpan
cpan Bot::BasicBot
cpan HTTP::Tiny # probably unnecessary
cpan IO::Socket::SSL

Next get the perl script here, and save it somewhere convenient. Give yourself execution permissions.

chmod u+x foursquare_irc.pl


Go to the media-rich and highly advanced authentication page mentioned earlier, and get your configuration starter. Copy it from the web page and paste it into a text file such as foursquare.cfg. Then jump down to the IRC-specific settings described after I repeat these instructions to those Winlozers in small simple words.

Windows
Since you are trapped in Windows, you have no Perl pre-installed. So first, go get Strawberry Perl. Be sure to get the right architecture for your machine: 32-bit or 64-bit. If you're not sure which one you have, then you probably don't want to go any farther with this project anyway. Strawberry Perl was written for Windows users, so it chooses bloat over customization. That means you don't need to install any of those packages I mentioned earlier, because Strawberry Perl pre-installs all of them for you. And yes, that strawberry on their home page is HUGE.

Next get the perl script here, and save it somewhere convenient that you can find again, like your Desktop. In the same place, create an empty text file such as foursquare.txt. In that file, paste the contents of the text box on the media-rich and highly advanced authentication page mentioned earlier. Add the IRC-specific settings described below after I insult some Mac people.

Mac
Go away.

IRC Settings
The highly advanced and media-rich webpage doesn't talk about IRC settings, because there is another version of this script for IRC-impaired people that doesn't use IRC, and I didn't want to confuse them with excess settings. So you'll need to manually add the following settings. Note that none of the stuff in parentheses is real - you have to come up with your own.


IRCChannel= (your IRC channel here, such as #RiskOfRuin)
IRCServer= (your IRC server here, such as irc.foonetic.net)
IRCPort=6667 (probably right, check your server)
IRCNick= (a probably-unique nickname for this script, such as oexkubhtn234)
IRCBoss= (YOUR nick on IRC - the bot only takes orders from this nick)

Run That Sucker
With all the settings in place, go connect your own nick to the IRC channel. Then execute the script:
(Linux) ./foursquare_irc.pl foursquare.cfg
(Windows) .\foursquare_irc.pl foursquare.txt
Yes, Windows people, you're going to need to open a command window. Sorry.

If you've configured everything correctly, you'll see the bot connect to your IRC channel and report its readiness. To interact with it, precede your command with its nick: oexkubhtn234 quit. Simple. It responds to the following commands:
  • quit - quits.
  • start - starts at first venue after waiting [0 .. MaxSlop] minutes.
  • start n - starts at nth venue.
  • status - tells you what it's up to in case you forgot.
  • settings - reports its settings and venues.
Please use this script responsibly!

04 April 2012

Happy 1988

It's 1988 in the Year a Month project, and there's a healthy list of albums this month. Once again I had to trim off Pantera (Power Metal) because it was difficult to find and expensive. That's a pity, because Wikipedia describes this album as a transitional one between their older glam rock sound and the heavier stuff on Cowboys From Hell. That sounds just like the sort of album I'd like to hear to get a sense of the "origin story" of the Pantera we all know and love. I'll keep my eyes open for it at a reasonable price at some point. Meanwhile, we have the usual suspects and a new contender.

1988 was an important year in my life, since it was the year that I graduated from high school and headed off to college. My listening habits were a little two-sided: most of my listening in the spring consisted of FM Radio, like most of suburban America. But my college was out in the middle of nowhere, with only one very mediocre rock music station. So the second half of the year was almost exclusively listening to the CDs that I and my roommate brought with us. And as college students, we didn't have a lot of money to spend on music, so we pretty much listened to the same 5-10 discs all the time. I couldn't tell you which ones those were, though.


Danzig: Danzig - let's all give Danzig a nice warm Year-a-Month welcome. My first introduction to Danzig was the single "Mother" on a mix tape a good friend made for me in college. Glenn Danzig, who started out in The Misfits, sings with a little more bluesy style than a lot of the stuff I've been listening to lately, but the guitars and drums still get my head bobbing and my foot tapping. I look forward to having it come up on the shuffle between a couple of thrash songs - it should break things up well.

Iron Maiden: Seventh Son of a Seventh Son - Iron Maiden continues its galloping metal style that it has perfected since Bruce Dickinson arrived. The keyboards they introduced in Somewhere in Time are more prevalent this time around, but they don't take over. Seventh Son is a concept album based on The Tale of Alvin Maker, which cements Maiden as the geek's metal band. I need to read that series sometime.

Judas Priest: Ram It Down - this album only made Gold in the US, unlike the Platinums from the previous several albums. That's a shame, because I think Ram It Down is just as good as any other album the past few years (months). In reading about this album on Wikipedia, I learned that this and Turbo (1986) were originally supposed to be a double album. The more commercial songs were released on Turbo, and the heavier ones were released on Ram It Down. I'll take the heavier ones, thanks.

Megadeth: So Far, So Good... So What! - most of this album is the same heavy-guitar distortion and high-speed riffs that characterize early Megadeth. One gigantic style departure is Anarchy in the UK, which is a cover of the Sex Pistols song; I don't quite understand why this song was included, it really doesn't fit with Megadeth's sound at all. It doesn't even have the right lyrics, since Dave Mustaine couldn't understand Johnny Rotten's singing. That makes millions of us, Dave.

Overkill: Under the Influence - in comparison to the other monster bands in my list, Overkill always sounds a little under-produced. That's especially true in this album, where a lot of the grandiose riffs from Taking Over are replaced with more of a raw thrash-metal sound. It's hard to put my finger on what exactly the differences are, but they are immediately noticeable.

Ozzy Osbourne: No Rest for the Wicked - on the other end of the spectrum, we have Ozzy, with his finely tuned voice echo. The very first song, Miracle Man, features voice synthesizers and other effects. Having heard Ozzy [try to] talk, I can imagine what a challenge he must be to record and produce. To reach this level of clarity and timing takes wizardry.


28 March 2012

Lotteries as Investments

There has been a lot of excitement lately about the Mega Millions lottery reaching its largest-ever jackpot of $476 million. This can happen whenever a long period of time goes by without a winner, as the jackpot continues to "roll over" and accumulate. Having co-workers and friends that enjoy thinking about probabilities means that a lot of impromptu discussions have sprouted regarding the general question: "Should I play?" The answer, unless you are already a billionaire, is no.

This post is based almost solely on the information in the excellent and accessible paper by Abrams and Garibaldi entitled, "Finding Good Bets in the Lottery, and Why You Shouldn't Take Them". I will cover some of the same ground, but with a focus on working up the current Mega Millions jackpot as an example, using their paper as a starting point. I'll show, specifically for this $476 million jackpot, that Mega Millions may be a good bet this week, depending on the number tickets sold. Spoiler alert: but it's still a bad investment.

Betting Vs Investing

Abrams and Garibaldi define "good bet" to mean any wager with positive expected return. My fellow poker players are very familiar with this concept, and it's why we head straight for the poker room in a casino instead of stopping to play craps or slots (well, most of us). If you're sitting there with pocket aces, you know it's a good idea, mathematically, to get all your chips committed pre-flop. In fact, you're pretty close to an 85% favorite to win against a single opponent.

A "good investment", on the other hand takes risk of ruin into account, and is much harder to understand. Under very specific circumstances, it might be right to fold those pocket aces pre-flop! If you're on the bubble in a satellite with a hard cut-off and you see two other big stacks get all-in ahead of you, it's probably better to fold AA. For those of you that don't follow poker jargon, imagine the case of real estate auction sales: you can get properties at fractions of their worth, but there is a reasonable chance (say 25%) that one of them will be totally worthless - and you must pay cash. The auction is only a good investment if you have enough capital to absorb some bad runs of luck: 3 out of your 4 houses you bought this time around turn out to be structurally unsound and worthless, instead of the expected 1 out of 4.

That's Nice - Should I Play or Not?

OK, enough background. Let's get to the analysis! I'll save you the formulas: the probability of any randomly selected ticket in Mega Millions being a jackpot winner is 1 in 175,711,536. There are also lesser prizes with correspondingly higher probabilities, and on the downside the jackpot needs to be diluted for taxes and the probability of having to split the prize with another winner. To begin, we must calculate the simple expected rate of return (eROR), which requires knowing the ticket sales. Since we don't know that for March 30, I plugged in the numbers from the previous drawing, and then gave some projections for color on the next one. I drew heavily from Abrams to calculate these numbers:

March 27: $363M jackpot, 190,922,875 tickets sold. eROR=-3%
March 30: $476M jackpot:
    100million tickets sold: eROR=58%
    200million tickets sold: eROR=24%
    300million tickets sold: eROR=Dead Even
    400million tickets sold: eROR=-17%
(Note: all returns assume 25% taxes withheld)

Abrams converts these financialish returns into break-even curves, which I won't show here (see page 14 of his paper if you're curious). Then he uses some calculus that I also won't include here and generates an upper and lower bound for all possible break-even curves for lotteries like Mega Millions. The end result, though, is that we want the jackpot to be large relative to the number of tickets sold. But you didn't need all the math above to tell you that. What the math tells us is how much larger it needs to be.

Well it turns out that anytime the Mega Millions jackpot (lump sum, after tax) is 20% more than its ticket sales - and as I said you'll need to project this number - it's a good bet. By the way, it also has to be larger than 171million (after tax), which is the straight-up probabilistic break-even regardless of sales. Abrams predicts that this will never happen, and that the surge in ticket-buying that surrounds a big jackpot more than makes up for the improved probability-weighted return. I think he fails to see the large numbers that can happen in a roll-over jackpot like Mega Millions, which is a natural human mistake.

There is an undefined upper-bound to the public's appetite for lottery tickets regardless of mathematical edge, as well as a diminishing stimulus to ever-higher jackpots. Eventually, an extra $100million in jackpot fails to generate an extra 100million ticket sales in a few days. And that's what we're seeing right now: the jackpot has gotten so big that the habitual and some-time players have all already joined the list. Even the almost-never players are about tapped out at this point, which lets the jackpot grow without adding additional ticket sales.

Yes Yes, 300 Million Tickets - Should I Play or Not?

Will March 30 be a good bet? This really comes down to your opinion of whether 300 million tickets will be sold. If I were a betting man, and I am, I would set my over-under line at just about that figure. But I'll look one drawing farther into the future, and say this: if it rolls over one more time, the jackpot will outpace demand. At that point, it will certainly be a good bet.

But will it be a good investment? The short answer is no. Abrams goes into a detailed portfolio analysis of the variance on the Texas Lottery, using the Nobel Prize-winning techniques developed by Markowitz and Sharpe in 1990. He calculates that for that particular lottery, a reasonable investor should invest nothing in any syndicate buying lottery tickets unless that syndicate buys at least 145,000 per week. These numbers are impressive, but they don't really apply to Mega Millions. To do that, I would have to retrace the rest of Abrams' work, which I leave as an exercise for the reader. But intuitively, I think we can all see that the variance on a 1-in-176million investment is crazy-high, and should be such a tiny sliver of any investment portfolio that only the largest investors would buy any tickets at all.

I am not that investor, so I won't be buying a ticket next week, regardless of the March 30 outcome.

As a post-script, as I was chasing down all the links for this post, I stumbled upon a less technical version (Word document) of the paper I wish I had found before working through the math for this post. If you want Abrams' own words, I suggest starting there. And if you want the spreadsheet I used to do the calculations, I put it into a public Google Docs file. You'll need to download it in order to play with the numbers, but help yourself.

05 March 2012

Happy 1987

It's 1987 in the Year a Month project, and this month is shaping up to be a good one.


Black Sabbath: The Eternal Idol - Wow, what a mess Black Sabbath was in while this album was being recorded and promoted. They had massive member turnover, apathetic reviews, and poor sales numbers. Then they made the poor decision to tour apartheid-era South Africa, and saw their other European shows cancelled by promoters in revenge. They were subsequently dropped by two record labels. Strangely, despite all the drama, this is a pretty good album. I like the guitars, and Tony Martin (no, I've never heard of him either) sounds enough like Dio to make the sound work pretty well.

Anthrax: Among the Living - I have State Of Euphoria (1988) and Persistence of Time (1990) already, and always wondered what the missing link was between Fistful of Metal's (1984) sound and those albums. Well, I found it. The guitars on this album are amazing, cranking out riff after riff of "screw you" metal goodness. But the vocals are turning into the Ethel Murman belly-holler that pulled Anthrax off of my playlist in the 1990s.

Dio: Dream Evil - I swear I think Dio gets better with every album. He hits it hard right off the bat with some near-thrash guitars on the first track, Night People, which for Dio is about as hard as it gets. Something about his voice makes him the perfect medium-metal singer to represent the 1980s.
Overkill: Taking Over - Overkill has some of the most technical and entertaining guitar licks of any 80s-era band in my collection. The vocals, bass, and drums just kind of follow along like lost children. There isn't anything all that notable about this album, except the extreme level of 1980s-ness clearly apparent on the cover. It rocks, I like it, whatever.

Motorhead: Rock 'n' Roll - this album may contain some of the songs that we heard at the recent Volbeat/Motorhead/Megadeth concert in Chicago. I say "may" because when Lemmy cranked up the on-stage guitar amp and blew one of the speakers, causing the poor sound guy to have to crank everything else to compensate, it damaged our hearing so much that we had no idea what songs he was playing. It took Megadeth three songs before they finally got the mix right again, and even then I couldn't tell you what Mustaine was saying between songs. Sorry, Lemmy, but you can't reach the volume control on my MP3 player.

25 February 2012

Random Hubble Desktop Wallpaper


As I settle into my new Arch workstation, I find myself going through all the little nesting behaviors that any user would demonstrate. Only it's a little more challenging this time around, because instead of a user-coddling operating system like Windows or Ubuntu, I'm using Arch Linux. And instead of using a familiar desktop environment like Gnome, I'm using KDE 4.8. So the most basic of things provides an opportunity for learning. For example, I spent a good 30 minutes trying to figure out how to set up the screensaver the other day. It's easy, and very similar to how every other operating system does it; but I just didn't know where to look.

One of my computing goals this year is to stop taking the features and options spoon-fed to me by the desktop environment and instead be willing to step up and exert my own will on the environment. Arch/KDE is a perfect combination for this, because they are both all about basic building blocks and customization. In my previous installation (Ubuntu 10.10), I had a little python script that I grabbed from Christian Stefanescu that will download the NASA image of the day and make it your desktop wallpaper. I still have that script, and I could use it with a few modifications for KDE instead of Gnome. But NASA's image of the day is hardly ever cool things like stars and galaxies, and instead is usually pictures of people smiling for the camera, or close-ups of a really important and boring piece of metal. I want something with some curb appeal.

I looked into a few other daily-image sites, like Alta Ski Area and National Geographic, but they just aren't designed to be wallpapers - the resolution is too small to look good at 2048x1152, and they're frequently in portrait-mode, which looks terrible on my widescreen monitor. Of course, Murphy's Law dictates that today when I go look at those sites to get the links above, they both are showing images that would look great as wallpapers. Trust me, they're the exception, not the rule. But I digress.

The official Hubble Site has a bunch of fantastic images in its gallery, but they don't pick one a day for you. There is a main page that shows thumbnails of all the images, a resolution-selection page when you click on a particular image, and finally another page that displays the image inline. I figured I could probably handle this with a Perl script, so I grabbed the HTML::Parser package from CPAN to do the heavy lifting, and did a little reading of its description page. It treats the incoming HTML document like a hierarchical tag system, just like most XML parsers do. I've never used an HTML parser before, but I wouldn't be surprised to learn that this is standard - it makes the most sense. You start by deriving your own class from HTML::Parser, and write start() and end() callbacks. Then as each tag (<div>, <a>, <img>, etc) is opened by the parser, it sends interesting info to the start() callback. When it closes, it calls the end() callback. In this way the entire tree of HTML is traversed, in a depth-first fashion.

Wallpaper Thumbnails Resolution-selection 2048-wide image

Being a Perl newb as well as an HTML::Parser newb, I did the easiest possible thing, which was to define three different classes - each tailor-made for one of the three pages that were required for finally getting the image. There is no error-checking or customization capability - paths are all hard-coded, and if anything goes wrong the script will probably just crash. But that means my wallpaper won't change for a couple days, or until I have time to investigate -- not exactly life-threatening. This is another example of utility code that simple doesn't warrant any more attention than is necessary to get it running. I finished it in about an hour.

I have this script scheduled to run every day at 4:00 pm, because that's about the time I get home from work and turn on the computer. It makes me happy to see a new wallpaper appear out of nowhere as I'm getting my email and paying bills. And after all, isn't that the point?

Download the source code if you're interested.

21 February 2012

Recovering an Unbootable Kernel Image

This is a quick how-to on rebuilding an Arch Linux initramfs image when both the main and fallback images are unbootable. This can happen if something goes wrong during an update to the "linux" package and the problem isn't detected and solved before a reboot. This post draws information from the Arch Wiki articles Change Root and mkinitcpio, as well as an Arch Forum post discussing a path problem causing an unbootable image. All the information necessary to recover is contained within these three links, but I felt that a cookbook would be helpful, especially in the stressful moment when a vital computer is sitting at the limited shell prior to booting the kernel.

This is intended to solve the specific problem when the Arch bootstrap claims it can't find the boot drive, and when it is very unlikely that the hardware is actually having a problem. In my case, I experienced this with regularity on a Virtual Machine, which was not having virtual hardware failure. It turned out to be exactly the problem in the forum post described above, but first I needed to recover the system.

Step 1 - Get It Booted
Your system isn't going to boot on its own: both the primary and fallback boot images are refusing to behave. So go get yourself an Arch ISO and burn it to CD or a USB. If you've already installed Arch, you know how to do this. Or read the Arch Wiki article about it if you've forgotten. Use the download and burn process as an opportunity to take a deep breath - that will help with the remaining steps.

Boot from the ISO, and choose the first option from the ISO's boot menu. But don't start Arch setup. Instead get the network running so you can update with pacman.

# aif -p partial-configuration-network

Answer the prompts. If this first step doesn't go well, don't sweat it - it just means you won't have internet access, which probably isn't required anyway.

Step 2 - Take Stock
We need to manually mount all the necessary partitions, and to do that we need to know what they are. If you remember how you partitioned your disk, that's great. But if you don't remember exactly which /dev/sdaX goes where, you'll need to do a little guessing. Luckily, fdisk can help. Note that I've trimmed the output some for brevity. I've also cheated a little and typed in some partitions from gparted because my /dev/sdb uses GPT.

# fdisk -l

Disk /dev/sda: 100.0 GB, 100030242816 bytes
   Device Boot     Start         End      Blocks   Id  System
/dev/sda1   *         63     3903794     1951866   83  Linux
/dev/sda2        3903795   195371567    95733886+  83  Linux


Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
   Device Boot     Start         End      Blocks   Id  System
/dev/sdb1             31 3871748080   3871748047   83 Linux
/dev/sdb2     3871748081 3907029134     35281054   xx Linux-Swap

On my system I have a roughly 2GB bootable ext2 partition on /dev/sda1 and the remainder of the 100GB SSD is ext4. I have a 1.8TB data partition at /dev/sdb1, and my swap file is /dev/sdb2. This is enough information for me to remember that sda2 mounts to / and sdb1 mounts to /caviar but contains the /var directory, which is sym-linked over from sda2.

If fdisk isn't enough to jog your memory, you may need to test-mount and explore a little.

Step 3 - Mount and Prep
Once you know which partitions you need to mount where, get it all mounted under /mnt/arch. Also mount the proc, sys, and dev directories so they'll be available to your chrooted sandbox.

# mount /dev/sda2 /mnt/arch
# mount /dev/sda1 /mnt/arch/boot
# mount /dev/sdb1 /mnt/arch/caviar
# mount -t proc proc /mnt/arch/proc
# mount -t sysfs sys /mnt/arch/sys
# mount -o bind /dev /mnt/arch/dev

In case you need to update with pacman, you'll want network access. If you got the network running in Step 1, copy the resolv.conf down into the chroot world.

# cp -L /etc/resolv.conf /mnt/arch/etc/resolv.conf

Step 4 - Chroot and Fix
Next, jump into your sandbox.

# chroot /mnt/arch /bin/bash

Now that you're here, feel free to poke around in logs to see what might have gone wrong. In my case, I had stupidly run pacman -Syu --noconfirm from a cron job without setting the PATH to include /sbin. As a result, the update script failed to call depmod but then blindly ran mkinitcpio on the incomplete map files, rendering the image stillborn. The depmod result should really be considered during a linux upgrade so that mkinitcpio doesn't trash the boot image, IMHO, but what do I know.

For now, let's assume you have the same problem I did. To resolve it, all I needed to do was the following:

# /sbin/depmod
# mkinitcpio -p linux

As a precaution, I also did a full update with pacman and made sure that everything went smoothly.

# pacman -Syu

All was well, and I was able to reboot into my system again.