Economy of Effort

Twitter LinkedIn GitHub Mail RSS

Best of 2016: Metal

2016 has ended, to much celebration. In spite of the fact that the worst ramifications of 2016 will manifest themselves in 2017 and beyond, people are looking to the new year in hopes of an upswing.

Not everything in 2016 was terrible, though. Some stuff was great. I am going to make a few Best of 2016 lists. We’ll see how far I get with them.

This list is the first one, and features what I consider to be the best albums (and EPs) in 2016 which fall under the general umbrella of “metal”.

Best Metal Album of 2016

Cobalt - Slow Forever

The contest was basically over before it began. Slow Forever came out in March, and nothing else really came close. This is just an amazing melting pot of extreme metal. Cobalt becomes less tethered to black metal on this album, pulling from blues, Americana, hardcore, Tool, psych, prog, and hard rock. And Charlie Fell comes roaring in like he was shot out of a fucking cannon, just spitting fire in what is hands down the best extreme vocal performance of the year.

The Rest of the Best

(in no particular order)

SubRosa - For This We Fought the Battle of Ages

I said “in no particular order”, but I put this one at the top because, if not for the Cobalt album, this would have been my #1 metal album of 2016. Doom metal has been enjoying a spike in interest, with a ton of bands churning out excellent but derivative albums. SubRosa is one of the bands moving the style forward, incorporating chamber music elements (similar to a number of post-rock bands) and Americana folk into something far more diverse than the “Praise Iommi” crowd produces. (Although, still, praise Iommi). The expressive, emotive sound they crafted on their earlier albums is perfected here, though really it was perfected on the last album. The atmosphere is simultaneously dark and beautiful, and the band flows from prettiness to harsh catharsis and back. The dual violins sing and then scream. The lyrics are often weighty, best illustrated by “Troubled Cells”, which is essentially a protest piece against the Mormon church’s treatment of LGBT people (frontwoman Rebecca Vernon is a practicing Mormon). This is a band at the top of their game, and the top of whatever subgenre one wants to label them.

Cult of Luna + Julie Christmas - Mariner

All of my sex dreams involve Julie Christmas screaming at me. She’s not even the one I’m having sex with, she’s just there for ambiance. The queen of my fear boners teams up with excellent Swedish post-metal band Cult of Luna. As much as Julie Christmas’s strangled-cat screaming freak outs make me melt, her level of restraint on this album works in its favor. It’s probably the most subdued I’ve heard her on an album. While she tends to be the focal point on her former bands’ records, here she’s a peer with the band, as Cult of Luna are too strong for her to overpower. Cult of Luna posted something interesting on their Facebook page after touring with Julie in support of this album, referencing how they “had no idea of how Julie and Andrew would be on a personal level” and how touring sometimes “takes out the worst in people”, but that they were happy with how well everyone got on during the tour. Reading between the lines, it sounds like Julie might have a reputation for being difficult, which is something I’ve suspected (Made Out of Babies basically went on to form a new band with all of their members except Julie). Fortunately, that didn’t seem to rear its head for Cult of Luna.

Oranssi Pazuzu - Värähtelijä

Another favorite from early in the year. It’s like krautrock black metal, which is awesome if you like krautrock, as I do. Unlike earlier releases from the band, though, the black metal influence isn’t dominant, but is part of an ever-shifting stylistic mix. The band creates melodic ambient grooves, which it then uses as launching pads to go into various freak-out excursions, and then uses them as the landing pads upon which they bring it back down and flow back into the steady groove. Some people (AMG reviewer and commenters mostly) have complained about the production, but it’s a thick boomy sound that brings to mind early Pink Floyd (which works with this material), and not that stereotypical shrill made-for-cassette black metal production. In fact, I would argue that the relative lack of “dynamic range” is part of what keeps the album from falling into that loud-soft-loud post-rock trope.

Inter Arma - Paradise Gallows

This album is just massive, both in sound and in running length (71 minutes, not including the hidden track after ~20 minutes of silence on the digital release). It took me some time to fully absorb, as it’s a difficult one to take in as background music during work. It’s an expansive, encompassing mix of sludge, prog, and doom, just a record to get absolutely lost in. The group consists of a number of multi-instrumentalist musicians, and they put their flexibility to use in creating a wide sonic palette with which to build these staggering, cavernous pieces. The cover art is some of the best of the year, with the collapsing ship being overtaken by the sea, and is befitting of the force-of-nature power conveyed by the music.

Neurosis - Fires Within Fires

I did not know what to expect from a Neurosis album in 2016. The previous album had released right before the last US presidential election, and the members have been so busy with solo projects and side bands. Neurosis remains as powerful as ever, but their sound has taken on a sense of age, of weariness. The shaman leading the rituals has become acutely aware of the fact that he’s an old man. The lyric “we will never, ever get to rest” during the climax of album closer “Reach” always hits me square, as it perfectly encapsulates what Neurosis sounds like today: old, wise, tired, but unbroken.

