See Your Current Git Branch In Your Shell Prompt – In Full, Glorious Color!

Here’s a cool bit of code that displays your current git branch in your shell prompt. Like this:

railsdeveloper.net_git_branch_in_shell_prompt

Pretty handy. Here’s all you have to do to get this beauty working for you. In your .bash_profile (or .bashrc ) file, add this:

(more…)

Application Development Secret: Give a Toy Away

As your web application matures and your users request more and more features, your code can quickly get out of hand. This leads to hidden bugs, recursive crap and “skeletons” lurking in your code closet.

But we both know it’s important to keep our code lean. But how do you do this when you’re adding features all the time? Or when you’re keeping up with the competition and responding to user requests?

It’s tempting to say, “We’ll just schedule time to refactor on a regular basis.” But as you’re pushing more and more updates, this often gets thrown on the back burner.

Let’s face it: it’s a lot more fun to release new features. It’s exciting. You get to envision something and bring it to life. You hear the “ooohs and ahhhhhs” of users. It feels good to make them happy.

On the other hand, refactoring existing code is like cleaning out the garage. Necessary and rewarding, but it can be dry. And since users can’t see this refactoring work, you don’t get the accolades that you get from new features.

So here is how I keep my code lean as I add more and more features. It’s called “give a toy away”. I use this approach every time I add a new feature to my Rails application or upgrade an existing feature. It’s a regular practice for me and a good habit you can get into. Here’s a little background:

Minimal Lifestyle

My wife and I live a “lean lifestyle”. Minimal. We value experiences over material objects, so we avoid conspicuous consumption. Our taste in interior design is mid-century modern (think “Dwell” magazine) and even our taste in music includes minimal techno.

Problem is, every birthday and Christmas my kids get new toys. Loads of them. For years, they piled up and became “clutter”. Many were outgrown and obsolete. They took up “mental space”.

Sure, we asked our kids to prune their toy collection from time to time, but it just never happened. So we came up with a new rule. It’s called “give a toy away”.

Give a Toy Away

Here’s how it works: Each time our kids get a new toy or gift, they need to give an old toy to charity.

In other words, they’re forced to make a decision and prioritize what they play with. In with the new, out with the old. The key is that we have them do this the same day. We say, “Look at these great new toys you got! Tonight you can choose a couple of old toys to give to needy kids”. Later that evening, we pull out a bag and have them stuff their old toys inside.

This, their toy collection doesn’t get out of hand and more important, they appreciate what they have. It also makes them feel good that their old toys will be enjoyed by somebody else.

Rails Development “Give a Toy Away”

I apply the same concept to my code. Every time I add a new feature or upgrade an existing feature, I go through my code and find an “old toy” to give away. It could be bloated controller code – like a “find” that is better pushed into a named scope in the model.

Sometimes the old toy is duplication in a view. Maybe I find something I can put into a partial. Or I shove some conditional code into a helper to get old logic out of my view.

Other times I refactor an existing feature completely. Whatever. Every time I look back at old code and see something that can be refactored, I tag it with a…

<%# TODO: Old toy %>

…and give it away when I add a new feature.

My general rule is that I try to simplify as I add complexity. This serves the twin benefits of keeping my app up-to-date and streamlined…and keeping me in touch with old code.

Try it. Get into the habit of giving away an “old toy” for every “new toy” you add. You can’t always make it a line-by-line exchange, but it’s good practice and keeps your code clean.

Developing the 9elements Way

For years, I’ve used my MBP hooked up to a 24″ external monitor, with my laptop closed and an extension keyboard.  However, I recently went back to the amazing site run by German web development firm, 9elements.

After watching their cool looped video (yes, in Flash!) I noticed something surprising: most of them code directly on their laptops with no external monitors attached (or at least not used). Seeing this work environment, I tried disconnecting my MBP and using it without an external monitor. I’ve found I’m just as productive now that I’ve set up Spaces correctly. Here’s the setup which works for me:

  • Space 1: Firefox and Safari
  • Space 2: Textmate
  • Space 3: Terminal (and sometimes Transmit)
  • Space 4: iTunes

It took a little getting used to at first, but now that I’m using this setup, it’s nice because when I’m mobile, I’m in my normal work setup wherever I go. I know some developers (and especially designers) like to use large external monitors hooked up with open laptops, but I’m starting to like my new setup.

Quick Search /
See Your Current Git Branch In Your Shell Prompt – In Full, Glorious Color!
February 15th, 2015

Here’s a cool bit of code that displays your current git branch in your shell prompt. Like this: Pretty handy. Here’s all you have to do to get this beauty working for you. In your .bash_profile (or .bashrc ) file, add this:

Zero Downtime Rails Migrations with the Large Hadron Migrator Gem
April 9th, 2013

