Skip to content

Instantly share code, notes, and snippets.

@bkeepers
bkeepers / gist:12632
Created Sep 24, 2008
Script that demonstrates a slight leak in Prawn's table generation code.
View gist:12632
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
View railify
#!/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')
View section_drop.rb
<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>
View index.html.erb
<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>
View gist:38005
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
View define.rb
# 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 }
View gist:75839
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.
#
View socks
#!/bin/sh
connect -H iphone.modem:3128 $@
View template.rb
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',
View deploy.rb
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