Ulcerate - Shrines of Paralysis

Although not blessed with the same caliber of album title as 2009’s [i]Everything is Fire[/i], Ulcerate’s avant-garde death metal still burns everything the fuck down. I loathe to refer to Ulcerate as “tech death” for the same reason there’s a number of bands I hate to refer to as “prog metal” - both of those labels bring to mind guitars playing as many notes as possible, like 4 people simultaneously pounding on a Rock Band guitar. Make no mistake, Ulcerate often plays at a breakneck pace, but much of that is in the blistering rhythms more so than any tweedly-deedly-dee shred king wannabe guitar wankery. In fact, it can take a careful listen to recognize the guitars are often holding and sustaining notes longer when the drums kick into full speed.

Sumac - What One Becomes

Aaron Turner’s best will always make my list. This has to make any list of best-produced metal albums of the year - recorded in an empty church, the reverberations feed back into the massive, overwhelming sound. That is, if you call it metal. It’s too heavy to call it anything else, really, but the band tosses traditional song structure aside. It’s just heavy avant-garde music. It’s definitely an album that can try your attention span, as that lack of structure makes it less accessible than a classic ISIS album - it’s more like Turner’s work with Old Man Gloom taken to a new stylistic extreme. The weirdest thing about this album is that it released on Thrill Jockey, which I still associate with post-rock and indie-jazz-rock bands like Tortoise, Isotope 217, and The Sea and Cake.

Lycus - Chasms

This one just barely released in 2016 (Google Play annoyingly continues to mark it 2015, but it was January 2016). Lycus doesn’t turn the funeral doom formula on its head, so much as they incorporate other elements to avoid predictability. Peppered throughout are trem-picked black metal screech-outs, which nicely break apart and mesh with the slower funeral doom marches, rather than clashing. The addition of cello adds more texture and dimension to the low rumbling sound. It’s the band’s shifts in tone and tempo, which work in service to the relentless doom march rather than derailing it, which make the album. Absolutely delightful, and I am still crushed that I had to choose between seeing Baroness or them at Psycho Las Vegas (and, as fun as Baroness’s set was, I think I may have made the wrong choice).

Mantar - Ode to the Flame

Oh yes. Mantar cooks up blackened sludge and delivers it in repeated gut punches. Ode to the Flame is a little less straightforward than the band’s debut album, and that makes all the difference. They pull bits from other genres into their mix, from doom to thrash to crust punk to groove, but with a persistent coat of grime layered on top. This is another one of those albums this year that delivers catchy songs in an extreme metal style, and it got a lot of great reviews but doesn’t seem to have made anyone’s best-of lists the way some of those others have. Well those lists are wrong, Mantar blows those other releases away.

Best Metal EPs of 2016

Gorguts - Pleiades’ Dust

If there were anything right in this world, Gorguts’ existence would spawn an identifiable new subgenre, a sort of Metal in Opposition update to the Rock in Opposition (RIO) genre of Henry Cow, Univers Zero, etc. On this EP, Gorguts puts avant-garde death metal into a multi-movement modern classical style of composition, culminating in a continuous 33 minute piece of music. And it demands to be listened to in a continuous 33 minutes of time, as it flows between ambient atmospherics and crushing experimental death metal bursts.

Tombs - All Empires Fall

Tombs has added synthesizer/electronics player (and second vocalist) Fade Kainer, which brings some new industrial and gothic elements into the mix. This EP is clearly the band experimenting with this new elements. It features sections of ambience that were hinted at with the track “Severed Lives” on 2014’s fabulous album Savage Gold, but Kainer’s presence greatly aids in the execution of these moments, adding the necessary texture to make them interesting. When not exploring these more subdued areas, the band kicks in with the same kind of propulsive metal that made Savage Gold so good.

Skeletonwitch - The Apothic Gloom

This one’s so good, and it’s a shame that it isn’t getting more attention, perhaps due to being an EP. The band dismissed their previous frontman due to his alcoholism, and enlisted Wolvhammer’s Adam Clemans to take over. His vocals have more of a presence than the previous vocalist’s, whose voice on the last album tended to get lost a bit in the audio soup with the trem-picked guitars and high hats. Skeletonwitch writes tight pieces that sound bigger and longer than their runtime, and that’s on full display here with what they’ve packed into a 20 minute EP.

Goya - Doomed Planet

This Arizona three-piece has been releasing quite a bit of material of late. This year alone, they released two new EPs, a third EP of early demos, and a two-song single of Nirvana covers. This EP is the best of the bunch, featuring two long heavy tracks of desert-tinged doom, a short instrumental piece, and a Marilyn Manson cover. Great for fans of thick fuzz and clean vocals.

