Skip to content

Instantly share code, notes, and snippets.

View ryw's full-sized avatar

Ry Walker ryw

View GitHub Profile
#######################
# Example Usage:
#######################
#
# mailbox = BadMailProcessor::Pop3.new(server, username, password)
# BadMailProcessor.run(mailbox) do |bounce|
# User.bounce(bounce[:email_address])
# my_action2
# end
#
@ryw
ryw / bathroom.rb
Created February 21, 2012 23:19 — forked from st23am/urinal_etiquette.rb
Test Problem
class Bathroom
# door is on the right
def initialize(params)
@stalls = params[:stalls]
@stall_ratings = rate_stalls
@line = params[:line]
end
def find_stall
@ryw
ryw / Engagment.io sample javascript
Created July 22, 2012 19:08
Sample Engagement.io javascript implementation code
<script type="text/javascript">
var _eioq = _eioq || [];
_eioq.push(['setApp', 'dfX4Xnqt3P2xpsaxqhKM']);
_eioq.push(['setUser', '[email protected]']);
_eioq.push(['trackEvent', 'visit']);
(function() {
var eio = document.createElement('script'); eio.type = 'text/javascript';
eio.src = 'http://app.engagement.io/eio.js') %>';
@ryw
ryw / gist:3792029
Created September 27, 2012 03:35
today is yesterday
$ bundle exec rake
.F.F.FFFFFF..F.................................
Failures:
1) Cohort::Query should do basic queries
Failure/Error: c["events"]["signed_up"].should == {"count" => 3}
expected: {"count"=>3}
got: {"people"=>{}, "count"=>0} (using ==)
@ryw
ryw / gist:3792038
Created September 27, 2012 03:39
with Date.current rather than Date.today
..F.....FF..
Failures:
1) Cohort::Query should calculate subfunnels
Failure/Error: c["Null"]["active_weeks"].should == ["week_0", "week_1"]
expected: ["week_0", "week_1"]
got: ["week_-1", "week_0"] (using ==)
# ./spec/models/cohort_query_spec.rb:57:in `block (2 levels) in <top (required)>'
@ryw
ryw / gist:3814014
Created October 1, 2012 19:47
Restore production Mongo data to dev & staging
namespace :db do
namespace :sync do
desc "Copy production database to local"
task :dev => :environment do
puts "Dumping production..."
system "mongodump -h #{ENV['PRODUCTION_MONGOHQ_DOMAIN']}:#{ENV['PRODUCTION_MONGOHQ_PORT']} -d #{ENV['PRODUCTION_MONGOHQ_DATABASE']} -u #{ENV['PRODUCTION_MONGOHQ_USER']} -p#{ENV['PRODUCTION_MONGOHQ_PASSWORD']} -o db/backups/"
puts "Restoring production to development..."
system "mongorestore -h localhost --drop -d crowdhall_web_v1_development db/backups/#{ENV['PRODUCTION_MONGOHQ_DATABASE']}/"
@ryw
ryw / gist:3814026
Created October 1, 2012 19:49
error on sync
Mon Oct 1 15:13:02 Creating index: { key: { _id: 1 }, ns: "crowdhall_v1_staging.categories", name: "_id_" }
Mon Oct 1 15:13:02 Assertion: 13111:field not found, expected type 2
0x10036b5fb 0x10009a81e 0x10009ac4c 0x1000098c2 0x100011b87 0x100018622 0x100016944 0x100019e54 0x100313b5d 0x100315697 0x10000126a 0x1000011e4
0 mongorestore 0x000000010036b5fb _ZN5mongo15printStackTraceERSo + 43
1 mongorestore 0x000000010009a81e _ZN5mongo11msgassertedEiPKc + 206
2 mongorestore 0x000000010009ac4c _ZN5mongo11msgassertedEiRKSs + 12
3 mongorestore 0x00000001000098c2 _ZNK5mongo11BSONElement3chkEi + 466
4 mongorestore 0x0000000100011b87 _ZN7Restore11createIndexEN5mongo7BSONObjEb + 2711
5 mongorestore 0x0000000100018622 _ZN7Restore9drillDownEN5boost11filesystem210basic_pathISsNS1_11path_traitsEEEbbb + 9906
6 mongorestore 0x0000000100016944 _
@ryw
ryw / modulus meteor deploy
Created July 18, 2013 00:26
My hacky script to deploy to Modulus
#!/bin/bash
# let's start fresh
rm -rf .demeteorized
rm /tmp/newfile
# run + cd
demeteorizer
cd .demeteorized
@ryw
ryw / Cincinnati Hackathon
Last active December 20, 2015 00:59
Collaborate on Cincinnati Hackathon
Hackathon
Principles:
* For fun, not profit
Potential Themes:
* Open data related http://data.cincinnati.com/navigator/search.aspx
@ryw
ryw / publication.coffee
Created February 5, 2014 16:14
Meteor aggregation
Meteor.publishAggregation = (params) ->
initializing = true
dummy = Random.id()
pub = params.handle
collection = params.collection
handle = collection.find(params.filter, params.options).observeChanges
added: (id, fields) ->
if !initializing
pub.changed(params.name, dummy, collection.aggregate(params.pipeline)[0])