Ruby Refactoring: Array#reduce and Default Variables

Background

Earlier in the week, late one night I was working with the RAML data structure. It contains an array of resources, each of which could in turn also have an array of resources inside of it. Each resource also has an array of methods, which in this case meant http verbs.

The structure from this perspective looks like this:

RAML#
resources# [
resource#
resources# []
methods# []
]
methods# []

In the spec there is no guarentee that a resource will contain any methods. I wanted to take this multi-deminsional structure and flatten it into an array of resources where each resource had at least one method in it.

Too Many Tools in the Field

Earlier in the week I found a logical bug in an open source project I had been building against. After double checking the documents to verify I hadn’t mis-understood anything I decided to open an issue for it…

Process: Thou Art a Cruel Mistress

Those who give up automated process for ease of development deserve neither.

— Benjamin Falk

Oh how I love to hate process. It’s put in place to make things simple, but when it’s heavily reliant on people just doing the right things, it sucks. All to often it’s ritual is used to haze new hires and harnessed as a tool to slow unwanted changes down by other entities in an organization.

Tig, Git’s Companion Tool

I wanted to share this amazing tool I learned about called tig. Taken strait from the github repo page:

Tig is an ncurses-based text-mode interface for git. It functions mainly as a Git repository browser, but can also assist in staging changes for commit at chunk level and act as a pager for output from various Git commands.

What it doesn’t mention is how amzing it is! This nugget has kept me at the command line longer these last couple days without needing to go go back to a GUI like Github to get a clearer picture of a project landscape. I haven’t had enough time yet to fashion a good .tigrc file yet but looking at the man page shows a ton of configurations for it.

Erlang’s Maps:to_json Not Found

I have been wanting to learn Erlang for quite some time, and last spring I bought the book Programming Erlang: Software for a Concurrent World to begin that journey. I read about 70% of the book and then life handed me some curve balls that suspended this great journey until recently. I rebooted my learning with Erlang by going through the book and doing the exercises at the end of each chapter. (Bonus: those exercises are under git if you are interested programming_erlang .) All was fine until I got to chapter five and learned of this disconnect…

Have You Found Your File?

When I need to find a file it’s normally when I am in Vim and I’ll happly use Ctrl P. However, there are tasks outside of Vim that require my attention daily and I have found the following tips and tricks to listing and finding files very usefull.

‘Raise’ in Ruby Is Just a Method

Today I was coding up a tricky bit of logic where I was using BasicObject to delegate all methods to another object it was encapsulating and I learned that raise is not a keyword in ruby.

Testing Against Multiple Rails Versions

Recently I wrote a Rails engine gem password_required. One of the first problems I ran into was not knowing what versions of Rails it would work with, so I kept the dependency rigid, “~> 4.1.6”. That of course alienated anyone working from the 4.0.x branch. I looked around at different packages to see how they handle this, and here is the solution I landed on.

Visiting South Cumberland State Park

Had a great time today with my wife and dog today! We decided to try and hit up a couple different state parks today but quickly discovered that maybe just one a weekend is more our pace. Did a fair amount of serious trail hiking and saw some really great waterfalls.

Bash Tips and Tricks

Using the up arrow to run previous commands in bash? If so you’re doing it wrong! Get to know you’re bash history and how you can use it to your advantage. When you press the up arrow you are cycling through you bash history, which you can see at anytime with the history command.