karlgrz

symphonic code: my gift to the coding gods

My Favorite Records of 2013

I listened to quite a lot of new music this year. Lots of metal, a bit of hip-hop, a ton of retro / psychedelic stuff. A lot of REALLY BAD garbage.

These are all the albums that stuck with me somehow. Mostly, these are the albums I played more than once. Overall, I'd say 2013 was one of the best musical outputs of any year this century (so far). Here's my favorites...

25.) The Safety Fire - Mouth of Swords

I was pumped to catch these guys with Between the Buried and Me in the fall of 2012. But I missed the show. I had heard so much good stuff about these guys but never listened to them before. Mouth of Swords really wowed me. Excellent metal record, right up the BTBaM alley. Tommy Giles even makes a guest appearance. I really like their song writing, solid record overall.

24.) Eminem - The Marshall Mathers LP 2

Ok, before I go into this record, my gripe with the title. I got into several heated arguments about the title, and how I don't think this record IN ANY WAY resembles a "follow-up" to the original opus. But I digress...

What a banger. Front to back, this record is awesome (with a couple misses in the middle). Rap God, Berzerk, and Brainless are all stand outs. This guy spits fire at the drop of a hat, and I love listening to him rhyme.

23.) David Bowie - The Next Day

Bowie is timeless. This record really blew me away. I wasn't expecting it to be bad, but I didn't think it would be this great. He keeps up with the times AND holds onto his bread and butter songwriting.

22.) Tesseract - Altered State

The sophomore record from Tesseract. 4 songs divided into 10 tracks. All clean vocals. Progressive metal masterpiece. A brilliant follow up to One, if you like intricate, progressive metal, check this out.

21.) Russian Circles - Memorial

I love this band. They make some excellent atmospheric instrumental metal. Memorial is no exception.

20.) Dead Letter Circus - The Catalyst Fire

I first heard about these Aussies from a friend of mine when he showed "One Step" and I was chomping at the bit for more.

I was really looking forward to this record, and it shines. Kim Benzie's voice is incredible. Reminds me of Maynard.

19.) Ghost - Infestissumam

Ahh, Ghost. What a band. What a record. These guys have really grown on me in the last year. Infestissumam is an excellent record. If you can put aside the EXTREMELY over-the-top Satanic references you get some truly great 70s-style fuzzy metal, and it rocks.

18.) Protest the Hero - Volition

What do you get when Protest the Hero has Lamb of God's Chris Adler play drums on their new record? A masterpiece, that's what. Better than everything they've ever done, in my opinion.

17.) Kanye West - Yeezus

Yeezus. Weird record. Really weird. But I like it. This guy is full of himself, almost to a fault. But he makes good tunes. Blood on the Leaves, what a jam.

16.) Red Fang - Whales and Leeches

I'd love to party with these guys. They make some kick ass tunes, and have been for a while. I put them in the same league as Mastodon, and they deserve it.

15.) Pelican - Forever Becoming

I played this record 3 times the first time I heard it. It's awesome. These Chicago natives know how to groove and write some truly magical tunes.

14.) The Ocean - Pelagial

Something about these guys strikes me as quite pretentious, but I don't care that much because they rock the house. Pelagial is beautiful, both with vocals and on the instrumental. These guys haven't made a bad record yet, and this one is really great.

13.) Carcass - Surgical Steel

CARCASS! Their first record since 1996 and it SLAMS! This has to be one of the best produced, best sounding albums of 2013. Solid riffs, incredible drums, and great songs. You want some good, solid death metal, then you've come to the right place.

12.) Anciients - Heart of Oak

I never heard of these guys before their debut record dropped. I listened to it the day it came out and was blown away. Kind of a heavier Mastodon with a bit less melody. Great record.

11.) Gorguts - Colored Sands

Razor blade proficiency on these riffs. Gorguts is awesome, and they put out one of the best death metal records of the year.

10.) Kylesa - Ultraviolet

This one caught me off guard. I've heard of Kylesa before, and had an idea what they were all about. They've had quite a history so far. Ultraviolet is just incredible.

The dual vocals of Laura Pleasants and Phillip Cope work so well together. And the twin drummers make for some interesting rhythmic assaults. Slamming record from start to finish.

9.) The Black Dahlia Murder - Everblack

Hands down one of my most anticipated records of the year, and boy did it deliver. I love this band. Everblack was incredible. Production, song writing, riffs, everything was great. I look forward to hearing these songs live when they come around with Carcass.

8.) Clutch - Earth Rocker

I never have been a die hard Clutch fan, but this record might have changed that. Every single song on this record is great. Gone Cold gives me goosebumps every time I hear it.

7.) The Dillinger Escape Plan - One of Us is The Killer

First time I listened to this record I was impressed, but I wasn't falling in love with it or anything. Then I let it sit there for a while, and came back later. And came back again. And again. Now I can't get these songs out of my head. Nothing's Funny and One of Us is the Killer do not leave my brain much. Incredible record from one of the best live bands I've ever seen (there, I said it).

6.) Nine Inch Nails - Hesitation Marks

Trent Reznor came back with a vengeance on Hesitation Marks, and it delivered. This record reminded me a lot of With Teeth or Year Zero more than anything else, and it rocked. Lots of catchy NIN type stuff, and the songs are still stuck in my head. I'm pissed I didn't get to catch any of the live shows, the production looked incredible.

5.) Uncle Acid & The Deadbeats - Mind Control

Best band name ever. This record had to be good to make it into my top 5. Just go listen to it. Stoner / psychedelic rock from the 70s with just enough headbanging groove to make it heavy.

4.) Queens of the Stone Age - ...Like Clockwork

I think this is the record I listened to the most out of anything that came out in 2013. It's so good. Josh Homme is one of my favorite song writers, and I've been a Queens of the Stone Age fan since Rated R. The supporting cast on ...Like Clockwork is all-stars, and the Elton John inspiration is bizarrely amazing. Vampyre of Time and Memory, Smooth Sailing, Fairweather Friends, My God Is The Sun, well, every song on this record should be a single. It's so good. Can't say anything more about it.

3.) Deafheaven - Sunbather

This record is terrifyingly beautiful. I listened to it the day it came out before everyone started praising the hell out of it (though, to be fair, people that leaked it were praising it like crazy long before the release date). I was excited to check it out because I had never heard of them before. Blown away is an understatement.

This record sounds like the band I would want to be in if I was a drummer. The drumming on this record is phenomenal. It's not the most technical or fast or whatever, but it is SO DAMN GOOD and so atmospheric and rhythmic that it makes me want to be drummer.

The guitars are epic. I love the way Kerry McCoy goes from some insanely black metal trill picking riff almost instantaneously into an epic thunderstorm of hanging chords and lush melodies.

George Clarke's vocals are insane. More than just a voice, he adds an additional instrument to each song. You can feel every word and scream that he puts out, and the production makes it that much more impactful.

It's such a damn good record. Do yourself a favor and just listen to it. Forget about genres, forget about preconceived notions of whatever you might think it is, just listen to it as a great piece of music and appreciate it for what it is. I can't wait to see them when they come around.

2.) Purson - The Circle and The Blue Door

Never heard of these folks before this record dropped. Never heard much press. Maybe that's why I love it so much.

Rosalie Cunningham's voice is beautiful, and every single one of these songs was stuck in my head after the first play through. They remind me of what would happen if Blue Oyster Cult, Janis Joplin, and Led Zeppelin all got in a room and decided to write an album together. There are so many beautiful moments on this record that you should just listen to it for yourself. The Contract, Spiderwood Farm, and Sapphire Ward really stood out for me, but the entire thing is a retro nod to the classics, and it's awesome.

1.) Atoms for Peace - Amok

What do you get when you stuff Thom Yorke, Flea, Nigel Godrich, Joey Waronker, and Mauro Refosco into a studio? Apparently a great record.

Seriously, I don't want to know how this was conceived. I don't care how it was recorded. All I know is the finished product is, hands down, the best record I heard all year. Every single moment on this record feels like it is in the right place and naturally belongs EXACTLY where they put it. It blows my mind how many awesome musical moments they have crammed into one album.

I dare you to listen to any song on this album and not be humming it to yourself all day. Try it. You will fail.

I like Radiohead, but I think this blows everything they've done out of the water. Judge, Jury, and Executioner, Default, Stuck Together Pieces, and Dropped...oh man, DROPPED, that song is a monument all to itself. That song sinks the teeth in and just grooves me away.

