Skip to content

Instantly share code, notes, and snippets.

Design Problem

I'm struggling to balance encapsulation with managing side effects in a specific scenario described here.

Classes

  • PriceSettings < ActiveRecord::Base (side-effect-based class methods, value-based instances) stores user parameters for price calculations
  • APIClient (adapter object) fetches statistics from an external API to use in price calculations
@katiebuilds
katiebuilds / ruby_test_suite_song.txt
Last active December 10, 2015 01:01
"If We Had A Test Suite" to the tune of "If I Were A Rich Man"
“If I Were a Rich Man” “If We Had a Test Suite”
Original by Katie
(lyrics from http://www.stlyrics.com/lyrics/fiddlerontheroof/ifiwerearichman.htm)
[TEVYE] [TURNER]
"Dear God, you made many, many poor people. Dear team, we wrote lots and lots of crufty code.
I realize, of course, that it's no shame to be poor. I realize, of course, that everyone writes some hacks.
But it's no great honor either! But it’s not great practice either!
So, what would have been so terrible if I had a small fortune?" So, what would have been so terrible if we’d refactored a bit?
@mislav
mislav / git-recently-checkout-branches.sh
Created November 19, 2015 15:35
Show list of recently checked-out branches in reverse-chronological order
#!/bin/bash
set -e
git reflog -n100 --pretty='%cr|%gs' --grep-reflog='checkout: moving' HEAD | {
seen=":"
git_dir="$(git rev-parse --git-dir)"
while read line; do
date="${line%%|*}"
branch="${line##* }"
if ! [[ $seen == *:"${branch}":* ]]; then
@gesellix
gesellix / screen-stuff.md
Created May 1, 2016 22:39
screen and Docker for Mac
screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty



screen -AmdS docker ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
screen -r docker
# enter, then disconnect with Ctrl-a d
screen -S docker -p 0 -X stuff $(printf root\\r\\n)
screen -r docker