Skip to content

Instantly share code, notes, and snippets.

View jacobo's full-sized avatar

Jacob Burkhart jacobo

  • HOVER
  • San Francisco, CA
View GitHub Profile
@jacobo
jacobo / gist:5391690
Created April 15, 2013 22:10
debugging in the console
class SimpleViz
def initialize(app, &lookup)
@app = app
end
def call(env)
puts caller
request = Rack::Request.new(env)
puts "-> #{request.request_method.upcase} (#{request.url})"
status, headers, body = @app.call(env)
puts "<--#{status}-- #{body.size}"
ERROR: no command given
Usage: test_worker <command> <options> -- <application options>
* where <command> is one of:
start start an instance of the application
stop stop all instances of the application
restart stop all instances and restart them afterwards
run start the application and stay on top
zap set the application to a stopped state
class TrapLoop
trap('TERM') { stop! }
trap('INT') { stop! }
trap('SIGTERM') { stop! }
def self.stop!
@loop = false
end
def self.safe_exit_point!
@jacobo
jacobo / gist:5166690
Created March 15, 2013 00:59
confused by sleep
require 'celluloid'
class DiCaprio
include Celluloid
def do_a_thing
puts "starting"
`sleep 1`
puts "finished"
end
@jacobo
jacobo / hax_background_jobs_with_celluloid.ru
Last active December 14, 2015 23:29
Example of running background jobs after request by spawning a thread using Celluloid
#Save this file as hax_background_jobs_with_celluloid.ru
#In one terminal run: rackup hax_background_jobs_with_celluloid.ru
#In another run: curl -v localhost:9292
require 'celluloid'
class CleverMailSender
class Sender
include Celluloid
def send_email(email)
@jacobo
jacobo / hax_background_jobs_with_threads.ru
Last active December 14, 2015 23:29
Example of running background jobs after request by spawning a thread
#Save this file as hax_background_jobs_with_threads.ru
#In one terminal run: rackup hax_background_jobs_with_threads.ru
#In another run: curl -v localhost:9292
class CleverMailSender
def self.send_email(email)
Thread.new do
puts "sending e-mail: #{email}"
5.times{|x| puts x; sleep 0.5}
puts "sent"
@jacobo
jacobo / hax_background_jobs_in_unicorn.ru
Created March 14, 2013 19:03
Example of running background jobs in unicorn without needing a separate background job processor (or spawning threads)
#Save this file as hax_background_jobs_in_unicorn.ru
#In one terminal run: unicorn hax_background_jobs_in_unicorn.ru
#In another run: curl -v localhost:8080
class CleverMailSender
class << self; attr_accessor :emails_to_send; end
self.emails_to_send = []
class BodyProxy
def initialize(body)
@body = body
@jacobo
jacobo / hax_background_jobs_in_thin.ru
Created March 14, 2013 19:01
Example of running background jobs in thin without needing a separate background job processor (or spawning threads)
#Save this file as hax_background_jobs_in_thin.ru
#In one terminal run: thin start --rackup hax_background_jobs_in_thin.ru
#In another run: curl -v localhost:3000
class CleverMailSender
class << self; attr_accessor :emails_to_send; end
self.emails_to_send = []
def initialize(app)
@app = app
end
Adambräu
Lindemans Framboise
Harpoon Raspberry UFO
Sam Adams Boston Lager (but only at Fenway Park)
Cuvée des Jacobins
Allagash White
Schneider Aventinus
Smithwick's
La Chouffe
Magic Hat Circus Boy
@jacobo
jacobo / gist:4163419
Created November 28, 2012 19:18
Talks

Bio

Jacob is the world's foremost expert on (within the subset of people who: work in Ruby for a living, surf the Pacific regularly, and brew sour beers). He does all these things in San Francisco California, while working at Engine Yard.



title