I look forward to the next record they write, but until then, I'm pretty sure I'll be playing this one a lot in the months / years to come. Album of the year, hands down.

Honorable Mentions

  • .letlive - The Blackest Beautiful
  • A Storm of Light - Nations to Flames
  • Alice in Chains - The Devil Put Dinosaurs Here
  • Amon Amarth - Deceiver of the Gods
  • Arctic Monkeys - AM
  • Autopsy - The Headless Ritual
  • Bad Rabbits - American Love
  • Black Sabbath - 13
  • Black Tusk - Tend No Wounds
  • Bring Me The Horizon - Sempiternal
  • Cult of Luna - Vertikal II
  • Felix Martin - The Scenic Album
  • Haken - The Mountain
  • I is Another - I is Another
  • Ihsahn - Das Seelenbrechen
  • In Solitude - Sister
  • Intronaut - Habitual Levitations
  • Karnivool - Asymmetry
  • Killswitch Engage - Disarm the Descent
  • Locrian - Return to Annihilation
  • Mouth of the Architect - Dawning
  • Mustasch - Sounds Like Hell, Feels Like Heaven
  • Norma Jean - Wrongdoers
  • Oblivion - Called to Rise
  • Orchid - The Mouths of Madness
  • Phantom Glue - A War of Light Cones
  • Pyres - Year of Sleep
  • Pyrramids - Brightest Darkest Day
  • Revocation - Revocation
  • Rosetta - The Anaesthete
  • Scorpion Child - Scorpion Child
  • She & Him - Volume 3
  • Soilwork - The Living Infinite
  • Sound City - Reel to Reel
  • Spiritual Beggars - Earth Blues
  • Stomach Earth - Stomach Earth
  • The Ongoing Concept - SAloon
  • Toxic Holocaust - Chemistry of Consciousness
  • True Widow - Circumambulation
  • Volto - Incitare
  • We Butter the Bread With Butter - Goldkinder
  • Windhand - Soma

Enabling Wifi in Raspbian

I've started playing around with a Raspberry Pi recently. It's pretty slick, but there are a few gotchas I've run into, particularly regarding wifi.

I'm using a Model B Raspberry Pi which came with a USB wifi dongle, since my TV and router are not in the same room.

With raspbmc, it asks for your ssid and passphrase, but with an image like raspian, you have to configure the settings yourself. It's not too bad, but the documentation I searched for was not very helpful or clear.

This worked for me. Here's is what my /etc/network/interfaces looks like:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid "YourSSIDGoesInHere"
wpa-psk "YourWifiPassphraseGoesInHere"

After that, run this to reboot the pi:

sudo reboot

Once it starts back up you should see a message displaying your pi's new IP address handed out from your router displayed during boot.

Testing Salt States Rapidly with Docker

At Mediafly we have been using Puppet for a lot of our configuration management. While it does the job, it's a little opinionated and a little more complex than I'd like.

I've been using Salt a lot lately outside of work and I love the simplicity. I'll save my opinions for another post, but I guess if I'm writing about it that means I enjoy using it, right?

In conjunction with that, we've also been experimenting a lot with Docker. I'm learning that I wish Docker was around a long, long time ago (or that I discovered LXC a long time ago).

I just wanted to share how I've been using Docker to rapidly test Salt states (and I presume you could do the same for puppet or Chef).

Before Docker, when I wanted to test a system state (using shell scripts, puppet, or even just manual statements) I would spin up a base ubuntu server image in AWS and have to wait for it to get going, which takes a long time (~2-3 minutes). Soon I'd grow tired of this and moved on to just using VMs in VirtualBox on my dev machine. While this helped out in the time of spinning up a new instance in a fresh state, it would still take up a lot more time than I'd like (as close to instant as possible).

With Docker, the feedback cycle shortens to near instantaneous. Here's how I do it. Note that I'm not advocating this as the best way by any means, this is just the simple approach that works very well for me.

Let's get a few assumptions out of the way. I will assume that you have Docker running properly in your environment. If you do not, this is the best way to get started.

Also, if you wish to persist changes to the Docker images you make, you should set up an account here so you can push and pull your images easily.

