Opaque IDs, editable titles in TIL URLs

Today I’d like to highlight something I built with some colleagues that I think is cool: the dynamic paths of Hashrocket’s daily learning site, Today I Learned (TIL). Check out the browser bar here: The URL it contains is: https://til.hashrocket.com/posts/ee0a1bc878-parameters-filtering What do you notice? Here’s my list: After posts/, the path starts with ee0a1bc878 (?) That’s followed by a dash, then the post title in kebab-case (parameters-filtering) When you visit the same URL with an altered kebab-case title (e.g. ee0a1bc878-nope), you get the same page 😵‍💫 When an admin changes the post’s title (e.g. “Rails Parameters FTW”), the URL changes too(ee0a1bc878-rails-parameters-ftw) 😳 There are some sneaky features in there! Let’s dig into them for a minute. ...

July 22, 2026

Autoformat Your Code

Auto-formatting code is good, and you should be doing it all the time. Why? It helps you write better code in real-time, preempt trivial discussions, and maybe even democratize programming. Better Code in Real-time First, writing better code in real-time: I’ll use the Prettier auto-formatter as an example. I have Prettier running everywhere, auto-formatting on write. This means that each time I write my file, which I do a lot, Prettier attempts to format my code. Neatening my work as I go along helps me think clearly and see refactoring opportunities. ...

March 10, 2022

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

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

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

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

Recreating Elixir's Enum.sum

I’m learning Elixir, and today as an exercise, I was challenged to recreate Enum.sum using recursion. Here’s my solution. For those new to the language, Enum.sum iterates over a list and returns the sum. Here’s an example: iex(0)> Enum.sum([1,2,3,4,5]) 15 Here is my implementation: defmodule MyList do @moduledoc """ Defines the list struct and functions. """ @doc """ Add all the items in a list together. """ def sum(list) do sum(list, 0) end defp sum([], count) do count end defp sum([h|t], count) do sum(t, count + h) end end And the execution: ...

June 30, 2016