Skip to content

Instantly share code, notes, and snippets.

View bkeepers's full-sized avatar

Brandon Keepers bkeepers

View GitHub Profile
@bkeepers
bkeepers / gist:12632
Created September 24, 2008 18:45
Script that demonstrates a slight leak in Prawn's table generation code.
require 'rubygems'
require 'prawn'
pid = fork do
loop do
data = [['1', '2']] * 20
headers = ['a', 'b']
Prawn::Document.generate("leak#{Process.pid}.pdf") do
table data, :headers => headers
#!/usr/bin/env ruby
# Generate a rails app (using EDGE rails), set up a git repo for it, and install common plugins
#
# USAGE: $0 some_app_name
#
# Adapted from http://github.com/foca/utility_scripts/
# Released under a WTFP license (http://sam.zoy.org/wtfpl/)
RAILS_DIR = File.expand_path('~/.rails')
@bkeepers
bkeepers / section_drop.rb
Created October 17, 2008 18:02
Archives section from http://opensoul.org
<table class="archives">
<thead>
<tr>
<th class="month"></th>
<th class="month">Jan</th>
<th class="month">Feb</th>
<th class="month">Mar</th>
<th class="month">Apr</th>
<th class="month">May</th>
<th class="month">Jun</th>
<table>
<% @parties.weeks.each do |week| %>
<tr>
<% week.days.each do |day| %>
<td>
<ul>
<% day.each do |party| %>
<li><!-- party info here --></li>
<% end %>
</ul>
class Section < ActiveRecord::Base
has_many :articles, :order => 'position'
end
class Article
default_scope :order => 'published_at DESC'
named_scope :by_author, :order => 'author'
named_scope :by_position, :order => 'position'
end
# Thoughts on a backend-agnostic search plugin
Scour.define Model do
backend :ferret # or :sphinx / :solr
index title, :sortable => true, :boost => 1.0
index content, author_id, created_at, updated_at
index author.name, :as => :author, :sortable => true
index first_name, last_name, :as => [:name, :fullname]
index tags.name, :as => :tags
index minor { author.age < 18 }
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
#
# This excercises the full set of migrations for your Rails app.
# It proves:
# - After full migration, the database is in the expected state, including:
# - All table structure
# - Default data (if any)
# - Full downward (version 0) migration functions correctly.
#
#!/bin/sh
connect -H iphone.modem:3128 $@
PLUGINS = {
'rspec' => 'git://github.com/dchelimsky/rspec.git',
'rspec-rails' => 'git://github.com/dchelimsky/rspec-rails.git',
'rspec-on-rails-matchers' => 'git://github.com/brandon/rspec-on-rails-matchers.git',
'awesomeness' => 'git://github.com/collectiveidea/awesomeness.git',
'awesome-backup' => 'git://github.com/collectiveidea/awesome-backup.git',
'exception_notification' => 'git://github.com/collectiveidea/exception_notification.git',
'action_mailer_optional_tls' => 'git://github.com/collectiveidea/action_mailer_optional_tls.git',
'cucumber' => 'git://github.com/aslakhellesoy/cucumber.git',
'webrat' => 'git://github.com/brynary/webrat.git',
set :scm, :git
set :branch, 'master'
set :git_enable_submodules, true
set :ssh_options, {:forward_agent => true}
desc "mod_rails restart"
namespace :deploy do
task :restart do
run "touch #{current_path}/tmp/restart.txt"
end