Honorable Mentions

Oh my god. It really hurt to keep the next 3 out of the top 10 albums.

Oathbreaker - Rheia

Hipster black metal alert! This is a varied album that moves from blast-beat black metal to shoegaze to soft atmospherics, all punctuated by vocalist Caro Tanghe. Tanghe often brings Julie Christmas to mind, both in her clean vocals and shrieking freak-outs. Really, “Deafheaven + Julie Christmas” wouldn’t be the worst way to describe the band, though Oathbreaker comes from a hardcore background that informs their style even as they distance themselves from it. What sets Oathbreaker apart is just the raw emotion that they convey, primarily through those vocals. The band breaks down the opening 8 minutes of the album in an excellent episode of the Song Exploder podcast.

Helms Alee - Stillicide

This is one of my most played albums this year, and it hurt to leave it off the 10. I almost wanted to cheat and call it an indie rock album and slip it on my Other Genres list instead. The Sludgelord describes it nicely: imagine Kylesa at their most psychedelic covering Sleater-Kinney. It’s sludge-y indie rock, driven by the vocals of all 3 members (2 female and 1 male). This album should be one of the ones getting the “hipster” indie crossover attention.

Vektor - Terminal Redux

The first couple of times I listened to this, I didn’t get very far. It’s a beast at 73 minutes long. After a little warming up, it started to click for me, scratching that same scifi-thrash itch that last year’s VHOL album so brilliantly did. I haven’t paid much attention to the album’s narrative - I don’t get much out of the “concept” part of “concept album” these days - but I get a lot out of the thrashy riffing. It’s a long album, but by the time “Recharging the Void” finishes, I’m ready to hear “Charging the Void” again.

Insomnium - Winter’s Gate

There were a few cold-weather atmospheric black metal albums this year, but Insomnium’s was the one that stood out the most. Written as a single album-length track, but broken up into parts (a la Crimson or A Pleasant Shade of Gray), this 40-minute album is intended to be taken as a whole, but does break down into separate songs much more cleanly than, say, the Gorguts EP. Everything about the compositions on this album screams “winter”. The compositions feed into the album’s winter theme extremely well, from the trem-picked blizzard winds to the soft piano evoking near-silent snowfall in softer moments like the first half of Part 5. It’s too bad I already finished playing through Icewind Dale: Enhanced Edition, because this would have made a great soundtrack for those play sessions. I’ll break it out again when I play through that expansion content of Pillars of Eternity.

If These Trees Could Talk - The Bones of a Dying World

The best instrumental post-metal album this year isn’t the Russian Circles album, it’s this one. The band signed to Metal Blade a year ago, whom promptly reissued their previously self-released first two albums. The band features three guitarists that create layered melodies, making for some mesmerizing passages as the guitars weave in and out of playing separate and interlocked parts. It’s debatable whether they should fall under post-metal or post-rock, much like Russian Circles, but what’s less debatable is that it’s an excellent record, and the band should get some more attention under Metal Blade’s wing.

SUNN O))) - НЕЖИТЬ: живьём в России (NOLIFE: Alive in Moscow)

This was a quiet release, as a limited edition triple-vinyl (all sold out) and Bandcamp digital download. This is a recording of the band’s first Moscow performance, with audio pulled both from the soundboard and audience, mixed and mastered together. As quiet as the release of the album was, the audio itself is HUGE. Massive. It makes previous SUNN O))) live albums like Domkirke and Aghartui Live 09-10 (the most recent live album, itself a digital + limited physical release) sound small in comparison. It is probably the closest representation of SUNN’s oppressing live sound put to recording. (Or at least, I assume, based on reputation, as I’ve yet to experience it in person. God, please let SUNN O))) be one of the Psycho headliners this year).

Meshuggah - The Violent Sleep of Reason

Much better than Koloss. So much better. Meshuggah style changes are always subtle movements within a relatively small area, like a quarterback shifting around in the pocket. They’re immediately identifiable as Meshuggah, yet people certainly identify different styles as favorites. For me, the best Meshuggah has been the more hard-charging Meshuggah on Chaosphere and ObZen. The Violent Sleep of Reason doesn’t quite keep pace with those releases, but it’s certainly closer than some of their more deliberately paced recordings. It’s also less repetitive than some of those other albums. It’s probably my third or fourth favorite Meshuggah album (depending on where I feel like putting Destroy Erase Improve), which is a pretty damn good ranking for an album.

Deftones - Gore

This is the first Deftones album that really landed with me. This is what “alternative metal” should be. It’s like an album from an alternate timeline, where the alternative metal of Faith No More, Helmet, Alice in Chains, and Soundgarden continued forward, and never took that right turn into nu-metal (which, yes, is an ironic idea given Around the Fur). As if there was a plague that was constrained to only wiping out the Family Values Tour ‘98. Gone is the preening nu-metal Fast and Furious ‘tude, and in its place is a mature, textured album, with some of the best songwriting the genre has seen of late.

