Skip to content

Instantly share code, notes, and snippets.

View tommeier's full-sized avatar

Tom Meier tommeier

View GitHub Profile
@tommeier
tommeier / deadlocks_spec.rb
Last active August 29, 2015 13:57
Deadlock specs
require 'spec_helper'
describe 'deadlocks' do
describe "on login" do
it 'should allow multiple requests to login at same time' do
# Check original is ok
::Customer.find_by(id: customer_id).should be_blank
forks = []
@tommeier
tommeier / buildkite_start_template
Last active August 29, 2015 14:13
Buildkite start template file
#!/usr/bin/env bash
set -e
echo '--- autostarting buildkite agent'
your-install-location/bin/buildbox-agent \
--token 'your-agent-access-token' \
--name 'your-agent-name' \
your-agent-additional-args
@tommeier
tommeier / boxen-buildkite-puppet.pp
Last active August 29, 2015 14:13
Boxen puppet commands for Buildkite agent install
class people::thing_with_buildbox {
$library_dir = "${home}/Library"
$launch_dir = "${library_dir}/LaunchAgents"
$plist_location = "${launch_dir}/io.buildbox.buildbox-agent.plist"
$buildbox_token = "YOUR_TOKEN"
$buildbox_install_dir = "${home}/.buildbox"
$buildbox_log_dir = "${buildbox_install_dir}/log"
$buildbox_bin_dir = "${buildbox_install_dir}/bin"
$plist_template_url = "https://github.com/buildbox/agent/blob/master/templates/launchd_local_with_gui.plist"
$agent_name = "canary"
#!/usr/bin/env ruby
require 'rubygems'
require 'yaml'
if ARGV.size < 1
puts "Usage: github-test.rb my-project.gemspec"
exit
end
require 'rubygems/specification'
#add this to your ~/.bash_profile and reload teminal
function delete_all_local_branches {
printf "\n\n\n\n== Would you like to delete ALL local branches? \nTHIS ACTION CANNOT BE UNDONE WITHOUT A WIZARDS HAT\nPlease select option (or any key to skip):\n"
echo "1) Delete all - (git branch branch_name -D)"
echo "-) Skip"
read -n1 -s -r -t30 INPUT
case "$INPUT" in
"1")
echo "== Deleting ALL local branches (please wait)..."
git for-each-ref --shell --format="%(refname)" refs/heads | \
class Something
CONSTANT_VALUES = ["Hooray - I have substance!", "Something Else"]
def self.do_something
puts "Constant value = #{Something::CONSTANT_VALUES.inspect}"
puts "Method Value = #{self.apply_something(Something::CONSTANT_VALUES)}"
end
def self.apply_something(values)
value_changed = [*values]
@tommeier
tommeier / Ruby Prof analysis
Created October 14, 2010 02:31
How to use Ruby Prof to analyse method
#Use ruby prof to analyse
require 'ruby-prof'
result = RubyProf.profile do
#Code to analyse in a method
end
# Print a graph profile to text
@tommeier
tommeier / gist:668606
Created November 9, 2010 02:00
Analyse your remote branches in origin (run in a git repo, with remote of origin)
function analyse_remote_branches {
printf "\n\n== Loading remote branches..\n"
git gc --prune=now
git remote prune origin
git for-each-ref --shell --format="%(refname)" refs/remotes/origin | \
while read branch
do
branch_name=${branch/refs\/remotes\/origin\//}
printf "\nRemote Branch : ${branch_name}\n"
result=`git log master..origin/${branch_name//\'/} --pretty=format:" -------> %h | %ar | %an | %s" --abbrev-commit --date-order --decorate -n 4`
@tommeier
tommeier / remove_system_gems.sh
Created February 10, 2011 00:24
Remove all the old crufty system gems
#Uninstall crappy old system gems
function remove_system_gems {
echo "Uninstalling all system gems... This could take a while..."
for x in `gem list --no-versions`; do gem uninstall $x --all --quiet --ignore-dependencies --user-install --executables; done
#TODO : Add check for trailing slash and remove
system_location=$@
if [ "$system_location" == "" ]; then
system_location='/Library/Ruby/Gems/1.8'
fi
folder_names=( 'specifications' 'gems' 'cache' 'doc' 'bundler/gems' )
#Changing an existing (MASSIVE) app from old school rails 2.3.5 land to > 2.3.8 (switching it to 2.3.11) with things like rails_xss can be a nightmare. Mainly because *EVERYTHING* is suddenly html escaped.
#To quickly find EVERY incidence of html escaping where you don't want it, on your views edit your test framework that browses the site
#In this example, the test framework was Webrat, so i (bundle open webrat) found the root method for loading a page response, and scanned the response.body for harmful display items. This will then load the page and print during the tests. In webrat the file is session.rb and "def request_page(url, http_method, data)" is the root method. Webrat 0.7.3
def request_page(url, http_method, data) #:nodoc:
h = headers
h['HTTP_REFERER'] = @current_url if @current_url