Skip to content

Instantly share code, notes, and snippets.

@obfuscurity
obfuscurity / gist:1096433
Created July 21, 2011 03:25
Goodbye irb, hello pry.
pry(main)> @foo = []
=> []
pry(main)> show-doc @foo.index
From: array.c in Ruby Core (C Method):
Number of lines: 14
signature: index(*)
@obfuscurity
obfuscurity / gist:1409152
Created November 30, 2011 14:00
Rakefile for blog post
# Rakefile
namespace :db do
require "sequel"
namespace :migrate do
Sequel.extension :migration
DB = Sequel.connect(ENV['DATABASE_URL'])
desc "Perform migration reset (full erase and migration up)"
task :reset do
@obfuscurity
obfuscurity / gist:1409163
Created November 30, 2011 14:03
001_BaseSchema.rb for blog post
# migrations/001_BaseSchema.rb
Sequel.migration do
up do
create_table(:accounts) do
primary_key :id
String :name, :size => 50, :null => false
TrueClass :enabled, :null => false, :default => false
DateTime :created_at, :null => false
DateTime :updated_at, :null => false
@obfuscurity
obfuscurity / gist:1409167
Created November 30, 2011 14:04
002_AddForeignKeys.rb for blog post
# migrations/002_AddForeignKeys.rb
Sequel.migration do
up do
alter_table(:accounts) do
add_foreign_key(:owner_id, :users)
end
end
down do
@obfuscurity
obfuscurity / gist:1409169
Created November 30, 2011 14:04
003_BootstrapAccount.rb for blog post
# migrations/003_BootstrapAccount.rb
Sequel.migration do
up do
timestamp = Time.now
self[:users].insert(
:username => "admin@foobar.com",
:password => "$2a$10$BpKGMuwioxQrfvkS0HPglOq3hTf1tvhY6KDdaFe3UynbxsvHTzDTm",
:api_token => "87bdbcb0-fb92-012e-a61c-109addaa2672",
@obfuscurity
obfuscurity / gist:1409393
Created November 30, 2011 15:11
Migration run for blog post
$ heroku config:add VERSION=2
Adding config vars and restarting app... done, v7
VERSION => 2
$ heroku run rake db:migrate:to
Running rake db:migrate:to attached to terminal... up, run.2
(in /app)
<= sq:migrate:to version=[2] executed
$ heroku run rake db:migrate:down
@obfuscurity
obfuscurity / migrate.rb
Created August 2, 2012 15:15 — forked from pcreux/migrate.rb
Migrate from Heroku Shared DB to Postgres `dev` Plan
#!/usr/bin/env ruby
#
# This script migrates your Heroku app from a Shared DB to a Postgres `dev` Plan
#
# Usage:
# ruby migrate.rb [app_name]
#
def usage
puts "migrate.rb [app_name]"
@obfuscurity
obfuscurity / gist:3707081
Created September 12, 2012 14:40 — forked from soffes/gist:3428401
Recruiter Reply
Thank you for your inquiry.
I am only looking for contract work. My rate is one thousand dollars an hour ($1,000/hr). I charge ten thousand dollars ($10,000) for referrals.
If this does not fit the positions you are looking for, please remove me from your list. I will also not refer someone else in my place.
Thanks,
Jason
import os
import os.path
import sys
from graphite.render.hashing import ConsistentHashRing
instances = []
unwelcome_instances = []
for arg in sys.argv[1:]:
unwelcome = False