Collecting URLs in Erlang

In chapter 16 of the book “Programming Erlang” Software for a Concurrent World” there is an example of reading through a web page and parsing out all of the anchor tags found in it. Here is the meat of the code that I found myself trying to understand for awhile and would now like to explain:

-import(lists, [reverse/1, reverse/2, map/2]).
gather_urls("<a href" ++ T, L) ->
{Url, T1} = collect_url_body(T, reverse("<a href")),
gather_urls(T1, [Url|L]);
gather_urls([_|T], L) ->
gather_urls(T, L);
gather_urls([], L) ->
collect_url_body("</a>" ++ T, L) -> {reverse(L, "</a>"), T};
collect_url_body([H|T], L) -> collect_url_body(T, [H|L]);
collect_url_body([], _) -> {[],[]}.

Burgess and Cummings Falls Adventure

Went out to the Burgess and Cummings Falls state parks this weekend. What an amazing set of parks that are fairly close together. Very excited to go back in the summer for some in-water action!

Cosmos Javascript

If you’ve been following my blog you’ll notice a spacy, cosmos background with little stars floating about. I saw this effect on another website and had to replicate it for myself! There isn’t too much going on, but I did enjoy building it. For anyone curious about the source; here is a repo created to help tool it out: Cosmos.

Kerl - Installing Erlang Easier

Installing Erlang has been somewhat of a pain. When trying to make sure I have the version I want, relying on the ppa has not been that great. Thankfully someone has shared with me an amazing tool, kerl.

Endless River Is Here!

I have been a huge Pink Floyd fan for most of my life, and I was pretty happy to hear when the new album “Endless River” was coming out. I decided to pre-order my collectors copy a couple months ago and since it showed up on my doorstep it has been playing non-stop.

Ruby Refactoring: Array#reduce and Default Variables


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:

resources# [
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.