Skip to content

Instantly share code, notes, and snippets.

View bonkydog's full-sized avatar

Brian Jenkins bonkydog

  • Nubank
  • SF Bay Area
View GitHub Profile
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
#
// 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) {
class ThingsController < ApplicationController
# GET /things
def index
@things = Thing.all
end
# GET /things/1
def show
@thing = Thing.find(params[:id])
end
# 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|
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"
#!/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
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
@bonkydog
bonkydog / serve_the_current_directory.bash
Created August 11, 2010 23:20
serve the current directory on port 8000
python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"
curl -X POST --basic --user '[email protected]' http://api.gsfn:3001/topics/bilbo_taggins/me_toos
sudo monit status | grep mongrel | ruby -n -e '$_ =~ /(mongrel_\w+)/; puts $1' | xargs -n1 sudo monit restart