Skip to content

Instantly share code, notes, and snippets.

View svenfuchs's full-sized avatar

Sven Fuchs svenfuchs

View GitHub Profile
@mislav
mislav / template-uri.rb
Created September 27, 2009 15:31
URI templates are, like, super-useful
# https://github.com/sporkmonger/addressable/
require 'addressable/template'
# http://dev.twitter.com/doc/get/statuses/followers
template = Addressable::Template.new 'http://{host=twitter.com}' +
'/statuses/followers{-prefix|/|id}.{format=json}' +
'?{-join|&|user_id,screen_name,cursor}'
template.expand(:id => 'mislav')
# => http://twitter.com/statuses/followers/mislav.json?
# Include an anonymous module
#
# Useful for defining a class with a base module. So, instead of:
#
# class Foo
# module Base
# def bar
# # ...
# end
# end
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 | ******** | |
@technoweenie
technoweenie / .gitignore
Created February 20, 2012 04:55
quick kestrel zeromq port attempt
node_modules
@technoweenie
technoweenie / heartbeat.rb
Created February 21, 2012 01:59
heartbeat actor w/ celluloid
require 'rbczmq'
require 'fileutils'
require 'celluloid'
class Heartbeat
include Celluloid
def self.start(id = nil, options = nil)
new(ZMQ::Context.new, id, options)
end
@saimonmoore
saimonmoore / gist:1883590
Created February 22, 2012 09:29
Clear out your dev db (with protection from #epicfailure)
function cleardb {
DEVDB="`ruby -e "require 'yaml'; puts YAML.load(File.open('config/database.yml'))['development']['database']"`"
if [[ $DEVDB =~ "production" ]]; then
echo 'WATCHOUT! cleardb running against production dump';
else
bundle exec rake db:drop db:create db:schema:load db:seed && bundle exec rake db:test:clone;
fi
}
# Save this in an empty directory as Vagrantfile and run:
#
# gem install vagrant
# vagrant up
# vagrant ssh
#
# You need to have a recent VirtualBox installed.
Vagrant::Config.run do |config|
config.vm.box = "travis-ruby"
config.vm.box_url = "http://files.travis-ci.org/boxes/provisioned/travis-ruby.box"
  • Strings
  • Arrays
  • Hashes
  • Classes
  • Conditionals (if)
  • Conditional (case)
  • Modules (for mixins)
  • Namespaces
  • requiring
  • Gems
@svenfuchs
svenfuchs / gist:5364262
Last active December 16, 2015 02:39
Travis CI Office

The Travis CI office

How to get to the Travis CI office: http://goo.gl/maps/vmidH

The address is Prinzessinnenstrasse 20, on the left driveway: