Skip to content

Instantly share code, notes, and snippets.

Avatar

Christopher Dwan radixhound

  • Self
  • Burnaby, BC, Canada
View GitHub Profile
View extended.log
---
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
---
View mongo_auth.rb
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
@radixhound
radixhound / authorization.rb
Created Jul 1, 2011
example of situation where our code blows up with mysql2 'connection is still waiting for a result' errors
View authorization.rb
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
@radixhound
radixhound / em_mysql2_adapter.rb
Created Jun 22, 2011
mysql2 error where the connection is still waiting for a result.
View em_mysql2_adapter.rb
##
# 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 / herokulog
Created Jun 15, 2011
heroku mysql2 gem fail
View herokulog
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 / dispatch_worker.rb
Created Jun 3, 2011
EM::HttpRequest is blowing up here
View dispatch_worker.rb
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 / curlrequest.sh
Created May 16, 2011
posting multipart form to goliath
View curlrequest.sh
curl http://localhost:9000/photos -X POST -F "photo=@yummyfood01.jpg"
You can’t perform that action at this time.