Base16 Shell Tmux Vim Color Switching Dead Simple

I’ve been using base16 as my terminal color scheme for a while now, I used to use solarized. I’ve been pleased with the results. Over all the base 16 suite is a great looking set of themes that works well in the shell and in vim. Chris has done a great job on it.

One of the issues that I’ve had is my setup was theme specific, meaning after I chose a theme, I was committed and switching colorschemes mid-coding session was painful. There were ad-hoc times where the visibility of a light theme was crucial to taking pride of my environment. Basically:

Dark themes + shitty projectors == :(

Typically I use a dark theme, but when I have do an ad-hoc presentation or someone comes over to pair program, it’s easier on the eyes to use a light theme.

Attempt 1: iTerm Profiles + Environment variables

Intially I created dedicated iTerm profiles so that I can import the correct colorscheme which would set the 16 ansi colors to the exact color. I had my .bashrc and .vimrc check the ITERM_PROFILE setting provided by iTerm to set the proper themes in tmux and vim. The solution roughly consisted of the following:

  1. Manually Create a new iTerm profile titled with the name of the base16 theme I wanted to use. e.g. base16-default.dark
  2. Manually update my bashrc to include logic to source the right iterm-shell init script. The bashrc would also tell tmux to source the right color schemes.
  3. Manually update my vimrc to set the right colorscheme and background accordingly

While this worked for the most part, it required creating a new iTerm and was pretty kludgy overall.

The biggest problem was that switching profiles wouldn’t change the ITERM_PROFILE environment variable in tmux. Since tmux is a client/server app it would hold on to the ITERM_PROFILE that was initially used when the tmux server was created. Therefore creating new tmux shells would have the original theme not the latest.

Attempt 2: (Current solution) auto-generated bash functions

I created a that will automatically create base16_{theme}_{dark|light} functions that will quickly switch to that theme. in addition the functions will create ~/.vimrc_background and ~/.base16_theme files. These files allow the following:

  • the .vimrc_background file will configure vim to use the latest use base16 profile.
  • the .base16_theme is a soft link to the latest activated theme so that it can be sourced newly created shell

In action

Super quick setup:

Until I convince Chris to include this in his project, clone my fork

$ git clone

Add the following to your bashrc (change the location to match where you’ve cloned the base-16 shell):

if [ -n "$PS1" ]; then # if statement guards adding these helpers for non-interative shells
  eval "$(~/Development/base-16/shell/"

Install the chriskempson/base16-vim plugin for super quick vundle setup, add to your vimrc:

plugin 'chriskempson/base16-vim'

then install base16-vim using :PluginInstall

Lastly, Add the following to your vimrc:

if filereadable(expand("~/.vimrc_background"))
  let base16colorspace=256
  source ~/.vimrc_background


In new shells, use the bash functions to change the color scheme:

$ base16_default_dark

Quick and painless color switching, Enjoy.

Starting Again

It’s a little cliche that I’m starting to blog again exactly the same time I tried this last year, which just so happens to fall in right after the new years. But I promise it’s not a resolution or anything ;) I think part of the problem was that I was drinking from a firehose for the better part of last year since I switched over to be a contractor. Now I think I should be in a better place where I can devote time to writing.

My Thoughts of ChefConf 2014

I’m sitting at the SFO airport trying to digest everything that I was exposed to after 3 intense days of Chef sessions and meeting the awesome chef community.


One thing that I learned is that Chef as a company is cool and laid back. I was taken by surprise on how cool they are. After watching Nathen Harvey’s presentation and then the open bar rock band show I realized how down to earth and funny they are. Even everyone that I met at all the hallway sessions were friends I hadn’t met yet. I felt wow these guys are genuinely awesome. I was initially skeptical because I thought that everyone was a little too nice and friendly, but by the end I was convinced that this is an awesome community, that I’m glad to be a part of.


The message that I recieved from the conference was that we as IT professionals have the power to change companies. We need to fully embrace the idea of continous delivery (which admittely I need to learn more about). That the devops movement is a shift in how software is maintained and that the shift requires more transparency, acceptance and trust than just adding a new ‘configuration management’ tool. I learned that it’s about building trust in the process. Showing real success stories in baby steps so that everyone can realize the potential that we sell them in slide decks and proposals.

Lastly the idea that we are all working together to make the software development process more delightful. By implementing a process that reduces the friction in changes we’re able to respond faster and provide value.

Call to action

Testing Express With Mocha

Even though this post doesn’t technically have anything to do with Mocha, I’m mentioning it in the title because I was using Mocha, but Mocha has a gap of features when it comes to testing http interactions. You need to augment it with another module.

I’m working with NodeJS and trying to experiment creating a web backend that will handle form posts from my simple html web page. In order to test the simple express app I wanted to use mocha.

After installing mocha and express I created my handler but wanted a way to fake the requests. I couldn’t fiqure out how to test the application so I started googling to see what was recommended. I found a post on wrecker showing to use supertest.

I then started to look to make sure that supertest is in fact the right tool that I need. I couldn’t find a definitive direction on how to test web form requests using node so I’m posting this.

I confirmed simply by reviewing code from the one of the nodejs contributors and confirmed that he is using supertest to test their http interactions.

var assert = require('assert');
var request = require('supertest');
var app = require('../server.js');