Aluk Todolo - Voix

Oranssi Pazuzu isn’t the only krautrock black metal I got to enjoy this year. Unlike the Oranssi Pazuzu album, this one is entirely instrumental, and it leans more towards focusing on extended hypnotic grooves a la Neu! or Tago Mago era Can (the best Can). As is a theme of many albums this year, the 43 minute length plays out as a single unbroken piece of music, divided up into six tracks named simply I through VI. Hypnotic really is the best word for this, as it’s very easy to get lost in. One particular late-night coding session of mine this month involved me with headphones on and this on repeat, and repeatedly hitting the end of the album and wondering where the time went. It’s enveloping, and relentlessly forward moving. Even softer parts, like IV, have an undeniable steady forward momentum. This will remain in my rotation for a long time as coding music.

Gojira - Magma

People call this Gojira’s “Black Album”. The Grammy nomination seems to lend some credence to that claim. But while Gojira may have turned down their heaviness, that’s in comparison with themselves. There’s no “Unforgiven” or “Nothing Else Matters” here, not unless you count the album’s instrumental outro. This is still a hard hitting metal album, and what they’ve traded down in heaviness and instrumental complexity, they’ve gained as songwriters. It’s not quite my ideal direction for them - I would have loved an album that uses these more song-oriented pieces in-between a couple of longer complex pieces, giving a taste of both worlds. While that’s not the way they went, I am satisfied with their final result. Just as long as the next one isn’t Gojira’s “Load”.

Khemmis - Hunted

Hunted is a sublime mix of traditional doom metal, jumpstarted with some Iron Maiden energy and guitar noodling. It’s another band that’s not satisfied to just slug out some slow riffs and wallow. (Although, again, praise Iommi.) What’s amazing is just how approachable the whole thing is. I could send this album to my dad, even though it’s ostensibly a doom metal album with track lengths that average nearly 9 minutes. (And it is an album that I repeatedly played in the car with my wife, to no complaint.) The compositions aren’t overly technical, but they also avoid staying in one place too long, deftly moving to new melodies without overwhelming the listener. Clean, emotive vocals dominate, with some doom growls joining the mix as additional texture. It’s easy to see why this got so much love on best of lists. Whereas the Helms Alee album is one I think should cross over to indie rock fans, this is one that should cross over to classic hard rock fans.

Russian Circles - Guidance

I still very much enjoy a bi-annual Russian Circles album, even if the formula becomes recognizable (pretty, gentler intro track, second track that kicks everything up a notch, etc). If there’s a knock on the album, it’s the existence of the group’s strong, similar back catalog. It’s hard to be mad when they consistently deliver such a high quality, and when so few other groups can deliver the same thing in the same sort of space.

Revocation - Great is Our Sin

I was surprised to see the slightly cool reception that this album received. The reviews were positive enough, but I don’t recall seeing it on many (if any) best-of lists, even as an honorable mention. I think this falls into the same issue as Russian Circles: they’ve been steadily prolific and maintained a high level of quality, but a formula is emerging. This album doesn’t depart very far from what they achieved on Deathless. That said, to me, this is Revocation at their most melodic and fluid. It’s a subtle maturing, but it feels like the rest of their package catching up to their technical acument. I think part of the issues with the cool reception is that the first track feels very Revocation-by-numbers, and first tracks have a way of sticking out the most and coloring opinions. It’s with the second track, “Theatre of Horror”, where the album begins in earnest.

Participation Ribbon

Abbath - Abbath

It was cool seeing Abbath on the Decibel Tour this year, playing a mix of his new solo album and some Immortal favorites. The solo album doesn’t stray far from what Immortal did well, which isn’t much surprise given he was that band’s primary composer in addition to being the frontman. It probably helps that Immortal took such a long break (only 3 albums released in the 2000s), because this would probably feel a lot more tired if the were 7 albums between Sons of Northern Darkness and this, instead of only one. Instead, it feels like Abbath had plenty of ideas left to explore within the general style Immortal perfected on that album.

Helion Prime - Helion Prime

Vektor isn’t the only band with a hard-drivin’ space metal album this year. Helion Prime’s debut album is a fun, cheesy chunk of space-themed power metal. Power metal is rarely my go-to, usually relegated to occasional change-up status, and this album isn’t going to be the one to change that. But it is a good time, helped in large part by the female not-at-all-operatic vocals. That vocalist has left the band, but in an interesting turn of events, Witch Mountain’s Kayla Dixon has been tapped to be the replacement. That makes two bands that Kayla fronts without appearing on any of their released albums, but hopefully both bands change that in 2017.