Are you working on a mature or legacy Rails app?  If so, you know migrations that change the structure of your tables (like adding indices) or update many rows can be troublesome.  You might be ask yourself, “Wow. I have this big app in production with lots of users and I have to perform an […]

How To Build a Product People Really Love
May 27th, 2011

Eric Wahlforss, one of the founders of SoundCloud, recently said, “To make a product people really love, find those people and iterate together with them”. This puts the focus on customers and what they want.  It’s democratization of development.  Obviously, you can go too far in this direction and cede to every feature demand, but […]

Introducing SoundCloud-Powered Multi-Track WebApp, “Sessian”
April 16th, 2011

Here’s a quick look at something I’m building with the SoundCloud developer tools. Now, I’m sure this type of app has been done a thousand times…but I thought other devs might like to see what’s possible with the tools and phenomenal support SoundCloud provides. Sessian is a browser-based multi-track app that uses SoundCloud embedded tracks […]

The Easy Way to Authenticate via SoundCloud
April 14th, 2011

Here’s a quick video I shot to help you get started with SoundCloud’s API in a Rails app. I recommend viewing in 480p to see more detail (you can also watch it on YouTube.com).

Rails 3 Bundler of Love
November 6th, 2010

Are you on Rails 3 yet? If not, you’re in for a treat. The Rails core team has done a great job with Rails 3. While there are lots of nice improvements, the best of the bunch is bundler. In my opinion, this feature alone is worth the upgrade. So pay attention here. You’re going […]

Steven Johnson’s New Book, Where Good Ideas Come From Inspires a New Site: SlowHunch.com
October 13th, 2010

If you do anything with the web – or want to develop more creative ideas – you must rush out and buy Steven Johnson’s new book Where Good Ideas Come From. One of the central themes of the book is that an idea is a process, not an event. A great idea, Johnson explains, doesn’t […]

Application Development Secret: Give a Toy Away
September 14th, 2010

As your web application matures and your users request more and more features, your code can quickly get out of hand. This leads to hidden bugs, recursive crap and “skeletons” lurking in your code closet. But we both know it’s important to keep our code lean. But how do you do this when you’re adding […]

Weekend Rails Development Project – Dj-Search.com
June 24th, 2010

A couple weekends ago, I slammed out a new site, called dj search. The concept behind the site is obvious: find a dj for your upcoming event. We wanted the design and functionality to be “as simple as simple can be”. Constructed with the help of a friend who is a professional dj, we cranked […]

Rails Paperclip Plugin Validation If No Attachment Present
June 19th, 2010

On a martial arts marketing website, Through the Ranks, I use ThoughtBot’s excellent file upload plugin, Paperclip, the defacto standard for managing Rails file uploads. However, one problem has been vexing me since day one. And that is validating only when an attachment exists. For example, in my Rails application, I give users the option […]

RailsRankings.com: 500 Errors
June 19th, 2010

What is going on with RailsRankings.com lately? Seems like every time I visit the site it looks like this: At least it’s good to know the site IS Rails, however.

Rails and jQuery: How to Integrate jQuery UI into Your Rails App
June 9th, 2010

Ahhhh….jQuery UI. Lucious. It’s the quickest way to get your app looking slick in no time. It’s also highly flexible. jQuery UI’s themeroller feature allows you to tweak your css settings (and the look of your jQuery ui elements) right in a web browser (Wow! We must be living in the 21st century!)

Will Paginate Page_Entries_Info Hide/Show
June 1st, 2010

The old standby Rails pagination plugin, Will Paginate has an excellent built-in method for showing the records found in a collection: What this does is returns a count of the model objects in your collection. This sometimes helpful, for example, if you want to show your users how many comments a blog post has. Or […]

The Hungry Beast
May 22nd, 2010
Developing the 9elements Way
May 22nd, 2010

For years, I’ve used my MBP hooked up to a 24″ external monitor, with my laptop closed and an extension keyboard.  However, I recently went back to the amazing site run by German web development firm, 9elements. After watching their cool looped video (yes, in Flash!) I noticed something surprising: most of them code directly […]

Rails and Cucumber – The Benefits of Using Cucumber in Your Next Ruby on Rails Application
May 21st, 2010

Ever wonder what the appeal of Cucumber is? Wonder if you should employ Cucumber to help develop your next Rails apps? Is it worth the time, effort and extra steps involved? My vote is a hearty “yes”. And here’s why: First, Cucumber forces you to SLOW DOWN. It forces you to stop and think. To […]

New to Rails? Here Are Nine Tips for Beginning Developers
May 21st, 2010

If you’re a designer who is just encountering Ruby on Rails…congrats! You’re going to love working the “agile way”. Rails is efficient, fast and a joy to work with. However, Rails can have a steep learning curve, especially for designers. But once you grasp the fundamentals, you’ll never look back.

Here are my top ten tips (and resources) for wrapping your head around Ruby on Rails as a designer: