Skip to content

Instantly share code, notes, and snippets.

@JoelQ
JoelQ / 10-blog-posts.md
Last active July 29, 2025 00:06
This History of Rails in 10 Blog posts

The History of Rails in 10 Blog Posts

Here are the notes for my RailsConf 2025 talk The History of Rails in 10 Blog Posts (video, slides)

Calling nostalgic veterans and newbies alike! We’re traveling through time on a tour of some of the most influential blog posts to hit the Rails community over the past two decades. With stops at iconic locations including in testing, service objects, and JavaScript, you won't want to miss it! Bring your chrono-passport and see you in 2003!

List of Articles

  1. FatModel, Skinny Controller - Foundational, refined what MVC means in the context of Rails
  2. Waiting for a Factory Girl - Changed the way the Rails community writes tests to this day

How not to implement a multi-step form

"That ticket touches the wizard code? Why don't YOU take that one". The wizard in question is so gnarly my colleagues are afraid to touch it.

Looking at the code through the lens of conditional cardinality reveals what went wrong and how we can make things better. This mental model will change the way you think about structuring logic and help you take your conditional code from scary to delightful.

Description

This talk is aimed at an intermediate to advanced audience. While it will driven by a practical example (refactoring a multi-step form), it will mainly be about some more theoretical principles and mental models for structuring conditional code.

@JoelQ
JoelQ / elm-types-glossary.md
Last active March 30, 2025 21:26
Elm Type Glossary

Elm Types Glossary

There's a lot of type terminology and jargon going around when discussing types in Elm. This glossary attempts to list some of the most common type terms along with synonyms, terms from other language communities, examples, and links to more detailed articles on each topic.

@JoelQ
JoelQ / fibonnacci.rb
Created February 4, 2025 01:18
Recursive cached fibonnacci
fib = Hash.new do |hash, n|
puts "calculating fib #{n}"
# base case
if n == 0 || n == 1
hash[n] = 1
else
# recursive case
hash[n] = hash[n - 1] + hash[n - 2]
end
@JoelQ
JoelQ / anamorphism.rb
Created January 2, 2025 19:19
Attempting to implement an anamorphism in Ruby to generate a series of squares
# This imagines `.unfold` to be an alternate constructor for `Enumerator` that's
# more complex than `.produce` but not as custom as the full `.new`. It follows the rules
# of anamorphisms (at least for arrays, not sure if this genericises to other structures)
class CustomEnumerator
def self.unfold(seed, &block)
Enumerator.new do |yielder|
loop do
seed, value = block.call(seed)
raise StopIteration if value.nil?
@JoelQ
JoelQ / dollar.rb
Last active September 23, 2024 03:02
Implementing value object semantics as an RSpec shared_example.
class Dollar
attr_reader :cents
def initialize(cents:)
@cents = cents
end
def hash
[self.class, cents].hash
end
@JoelQ
JoelQ / month.rb
Last active September 2, 2024 18:44
require "date"
class Month
include Comparable
MONTHS_PER_YEAR = 12
def self.from_date(date)
self.from_parts(date.year, date.month)
end
@JoelQ
JoelQ / tree_enumerator.rb
Created August 21, 2022 22:15
Demonstration of how using `Enumerator` makes it nicer to work with a data structure that has multiple valid traversals such as a binary tree
class Tree
attr_reader :val, :left, :right
def self.empty
EmptyTree.new
end
def self.leaf(val)
new(val, empty, empty)
end
@JoelQ
JoelQ / RandomToTask.elm
Last active July 27, 2024 09:23
Turn an Elm random generator into task, allowing it to be chained with other side effects.
-- 0.19
randomToTask : Generator a -> Task x a
randomToTask generator =
Time.now
|> Task.map (Tuple.first << Random.step generator << Random.initialSeed << Time.posixToMillis)
-- 0.18
@JoelQ
JoelQ / tally.rb
Last active April 13, 2024 16:27
Demonstration of using a rich object to represent a composite count and how it makes the math easier to deal with
class Tally
def self.empty
new({})
end
def initialize(raw)
@raw = empty_hash.merge raw.slice(:small, :medium, :large)
end
# Accessors