Kvelertak - Nattesferd

This album sounds like an extreme metal band covering classic hard rock songs from a parallel timeline. The songs sound familiar, like they’re forgotten hits from that mid-70s-to-early-80s period of arena rock, bar bands, and punk. Songs that, if sung and produced in clean fashion, you could easily imagine alongside Thin Lizzy and Ted Nugent, alongside Van Halen and Lynyrd Skynyrd and The Ramones. It’s like a classic hard rock album from a reality where growled vocals tagged along with fuzzy overdriven guitars when they went mainstream.

Sumerlands - Sumerlands

Sumerlands is a music geek’s love letter to late ’80s American metal, written to mimic that style but without the imperative to stick closer to radio-friendliness. It’s got that Fates Warning, Queensryche thing going on, which were some of my entry points into the genre. I think the album is great, but what I’m not certain of is if there’s a band-sustaining theme there, or if this is just better as a one-off.

Gatecreeper - Sonoran Depravation

Apparently retro is in, because here’s another one. For Gatecreeper, it’s classic Swedish, maxed-out-HM-2-pedal death metal. Sonoran Deprevation is their debut full-length, and at just under 31 minutes, it’s a lean and dialed-in assault. There’s no fat here, just a straight-ahead riff delivery device. Not a lot in terms of originality, but it stands out for just how well it does what it does, and for how directly it achieves it. That economy makes this a great one to throw down for some immediate, unencumbered ass-kicking.


The “metal” in BABYMETAL faded pretty hard over the course of their debut album after a strong start, which made me wonder if the band was ultimately going to just be J-Pop with distorted guitars going forward. Instead, they doubled-down on metal for the second record, pulling in power metal and djent and stomping on the gas pedal. This time around, only one song in the second half really dials down the metal (“No Rain, No Rainbow”), but it is bracketed on each side with balls-to-the-wall \m/ \m/. In the end, it is still a tad gimmicky, and the band (while good) is mainly notable for meshing disparate sounds and styles together more so than crafting new ones, but it’s a fun album that doesn’t lose its edge halfway through like the debut (and is also, wisely, a tad shorter at 53 minutes).

Borknagar - Winter Thrice

Borknagar’s 2012 album Urd was like their version of Kurt Warner’s Super Bowl season with the Arizona Cardinals - a recapturing of quality the band had enjoyed during their previous peak (which I would argue was the 98-00 period with The Archaic Course and Quintessence albums). It was a tall order to expect them to maintain that level, and unsurprisingly, they fall a bit short here. But the album is notable in that it’s a getting-the-singers-all-back-together effort, with vocalist Garm joining Vintersorg, ICS Vortex, and Lars Nedland, albeit in a guest capacity on a couple of tracks. Stylistically, this doesn’t deviate much from Urd, outside of not being quite as consistently good. Leaving a couple of tracks from the 50 minute running length on the cutting room floor would have helped the rest of the material stand out.

ActiveRecord Save Not Updating Hstore Fields in Rails 4.0-4.1

Here’s some behavior you might not expect when using Postgres’s hstore with ActiveRecord.

ActiveRecord::Base#update_attributes does what you’d think:

[0] pry(main)> thing =
[1] pry(main)> thing.update_attributes({data: {'mykey' => 'myval'}})
[2] pry(main)> thing.reload
[3] pry(main)>['mykey']
=> "myval"

However, ActiveRecord::Base#save might not:

[0] pry(main)> thing =
[1] pry(main)>['mykey'] = 'myval'
=> "myval"
[2] pry(main)>
(0.3ms) BEGIN
SQL (0.4ms) INSERT INTO "things" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id" [["created_at", "2014-12-17 04:02:03.119354"], ["updated_at", "2014-12-17 04:02:03.119354"]]
(0.9ms) COMMIT
=> true
[3] pry(main)> thing.reload
[4] pry(main)>['mykey']
=> nil

Huh? I left the SQL log line in the output here so we can see that our hstore field is indeed left out of the SQL INSERT statement entirely, which explains why the field is nil once we re-fetch the object from the database.

But why is it doing this? It turns out that, in Rails 4.0 and 4.1, this operation doesn’t mark the field as “dirty” in ActiveRecord, so the change is not detected and included in the save operation.

We can mark it manually with ActiveModel::Dirty’s attr_name_will_change!, eg.

[0] pry(main)> thing =
[1] pry(main)> thing.data_will_change!
[2] pry(main)>['mykey'] = 'myval'
=> "myval"
[3] pry(main)>
(0.3ms) BEGIN
SQL (0.3ms) INSERT INTO "things" ("created_at", "data", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["created_at", "2014-12-17 04:08:32.066027"], ["data", "\"mykey\"=>\"myval\""], ["updated_at", "2014-12-17 04:08:32.066027"]]
(1.0ms) COMMIT
=> true
[4] pry(main)> thing.reload
[5] pry(main)>['mykey']
=> "myval"

