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
tobyhede / gist:3179978
Created Jul 26, 2012
Ruby/Rails date format cheat sheet
View gist:3179978
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%e - Day of the month without leading 0 (1..31)
%g - Year in YY (00-99)
tobyhede / postsql.sql
Created May 17, 2012
PostgreSQL as JSON Document Store
View postsql.sql
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8
-- Inspired by
-- JSON Types need to be mapped into corresponding PG types


Short present tense imperative phrase, less than 50 characters, like a git commit message.


proposed, accepted, rejected, deprecated, superseded, etc.


What is the issue that we're seeing that is motivating this decision or change.


Keybase proof

I hereby claim:

  • I am tobyhede on github.
  • I am tobyhede ( on keybase.
  • I have a public key whose fingerprint is 9AA8 2B2E D31F EC90 2F24 7373 0678 0493 F70A EDB6

To claim this, I am signing this object:

tobyhede / generate_tseries.sql
Created Jun 25, 2016
Easily generate timeseries data in PostgreSQL
View generate_tseries.sql
SELECT ts, (random()*9999)::int as count from generate_series(
'1 sec'::interval
) date;
tobyhede / tap.rb
Last active Jan 2, 2016
To tap or not to tap ...
View tap.rb
#assuming a method returning an account
Account.where(email: email).first_or_create.tap do |account|
account.update_attributes!(name: name, login: login, image: image)
account = Account.where(email: email).first_or_create
account.update_attributes!(name: name, login: login, image: image)
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
You can’t perform that action at this time.