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
# $ source README.sh | |
which redis-server && \ | |
which sqlite3 && \ | |
which java && \ | |
which mongo && \ | |
bundle install && \ | |
rake test docs && \ | |
open doc/index.html |
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 "stateful" | |
class Folder < ActiveRecord::Base | |
include Stateful | |
# ... | |
stateful do | |
state :active | |
state :inactive |
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
######################################################################## | |
### Rakefile for encrypted passwords | |
######################################################################## | |
# | |
# Here's a little Rakefile to manage your encrypted password file! It's | |
# really easy to use: | |
# | |
# 1) put the email addresses of the keys you want in AUTHORIZED_USERS | |
# 2) create a passwords.txt (and ignore it in your SCM) | |
# 3) run `rake passwords:encrypt` |
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
# When anything, including nil, is a valid param and you need | |
# a clear way to know if a param was set or not. | |
def foo a, b = (b_was_not_passed = true; nil) | |
result = [a] | |
result << b unless b_was_not_passed | |
result | |
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
diff --git a/Rakefile b/Rakefile | |
index 0794562..2aa2c18 100644 | |
--- a/Rakefile | |
+++ b/Rakefile | |
@@ -6,6 +6,7 @@ require 'rubygems' | |
require 'rubygems/package_task' | |
require 'hoe' | |
+Hoe::RUBY_FLAGS.insert 0, "--disable-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
def run | |
begin | |
started | |
result = constantize(object).send(method_name, *args) | |
Whatever::Job.keep? ? completed : destroy | |
result | |
rescue Exception => exception | |
failed(exception.message) | |
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
################################################################################ | |
### M E T H O D N A M E :: address ############################################ | |
### A R G U M E N T S :: separator[String] ################################## | |
### R E T U R N S :: String ############################################# | |
### A U T H O R :: Alan Smithee ####################################### | |
### D A T E :: 1989-10-31 ######################################### | |
################################################################################ | |
def address separator |
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
puts "Hello, #{ENV['USER']}! I'm a gist!" |
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 Intercession | |
# Duh. | |
VERSION = "3.0.0" | |
def initialize app, behavior | |
@app = app | |
@behavior = behavior | |
@after = @behavior.instance_methods.map(&:to_s).include? "after" | |
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
class Intercession | |
def initialize app, behavior | |
@app = app | |
@behavior = behavior | |
@before, @after = %w(before after).map { |m| @behavior.instance_methods.map(&:to_s).include? m } | |
end | |
def call env | |
session = env["rack.session"] and session.extend @behavior |