The Easy Way to Get Started with PostgreSQL on a Mac: and Induction

Here’s how to get started with PostgreSQL in minutes without having to touch the command line. You’ll need two applications to run and manage PostgreSQL, and Induction. is the equivalent of the MySQL server you get with MAMP and Induction is the equivalent to something like Sequel Pro if you are coming from MySQL. Up and Running Once you have those two applications downloaded and installed, here’s what you need to do to get your PostgreSQL server running and be able to use Induction as a [...]

Extending ActiveModel via ActiveSupport::Concern

In a project I’ve been working on we have some functionality that is shared across multiple models – assigning a default record on a has_many association. Obviously we didn’t want to duplicate the methods in each model, so we explored our options for sharing the logic. We figure we could:Setup a HasDefault base class that we could extend our models from (i.e. class CreditCard < HasDefault) Extend the functionality of ActiveRecord::BaseInspired by how has_secure_password is setup, we decided to extend the functionality of ActiveRecord::Base so we could just [...]

Code Highlighting and Marked Preview Styles in nvALT

Everyone loves nvALT, but the markdown preview you get out of the box isn’t anything special. Although there are some instructions on customizing the markdown preview in nvALT, he doesn’t go into specifics about where to find new styles or exactly how to import them. Personally, I like the previews that I get in Marked, another one of Brett Terpstra‘s creations. Knowing that the markdown preview styles are stored in a plain CSS file in nvALT, I figured it was the same for Marked. The first [...]

Work Faster with Basic Shell Commands

Writing your own shell scripts may seem a little intimidating at first, but it’s actually quite simple and can drastically improve your workflow. Any sequence of commands you would run from the command line you can put into a shell script. For example, when I want to start coding on a project, I usually end up opening my editor from the terminal and a new tab in my browser to view the project. This doesn’t take very long, but since [...]

The MacBook Air and Web Development

I migrated to a MacBook Air as my primary development machine a few months ago and I think it is the ideal computer for a web developer. I think it’s the future of personal computing and that everyone should do themselves a favor and pick one up the first chance they get. There are already some great articles reviewing the specs of the computer and why it is well-suited for web development, but I just wanted to point out a few, hopefully [...]

The CodeIgniter Decorator Library

I’ve been thinking a lot lately about how I can clean up my CodeIgniter code, specifically my controllers and views. CodeIgniter is dead simple to work with, but on larger, more complex projects I find that my controllers get a little long and my views get messy. Here are my main issues and how I’ve decided to address them. Controllers The main thing I don’t like doing in my controllers is all of the data retrieval and preparation to pass data [...]

Cleaning Up Your CodeIgniter Controllers

One of the issues I’ve always had with CodeIgniter is that it’s kind of difficult to keep my controllers skinny and my models fat. Certain things that are typically handled in the model with other MVC frameworks are often handled in the controller in CI. For example, it’s fairly common to see code like this in a controller: application/controllers/products.php class Products extends CI_Controller {public function edit($product_id) { $this->form_validation [...]

Changing Default Error Delimiters in CodeIgniter

One thing that I end up doing in almost every CodeIgniter project is changing the default error delimiters from a plain ol’ paragraph <p></p>to a fancy shmancy paragraph with an error class on it <p class="error"></p>Not a big deal, but I always want a CSS hook for styling my form errors. There are two ways I used to handle this:Set error delimiters on an as-needed basis in my controller, but that resulted in a lot of code duplication and calling set_error_delimiters() all over the place. Set error [...]

My Path To Vim Enlightenment

It’s been about 2 months now since I began using Vim as my full-time editor and I can easily say that my productivity has increased as a result. I’m still only scratching the surface of what the editor can do, but I’m confident that this is going to be one of the single best moves I make in my programming career. Not only will it save me time and money  by not trying out every new editor that comes out on [...]

User Group-specific Controllers in CodeIgniter

I’ve been building out an application that has 2 types of users, corporate and operations. Each user type has access to a lot of the same methods, but operations has access to a little more than corporate. I’ve been struggling with how to break up the code for these two types of users since a lot of it is shared. At first, I thought I had a couple options: 1. Separate the logic into different directories This would mean that I have completely separate [...]