Skip to content

Instantly share code, notes, and snippets.

View tbuehlmann's full-sized avatar

Tobias Bühlmann tbuehlmann

View GitHub Profile
require 'rubygems'
require 'em-websocket'
require 'sinatra/base'
require 'thin'
class App < Sinatra::Base
get '/' do
return "foo"
end
end
LocalJumpError: no block given (yield)
$ torquebox list
rack_app.war
Descriptor: /home/tobias/src/torquebox-3.0.2/jboss/standalone/deployments/rack_app.war-knob.yml
Status: deployed
(Satellite::Application.config.database_configuration['development']['pool'] + 1).times do
Thread.new do
Thread.abort_on_exception = true
ActiveRecord::Base.connection
sleep
end
end
# => 26
# [2] pry(main)> Error: could not obtain a database connection within 5.000 seconds (waited 5.000 seconds)
class RegistrationsController < ApplicationController
before_filter :authenticate_athlete!, :only => [:new, :create]
def new
@race = Race.find(params[:race_id])
@registration = @race.registrations.new
end
def create
@race = Race.find(params[:race_id])
# app/models/list.rb
class List < AR::Base
has_many :list_tasks
has_many :tasks, through: :list_tasks
end
# app/models/task.rb
class Task < AR::Base
has_many :list_tasks
has_many :lists, through: :list_tasks
# ps -ef | grep nginx
root 10334 1 0 08:55 ? 00:00:00 [nginx]
root 10448 1 0 09:07 ? 00:00:00 [nginx]
root 10666 1 99 09:18 ? 00:21:58 (nginx)
root 10799 10762 0 09:40 pts/1 00:00:00 grep --color=auto nginx
# app/controllers/packages_controller.rb
class PackagesController < ApplicationController
def index
# ...
end
def show
# ...
end
[1] pry(main)> PushNotification.last.relevant_app_instances
PushNotification Load (2.2ms) SELECT "notifications".* FROM "notifications" WHERE "notifications"."type" IN ('PushNotification') ORDER BY "notifications"."id" DESC LIMIT 1
AppInstance Load (1.2ms) SELECT "app_instances".* FROM "app_instances" INNER JOIN "apps" ON "app_instances"."app_id" = "apps"."id" INNER JOIN "app_bundles" ON "apps"."app_bundle_id" = "app_bundles"."id" INNER JOIN "app_bundle_notifications" ON "app_bundles"."id" = "app_bundle_notifications"."app_bundle_id" WHERE "app_bundle_notifications"."notification_id" = $1 AND "app_instances"."app_id" IN (SELECT "apps"."id" FROM "apps" INNER JOIN "app_bundles" ON "apps"."app_bundle_id" = "app_bundles"."id" INNER JOIN "app_bundle_notifications" ON "app_bundles"."id" = "app_bundle_notifications"."app_bundle_id" WHERE "app_bundle_notifications"."notification_id" = $1 AND "apps"."type" IN ('AndroidApp', 'IosApp')) [["notification_id", 2], ["notification_id", 2]]
PG::ProtocolViolation: E
require 'bunny'
connection = Bunny.new
connection.start
channel = connection.create_channel
exchange = channel.default_exchange
puts channel.queues.keys.inspect # []