Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
LOOKING INTENTLY INTO THE VOID

Daniel Schierbeck dasch

💭
LOOKING INTENTLY INTO THE VOID
View GitHub Profile
@dasch
dasch / faster_helper.rb
Created Jan 25, 2012 — forked from dnagir/faster_helper.rb
The spec helper I use to run faster specs
View faster_helper.rb
ENV["RAILS_ENV"] ||= 'test'
cur_dir = File.expand_path(File.dirname(__FILE__) + '/..')
$LOAD_PATH << "#{cur_dir}"
if defined? Bundler
# Most likely going with the full env
require 'spec_helper'
else
$LOAD_PATH << "#{cur_dir}/app/models"
@dasch
dasch / gist:1130665
Created Aug 7, 2011 — forked from dkubb/gist:1130086
case with predicates
View gist:1130665
require 'rubygems'
require 'backports' # aliases Proc#=== to Proc#call
rs = (0..10000).to_a.sample(30)
rs.each do |r|
case r
when lambda { |n| n.zero? } then puts "#{r} is zero"
when lambda { |n| (n % 5).zero? } then puts "#{r} is fiven"
when lambda { |n| (n % 4).zero? } then puts "#{r} is fourven"
View compl1.rb
# compl1.rb - Redis autocomplete example
# download female-names.txt from http://antirez.com/misc/female-names.txt
require 'rubygems'
require 'redis'
r = Redis.new
# Create the completion sorted set
if !r.exists(:compl)
@dasch
dasch / compl1.rb
Created Sep 10, 2010 — forked from antirez/compl1.rb
Redis auto-completion
View compl1.rb
# compl1.rb - Redis autocomplete example
# download female-names.txt from http://antirez.com/misc/female-names.txt
require 'rubygems'
require 'redis'
r = Redis.new
# Create the completion sorted set
if !r.exists(:compl)
View database.yml
test:
adapter: sqlite3
database: ":memory:"