Discover gists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "sinatra" | |
get '/' do | |
'hi' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##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" |