Skip to content

Instantly share code, notes, and snippets.

Pedro Belo pedro

Block or report user

Report or block pedro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View rackup.ru
$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'
View rescue_all_mailer_errors.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
View rackup.ru
require File.dirname(__FILE__) + "/../app/mailer.rb"
set_option :run, false
set_option :env, ENV['APP_ENV'] || :development
run Sinatra.application
View gist:16651
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)
View rackup.ru
# APP_ROOT/config/rackup.ru
require File.dirname(__FILE__) + "/../myapp"
set_option :run, false
set_option :env, :production
disable :reload
run Sinatra.application
View *scratch*
remote = Rush::Box.new('root@ec2-75-101-233-253.compute-1.amazonaws.com')
remote.bash("ls")
View gist:137834
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"
View gist:176634
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
View gist:210485
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
View test.js
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.
You can’t perform that action at this time.