Skip to content

Instantly share code, notes, and snippets.

Avatar

Joël Quenneville JoelQ

  • Thoughtbot
  • Boston
View GitHub Profile
@JoelQ
JoelQ / ellie_examples.md
Last active Jul 28, 2021
List of helpful Ellie's I've written
View ellie_examples.md
@JoelQ
JoelQ / list-pattern-matching-elm.md
Last active Oct 29, 2020
What does `x :: xs` pattern matching mean in Elm?
View list-pattern-matching-elm.md

What does x :: xs pattern matching mean in Elm?

:: is the list prepend operator in Elm.

3 :: 2 :: 1 :: []

is equivalent to

View MUTATION-NOTES.md

Mutation in Ruby

Mutation-related bugs are some of the most common in the Ruby world. Joël and German explore many of the gotchas related to mutation, how to avoid them, and discuss when mutation might not be necessary at all.

Mutation vs Reassignment

In mutation, the value of an object changes but its identity remains the same:

View THOUGHTBOT_RUBY.md

Thoughtbot's Approach to Ruby

We've been writing Ruby for years on lots of different projects and in many different environments. This has led to thoughtbot's Ruby style to be somewhat different to the rest of the community's. In particular, we tend to focus on a sub-set of Ruby's features. Derek and Joël some of those differences and the reasoning behind them.

Style guide: https://github.com/thoughtbot/guides

@JoelQ
JoelQ / RandomToTask.elm
Last active Sep 30, 2021
Turn an Elm random generator into task, allowing it to be chained with other side effects.
View RandomToTask.elm
-- 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
View suggestion.elm
delay : Time -> a -> Cmd a
delay t x =
Task.perform (always x) <| Process.sleep t
cmd : msg -> Cmd msg
cmd msg =
Task.perform (always msg) (Task.succeed msg)
initSeed = 100
@JoelQ
JoelQ / ENUM.md
Created Aug 4, 2017
Proposed Weekly Iteration on Enums with examples in Elm
View ENUM.md

Weekly Iteration - Enums

Outline

  • Intro
  • Describe Enums as a concept
  • Look some Enum refactorings in Elm
  • Enums vs strings
  • Compare with Enums in other languages (Swift, C)
  • Discuss mapping to numbers
@JoelQ
JoelQ / NEWTYPE.md
Last active Oct 5, 2017
Wrapping primitives in custom types in Elm
View NEWTYPE.md

Domain-Specific Types in Elm

Compilers are powerful helpers but they can only do so much with primitives. Joël and Stephanie fix a bug by introducing domain-specific types. Learn about how these encode real-world context, what are the downsides, and how some functional programming concepts can make those downsides go away.

Primitive Obsession

Previously discussed, don't depend too heavily on low-level constructs.

Dangerous

@JoelQ
JoelQ / PRIMITIVE_OBSESSION.md
Last active Sep 14, 2017
Weekly Iteration - Primitive Obsession
View PRIMITIVE_OBSESSION.md

Weekly Iteration - Primitive Obsession

Our languages give us great tools in the form of primitives: things like integers, strings, and arrays. However, over-relying on these leads to problems. This practice even has it's own fancy code smell name: Primitive Obssession. In this video, Derek and Joël take a look at Primitive Obsession and the various abstraction tools languages provide to deal with it.

What does it look like in Ruby?

Over relying on hashes/arrays

Representing dollars/cents as an two-element array:

@JoelQ
JoelQ / MUTATION.md
Last active Jul 14, 2017
Proposed Weekly Iteration on mutation in Ruby
View MUTATION.md

Weekly Iteration - Mutation

Outline

  • Intro
  • Explain mutation vs re-assignment
  • Discuss Gotchas
    • Mutating a value in a list
    • Array constructor
    • Hash constructor