The documentation states that attr_name_will_change! should be called before changes to the attribute, as seen in the example above.

Doesn’t this seem like a pain? Well, as discussed in Rails issue #6127, it was expected behavior for Rails 4.0 and 4.1, but improvements to serialized attributes have been merged into Rails and will appear in Rails 4.2. Setting values and calling save will just work.

So, in the meantime, the workaround is manually marking properties as dirty with attr_data_will_change! before making and saving changes to those fields.

PostgreSQL Hstore Default Value in Rails 4

Having used activerecord-postgres-hstore before native hstore support was added to Rails 4, I was used to the behavior of empty hstore fields returning an empty hash {} when a row with such a field was instantiated into an ActiveRecord object, as was discussed and added in the gem’s issue #22.

This behavior changed in Rails 4’s hstore support. An ActiveRecord object with an empty hstore field will return nil for that field rather than an empty hash. (When someone opened a bug in the Rails repo to suggest implementing the same behavior in the new native hstore support, it was brushed off.)

By default, that leaves us to have to nil-check every hstore property in our objects before accessing any keys (eg. &&['mykey']). However, we can get our “empty” hstore fields instantiating as empty hashes instead of nil with a tweak of our migration.

Simply add default: '', null: false to the migration, eg.

class AddDataToThings < ActiveRecord::Migration
def change
add_column :things, :data, :hstore, default: '', null: false

With that default in place, our empty hstore fields will instantiate as empty hashes, and we can avoid the nil check:

[1] pry(main)> thing =
=> #<Thing id: nil, ... >
[2] pry(main)>
=> {}

Beyond Ctrl: Make That Caps Lock Key Useful

tl;dr: Supercharge your Caps Lock key by making it Esc when tapped, and Ctrl when held

Caps Lock. A useless key sitting in prime keyboard real estate. Many software developers and power users repurpose the key by remapping it to Control.

After all, on old UNIX terminals, that’s exactly what the key to the left of “A” was:

Replacing the Caps Lock key with Ctrl makes a lot of keyboard shortcuts more convenient. But we need not stop there. Some true Men and Women of Genius came to the realization that, since Ctrl’s behavior is based around behind held down (a modifier key) and doesn’t do anything when pressed and released, it is possible to make Caps Lock do something else when tapped instead of held. For Vim users, the obvious choice is the Esc key.

We can do this in both Mac OS X and Linux.


If you want all Ctrl keys to behave like Esc when tapped

This is the easiest way, and the option I use. (I rarely find myself hitting the normal Ctrl keys anyway.)

First, open System Preferences -> Keyboard, and click Modifier Keys button. Click the Caps Lock drop-down and set it to Control:

Now, install Karabiner (formerly known as KeyRemap4MacBook). If you are a Homebrew user, you should check out Homebrew Cask and install Karabiner with $ brew cask install karabiner

Open Karabiner. Enable the first setting from the screenshot below:

The other option I have there, “Disable Escape Key”, is something I’ve done just to get myself in the habit of using the Caps Lock key for Esc. It is not required, it is just an option if you want to help train yourself to use the new key.

If you only want the Caps Lock key to behave like Esc when tapped

To do this, we’re going to take a slightly different approach. Instead of using OS X’s native Caps Lock remapping, we need to use another app, called Seil (from the same developer as Karabiner) to remap the Esc key to F19, and then use Karabiner to map F19 to our cool Ctrl/Esc hybrid key.

Install both Karabiner and Seil. (Here again, if you use Homebrew Cask, you can do this with $ brew cask install karabiner and $ brew cask install seil)

Open Seil. First, enable the “Change Caps Lock” option, and set the keycode to 80:

Next, in Karabiner, enable the “F19 for Escape and Control” option:


To accomplish the same setup in Linux, we need to use a tool called xcape.

Build and install xcape per the instructions on the project’s Wiki page. One additional step I take after building the app is copying the xcape executable to /usr/local/bin.

If you only want the Caps Lock key to behave like Esc when tapped

Add the following lines to your ~/.profile:

setxkbmap -option 'caps:ctrl_modifier'
xcape -e 'Caps_Lock=Escape'

If you want all Ctrl keys to behave like Esc when tapped

Same as above, except we add more arguments to the xcape line:

setxkbmap -option 'caps:ctrl_modifier'
xcape -e 'Caps_Lock=Escape;Control_L=Escape;Control_R=Escape'

Note: If you use some other method of remapping the Caps Lock key to Ctrl (some desktop environments have it as an option in their Keyboard settings, much like OS X), then the Caps_Lock=Escape mapping may not do anything, and you will need to use the Control_L one.

One last little tidbit: Ubuntu 14.10 (“Utopic”) has xcape in the universe repos, at least as of the time of this writing. Hopefully it will be included in Ubuntu releases from here on out.

Now Your Caps Lock Key Rules

The most useless key on the keyboard (except maybe for Pause, when’s the last time you used that?) is now your Swiss Army knife. Vim’s keybindings will make a lot more sense now that you can use your pinky the way Bill Joy did on his old ADM3A terminal:

Convert HTML to Haml (and Back Again) Within a Vim Buffer

Haml is great. Haml is the JSON to HTML’s XML: all of the garbage and noise stripped away, with only the data and minimal amount of ceremony left.

I use Haml on all Rails projects now, but when dealing with legacy projects, I still encounter HTML/ERb templates.

Using the html2haml command-line tool, I can easily convert HTML/ERb in my Vim buffer into Haml.

The project distributes as a Ruby gem, so installing is accomplished with:

$ gem install html2haml

Then, the magic is done with some Vim bindings to feed a buffer or visually-selected chunk of text to the application, and paste its output back into the buffer, replacing the original text.

nmap <leader>h :%!html2haml --erb 2> /dev/null<CR>:set ft=haml<CR>
vmap <leader>h :!html2haml --erb 2> /dev/null<CR>

When changing the entire file, I’ve also added the command to change the filetype in the Vim buffer, for convenience.

That takes us from HTML/ERb to Haml, but what if we need to go back in the other direction? This is possible with the haml2erb tool. Unfortunately, this tool is not actively maintained the way html2haml is. For me, on Ruby 2.1.1, it was necessary to install the 0.3.0 prerelease version, as the last official version would not build. Once installed, though, it worked as expected.

We must explicitly indicate which version to install in order to install prerelease gems:

$ gem install haml2erb -v '0.3.0.pre.3'

The Vim bindings are much the same as the html2haml ones:

nmap <leader>e :%!haml2erb 2> /dev/null<CR>:set ft=eruby<CR>
vmap <leader>e :!haml2erb 2> /dev/null<CR>

I have not used this nearly as much as html2haml, as I’m rarely changing layout code from Haml back into HTML. However, the couple of times I have needed to do it, it has worked exactly as expected..

Fixed the Archive Page

Finally got around to fixing the Archive page on this site.

If I recall correctly, what happened originally is that I was attempting to get rid of the “/blog/” part of the archive path, but got distracted halfway through and left it incomplete.

For reference: this part of the archive path is not a user-configurable part of Octopress per se. It is a default location for a file in Jekyll, which is in source/blog/archive in an Octopress site repository. Simply moving the archive/ folder out of blog/ and into the top level of source/ will make the archive page generate without the “/blog/” part of the page. (For further reference, see the workaround post on the issue on Github)

Vim Tricks for Ruby Hashes

I have a couple of functions in my .vimrc for manipulating Ruby hashes.

The first one is to convert hashes from Ruby 1.8 style into Ruby 1.9+ style, eg.

# before
:symbol_key => 'value'
# after
symbol_key: 'value'

I create this function for both Normal and Visual modes to allow updating either a selected hash, or the entire file.

function! RubyHashesAll()
:%s/:\([^ ]*\)\(\s*\)=>/\1:/ge
function! RubyHashesSelected()
:'<,'>s/:\([^ ]*\)\(\s*\)=>/\1:/ge
nmap <Leader>rhh :call RubyHashesAll()<CR>
vmap <Leader>rhh :call RubyHashesSelected()<CR>

Next, I have one for taking a hash and extracting an array of the hash keys.

# before
{ 'one' => two, :three => 'four', five: 6 }
# after
['one', :three, :five]

Here, I have the command bound only in Visual mode, as I don’t see a case where I’d want to do this globally.

function! RubyExtractHashKeys()
vmap <Leader>rhe :call RubyExtractHashKeys()<CR>

The regexes can probably be improved to fix some edge cases, and I’m certain there’s a way in Vim to make it so that I don’t have to define the All and Selected versions of RubyHashes as separate functions. But these do the job for me now, until I reach a higher plane of Vim mastery.

Zsh, Tmux, Vim, and 256 Color Madness

tl;dr: You want $TERM to be screen-256color when tmux is running, and you want it to be xterm-256color when tmux is not running. Also, launch tmux with -2 argument.

I love tmux. It is the primary reason why I switched from using gVim to console vim. I love having a fully terminal-based workflow. It beats switching between a GUI editor app and terminal window any day.

This switch, however, was not without some issues. Here are the solutions to two that I encountered.

Weirdness with zsh, tmux, and vim


  • when $TERM is screen-256color but tmux is not running, zsh will echo your command into the output when you hit Enter:

Notice how the output of the “ls” and “echo” commands repeat themselves in the output stream as soon as I switched to screen-256color.

  • when $TERM is xterm-256color while tmux is running, colors will not display properly in Vim:

vim /etc/default/grub while TERM=screen-256color:

vim /etc/default/grub while TERM=xterm-256color:


In my zsh config (~/.zshrc), I set xterm-256color to be the default TERM, but right after that, added a command that would re-export TERM as screen-256color if tmux is running:

export TERM=xterm-256color
[ -n "$TMUX" ] && export TERM=screen-256color

No Vim colorschemes when tmux is launched by terminal app in place of shell


I ran into a specific set of circumstances where my Vim colorscheme would not display.

Terminal applications usually launch a shell by default, but some (like gnome-terminal) have the option of defining a command to be run rather instead of the shell.

If I set this command to tmux, tmux would indeed launch. However, if I then ran Vim, the colorscheme would not display correctly.

However, if I allowed gnome-terminal to launch a shell, and then ran tmux myself from that shell, Vim would display properly within that tmux session.


I got my clue from this StackOverflow post. Basically, what is happening is that, when running tmux from within my shell, which is configured for 256 colors, tmux would launch in 256 color mode. But when I had gnome-terminal launch tmux directly, it would not.

The easy way around this was to use the “-2” argument for tmux, making the command tmux -2.

With that command in place, tmux launches whenever firing up gnome-terminal, and does so in 256 color mode.

Careful What You Name Your Rails Partials

tl;dr: Hyphens bad.

I encountered a strange bug in Rails 3.2.13 this week. I kept getting an error that traced back to the very start of a partial:

_example-partial-logged-in.html.haml:1: syntax error, unexpected keyword_in, expecting keyword_end

I tracked it down to this issue, which pointed out that the error was related to the hyphenated name ending with a Ruby reserved word.

By convention, Rails uses underscores for word separation in file names. Hyphens are not completely disallowed (the above works if I rename the file to end with a non-reserve word), but can lead to issues.

The issue linked above contains a pull request for a better error message, which was merged into Rails 4. But for those still on Rails 3 and earlier, if you see this vague error message, now you know why.

Reattach-to-user-namespace: The Fix for Your Tmux in OS X Woes

tl;dr: Things not behaving right in tmux on OS X? Install reattach-to-user-namespace

Are you a tmux + Mac OS X user? Have you had any of the following problems?

  • Running launchctl to start services fails with a message like launch_msg(): Socket is not connected
  • Using the OS X Pasteboard commands pbcopy and pbpaste and having them not work
  • Launching a GUI app from the terminal and getting a “ghost window”: the app window loads in the background, with no dock icon, cannot be Command-Tab’d to, and the app’s menu does not populate the top bar when the window gains focus

Why does this happen? Chris Johnsen has some details

tmux uses the daemon(3) library function when starting its server process. In Mac OS X 10.5, Apple changed daemon(3) to move the resulting process from its original bootstrap namespace to the root bootstrap namespace. This means that the tmux server, and its children, will automatically and uncontrollably lose access to what would have been their original bootstrap namespace (i.e. the one that has access to the pasteboard service).

It turns out that Apple has patched the version of GNU screen that they distribute with OS X to avoid this problem. But this is 2013, and we UNIX geeks have moved on to tmux, right? Chris goes on in that README to explain why porting Apple’s screen patch to tmux would be tricky.

So, instead, he provides the reattach-to-user-namespace wrapper program. This allows us to launch a process and have that process be attached to the per-user bootstrap namespace, which, to put it simply, makes the program behave as we are expecting.

The “trick” is to configure tmux to launch its shells with the reattach-to-user-namespace wrapper. By doing that, the shells tmux launches, as well as everything those shells launch, will be attached to the user namespace, and the problems listed at the top of this post will no longer be issues. We can use the default-command option in ~/.tmux.conf to wrap our shell launching command.

First, we need to install reattach-to-user-namespace. If you use Homebrew or MacPorts, this is as easy as:

; with Homebrew
$ brew install reattach-to-user-namespace

; with MacPorts
$ port install tmux-pasteboard

I use the same dotfiles for Linux as well as OS X, so I only want to do this in the OS X environment. I accomplish this with the following:

" at the end of the file
if-shell 'test "$(uname)" = "Darwin"' 'source ~/.tmux-osx.conf'
set-option -g default-command "reattach-to-user-namespace -l zsh"

If you only use OS X, you can skip creating an external file, and just put the set-option line directly in your ~/.tmux.conf. Also, I am using zsh, so my command to reattach-to-user-namespace is zsh. If you’re using a different shell, change that to your shell’s name.

With this configuration in place, kill and re-launch tmux. The shells that tmux launches should now get attached to the user namespace, and namespace-related issues should be resolved.