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 'uri' | |
require 'yaml' | |
def hash_to_param(hash) | |
params = [] | |
hash.each do |k,v| | |
params << "#{URI.escape(k)}=#{URI.escape(v)}" | |
end | |
params.join("&") | |
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
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: mongodb | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the mongodb data-store | |
# Description: starts mongodb using start-stop-daemon |
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
mocked.send(:__mock_proxy).reset |
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 'bluecloth' | |
source_file = $*[0] | |
output_file = $*[1] | |
content = File.read(source_file) | |
File.open(output_file,"w") {|f| f.write BlueCloth.new(content).to_html } | |
puts "done" |
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
%w(rubygems active_record sqlite3).each {|lib| require lib} | |
ActiveRecord::Base.establish_connection({:adapter => 'sqlite3', | |
:database => 'rtest.sqlite3' | |
}) | |
class TestMigration < ActiveRecord::Migration | |
def self.up | |
create_table :joons do |t| | |
t.string :name |
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
%w(rubygems active_record spec sqlite3).each {|lib| require lib} | |
ActiveRecord::Base.establish_connection({:adapter => 'sqlite3', | |
:database => 'rtest.sqlite3' | |
}) | |
# ActiveRecord transactional specs (without Rails) | |
Spec::Runner.configure do |config| | |
config.before do | |
ActiveRecord::Base.connection.begin_db_transaction |
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
desc "my task do something" | |
task :do_something => :environment do | |
options = {} | |
$*.each {|arg| options[arg.split(":")[0]] = arg.split(":")[1]} | |
options.reject! {|k,v| v == "" || v.nil? } | |
# I now have {"setting" => "WHATEVER", "user" => "me"} | |
# for whatever I want to do. | |
# ... | |
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 "uri";require "rack";class Object;def meta_def m,&b;(class<URL(*a). | |
to_s;end;def r404 p;P%"#{p} not found"end;def r500 k,m,e;raise e;end;def r501 m | |
P%"#{m.upcase} not implemented"end;def to_a;@env['rack.session']=@state;r=Rack:: | |
Response.new(@body,@status,@headers);@cookies.each{|k,v|next if @old_cookies[ | |
k]==v;v={:value=>v,:path=>self/"/"} if String===v;r.set_cookie(k,v)};r.to_a;end | |
def initialize(env,m) r=@request=Rack::Request.new(@env=env);@root,@input, | |
@cookies,@state,@headers,@status,@method=r.script_name.sub(/\/$/,''),n(r.params | |
),H[@old_cookies = r.cookies],H[r.session],{},m=~/r(\d+)/?$1.to_i: 200,m end;def | |
n h;Hash===h ?h.inject(H[]){|m,(k,v)|m[k]=n(v);m}: h end;def service *a;r=catch( | |
:halt){send(@method,*a)};@body||=r;self;end;end;module Controllers;@r=[];class<< |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>org.mongo.mongod</string> | |
<key>RunAtLoad</key> | |
<true/> | |
<key>ProgramArguments</key> | |
<array> |
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
sudo curl http://betterthangrep.com/ack-standalone > /usr/local/bin/ack && chmod 0755 !#:3 |
OlderNewer