Skip to content

Instantly share code, notes, and snippets.

namespace :db do
task :pivot => :environment do
schema = Mongoid::Config.master[:schema_info]
pivots = Dir[File.join('db', 'pivots', '*.rb')]
previous_pivots = schema.find.map {|p| p['file']}
pivots_to_run = (pivots - previous_pivots).sort
@chrislloyd
chrislloyd / malfunction
Created November 30, 2011 03:59
malfunction
all for the best - thom yorke
feels like ecstasy - 65daysofstatic
evan spring - plaid
szerencsétlen - venetian snares
known(1) - autechre
sweet love for planet earth - fuck buttons
it's guy time (i don't mind) - 65daysofstatic
the end - enduser
down - drumcorps
skip divided (modselektor remix) - thom yorke
task1.hs:43:22:
Could not deduce (a ~ Query)
from the context (Data a)
bound by a type expected by the context: Data a => a -> a
at task1.hs:(42,14)-(44,22)
`a' is a rigid type variable bound by
a type expected by the context: Data a => a -> a at task1.hs:42:14
In the expression: a
In a case alternative: (SNot (SNot a)) -> a
In the expression:
require 'benchmark'
require 'redis'
require 'digest/md5'
n = 10000
redis = Redis.new
Benchmark.bm do |bm|
bm.report do
n.times { Digest::MD5.hexdigest 'christopher.lloyd@gmail.com' }
eg1 = ['not', ['nor', ['var', 'a'], ['var', 'c']]]
eg2 = ['nor', ['nor', ['var', 'a'], ['var', 'b']], ['var', 'a']]
eg3 = ['not', ['nor', ['var', 'a'], ['var', 'b']]]
findVars = (q) ->
switch q[0]
when 'nor'
# Intersect these two vals
findVars(q[1]) + findVars(q[2])
when 'not' then findVars(q[1])

So why is the asset pipeline awesome?

  1. Works on Heroku. Also, Cedar is awesome.
  2. Minifies/gzips assets in production, leaves them raw in dev.
  3. gem 'backbone-rails' and in your application.js.coffee #= require backbone. Bam!
@chrislloyd
chrislloyd / heroku-switch.sh
Created July 23, 2011 14:06
Switch Heroku accounts
heroku-switch() {
cd $HOME/.heroku
ln -fs $1.credentials credentials
}
require 'logger'
class String
LOGGER = Logger.new($stderr)
def -@; LOGGER.info self; end
end
# Extracted earlier, hardcoded for speed
ENTITIES = %w(I-ORG O I-MISC I-PER I-LOC B-LOC B-MISC MO B-ORG)
#!/usr/bin/env macruby
framework 'cocoa'
loop do
puts NSWorkspace.sharedWorkspace.activeApplication['NSApplicationPath']
sleep 1
end
#!/usr/bin/env ruby
# gem install colored
require 'colored'
features = []
Dir['{rec.sport.hockey,talk.politics.guns}/*'].each do |filename|
puts "Extracting features for #{filename.blue.bold}"
begin