Work Small

Write programs that do one thing and do it well. –The Unix Philosophy I believe in working small. I love small Git commits and pull requests. When I commit, I like a short message. The code should only do what’s described by that message, in limited migrations, each of which can be rolled back. The changes should touch a limited number of files, and leave a green test suite. Everything should be reversible without side effects. ...

June 10, 2017

What We Learned Porting a Rails App to Phoenix

Tilex, our Phoenix port of Today I Learned, is coming really well. After a personal hiatus for RailsConf prep, I’m back full-swing. My coworkers have really been bringing quality commits as well, and I feel we are very close to a successful port. This experiment, for me, began with a desire for knowledge. What does a CMS look like in Elixir and Phoenix? Would it be harder to write and maintain? What would be the tradeoffs? Would Elixir’s legendary fault-tolerance and concurrency matter for a glorified CRUD application? ...

June 5, 2017

You Should Blog

I created this blog to reflect on my code and development as a programmer. In that spirit, I’d like to make a pitch to anybody reading: you should blog. Why? For me, it’s been an invaluable opportunity to practice explaining my thoughts, and to watch myself grow. Explaining Thoughts Translating technical ideas into words is one of the great challenges of being a programmer. We have to master it. Communicating well with everyone on your team is crucial. ...

February 11, 2017

Reset an Ecto Heroku Postgres Database

We introduced some breaking database changes to our Phoenix port of Today I Learned on Friday; today I deployed them to staging. Resetting an Ecto Heroku database, with new seed data, turned out to be a little tricky, and I wanted to document what I learned. This blog post assumes you already have the Heroku Toolbelt and an Ecto-supported application in production. First, make sure you deploy the breaking changes: $ git push <your_remote> master To drop a Heroku database, first we need the name of the database. DATABASE_URL is specific enough if there’s only one, but I think it’s a best practice to reference the specific database you’re attempting to destroy, every time. ...

January 7, 2017

Vim Nonrecursive Mappings

My first PR to a new Vim plugin was merged this week, check it out, adding non-recursive Vim mappings to vim-termbux. vim-termbux is a plugin by my friend Dillon Hafer that emulates the behavior of vim-turbux— sending test run output to somewhere outside of Vim– in iTerm. If you write a lot of tests in iTerm and Vim, but prefer to stay outside of Tmux for whatever reason (fingers don’t like the mappings, etc.), than this plugin is for you. ...

December 17, 2016

Porting TIL from Rails to Phoenix: Initial Commits

Last week, I started a new project: porting Today I Learned from Ruby on Rails to Phoenix (Elixir). The first few commits were pair programmed with Josh Branchaud, and I hope to work with him and other Rocketeers going forward. The repo for the new codebase is here. There’s a lot of work to do to reproduce even the MVP functionality of TIL. We’re using the ‘Projects’ feature of Github to track progress right in the repo. ...

November 29, 2016

Learn to Test

What is a skill one could learn to set themselves apart from other entry-level programmers? Testing. The web frameworks of today all have mature test libraries. Hashrocket’s default tool is Ruby on Rails, and testing is a fundamental part of that community. Everything we do is test-driven. New apprentices who come into any consultancy will have a lot to learn. At Hashrocket we use a pretty customized setup of Vim and Tmux, and have a ton of aliases and shorthands that can be hard to pick up. Our apprentices pair program with full-time developers, on real projects. It can be daunting at first. ...

July 15, 2016

Why Elixir?

I’ve been learning and using Elixir lately, and loving it. More than once, I’ve been asked some version of the question: why are you learning Elixir? What makes this language unique? I thought I’d take a moment and try to distill my rationale. There are two main points: Elixir solves problems, and it’s aesthetically interesting to me as a language. Real Problem Solving Elixir is written in Erlang, a language for telephony. Erlang is thus optimized for two things: ...

July 6, 2016

Writing Elixir Sigils

Sigils are a mechanism for working with textual representations in Elixir. If you’ve ever made an array of Strings in Ruby with %w(), the API is similar. A neat feature of sigils is that we can make custom variants, or override existing Kernel variants. The latter is generally discouraged. Creating a Sigil Here’s some code I wrote for an exercise, defining a new sigil, u: defmodule SigilWriter do @moduledoc """ Provides a module for creating new sigils. """ @doc """ Defines the new sigil function for `u`. """ def sigil_u(content, _opts) do content |> String.split |> Enum.map(&String.downcase/1) end @doc """ Calls the `u` sigil. """ def split_and_downcase(content) do ~u(#{content}) end end The sigil_u function defines the new u sigil— u is just a convenience method. This function takes the content, splits it, and downcases each word in the list. This only works because u is not already a defined sigil in Elixir. ...

July 4, 2016

How and Why to Squash Your Pull Request

Many pull requests go through a cycle: programmer opens pull request, maintainer gives feedback, programmer makes changes, repeat until ready to merge, maintainer merges. Prior to the merge, the pull request can be messy, full of reverts, fixups, and WIP commits. In the end, those commits are noise. We can tell a better story by squashing the branch. Consider this Git branch history: * 724d574 (HEAD -> issue/38) Good to merge! * e2af5ac Refactoring the previous commit * 3e36475 Test are passing here * ea479cb Revert "Ooops" * 77aee1d Ooops * 4c7ead2 Test breaker The final commit at the top, 724d574, has been approved to merge by the maintainer. But this branch is a mess. We have a commit that’s just refactoring (e2af5ac), two commits that cancel each other out (ea479cb and 77aee1d), and one that has failing tests (4c7ead2). ...

July 3, 2016