The best way to get Salt onto a fresh machine is with salt-bootstrap. As such, you should clone this repo in your dev environment somewhere that your Docker container can access it (I'll explain later). You'll also need the Salt states you'll be running (if you are just getting started you can clone this, which are some very good examples to get started).

Now, let's get started with a fresh ubuntu image. We're going to use 12.04 (at the time of writing) which is the default Docker ubuntu image. First, start the Docker daemon:

sudo docker -d

Next, let's run the following command, which will attempt to connect to the base ubuntu image from index.docker.io - since this is the first time it is running, Docker will download the image to your dev environment:

sudo docker run -i -t ubuntu /bin/bash

Once this all downloads, you should be at a bash shell prompt, with a vanilla ubuntu 12.04 install, as the root user.

Now, for Salt testing, we want this container to have access to our code in our Salt repository, wherever that may be. To do this, let's create the folder /srv/salt inside our Docker container:

mkdir -p /srv/salt

Salt by default looks for states inside /srv/salt, so we'll use this for our testing.

Now, we want to commit the change we just made, so that the /srv/salt directory persists in our Docker image.

In another terminal, run the following command to get the list of running Docker containers:

sudo docker ps

This will come back with something like this:

karl@karl-VirtualBox:~$ sudo docker ps
[sudo] password for karl: 
ID                  IMAGE                              COMMAND             CREATED             STATUS              PORTS
93963124836e        ubuntu:latest   /bin/bash           15 seconds ago      Up 15 seconds     

Now, to commit the changes, run this, replacing the ID you see in your environment:

sudo docker commit 93963124836e karlgrz/salt-base

Ok, couple things here. karlgrz/salt-base is just a name for an image I want to push up to index.docker.io and takes the form of username/image-name. This could be whatever you want if you are not pushing to a repository, I just like to follow that practice. If you did want to push it to index.docker.io, you just issue the following command:

sudo docker push karlgrz/salt-base

Now you have an image that is base ubuntu, plus a folder at /srv/salt. Now, let's make another directory, which is where that salt-bootstrap repo will be mounted, inside our Docker container:

mkdir -p /srv/salt-bootstrap

Again, commit the change:

sudo docker commit 93963124836e karlgrz/salt-base

Now we have the following folder structure in our Docker container:

- srv
    - salt
    - salt-bootstrap

In the shell, hit Ctrl+D to exit and disconnect from the Docker container.

Now we want to mount our Salt states repo and the salt-bootstrap repo INSIDE that Docker container (because we shouldn't need to do any editing of source code inside there, leave that for your comfortable dev environment).

Start the Docker container like this to do that (replacing your local paths as necessary):

sudo docker run -i -v /home/karl/workspace/salt-bootstrap:/srv/salt-bootstrap -v /home/karl/workspace/salt-states:/srv/salt -t karlgrz/salt-base /bin/bash

Ok, now if you cd in to /srv/salt in our Docker container, you will see all the code from /home/karl/workspace/salt-states, and /srv/salt-bootstrap contains the salt-bootstrap stuff.

That's it! Now run the following command from /srv inside the Docker container:

salt-call --local state.highstate

And that will run salt locally, using the states in /srv/salt. You can view the output like you would on a normal machine, but now, when you stop and re-start the Docker container, you're at a fresh state. No need to wait for an AWS instance or a VM to spin up. This makes that feedback cycle SO MUCH FASTER!

Obviously, you aren't limited to just Salt or Puppet or Chef testing here. Docker presents new ways to control deployments and infrastructure partitioning that have been eye opening to me, and I think I've only begun to scratch the surface.

Stub Remote API Calls Locally with Nginx

One of the things that makes distributed systems development somewhat of a challenge is interacting with all the remote APIs that your system requires to function properly.

I find this a challenge when developing on the train (as I spend over 2 hours a day on one). 4G LTE is great and all, but there are dead zones and dropouts that make some API calls annoyingly long to respond.

Lately I've been messing around with stubbing out the remote calls locally using nginx, so I thought I would share how I do it.

It's quite simple, really, and seems to help me rapidly iterate over my own logic without needing to make expensive remote calls. Most recently, I've been interacting with some remote APIs using 3 legged oAuth authentication, which if you have any experience with that you can understand the frustration.

Start by installing nginx (I'm assuming Ubuntu here, so substitute for your particular distribution):

sudo apt-get install nginx

Basic install. Nothing fancy. Now, let's say we want to stub out a call to remoteapi.yourdomain.com/first_stub_action?param=something. We need to use a different host in our dev environment, so a pattern I usually use is to replace .com with .dev and just redirect that URL in my hosts file.

Let's start by making /var/www if it doesn't exist (note: you don't need to use this, but it's pretty common for serving files, so I'll stick with that). We also want a folder for our stubbed endpoint, so let's create that in one shot:

mkdir -p /var/www/remoteapi.yourdomain.dev

That folder could be whatever you want as long as that's what you specify as the root in our nginx config (coming up shortly).

Now, what should this call return? I like json, so let's use that. We're going to create a file (can also be whatever you want), I like the naming convention of calling it the action you are stubbing. For this call I'll use first_stub_action.json:

touch /var/www/remoteapi.yourdomain.dev/first_stub_action.json

Then let's paste the following into that file (using the editor of your choice or cat or whatever...doesn't matter): (note: this is simplified for the example)

{
    "status": "ok",
    "value": "testValue"
}

Ok, now let's edit /etc/nginx/sites-available/default with the meat of what makes this work:

server {
    listen 80; 
    server_name remoteapi.yourdomain.dev;
    access_log   /var/log/nginx/remoteapi.yourdomain.dev_access_log;
    error_log   /var/log/nginx/remoteapi.yourdomain.dev_error_log;

    location / { 
        root /var/www/remoteapi.yourdomain.dev/;
        try_files $uri /first_stub_action.json;
    }   
}

The key's here lie in the location. try_files tries to resolve a url (denoted by $uri) and will continue trying files down the line until it either finds something that is valid or returns the last endpoint. You can even add a =404 at the end of the list to return a 404 if you want to (which is nice for testing errors). But in our case, we want to always return the first_stub_action.json file.

Basically, any request made to remoteapi.yourdomain.dev with this configuration will return the contents of /var/www/remoteapi.yourdomain.dev/first_stub_action.json. Success!

This is ready to go, we just need to restart nginx and add an entry into our hosts file for this .dev subdomain.

Add the following line to /etc/hosts:

127.0.0.1    remoteapi.yourdomain.dev

Then restart nginx:

sudo service nginx restart

If you navigate to remoteapi.yourdomain.dev/first_stub_action?param=something in your browser, you should see the contents of first_stub_action.json returned. Success!

But wait...what if we have OTHER URLs that we need to stub from the same subdomain? Right now, the way this is configured, EVERY call to remoteapi.yourdomain.dev will return the same result. It's nice if you only are stubbing one call, but what about multiple actions?

That's easy, just add different locations and files for the different calls.

touch /var/www/remoteapi.yourdomain.dev/second_stub_action.json

And copy whatever you want to be returned into that file:

{
    "status": "ok",
    "value": "somethingElse"
}

And now our site config looks like this:

server {
    listen 80; 
    server_name remoteapi.yourdomain.dev;
    access_log   /var/log/nginx/remoteapi.yourdomain.dev_access_log;
    error_log   /var/log/nginx/remoteapi.yourdomain.dev_error_log;

    location / { 
        root /var/www/remoteapi.yourdomain.dev/;        
    }   

    location /first_stub_action {
        try_files $uri /first_stub_action.json;
    }

    location /second_stub_action {
        try_files $uri /second_stub_action.json;
    }
}

Now, when we go to remoteapi.yourdomain.dev/first_stub_action?param=something we get the contents of first_stub_action.json:

first_stub_action_screenshot

and when we go to remoteapi.yourdomain.dev/second_stub_action?param2=somethingElse, we get the contents of second_stub_action.json:

second_stub_action_screenshot

Success! A by product of this configuration is you will also get a 404 returned for any endpoint that has not been specified, which can be good or bad depending on your goals:

404_missing_action_screenshot

I hope this helps you as much as it has helped me in quickly stubbing out remote api calls, without a lot of ceremony and nonsense, so I can get on with actually writing the code that I'm interested in writing.

One Reason I Like LINQ in C#

This is one of my favorite things about LINQ in C#. This code:

var nonBlank = false;

foreach (var byteval in arrayOfBytes)
{
    if (byteval <= 0) 
        continue;
    nonBlank = true;
    break;
}

Becomes this code:

var nonBlank = arrayOfBytes.Any(byteval => byteval > 0);