🏳️⚧️
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--skip-action-mailer | |
--skip-action-mailbox | |
--skip-action-text | |
--skip-active-job | |
--skip-active-storage | |
--skip-action-cable | |
--skip-jbuilder | |
--skip-bootsnap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec::Matchers.define :notify_bugsnag do |error = nil, message = nil| | |
supports_block_expectations | |
match do |block| | |
if error | |
expect(Bugsnag).to receive(:notify).with(instance_of(error)) | |
else | |
expect(Bugsnag).to receive(:notify) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Foo | |
def foo | |
blah | |
end | |
private def blah | |
"foo" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "json" | |
require "net/http" | |
require "uri" | |
# The standard library Net::HTTP module is a bit convoluted, but here is an example of a flexible | |
# system for making different kinds of HTTP requests. To see some convenience methods you can | |
# consult the docs: https://ruby-doc.org/stdlib-2.5.5/libdoc/net/http/rdoc/Net/HTTP.html | |
class HttpConnection | |
def get(url, params = nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def beep(a, b) | |
result = "" | |
result += a.to_s | |
if a && b | |
result += " and " | |
end | |
result += b.to_s | |
end | |
puts beep("foo", "bar") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Expectation | |
def to(matcher = nil, &block) | |
if block_given? | |
puts "block passed to `to` method" | |
yield | |
end | |
end | |
end | |
def expect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "time" | |
p now = Time.parse("2020-08-07") | |
p date = Time.parse("2013-08-07") | |
delta, _ = (now.to_i - date.to_i).divmod(24 * 60 * 60) | |
years, rest = delta.divmod(365) | |
months, days = rest.divmod(30) | |
puts "years: #{years}" | |
puts "months: #{months}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "psych" | |
require "pry" | |
# Handler for detecting scalar values | |
class YayHandler < Psych::Handler | |
# States: | |
# a -> start_map -> b | |
# b -> scalar -> c (push key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash --login | |
# Select only staged Ruby files, this may be expanded to other file types if necessary. | |
FILES="$(git diff --cached --name-only --diff-filter=AMC | grep -E "\.(erb|rake|rb)$" | tr '\n' ' ')" | |
# Check for ruby style errors | |
if [ -n "$FILES" ]; then | |
bundle exec rubocop --force-exclusion --format=simple ${FILES} | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
ci = "!source ~/.githelpers && fuzzy_checkout" |
NewerOlder