Skip to content

Instantly share code, notes, and snippets.

View vanpelt's full-sized avatar
pro

Chris Van Pelt vanpelt

pro
View GitHub Profile
@vanpelt
vanpelt / mongostat.txt
Created June 12, 2012 22:53
Couple minutes of mongostat during outage today.
vanpelt@mongo0-builder:~$ mongostat
connected to: 127.0.0.1
insert query update delete getmore command flushes mapped vsize res faults locked % idx miss % qr|qw ar|aw netIn netOut conn set repl time
4 20 95 0 8 24 0 153g 158g 4.74g 256 10 0 19|29 20|29 21k 54k 500 dlabs M 22:48:59
5 19 188 0 8 25 0 153g 158g 4.73g 241 4.7 0 14|16 19|16 38k 58k 497 dlabs M 22:49:00
6 24 205 0 10 33 0 153g 158g 4.73g 273 10.6 0 19|10 20|10 67k 146k 497 dlabs M 22:49:01
4 11 121 0 2 16 0 153g 158g 4.73g 173 17.1 0 11|15 18|16 24k 37k 497 dlabs M 22:49:02
3 17 61 0 6 27 0 153g 158g 4.74g 196 10.4 0 20|19 21|19 14k 33k 497 dlabs M 22:49:0
@vanpelt
vanpelt / virtual_hat.rb
Created April 12, 2012 18:11
Virtual Hat
require 'pp'
@candidates = {
"Joseph Childress" => 7,
"Brian Reavey" => 6,
"Vaughn Hester" => 10,
"Lukas Biewald" => 1
}
def pick_winner
pool = @candidates.map do |name, quarters|
[name] * quarters
@vanpelt
vanpelt / Gemfile
Created December 8, 2011 23:01
sample crowdflower webhook endpoint
source :rubygems
gem "sinatra"
gem "json"
@vanpelt
vanpelt / gist:1436817
Created December 6, 2011 04:58
payload.json
{"updated_at":"2011-12-05T22:33:01+00:00","data":{"city":"Lower Sackville","address":"409 Glendale Dr","title":"5 or 10 Passes to Group Exercise Classes at Sackville Sports Stadium (Up to 52% Off)","url":"http://groupon.com/deals/sackville-sports-stadium","merchant_name":"Sackville Sports Stadium","business_location_id":"312838"},"created_at":"2011-11-30T04:19:24+00:00","missed_count":0,"agreement":0.757009345794392,"state":"finalized","difficulty":0,"results":{"source_phone_correct":{"agg":"yes","confidence":0.68349326903365},"corrected_phone":{"agg":"(902) 869-4141","confidence":0.68349326903365},"judgments":[{"data":{"source_phone_correct":"yes","_clicks":["http://www.google.com/search?q=Sackville+Sports+Stadium+Lower+Sackville"],"corrected_phone":"(902) 869-4141"},"rejected":null,"trust":1.0,"unit_id":115484258,"webhook_sent_at":null,"created_at":"2011-11-30T04:59:07+00:00","unit_state":"finalized","region":"WA","country":"USA","worker_trust":0.972385620915033,"worker_id":4749840,"external_type":"prodege"
tender+c24e3bd6eed71a9d9f0f47d503ec0aff2ecad7c2a@tenderapp.com
@vanpelt
vanpelt / universe.rb
Created May 6, 2011 23:45
The Universe... in Ruby
class Matter
attr_accessor :position, :mass
def initialize(position, mass)
@position = position
@mass = mass
end
def <=> other_matter
@distance <=> other_matter.distance
end
@vanpelt
vanpelt / bulk_insert.rb
Created March 29, 2011 20:18
Allows us to do bulk inserts with Postgres
class BulkInsert
class InvalidModel < Exception; end
def initialize(model)
@model = model
@records = []
end
def add_record(record)
raise InvalidModel.new("#{record.class} must be a #{@model}") unless record.is_a?(@model)
@vanpelt
vanpelt / features.rb
Created January 5, 2011 07:46
Simple ruby module to make rolling out features easy...
module Features
def self.allowed?(feature, user)
case redis.get(key(feature))
when "admin": user.admin
when "diy": user.admin || user.diy
when "enterprise": user.admin || !user.diy
when "all": true
when /^\d+$/: user.admin || user.id % state.to_i == 0
else
false

#Tools Engineer

CrowdFlower is funded, growing, and, frankly, where the action is at in San Francisco. As our client base continues to grow, we need you to make sure their projects go smoothly.

Skills that are a must

Startup: You're able to learn quickly, design creative solutions, and work independently.

People: As a tools engineer you’ll work with lots of people—both technical and non-technical.

class FakeApp < Sinatra::Base
set :raise_errors, false
set :show_exceptions, false
set :dump_errors, false
#set :logging, true
post '/start' do
secret_key = "your secret"
payload = JSON.parse(params[:payload])
if(Digest::SHA1.hexdigest(params[:payload]+secret_key) == params[:signature])