Skip to content

Instantly share code, notes, and snippets.

View pedro's full-sized avatar

Pedro Belo pedro

  • San Francisco, CA
  • X @ped
View GitHub Profile
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/sinatra/lib'
require 'sinatra'
Sinatra::Application.default_options.merge!(
:run => false,
:env => :development # ENV['RACK_ENV']
)
require File.dirname(__FILE__) + '/../app/mailer.rb'
class UsersController ...
def create
@user = User.create(params[:user])
Notifier.deliver_activation(@user)
redirect_to :controller => :dashboard
rescue Exception => e
logger.error e
...
end
end
require File.dirname(__FILE__) + "/../app/mailer.rb"
set_option :run, false
set_option :env, ENV['APP_ENV'] || :development
run Sinatra.application
diff --git a/app/models/hot_slug.rb b/app/models/hot_slug.rb
index 9798a94..93718c0 100644
--- a/app/models/hot_slug.rb
+++ b/app/models/hot_slug.rb
@@ -8,7 +8,14 @@ class HotSlug < ActiveRecord::Base
end
def railgun_slug
- RestClient::Resource.new("http://#{instance.local_ip}:1000/slugs/#{slug}", 'core', 'ASL938i54lDfU')
+ RestClient::Resource.new("http://#{instance.local_ip}:1000/slugs/#{slug}", :user => 'core', :password => 'ASL938i54lDfU', :headers => environment)
# APP_ROOT/config/rackup.ru
require File.dirname(__FILE__) + "/../myapp"
set_option :run, false
set_option :env, :production
disable :reload
run Sinatra.application
@pedro
pedro / *scratch*
Created December 18, 2008 21:04 — forked from bmizerany/*scratch*
remote = Rush::Box.new('root@ec2-75-101-233-253.compute-1.amazonaws.com')
remote.bash("ls")
require 'sinatra'
require 'builder'
def home
content_type 'text/xml', :charset => 'utf-8'
builder do |xml|
xml.instruct!
xml.Response do
xml.Gather("numDigits" => "1", "action" => "press", "method" => "POST") do
xml.Say "For a good time, press 1"
class Post < Sequel::Model
one_to_many :taggings
many_to_many :tags, :join_table => :taggings
end
class Tag < Sequel::Model
one_to_many :taggings
end
class Tagging < Sequel::Model
describe 'Bacon and Mocha sucks together' do
it "sucks when you have a spec using only mocha, not bacon, to assert something" do
str = 'a'
str.expects(:size)
str.size
end
end
# this raises Bacon::Error: empty specification
# after spending 20 minutes trying to fix I decided to just add
var sys = require('sys'),
http = require('http'),
spawn = require('child_process').spawn
// this is a simple proxy
http.createServer(function(req, res) {
// and here is the problem: if I try to do any IO before
// proxying (like making another request or spawning) it
// freezes the whole thing.