Skip to content

Instantly share code, notes, and snippets.

Elliot Winkler mcmire

Block or report user

Report or block mcmire

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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)
@mcmire
mcmire / .eslintrc.yml
Last active Jan 9, 2019
My ESLint configuration
View .eslintrc.yml
---
env:
browser: true
node: true
es6: true
extends: eslint:recommended
globals:
module: true
require: true
parserOptions:
@mcmire
mcmire / _css_overrides.html.erb
Created Nov 11, 2016
Disable transitions and animations in tests
View _css_overrides.html.erb
<% if Rails.env.test? %>
<style type="text/css">
* {
transition-duration: 0s !important;
animation-duration: 0s !important;
}
</style>
<% end %>
@mcmire
mcmire / have_body_including.rb
Created Nov 2, 2016
Matcher for testing an email's body using Markdown
View have_body_including.rb
# You'll need to install the `reverse_markdown` gem in order for this to work.
module Matchers
def have_body_including(expected_inner_body)
HaveBodyIncludingMatcher.new(expected_inner_body)
end
class HaveBodyIncludingMatcher
def initialize(expected_inner_body)
@expected_inner_body = expected_inner_body.rstrip.gsub(\s+/, "")
@mcmire
mcmire / .rubocop.yml
Last active Oct 2, 2018
My Rubocop settings
View .rubocop.yml
---
AllCops:
Exclude:
- db/schema.rb
TargetRubyVersion: 2.5
Layout/AlignParameters:
EnforcedStyle: with_fixed_indentation
Layout/ClassStructure:
Enabled: true
Layout/DotPosition:
You can’t perform that action at this time.