Skip to content

Instantly share code, notes, and snippets.

@pat
pat / webmock_json_helpers.rb
Created December 14, 2021 06:52
Helpers for stubbing JSON requests with Webmock
# frozen_string_literal: true
require "delegate"
require "webmock/rspec"
module WebmockJSONHelpers
def stub_request(method, uri)
RequestStub.new(super)
end
@eborden
eborden / cheesecake.md
Last active January 15, 2021 02:57
My Mom's South Philly Cheesecake

Story

My Mother worked as a special needs teacher at Saint Catherine's school in Philadelphia. She became friends with a parent of two autistic twins. This mother was South Philly in every way. Big hair, big attitude, larger than life. She shared this recipe with my mother and it has been a staple in our household.

Ingredients

  • 1 lb cream cheese
  • 1 lb ricotta cheese
  • 6 eggs
@eebs
eebs / sql_statement_profiling.rb
Created December 17, 2019 21:29
spec/support/sql_statement_profiling.rb
RSpec.configure do |config|
example_sql_counts = Hash.new(0)
config.around(:example) do |procsy|
sql_count = 0
callback = ->(*args) { sql_count +=1 }
ActiveSupport::Notifications.subscribed(callback, "sql.active_record") do
procsy.call
end
@radar
radar / Exam.md
Last active August 7, 2018 02:20

JEP Exam Rubric

  • Gemfile entries
    • rubocop (under development)
    • rspec-rails (under development + test)
    • devise (outside of any group)
    • mongoid (outside of any group)
  • Generated Mongoid configuration present at config/mongoid.yml
  • Rubocop rules pass
  • db/seeds.rb
    • Creates a book
@chrismccord
chrismccord / upgrade.md
Last active April 7, 2023 12:03
Phoenix 1.2.x to 1.3.0 Upgrade Instructions

If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8

To use the new phx.new project generator, you can install the archive with the following command:

$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez

Bump your phoenix dep

Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs:

@pdougall1
pdougall1 / gist:a8b1206758aab172509c
Created November 9, 2015 00:24
refactoring flow
╔═════════════════╗ ┌─────┐ ╔═══════════════════╗
║ ║ │ YES │ ║ Make the intended ║
───────▶║ Is it open? ╠──┴─────┴──────▶║ change. ║
▲ ║ ║ ▲ ║ ║
│ ╚═════════╦═══════╝ │ ╚═══════════════════╝
│ │ │
│ ┌────┤ │
│ │ NO │ │
│ └────┤ │
│ │ │
@elle
elle / 2015-poodnyc-notes.md
Last active September 12, 2021 11:05
Notes from Poodnyc 2015 workshop

Rules for Horizontal Refactoring

  • If you go red, undo
  • Only change one line at a time
  1. Find two strings that are the most alike
  2. Find the smallest difference
  3. Make the smallest change that make the tests pass

How to make a small change

@pdougall1
pdougall1 / gist:e79fee71e3997fe13f09
Last active November 3, 2015 20:16
POODR class notes (day 2)

Code smells, get really good at code smell (brown bag)

All you have to know is the codes smells

make a million new things > mutate objects

Forwardable (delegation)

Don't go on a virtical tangent, instead tiptoe away and finish the horizontal refactor

@pdougall1
pdougall1 / gist:451e723c59c44e45e02a
Last active November 3, 2015 20:16
POODR class notes

Notes and observations

  • The next one to prove the first is wrong
  • Choose a name inline with the concept in the domain.
    • Good OO code names concepts, not worried about implementation
  • Terseness is cleverness (not goodness), stop picking on each other for being simple.
  • Smallest change you can make to prove the last test insuficient.
  • Solve the easy problems first, then maybe the hard ones become easy.
  • DRY is good, but sometimes duplication makes sense, if it passes the inebriation test, check it in and walk away
  • Open/Close Add new features without adding new code
  • lean on the green
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do