Skip to content

Instantly share code, notes, and snippets.

saimonmoore / gist:1883590
Created Feb 22, 2012
Clear out your dev db (with protection from #epicfailure)
View gist:1883590
function cleardb {
DEVDB="`ruby -e "require 'yaml'; puts YAML.load('config/database.yml'))['development']['database']"`"
if [[ $DEVDB =~ "production" ]]; then
echo 'WATCHOUT! cleardb running against production dump';
bundle exec rake db:drop db:create db:schema:load db:seed && bundle exec rake db:test:clone;
technoweenie / heartbeat.rb
Created Feb 21, 2012
heartbeat actor w/ celluloid
View heartbeat.rb
require 'rbczmq'
require 'fileutils'
require 'celluloid'
class Heartbeat
include Celluloid
def self.start(id = nil, options = nil)
new(, id, options)
technoweenie / .gitignore
Created Feb 20, 2012
quick kestrel zeromq port attempt
View .gitignore
jnx /
Created Oct 1, 2011
rbenv install and system wide install on Ubuntu 10.04 LTS.
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone git:// /usr/local/rbenv
# Add rbenv to the path:
rtomayko / optparse-template.rb
Last active Jan 19, 2020
Ruby optparse template
View optparse-template.rb
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
View gist:1062178
vagrant@lucid32:~$ sudo su postgres
postgres@lucid32:/home/vagrant$ psql
psql (8.4.8)
Type "help" for help.
postgres=# SELECT * FROM pg_user;
usename | usesysid | usecreatedb | usesuper | usecatupd | passwd | valuntil | useconfig
postgres | 10 | t | t | t | ******** | |
rails | 16385 | t | t | t | ******** | |
Overbryd /
Created Jun 22, 2011
Hacking Club Mate "imatate"

Hacking Club Mate "imatate"

Read about the end result here

Join me when I start brewing my first batch of Club Mate. Inspired by a podcast from chaos radio express on the topic "Hackerbrausen" (Hacker's soda, listen here) I want to try this by myself.

So far I have bought all the necessary ingrediends and tools to get started. And with the help from Jan (@janl) I can even carbonate the end result :)

When? Where?

View include_anonymous.rb
# Include an anonymous module
# Useful for defining a class with a base module. So, instead of:
# class Foo
# module Base
# def bar
# # ...
# end
# end
mnutt / Instrument Anything in Rails
Created Sep 6, 2010
How to use Rails 3.0's new notification system to inject custom log events
View Instrument Anything in Rails

Instrument Anything in Rails 3

With Rails 3.0 released a few weeks ago I've migrated a few apps and I'm constantly finding useful new improvements. One such improvement is the ability to log anything in the same way that Rails internally logs ActiveRecord and ActionView. By default Rails 3 logs look slightly spiffier than those produced by Rails 2.3: (notice the second line has been cleaned up)

Started GET "/" for at Mon Sep 06 01:07:11 -0400 2010
  Processing by HomeController#index as HTML
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
Rendered layouts/_nav.html.erb (363.4ms)
mislav / template-uri.rb
Created Sep 27, 2009
URI templates are, like, super-useful
View template-uri.rb
require 'addressable/template'
template = 'http://{}' +
'/statuses/followers{-prefix|/|id}.{format=json}' +
template.expand(:id => 'mislav')
# =>