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 'rubygems' | |
require 'crypt/blowfish' | |
require 'base64' | |
# simple wrapper for blowfish encryption. Assumes all string IO in base64. | |
module Encryption | |
extend self | |
class NilKey < StandardError; 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
task :test => "test:javascript" | |
namespace :test do | |
task :javascript, :expresso_args do |t, args| | |
node = `/usr/bin/env which node` | |
if node == "" | |
puts "Skipping JavaScript unit tests: no 'node' executable found." | |
puts "Please install node.js v0.4.0 or newer." | |
else | |
puts "Running JavaScript unit tests:" |
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 Spinner | |
def initialize printer=nil | |
@spinner = %w[| / - \\] | |
@count = 0 | |
@printer ||= $stderr | |
end | |
def print | |
@printer.print "\r"+@spinner[@count] | |
@count += 1 |
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
#!/bin/sh | |
# create a txt file to write today's notes | |
DIRNAME="${HOME}/Documents/stuff_i_did/`date +%Y`/`date +%m`/" | |
FILENAME="${DIRNAME}`date +%Y-%m-%d`.txt" | |
mkdir -p $DIRNAME | |
if [ ! -f $FILENAME ]; then | |
echo "--- | |
# `whoami` did stuff today | |
- `date +%Y-%m-%d` |
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
## | |
# config/initializers/load_smtp_settings.rb | |
# | |
smtp_settings = YAML.load(File.new('config/smtp_settings.yml'))[Rails.env].symbolize_keys! | |
ActionMailer::Base.smtp_settings = smtp_settings |
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
# :: is required for ruby 1.9.1 | |
# require_relative will fail in ruby 1.9.2 | |
require ::File.dirname(__FILE__) + '/lib/all' | |
trap("USR2") do | |
puts "Stopping due to timeout..." | |
puts caller | |
exit! 1 | |
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
Rails.application.config.generators do |g| | |
g.template_engine :haml | |
g.javascript_engine :js | |
g.integration_tool :cucumber | |
g.test_framework :test_unit, :fixture => false, | |
:views => true, | |
:fixture_replacement => :factory_girl | |
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
ActiveRecord::Base.class_eval do | |
# Setup some useful generic scopes | |
named_scope :ordered, proc{ { :order => primary_key } } | |
named_scope :where, proc{|*conditions| { :conditions => conditions.size == 1 ? conditions.first : conditions } } | |
named_scope :joins, proc{|joins| { :joins => Array(joins).join(' ') } } | |
named_scope :limit, proc{|count| { :limit => count } } | |
named_scope :offset, proc{|offset| { :offset => offset } } | |
named_scope :order, proc{|order| { :order => order.to_s } } |
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
gem 'rack-rewrite' |
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 "delegate" | |
class ObjectDelegator < SimpleDelegator | |
undef_method :class, :object_id | |
end | |
def Object.delegate(object, delegation) | |
ObjectDelegator.new(object).tap{|x| Array(delegation).each{|m| x.extend m } } | |
end |