This file contains hidden or 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
# To use, simply define @__callbacks as a hash where the keys are events | |
# and the values respond to #call (e.g. lambdas, procs, methods) | |
# | |
# This implementation assumes you only have one callback per event, but | |
# you could use an array instead if you wanted | |
module SimpleCallbacks | |
def run_callback(type, *args) | |
@__callbacks[type].call(*args) if @__callbacks.has_key?(type) | |
end | |
end |
This file contains hidden or 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
AllCops: | |
DisabledByDefault: true | |
Style/IndentationConsistency: | |
Enabled: true | |
AutoCorrect: true | |
Style/CommentIndentation: | |
Enabled: true | |
AutoCorrect: true |
This file contains hidden or 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
## | |
# Run syntax checks before pushing | |
# | |
# Installation: | |
# 1. Copy this gist to .git/hooks/pre-push | |
# 2. chmod +x .git/hooks/pre-push | |
# | |
# NOTE: you can also just call `bundle exec rubocop --auto-correct` if you would rather | |
#! /usr/bin/env sh |
This file contains hidden or 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 'method_source' | |
require 'set' | |
def load_environment! | |
load 'config/environment.rb' | |
end | |
BASE_DIR = File.expand_path('../', Dir.pwd) | |
pre_objects = Set.new(ObjectSpace.each_object(Module)) |
This file contains hidden or 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
ag -G '(test|lib)' Backupify::Office365 -l | xargs sed -i '' 's/Backupify::Office365/Office365/g' |
This file contains hidden or 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
while true; do ps -elf |\grep -q 'futex.*assenger.*[R]ack' && curl http://textbelt.com/text -d number=$PHONE_NUMBER -d "message=FUTEX" && break || sleep 30; done |
This file contains hidden or 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
# @example | |
# assert_completed_in 3.seconds do | |
# MyJob.perform | |
# end | |
def assert_completed_in(seconds, message: nil, strategy: :timeout) | |
case strategy | |
when :timeout | |
begin | |
Timeout.timeout(seconds) { yield } | |
rescue Timeout::Error |
This file contains hidden or 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 String | |
def black; "\033[30m#{self}\033[0m" end | |
def red; "\033[31m#{self}\033[0m" end | |
def green; "\033[32m#{self}\033[0m" end | |
def brown; "\033[33m#{self}\033[0m" end | |
def blue; "\033[34m#{self}\033[0m" end | |
def magenta; "\033[35m#{self}\033[0m" end | |
def cyan; "\033[36m#{self}\033[0m" end | |
def gray; "\033[37m#{self}\033[0m" end | |
def bg_black; "\033[40m#{self}\033[0m" end |
This file contains hidden or 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
if ENV['FG_STATS'] | |
at_exit { require 'rubygems'; require 'pry'; binding.pry } | |
end | |
# Normal test helper code w/ Minitest | |
if ENV['FG_STATS'] | |
class TestInefficiencyAnalyzer | |
def initialize(adapter) | |
case adapter |