Loading...
January 22, 2012#

Simple Feature Flags for Rails + Mongoid

Selectively rolling out new bits of an app using feature flags isn’t exactly a new idea. But being reminded of it during the keynote preceding the overall awesomeness of Heroku’s developer conference last week, right in the midst of my work adding more and more faster and faster to Fullscreen’s products, made me think that it was high time we got something like this hooked up.

Like any properly lazy developer, the first thing I did was search for a gem that could do this shit for me. And there were a few. And some looked pretty good. But the basic use cases for this feature were totally simple and concrete.

1. Enable and disable a feature on a per-user basis
2. Enable and disable a feature globally

And since I was looking for an easy feature to start learning TDD on (a post for another time) I figured I’d do it myself. Continue Reading

December 9, 2011#

Unlearning Perfection

A few weeks ago I had a quick email exchange with someone asking “if I were to give advice to designers attending Startup Weekend, what would it be?” This has Blog Post written all over it.

I’m guessing I was asked not just because I’m a Designer Who Codes, but also because I’ve also done a bunch of Startup Weekends and hackdays and have generally fared pretty well. (I say this as explanation and run-up and not to brag, by which I mean I just bragged, and deal with it.)

Good hackday performance in my case is mostly due to my ability to sniff out people who are smarter, more talented, and harder-working than myself, to grab them, and to NEVER LET GO. That, and maybe also a little bit because the unique time constraints and pressure of these one-or-two-day timelines has helped to figure out how to approach design with an eye towards ROI, learning where design can really add to the perceived value of a quick prototype and how it can help sell the broad vision of a product. Continue Reading

December 3, 2011#

Coffeescript: Organizing Classes In Separate Files

Coffeescript is so hot right now and everyone loves it and so do I. The syntax for creating classes without having to use prototype.whatever() is a joyous abstraction the more I get into it.

class Taco

  constructor: (@filling) ->
    @filling = 'carnitas' unless @filling?

When I started organizing classes in separate files (taco.coffee.js, burrito.coffee.js, etc.) I ran into a little bit of trouble creating instances of those classes in my main application.coffee.js file. Turns out I needed to declare my classes on the global window object to make it work.

class window.Taco

Then you shouldn’t have problems instantiating those classes from other files that are part of your application.

December 1, 2011#

Ruby: Do Something To X Items With first(x)

Learning Ruby (even after a year-and-some I’m constantly learning) means I get to enjoy a lot of Holy Shit That Was So Easy! moments like this one.

I had an array that I wanted to just grab the first few items from and perform an operation on them. (In this case, I was taking an array of country codes, which could be any length, and displaying the full names of the first three using the Carmen gem to map codes to country names.)

My first thought was to loop through the whole array using each_with_index and just perform the operation to the first three. Or, since that’s really inefficient, wrap it in 3.times do so it doesn’t have to loop through the whole array.

first(x) is actually even more concise than either of those solutions:

array.first(3).each do |c|
  c = Carmen::country_name(c)
end

Or even sweeter, in just one line:

array.first(3).map {|c| Carmen::country_name(c)}
November 16, 2011#

Git: Stashing

There have been a lot of times when I’m caught in middle of getting ‘er done on some fix or feature and need to update the branch I’m working on with someone else’s work. I usually try to git pull origin whatever and then I’m rudely reminded as the merge fails that I have one or more dirty, dirty files with uncommitted changes. I hastily commit my halfassed, partially-finished work with a message all like “incomplete work-in-progress” just so I can have a clean working tree to complete the merge.

Part of the reason I love the Git workflow is that it forces me to think critically about my process and to break tasks down into discernible goals so that I’m committing workable, finished code, no matter how tiny the chunks are. If every commit represents a discrete addition to the feature or project, I’m doing a good job of breaking larger features down into measurable tasks. Committing a bunch of half-finished stuff doesn’t fit well into this approach.

Enter the stash. Continue Reading

November 15, 2011#

Git: Removing Individual Commits With Rebase

I was pretty much scared completely shitless of git rebase for the longest time since it’s really powerful and in the wrong hands (mine) could cause some serious damage.

BUT. It’s actually not that hard to remove a single commit from your history using interactive rebase. I made a couple of embarrassing commits to a public repository that no one’s really looking at yet and figured I’d see if I could just, you know, kind of make it like they never happened in the first place. Continue Reading

November 12, 2011#

jQuery: DOM Element Existence

I probably have asked Google a thousand times how to check whether a DOM element exists. jQuery will always return a jQuery object when asked, so this won’t work:

if ($("#element")) {
  /* do something */
}

The move here is to check the length of that object, which is going to be zero if the object doesn’t exist.

if ($("#element").length > 0) {
  /* do something */
}

Or, even easier:

if ($("#element").length) {
  /* do something */
}
November 9, 2011#

I Got A Lot To Teach, But Even More To Learn

TL;DR: I never remember anything, so in an attempt to stop forgetting I’m going to start posting code and design hints and hacks as I discover them, even when they’re easy or old or obvious.

I’m probably always gonna be a bit like a bull in a china shop when I run into something I don’t understand. I smash through like seventeen browser tabs and Stack Overflow and some Google Groups post and another random mailing list and I try one thing and try another and then it works. And then I forget everything just in time to do it all again then next time.

After years of hacking away with design tools and programming langages like this I know, like, just enough to be dangerous about a lot of things. I don’t want to be just dangerous enough, though: I want to be really really dangerous.

I want to know as much about the tactics and details as I do the principles of designing and building software products, and I’m lucky enough to do things that teach me something new every single day. So from now on, whenever I pick up some little hint or tip or hack, whether it’s mind-blowingly head-exploding or really obvious, I’m going to throw up a little post about it. It may or may not help someone else, but it’ll definitely help me.

November 8, 2011#

Upgrading To Lion

I just upgraded my Macbook to Lion because I wanted to turn my computer into a big iPhone and because I was jealous of the sexy scrollbars that everyone around me was starting to have. It was a really seamless process, thanks in part to Apple’s easy download-and-install process and in part to Daniel Fischer’s step-by-step guide.

Since I use RVM and Homebrew that walkthrough pretty much covered everything I needed, but I did run into two other small things along the way.

Upgrading Homebrew: Permissions

When I tried to brew upgrade I got the following error as Homebrew attempted to upgrade the first installed package:

Error: Permission denied - /usr/local/Cellar/libtiff/3.9.5

The following fixed that error and I was able to run brew upgrade without a problem.

sudo chown -R '' /usr/local

Java Runtime

Lion also must have uninstalled whatever Java runtime I previously had and apparently doesn’t ship with Java anymore. If you do things like compress your assets with Jammit you’re going to need to download and install Java from Apple’s website.

November 7, 2011#

Convert-o-matic: A Perfect Landing Page Template

Download the project from Github or directly as a .zip file

Convert-o-matic on Github

Everyone needs a landing page for something, don’t we? For a while now I’ve seen this infographic from KISSmetrics popping up anytime I look for tips and tricks on landing page design. It’s pretty spot on.

I basically mapped the elements one-for-one to an HTML5 Boilerplate-based starter template because I wanted an easy way to create simple and effective landing pages without too much effort. All you need is a bit of basic HTML knowledge to use it to quickly validate an idea for a project or to create a landing page in a pinch that subscribes to best practices. You can use the minimal version or customize gradients and colors without too much trouble. (I’d highly recommend editing the copy.)

Download the project from Github or directly as a .zip file