Skip to content

Instantly share code, notes, and snippets.


Joël Quenneville JoelQ

  • Thoughtbot
  • Boston
View GitHub Profile
JoelQ / hamming_benchmark_classic.rb
Created Jun 29, 2018
Hamming Benchmark - Classic
View hamming_benchmark_classic.rb
class Hamming
def self.eager(s1, s2)
count { |c1, c2| c1 != c2 }
def self.half_lazy(s1, s2)
JoelQ / hamming_benchmark_take.rb
Created Jun 29, 2018
Hamming Lazy/Eager benchmarks
View hamming_benchmark_take.rb
class Hamming
def self.eager(s1, s2)
count { |c1, c2| c1 != c2 }
def self.half_lazy_args(s1, s2)
JoelQ /
Created Jun 20, 2018
Edges to different groups


You have a graph where the nodes are in groups. You want to create edges between all nodes that are in different groups.

For example, given the following groups:

[[1, 2], [3], [4, 5]]
JoelQ / MapZero.elm
Created May 30, 2018
A look at mapN functions in Elm. The `map0` function is just the constructor function! Haskell folks would call this pure/return.
View MapZero.elm
-- Maybe
map2 f v1 v2 = Just f |> andMap v1 |> andMap v2
map f v1 = Just f |> andMap v1
map0 f = Just f
-- List
map2 f v1 v2 = singleton f |> andMap v1 |> andMap v2
map f v1 = singleton f |> andMap v1
JoelQ / Folding.elm
Created Mar 20, 2018
Folding a list is like replacing the cons and empty constructors
View Folding.elm
type MyList a
= Cons a (MyList a)
| Empty
add : Int -> Int -> Int
add a b =
a + b
JoelQ /
Created Feb 9, 2018
Refactoring a pipeline of functions in Elm

Refactoring maybe code in Elm

Given this ugly series of cases:

optionalFormattedFriendAddress : Maybe Friend -> Maybe String
optionalFormattedFriendAddress maybeFriend =
    maybeAddress = case maybeFriend of
      Just friend -> Just friend.address

A Darwinian Nightmare

It seemed to have stepped right out of the pages of a horror novel. The mutant shape-shifter struck without warning, defying a mere mortal's attempts to detect it. It seemed to distort the fabric of reality itself. And it was going to ruin my job interview.

We've all encountered this monster at some point. Like many classic monsters, it is our own creation. Every year it devastate projects worldwide. The fearsome mutation bug is an expert at hiding and altering your programs in subtle and

JoelQ / empty_list.rb
Created Jan 18, 2018
Linked-list (cons list) implementation in Ruby
View empty_list.rb
class EmptyList
def prepend(value), self)
def inspect
def map(&block)
JoelQ /
Last active Jan 12, 2018
Attempted solution to the square-sum challenge

Square-Sum Challenge

Write out the numbers 1-15 such that any two numbers in the series add up to a square number

Inspired by

Possible squares

There are 6 possible squares that can be made by adding two numbers under 16: