Skip to content

Instantly share code, notes, and snippets.

View jbarnette's full-sized avatar

John Barnette jbarnette

View GitHub Profile
########################################################################
### 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`
# 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
################################################################################
### 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
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
require "intercession"
require "myapp"
require "myapp/session_extras"
use Rack::Session::Cookie, :secret => "I'll punchasize your face for FREE!"
use Intercession, MyApp::SessionExtras
run MyApp
@jbarnette
jbarnette / boom.markdown
Created February 18, 2010 15:07 — forked from defunkt/mini.rb

JUST USE MINITEST/SPEC YOU BASTARD

class JsonHax
def initialize(app)
@app = app
end
def call(env)
if env['CONTENT_TYPE'] == 'application/json'
env['CONTENT_TYPE'] = 'application/xml'
env['REQUEST_URI'].gsub!(/\.json/, '.xml')
require "test_helper"
require "action_view/test_case"
class TestBusinessSearchHelpers < ActionView::TestCase
include BusinessSearchHelper
def test_format_address
{
"Foo Goo 123" => "Foo Goo 123",
(in /Users/drnic/newproj)
rake announce # publish # Announce your release.
rake check_extra_deps # deps # Install missing dependencies.
rake check_manifest # debug # Verify the manifest.
rake clean # # Clean up all the extras.
rake config_hoe # debug # Create a fresh ~/.hoerc file.
rake debug_email # publish # Generate email announcement file.
rake debug_gem # debug # Show information about the gem.
rake deps:email # deps # Print a contact list for gems dependent on this gem
rake deps:fetch # deps # Fetch all the dependent gems of this gem into tarballs
RAILS_ROOT ||= ENV["RAILS_ROOT"]
namespace :bundle do
js_bundle = Rails.root + "/public/javascripts/bundle.js"
js_files = Dir[Rails.root + "/public/javascripts/{github,jquery}.*.js"].sort
task :all => [ js_bundle, :gist_js, :css ]
file js_bundle => js_files do |task|
require 'lib/js_minimizer'