Ruby’s % Notation

For some reason my brain has defected and has chosen a life of NEVER being able to recall basically anything related to Ruby’s % notation. After seeing this list on a recent Arkency blog post (an awesome blog) I’ve decided to steal repost it here for my own personal reference.   %q[ ] # Non-interpolated String […]

Git: Amend

Have you ever had this happen to you? You finish writing some awesome code.  You’re a bad ass and you know it. You hit the command line, because you stopped creating GUI interfaces using visual basic a long time ago. Issue a little “git add” here and there, add some broth, a potato.  Baby, you’ve […]

YDD Guidelines – YOLO Driven Development

For anyone who’s just starting to get into YDD (YOLO Driven Development), here are some good guidelines put together by GitHub user Todor Grudev (tagrudev):   View the code on Gist. ps. this is a joke, don’t do any of this stuff… or do it! YOLO!

||= WAT?

First off, I stole this pic from Greg Pike’s post about Javascript.  Now that the confession is out of the way… Today at App Academy my pair and I were asked to explain the meaning of Ruby’s “double pipe equals” operator  to our cohorts.  I figured that might be a good topic to post here. The […]

Quick and Dirty: Public vs Private vs Protected

Ruby provides 3 ways of classifying a methods in a Class: Public, Private and Protected.  These keywords are used to declare a method’s visibility and essentially what you’re doing is restricting access to the individual methods contained in your class. Here’s a quick and dirty about the differences: Public These methods are accessible by anyone who calls […]

Parallel Assignment

Here’s a cool trick for dealing with situations where you want to assign multiple values at the same time. The technique used is called parallel assignment and it looks something like this:   View the code on Gist.   If you’re working with game boards, this is super useful way to pass around board coordinates!!

Something to Lookout For

If anyone actually reads this, here’s an unusual circumstance to look out for… circular object references that cause Pry to go BSC. (For those who don’t know, Pry is a Ruby shell that can be used as a replacement for the default Ruby shell, IRB (like IPython for python people).) Today I witnessed a pretty strange […]

Sublime Text 2 and RVM

Did you know it’s possible to run (aka build) your Ruby code straight from inside of Sublime Text 2? That’s easy, just make sure your code is saved as a .rb file and hit Command+B.  But wait, there’s more… Did you also know it’s possible to run your Ruby code straight from inside of Sublime […]

The Parallel Gem and PostgreSQL (oh, and rails.)

Some Preface An app I’m working on has a rake that that basically gathers data from the web.  Doing things serially is really REALLY slow and to get around this I started using the (fantastic) parallel gem by Michael Grosser. This gem is great — it’s simple to use and in something like 3 minutes […]

Sorting an Array of Hashes via a Hash Key

My use case for this is that i have a rails app using STI.  I’ve got an array of results from all of my inheriting models and i’d like to sort them ALL based on a common attribute they share — a zip code. Here is a RIDICULOUSLY simple way to use Ruby to sort […]