Skip to content

Instantly share code, notes, and snippets.

Elliot Winkler mcmire

View GitHub Profile
@mcmire
mcmire / super_diff_81.md
Last active May 15, 2020
super_diff #81
View super_diff_81.md

Let's say you have this test:

expected = {
  created_at: "Tue Jan 13 19:28:24 +0000 2009",
  favourites_count: 38,
  geo_enabled: false,
  verified: true,
  media_count: 51_044,
  statuses_count: 273_860,
@mcmire
mcmire / 00_README.md
Last active Feb 29, 2020
Installation and uninstallation scripts for dotfiles
View 00_README.md

This gist provides scripts that you can use to install files inside of a dotfiles repo into your home directory and uninstall them if you wish. To use these, download the zip file of this gist and unzip it into the bin folder of your dotfiles repo. Then run chmod +x bin/install bin/uninstall. After this, run:

bin/install --help
bin/uninstall --help
@mcmire
mcmire / active_record_persistence_instrumenter.rb
Created Oct 23, 2019
Produces a tree of ActiveRecord + Fabrication calls
View active_record_persistence_instrumenter.rb
# This file allows to you to debug use of fabricators in tests by producing a hierarchical tree of
# objects created via ActiveRecord and Fabrication.
#
# Place this at spec/support/active_record_persistence_instrumenter.rb.
#
module PersistenceInstrumenter
class Tree
def initialize
@stack = []
@children = []
@mcmire
mcmire / graphql.md
Last active Aug 29, 2019
Guide to GraphQL
View graphql.md

A Guide to GraphQL

We use GraphQL to implement APIs across our tech stack, particularly as a protocol for communication between a backend app and frontend app.

[REST][rest] is a mainstay in the API world; its concepts are more or less integrated into Rails, Django, Symfony, and other modern web frameworks. But GraphQL, which was developed and released by Facebook in 2015, offers a fundamentally different approach.

@mcmire
mcmire / 00_README.md
Last active Jul 11, 2019
validate_not_nil matcher (sketch)
View 00_README.md

You can use this matcher like so:

RSpec.describe User, type: :model do
  it { is_expected.to validate_not_nil(:favorite_numbers) }
end
@mcmire
mcmire / package.json
Created Dec 18, 2018
TypeScript configuration
View package.json
{
...,
"dependencies": {
"typescript": "^3.2.2"
},
"devDependencies": {
"tslint": "^5.11.0",
"typescript-tslint-plugin": "^0.2.1"
}
}
@mcmire
mcmire / checksum.sh
Created Jul 12, 2018
Calculate a checksum of multiple directories
View checksum.sh
#!/bin/bash
set -euo pipefail
uname=$(uname)
checksum() {
if [[ $uname == 'Darwin' ]]; then
md5 -r
else
@mcmire
mcmire / have_row.rb
Created May 4, 2018
Table matchers for RSpec
View have_row.rb
module FeatureSpecs
def have_row(expected_row)
HaveRowMatcher.new(self, expected_row)
end
class HaveRowMatcher
def initialize(context, expected_row)
@context = context
@expected_row = expected_row
end
@mcmire
mcmire / bypass_broken_images_middleware.rb
Last active Sep 18, 2018
Ignore requests for broken images in Capybara tests
View bypass_broken_images_middleware.rb
# Instructions
# ------------
#
# * Save this as app/middlewares/bypass_broken_images_middleware.rb
# * Add the following inside of the Rails.application.configure block
# in config/environments/test.rb:
#
# config.middleware.insert_before(
#  ActionDispatch::DebugExceptions,
#  BypassBrokenImagesMiddleware,
@mcmire
mcmire / time_zones.txt
Created Mar 22, 2017
Time zone identifiers in Rails
View time_zones.txt
[1] pry(main)> ActiveSupport::TimeZone.us_zones.map { |zone| puts "#{zone.name.inspect} => #{zone.tzinfo.name.inspect} (#{zone.utc_offset / 3600} from UTC)" }; nil
"Hawaii" => "Pacific/Honolulu" (-10 from UTC)
"Alaska" => "America/Juneau" (-9 from UTC)
"Pacific Time (US & Canada)" => "America/Los_Angeles" (-8 from UTC)
"Arizona" => "America/Phoenix" (-7 from UTC)
"Mountain Time (US & Canada)" => "America/Denver" (-7 from UTC)
"Central Time (US & Canada)" => "America/Chicago" (-6 from UTC)
"Eastern Time (US & Canada)" => "America/New_York" (-5 from UTC)
"Indiana (East)" => "America/Indiana/Indianapolis" (-5 from UTC)
You can’t perform that action at this time.