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 | |
# | |
# Prints out top 5 contributors per file (as determined by # of commits) on every file in the repository | |
# | |
files = `git ls-files`.lines.map(&:chomp) | |
stats_by_file = {} | |
files.each_with_index do |file, index| |
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 StructThatDisallowsNil | |
def self.new(*args) | |
Struct.new(*args).tap do |klass| | |
klass.prepend Module.new { | |
def initialize(*) | |
super | |
members.each do |member| | |
fail "#{member} cannot be nil" if send(member).nil? | |
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
DisableSettingInverse.disabled = true | |
child = Child.new(parent_id: 12345) | |
parent = Parent.new | |
parent.children = [child] | |
child.parent_id # => 12345 | |
DisableSettingInverse.disabled = false |
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 bash | |
# Show how to check, save, restore the errexit shell option that is commonly set | |
# using "set -e". This is useful for functions that care about non-zero exit statuses | |
# and want to do something because of it such as a retry function. | |
set -eu | |
echo "Shell options: $-" |
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 "optparse" | |
SCRIPT_NAME = File.basename(__FILE__) | |
ARGS_TO_FORWARD = ARGV.dup | |
ARGV.delete_if { |arg| arg !~ /-h|--help/ } | |
OptionParser.new do |opts| |
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 bash | |
# A simple front-end for running git unmerged in a project-specific way. | |
# | |
# ## Options | |
# | |
# -l for local comparing against local branches. The default is to compare against remote branches. | |
# | |
INCLUDE_BRANCH_CONVENTION="rails5/" |
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
source "https://rubygems.org" | |
ruby "~> " + File.read("#{Bundler.root}/.ruby-version").strip | |
require_relative 'dual_boot/bootboot-lite' | |
if ENV['DEPENDENCIES_NEXT'] | |
Bundler.settings.app_cache_path = "vendor/cache-rails_5.0" | |
# Add any gem you want here, they will be loaded only when running |
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 'optparse' | |
require 'shellwords' | |
options = {} | |
OptionParser.new do |opts| | |
opts.banner = "Usage: #{__FILE__} [options]" | |
opts.on("-g", "--gem=GEM") do |gem| |
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 | |
## | |
# ruby load-manual-urls.rb --urls manual-urls.txt | |
# | |
require 'optparse' | |
require 'csv' | |
STDOUT.sync = true |
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 | |
MAX_RETRIES = 4 | |
SLEEP=2 | |
COMMAND=ARGV.join(' ') | |
count = 0 | |
loop do | |
puts "Running: #{COMMAND.inspect}" | |
unless system(COMMAND) |
NewerOlder