describe('Post', function() {
 describe('Sunny path', function() {
   it('should just work', function(done) {
      .expect(/Hello there!/, done);

here’s the result

EmbjerJS Is a More Than Just Model View Controller

I’m learning EmbjerJS, and it’s a great framework. One of the things that I struggled with is that I thought it was a vanilla MVC javascript framework. I said OK, I know MVC so this is great..then I read a few docs about how Ember view binding works and tried to create a quick prototype. I could not get a simple form post working. Why?

I assumed it was just an MVC framework.

The View (in MVC) is in charge of presentation, is uses the attributes/methods from model to make determinations on how to render the UI. Therefore the view reads from the model and sends events/commands to the controller. The Controller (in MVC) is in charge of dealing with those commands, it handles requests and input from the user and makes things happen.

In the strict MVC pattern, Controllers are not responsible for is acting as a facade over the model.

Here’s a diagram of how I understand vanilla MVC:

Back to my problem

So I created a model object to match the form data, and the view pulled properties from it to show on the form as expected. I have read about Ember’s view binding, so after the user edited the form and clicked save, I expected my model to have those attributes automatically reflected on my model from the form, but it wasn’t working. obvisously I wasn’t getting it.

So I started working through their walkthrough.

After 2 hours I completed their walkthrough and it hit me. This is not just an MVC framework, it’s a cross between a MVVM framework and a MVP framework.

Let me explain..

In a MVVM (Model-View-ViewModel) The Model object is not decorated with any properties that are view specific. (Which is true in EmberJS) The View does not interact with the Model but instead interacts with a decorated Model called the ViewModel. These decorations are UI specific to help facilate the view. In addition to having UI specific fields, The ViewModel object can also constructed in a way that it hides away all the complexities of dealing with UIs where you have multiple models in order to render a view. Therefore the View just needs to communicate ViewModel and not have to know the relationships between models.

But there is no concept of ViewModel in EmberJS. So the Controllers play that role.

In MVP, (Model-View-Presenter) The presenter does what normally the controller would do in MVC (handle commands from the user). It also has the added responsiblity of creating methods that help the presentation (thus presenter). Methods like hiding/showing logic and handling staleness dependencies of controls can all be handled by the presenter to keep the view simple.

But there is no concept of a Presenter in EmberJS. So the Controllers play that role.

In EmberJS it’s more of a straight line:

Note that the default controller implementation proxies ‘gets’ from the view to the backing model so that it feels more like the vanilla MVC.

Once I was able to understand that, it was clear what my problem was. I expected once the user issued the ‘save’ command the model would reflect the form data (via Ember’s view binding). But it was the Controller that received all the form data. I needed to set the data on the model and was able to get a simple form post!

I hope this helps someone understand EmberJS better as it did for me..

Using Rails Composer – Followup

I just wanted to follow up on using rails composer. After speaking with Ryan McGeary, I’ve since decided that using rails composer wasn’t the right tool for this job.

  • Rail composer sets up more stuff than I need, and it would take some work trimming out some of the gems/files it has.
  • Devise was more than I needed for the scope of the project that I need.
  • It’s even questionable whether or not I should use rails.
  • I want to learn a new JavaScript MVC framework. (I chose EmberJS)
  • It also reduces the need for another node in the system I’m trying to create.

EmberJS: The Id Property Must Be Defined as a Number or String for Fixture

I’m creating my first application using EmberJS and I recieved the following error:

the id property must be defined as a number or string for fixture.

This occurred when I was simply trying to save the model after the user clicks the action. I was a little confused by this error, because if you try to define an id property in the model EmberJS yells at you with this message:

You may not set 'id' as an attribute on your model.

I’ve read that it’s the store’s job to assign the id of the model record. It turns out that this is due to using DS.FixtureAdapter, instead of the DS.RESTAdapter.

It turns out that the use case for the FixtureAdapter is when you want to build an app and don’t want to be concerned with the backend. In other words, the RESTAdapter would actually send the restful requests to an endpoint for your crud and verb actions. Where as the FixtureAdapter is a stub. For example, a front-end developer that is only in charge of the UI and doesn’t want to setup the dependencies for the backend. This way you could mimick the responses that you would get from a real backend. This is why EmberJS is asking for an id:

FixtureAdapter is faking a real backend

And a real backend is required to set one.

Thanks to jkarsrud on freenode#emberjs for his help.

How to Cherry Pick Git Commit Using Tig

The problem

Recently I needed to grab a commit that was on a release branch and bring it over to the master branch. We weren’t ready to merge the whole branch and but I needed a specific commit.

I do not want to have a merge conflict when the release branch is merged back into master.


Git supports this via cherry-pick. This approach allows git to know that the commit that was cherry picked can be skipped when merging the branch to the destination containing the cherry-picked commit.

I was able to use tig to accomplish this by doing the following:

checkout the destination branch: git checkout master

then open tig

then press ‘b’ to see all the branches

then select the branch that contains the commit you want

once you select the commit you want press ‘P’ (case sensitive)

the commit should now be on master git push origin to push the change.

Using Rails Composer

I’ve decided to use rails composer for an app that I’m building. For those that don’t know rails composer is “like the Rails generator on steroids.”

I looked at a few generators and most of them were old, but it was a toss up with rails composer and suspenders. I ended up choosing rails composer but I haven’t done a pros and cons evaluation between them.

Stay tuned for my review on using rails composer.

Octopress How to Switch From Dark Color in Code Snippets

Octopress comes ‘out of the box’ so to speak with two solarized colorschemes. The default is dark, changing it to light is as simple as this: