Skip to content

Instantly share code, notes, and snippets.

View radixhound's full-sized avatar

Christopher Dwan radixhound

  • Self
  • Burnaby, BC, Canada
View GitHub Profile
@radixhound
radixhound / curlrequest.sh
Created May 16, 2011 17:05
posting multipart form to goliath
curl http://localhost:9000/photos -X POST -F "[email protected]"
@radixhound
radixhound / dispatch_worker.rb
Created June 3, 2011 22:13
EM::HttpRequest is blowing up here
def queue
@json_headers = { "Content-Type" => 'application/json', 'Accept' => 'application/json'}
if ::EM.reactor_running?
# EM.synchrony do #start a new fiber...
req = EM::HttpRequest.new(@@dispatcher_url)
puts "dispatching worker #{@body}"
req.apost({:head=>@json_headers, :body=>JSON.generate(@body)})
req.callback do
puts "dispatch worker - success!!"
@radixhound
radixhound / herokulog
Created June 15, 2011 23:50
heroku mysql2 gem fail
Can't install mysql2 gem..
Using mysql2 (0.3.3) from https://github.com/brianmario/mysql2.git (at master) with native extensions /usr/local/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/usr/local/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
@radixhound
radixhound / em_mysql2_adapter.rb
Created June 22, 2011 16:40
mysql2 error where the connection is still waiting for a result.
##
# added output to test the state at query and result
#
def query(sql, opts={})
puts "#{Time.now.to_f}\t#{Fiber.current.object_id}\tQUERY: #{sql}"
if ::EM.reactor_running?
super(sql, opts.merge(:async => true))
deferrable = ::EM::DefaultDeferrable.new
@radixhound
radixhound / authorization.rb
Created July 1, 2011 07:30
example of situation where our code blows up with mysql2 'connection is still waiting for a result' errors
class Authorization < Goliath::Synchrony::MongoReceiver
include Goliath::Validation
include Goliath::Rack::Validator
# time period to aggregate stats over, in seconds
class MissingApikeyError < BadRequestError ; end
class DatabaseSaveError < BadRequestError ; end
class RateLimitExceededError < ForbiddenError ; end
class UserIDMismatchError < UnauthorizedError ; end
class MongoAuth
include Goliath::Rack::AsyncMiddleware
include Goliath::Validation
include Goliath::Rack::Validator
class MissingApikeyError < BadRequestError ; end
class DatabaseSaveError < BadRequestError ; end
class RateLimitExceededError < ForbiddenError ; end
class UserIDMismatchError < UnauthorizedError ; end
---
Pre-Process - my Fiber is 2166354320
---
CHECKING USER - my Fiber is 2166354320
Querying on fiber 2166354320
callback chain?
auth is back
WOOT NO ERROR - 2174548140
ABOUT TO SAVE - my Fiber is 2174548140
---
module SecretKey
protected
def fix_plumbing(*args)
_fix_plumbing(*args) if defined?(:_fix_plumbing)
end
def twist_knob
_twist_knob if defined?(:_twist_knob)
end