Skip to content

Instantly share code, notes, and snippets.

require "logger"
def memory
x = 1 # Make a scope
`ps -p#{Process.pid} -orss`.split("\n")[1].to_i
end
def logger
p memory
end
Screw.XHR = function() {};
Screw.XHR.returns = function(str, type, status) {
codes = {
100: "Continue",
101: "Switching Protocols",
200: "OK",
201: "Created",
202: "Accepted",
203: "Non-Authoritative Information",
204: "No Content",
require "logger"
def memory
x = 1 # Make a scope
`ps -p#{Process.pid} -orss`.split("\n")[1].to_i
end
def objects
ret = 0
ObjectSpace.each_object {|o| ret += 1}
$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'
@bmizerany
bmizerany / myapp.rb
Created July 25, 2008 23:28 — forked from pedro/rackup.ru
Running Sinatra in a rackup file
require "rubygems"
require "sinatra"
get '/' do
'hi'
end
module Accountable
class Transaction < ::ActiveRecord::Base # to ensure not clashing with Accountable::ActiveRecord::Macro
has_many :credits
has_many :debits
end
end
module Accountable
module Accounts
class Base < ::ActiveRecord::Base #see above
@adzap
adzap / development.rb
Created July 25, 2008 23:50
Restart task for passenger with debug option
# ... bottom of your development.rb
if File.exists?(File.join(RAILS_ROOT,'tmp', 'debug.txt'))
require 'ruby-debug'
Debugger.wait_connection = true
Debugger.start_remote
File.delete(File.join(RAILS_ROOT,'tmp', 'debug.txt'))
end
require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'aws/s3'
include AWS::S3
BUCKET = 'your-bucket-name'
AWS::S3::Base.establish_connection!(
:access_key_id => 'your-amazon-access-id',
@mattmccray
mattmccray / sftp.thor.rb
Created July 26, 2008 00:04
Thor task for sftp syncing
# module: sftp
# A generic Thor module for sftp syncing.
#
# 1. Call `thor sftp:setup` to create config file.
# 2. Edit the config file
# 3. Call `tor sftp:sync` start the sync
#
# Ze end.
##haml
-form_for @order, :action => url(:shipping) do
.checkoutWrapper
-fields_for @order.shipping_info do
.shippingAddress
%h4
Shipping Address
%fieldset#shippingAddress
%div
%span=text_control :name, :label => "Name"