Elixir Agent - a Lightweight GenServer

If you come from Erlang and are familiar with the GenServer behaviour you may be interested in the Agent set of methods that ship with Elixir. They provide a lightweight mechanic to save and retrieve state. Here are two functionally equivalent modules, one written as a GenServer and the other with Agent.

Project Barrier of Entry

"How much you know?"

How hard is it for a new person to pick up your project and start working on it? Think about the supporting database, message queues, mailer software, and any other systems your project ties into. Is there any kind of development credentials they’ll need? What is the process to get a change into production? When you go beyond the run-of-the-mill framework inside the vacuum of your local machine the barrier to getting started on a project can start to sky rocket. What are some ways we can help mitigate this?

Formatting JSON With Jq

If you haven’t tried it out yet, I highly recommend checking out the application jq. It allows you to quickly format json with bash or any other light weight scripting languages. I’ve been playing around with this for about a week and I would like to share some of the features it has.

Playing With JSONb and Postgres

This week I had the opportunity to play around with JSONb, a feature added to Postgres 9.4. It is similar to the native JSON column introduced in 9.3 but with some extra benefits. The two largest values that I have found so far is that JSONb can be indexed and the cost of selecting keys is quite a bit less. I also made a Ruby/Docker playground you can use to run some tests yourself. Check out jsonb_tests if you would like to try some of these features out yourself!

Putting Out Fires

"It burns when I program"

This week at work we were faced with one of those pre-launch fires. Stakes were high and emotions where even higher. Nothing feels worse in the work place then the pressure of tackling something like lost data or an uncontrollable outage. Needless to say, after long hours and several dead ends we were able to triage the problem and prevent a launch disaster. Looking back at it now, several days later, it reminded me of the time our barn caught fire growing up.

Commits That Matter

"Bad commit Messages"

Work in software long enough and you’ll eventually need to do some serious digging into the code base to try and figure out why code was done a certain way. Commit messages can be a great tool when digging up the past to uncover these mysteries. Please don’t be that person who makes understanding the past harder. There a two main classes that I believe hinder this; pointless commits and useless commit messages. The following examples are a breakdown of such offenses.

Paging With Offset Kills Performance

This week I’ve been working on extracting records from a service and enhancing them with extra data. The api of this service supports a fairly typical paging style of ?page=x&limit=y; which allowed me to form parallel requests to fully saturate ingesting and processing of the data. At the start of task things looked great with my measurements, it was processing about 1200 records a second! Several minutes in the rate began to plummet to ~250 a second. What was going on?

JSONb With Postgres and Rails

If you’re using ActiveRecord 4.2+ you’re in luck. It carries support for Postgres’ JSONb feature. JSONb, and it’s cousin JSON allow you to store json natively as a column in your database tables. The power of these is being able to then query directly against data stored in the data. For instance the following query would be able to grab all email addresses where the json column “preferences” has a key of contact_me set to true.

-- json
SELECT email FROM users WHERE preferences->>'contact_me' = 'true';
-- jsonb
SELECT email FROM users WHERE preferences @> '{"contact_me":true}';

Better Ruby Hash Handling

You’ll be hard pressed to escape working with hashes in Ruby, but don’t make using them a painful experience. Here are some helpful tips that I’ve collected that I would like to share.

The Best Laid Plans

The best laid plans of mice and men often go awry.

If I can, I would like to take you into my imagination. Let us pretend we work at Widgets Inc. Now, Widgets Inc has been around for awhile and is going through a phase in it’s life where the technical decisions made by previous generations no longer seem viable. Our company struggles keeping it’s current infrastructure going, while at the same time wants to make some serious changes to it. One of the biggest challenges, we believe, is our lack of leadership in the company. If we had leadership with a grand vision to unify and replace all of our old architecture things would be so much better!