Skip to content

Instantly share code, notes, and snippets.

View Winslett's full-sized avatar

Christopher Winslett Winslett

View GitHub Profile
@Winslett
Winslett / gist:5010481
Last active December 14, 2015 01:59
Mongoid Sample
production:
sessions:
default:
uri: mongodb://<username>:<password>@<host>:<port>/<database_name>
options:
skip_version_check: true
consistency: :strong
safe: true
max_retries: 30
retry_interval: 1
@Winslett
Winslett / gist:4135972
Created November 23, 2012 14:51
Night Before Christmas
Twas the night before Christmas, when all through the house
Not a creature was stirring, not even a mouse.
The stockings were hung by the chimney with care,
In hopes that St Nicholas soon would be there.
The children were nestled all snug in their beds,
While visions of sugar-plums danced in their heads.
And mamma in her ‘kerchief, and I in my cap,
Had just settled our brains for a long winter’s nap.
@Winslett
Winslett / gist:3130646
Created July 17, 2012 17:13
Ruby - MongoDB Forked Connection Pattern
require 'rubygems'
require 'mongo'
@conn = Mongo::Connection.new("localhost", 27017, :pool_size => 10, :pool_timeout => 5)
@db = @conn['mongomapper_resque_development']
@coll = @db['users']
puts @db.command({getLastError: 1})
1.upto(10) do
@Winslett
Winslett / mongoid.yml
Created June 1, 2012 20:41
MongoHQ & Heroku
heroku config:set MONGOHQ_URL='mongodb://myusername:[email protected]:27017/my_database'
@Winslett
Winslett / gist:1533816
Created December 29, 2011 12:17
Bash Function to Split MySQL Dumps - BSD Split Only
function split_db_dump {
if [ -f $1 ]
then
split -p 'Table structure' $1
for file in x*
do
head -n1 $file | grep -oE '`[^`]+`' | sed 's/`//g' | xargs -n1 -I {} mv $file {}
done
else
echo "File name is required"
@Winslett
Winslett / gist:1255731
Created October 1, 2011 07:34
Engine Yard Backup from RDS
diff -r winslett.ey_cloud_server-1.4.24/lib/ey_backup/cli.rb /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/ey_cloud_server-1.4.24/lib/ey_backup/cli.rb
77a78,81
>
> opts.on("-h", "--host HOSTNAME", "Remote hostname to connect, defaults to local") do |host|
> options[:host] = host
> end
diff -r winslett.ey_cloud_server-1.4.24/lib/ey_backup/engine.rb /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/ey_cloud_server-1.4.24/lib/ey_backup/engine.rb
6c6
< attr_reader :username, :password
---
@Winslett
Winslett / gist:1176330
Created August 28, 2011 06:49
Possible EY Backup Reloading Across Servers
#
# Possible cross-server database restoring of databases by adding the following at line 79 of:
#
# /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/ey_cloud_server-1.4.24/lib/ey_backup/cli.rb
#
# Then, you could run the following:
#
# eybackup -E my_other_environment -D my_local_db_name_if_different --restore 9:mybackedup_database.sql.gz
#
opts.on("-E", "--environment EY_Environment", "Engine Yard Environment.") do |environment|