This file contains hidden or 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 "net/http" | |
| # Example Usage: | |
| # | |
| # use Rack::Proxy do |req| | |
| # if req.path =~ %r{^/remote/service.php$} | |
| # URI.parse("http://remote-service-provider.com/service-end-point.php?#{req.query}") | |
| # end | |
| # end | |
| # |
This file contains hidden or 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
| // Douglas Crockford-fu from JavaScript: The Good Parts | |
| // http://oreilly.com/catalog/9780596517748/ | |
| Function.prototype.method = function (name, func) { | |
| this.prototype[name] = func; | |
| return this; | |
| }; | |
| if (typeof Object.create !== ' function') { | |
| Object.create = function (o) { |
This file contains hidden or 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
| class ThingsController < ApplicationController | |
| # GET /things | |
| def index | |
| @things = Thing.all | |
| end | |
| # GET /things/1 | |
| def show | |
| @thing = Thing.find(params[:id]) | |
| end |
This file contains hidden or 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
| # Example activerecord interator based on using an indexed 'id' column. | |
| # See http://schuerig.de/michael/blog/index.php/2007/02/03/ar-enumerable/ | |
| # and http://weblog.jamisbuck.org/2007/4/6/faking-cursors-in-activerecord | |
| class << ActiveRecord::Base | |
| def each(chunk_size=1000) | |
| (0..self.last.id / chunk_size).each do |offset| | |
| self.find(:all, | |
| :limit => chunk_size, | |
| :conditions => ["id > ?", offset * chunk_size]).each do |i| |
This file contains hidden or 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
| namespace :bundler do | |
| task :install do | |
| run("gem install bundler --source=http://gemcutter.org") | |
| end | |
| task :symlink_vendor do | |
| shared_gems = File.join(shared_path, 'vendor/gems') | |
| release_gems = "#{release_path}/vendor/gems" |
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| require "rubygems" | |
| require "g" | |
| # check "Listen for incoming notifications" in your Growl preference pane | |
| begin | |
| raise if ARGV.size != 1 | |
| fork do | |
| Process.setpgrp |
This file contains hidden or 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
| openssl genrsa -des3 -out foo.key 1024 | |
| openssl req -new -key foo.key -out mysqql.csr | |
| mv foo.key foo.key.com | |
| openssl rsa -in foo.key.com -out foo.key | |
| openssl x509 -req -days 365 -in foo.csr -signkey foo.key -out foo.crt |
This file contains hidden or 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
| python -c "import SimpleHTTPServer;SimpleHTTPServer.test()" |
This file contains hidden or 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
| curl -X POST --basic --user 'brian+repetition@example.com' http://api.gsfn:3001/topics/bilbo_taggins/me_toos |
This file contains hidden or 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
| sudo monit status | grep mongrel | ruby -n -e '$_ =~ /(mongrel_\w+)/; puts $1' | xargs -n1 sudo monit restart |
OlderNewer