Skip to content

Instantly share code, notes, and snippets.


Toby Hede tobyhede

Block or report user

Report or block tobyhede

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View To Tap or Not To Tap.rb
app.users.find_by!(:identifier => identifier).tap do |user|
user = app.users.find_by!(:identifier => identifier)
tobyhede / gist:5914924
Created Jul 3, 2013
Coffeescript super argument ordering. See the snake.
View gist:5914924
class Animal
constructor: (@name) ->
move: (meters, direction = "north") ->
console.log @name + " moved #{direction} #{meters}m."
class Snake extends Animal
move: (direction = "south", meters = 5) ->
console.log "Slithering..."
super meters, direction
tobyhede / gist:5753979
Created Jun 11, 2013
vagrant chef reset
View gist:5753979
/usr/bin/vagrant destroy --force
yes | knife client delete {NODE_NAME}
yes | knife node delete {NODE_NAME}
/usr/bin/vagrant up
knife bootstrap localhost --node-name {NODE_NAME} --ssh-user vagrant --ssh-password vagrant --ssh-port 2222 --sudo
/usr/bin/vagrant provision
tobyhede / gist:5562556
Created May 12, 2013
STDOUT: STDERR: update-rc.d: /etc/init.d/postgresql-9.2: file does not exist
View gist:5562556
Recipe: postgresql::server_debian
* package[postgresql-9.2] action install[2013-05-12T07:44:03+02:00] INFO: Processing package[postgresql-9.2] action install (postgresql::server_debian line 26)
[2013-05-12T07:44:03+02:00] DEBUG: package[postgresql-9.2] checking package status for postgresql-9.2
Installed: 9.2.4-0ppa1~lucid
Candidate: 9.2.4-0ppa1~lucid
Version table:
*** 9.2.4-0ppa1~lucid 0
500 lucid/main Packages
100 /var/lib/dpkg/status
tobyhede /
Created Jan 20, 2013
Capture and restore Heroku Database to Local
heroku pgbackups:capture
curl -o latest.dump `heroku pgbackups:url`
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump
tobyhede / reset_pg_sequence
Created Jan 2, 2013
Reset PG sequence to max value
View reset_pg_sequence
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));
# 0. Make sure you have Ruby 1.9.3 installed, and optionally RVM and PostgreSQL
# 0.2 If you are on the Mac, make sure you have a c compiler by installing XCode Command Line Tools or gcc4.2 with homebrew
# 0.5 Make sure you have bundler version ~> 1.2 as Rails depends on it
gem install bundler
# 1. Get edge Rails source (master branch)
git clone

list tables

SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' ORDER BY table_name ASC

list column names

SELECT column_name FROM information_schema.columns WHERE table_name ='training_contracts' ORDER BY column_name ASC;
tobyhede / gist:3890243
Last active Oct 11, 2015
Dump and restore postgres to remote server
View gist:3890243
Pipe directly to remote server
pg_dump -C -U dbuser {DBNAME} | psql -h -U {DBUSER} >> restore.log
And with passwords as required
PGPASSWORD="{DBPASSWORD}" pg_dump -C -U dbuser {DBNAME} | PGPASSWORD="{DBPASSWORD}" psql -h -U {DBUSER} >> restore.log
You can’t perform that action at this time.