Skip to content

Instantly share code, notes, and snippets.

@gotascii
gotascii / simple_deployer.rb
Created March 22, 2011 14:46
cc.rb auto-deployer
# This plugin will deploy your app using capistrano.
# If the build fails the app won't de be deployed and if it passes it will try to deploy to a list of stages you can supply.
#
# Configuration
# In your project's cruise_config.rb file:
#
# Pass an array of stages you want to deploy to
# project.cap_deployer.stages = ['integration', 'staging']
#
# source ~/.rvm/scripts/rvm before deployment?
@gotascii
gotascii / campfire.rb
Created March 22, 2011 15:00
cap recipe to notify campfire on deploy
require 'uri'
require 'tinder'
class Campfire
attr_reader :config
def initialize(config)
@config = config
end
@gotascii
gotascii / rrt
Created April 14, 2011 18:01
command-line rails test runner
#!/usr/bin/env ruby
def run_testunit(runner, path)
path = path.gsub(/\/?test\/?/, '')
path.gsub!(/_test.rb/, '')
exec "#{runner} -I'test' test/#{path}_test.rb"
end
def run_unit(runner)
run_testunit runner, "unit/#{ARGV[1]}"
@gotascii
gotascii / stubs.js
Created April 25, 2011 11:37
simple node stubs
stubs = []
module.exports =
stub: (obj, name, fun) ->
stubs.push({'obj':obj, 'name':name, 'fun':obj[name]})
obj[name] = if fun? then fun else ->
unstub: ->
for stubbed in stubs
stubbed.obj[stubbed.name] = stubbed.fun
stubs.length = 0
@gotascii
gotascii / quiz.js
Created April 28, 2011 12:39
javascript quiz question
function House() {
this.vandalize = function() {
this.vandalized = true;
}
}
function Punk() {
this.onParty = function(handler) {
this.handler = handler;
}
@gotascii
gotascii / hrm.rb
Created February 10, 2012 20:06
Hm
next unless delivery_message =
begin
Message.find_by_id(message.id)
rescue SecurityContextException => ex
logger.warn{ "message_broadcaster Could not load message #{message.id} for user #{subscription.user.id}" }
end
if subscription.client.delivery_appropriate?(delivery_message)
# logger.debug{ "SENDING mid: #{message.id} to uid:#{subscription.client.user_id} client_id:#{subscription.client}" }
subscription.client.deliver_message(delivery_message)
else
let mapleader = ","
call pathogen#infect("~/.vim/langs")
call pathogen#infect()
""
"" File types
""
" Some file types should wrap their text
irb(main):009:0> GC.enable_stats
=> false
irb(main):013:0> GC.clear_stats
=> nil
irb(main):014:0> n.ar_users.select("id").find_in_batches(:batch_size => 1000) {|u| u }
=> nil
irb(main):015:0> GC.allocated_size
=> 902823508
irb(main):016:0> ObjectSpace.allocated_objects
=> 104920800
def cats(user_id, network_id)
email = "bob#{user_id}_#{network_id}@weird.com"
n = Network.find_or_create_by_email(email)
mu = MetaUser.find_or_create_by_email(email)
User.create do |u|
u.id = user_id
u.network = n
u.meta_user = mu
end
end
[
{
"type": "exception",
"time": "2011-09-12T21:33:12Z"
},
{
"type": "exception",
"time": "2011-09-12T21:35:12Z"
}
]