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
#!/usr/bin/env ruby | |
require 'bundler' | |
require 'benchmark' | |
REGEXPS = [ | |
/^no such file to load -- (.+)$/i, | |
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i, | |
/^Missing API definition file in (.+)$/i, | |
/^cannot load such file -- (.+)$/i, |
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 'rubygems' | |
require 'active_record' | |
ActiveRecord::Base.establish_connection("adapter" => "sqlite3", "database" => ":memory:") | |
class Widget < ActiveRecord::Base | |
connection.create_table table_name do |t| | |
t.string :name | |
t.integer :thing_count | |
end unless table_exists? |
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 'rubygems' | |
require 'active_record' | |
require 'logger' | |
# Run as `ruby row_lock_test.rb [mysql|postgresql]` to see current Rails behavior when two processes | |
# try to destroy a record at the same time. | |
# | |
# Run as `ruby row_lock_test.rb [mysql|postgresql] patch` to see the behavior desired in pull request | |
# https://github.com/rails/rails/pull/7965 | |
# |
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
Current ActiveRecord code: | |
Selector Thread reports shared record exists | |
Thread 1 (0.8ms) BEGIN | |
Thread 1 running before_destroy callback | |
Thread 2 (0.6ms) BEGIN | |
Thread 2 running before_destroy callback | |
Selector Thread reports shared record exists | |
Thread 1 running before_destroy callback | |
Thread 2 running before_destroy callback |
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
#!/bin/bash | |
# This script can be used as a git pre-push hook to guard against accidentally | |
# pushing to remote branches that may have special meaning and trigger other | |
# behavior. If you try to push to one of these branches, you will be prompted | |
# to confirm that is what you really meant to do. | |
set -o errexit | |
# set -o xtrace |
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
#!/usr/bin/env ruby | |
# This script will handle refreshing your local git repository and merging in | |
# the latest changes from a remote branch on origin and then syncing the local | |
# branch back to origin (if applicable). | |
# | |
# This can be useful for such things as keeping your Pull Request branches in | |
# sync with the latest changes to master. | |
# | |
# Usage: `merge_branch [options] source [destination] |
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
[alias] | |
cleanup = "!git branch --merged master | grep -v '\\*\\|master\\|develop\\|deploy\\|release\\|staging\\|sprint' | xargs -n 1 git branch -d" |
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
#!/bin/sh | |
if [ "$2" == "" ]; then | |
>&2 echo "Usage: $0 backup|restore volume_name" | |
exit 1 | |
fi | |
if [ "$1" == "backup" ]; then | |
docker run -it --rm -v $2:/volume -v `pwd`:/backup alpine tar -cjf /backup/$2.tar.bz2 -C /volume ./ | |
elif [ "$1" == "restore" ]; then |
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
#!/bin/bash | |
# Run rubocop with automatic fixes on any new or modified git files | |
set -o errexit | |
# set -o xtrace | |
changed_files=`git diff --cached --name-only --diff-filter=ACM | grep -e '\.rb$' | cat` | |
if [ "$changed_files" != "" ]; then | |
ruby_version=`cat .ruby-version | tr -d '[:space:]'` |
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
#!/bin/bash | |
# Strip trailing whitespace from modified code files in git. | |
set -o errexit | |
# set -o xtrace | |
git diff --cached --name-only --diff-filter=ACM | egrep -e '\.(rb|js|css|scss|erb|html)$' | xargs sed -i '' -E 's/[[:space:]]+$//' |
OlderNewer