Skip to content

Instantly share code, notes, and snippets.

View bdurand's full-sized avatar

Brian Durand bdurand

  • San Francisco, CA
View GitHub Profile
#!/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
@bdurand
bdurand / git_cleanup_alias
Created September 6, 2018 20:51
Git Cleanup Alias
[alias]
cleanup = "!git branch --merged master | grep -v '\\*\\|master\\|develop\\|deploy\\|release\\|staging\\|sprint' | xargs -n 1 git branch -d"
@bdurand
bdurand / row_lock_test_output.txt
Created October 18, 2012 17:10
ActiveRecord Row Lock Test Output
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
@bdurand
bdurand / counter_cache_test.rb
Created October 13, 2012 17:45
Demonstrate counter_cache/destroy callback race condition
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?