Skip to content

Instantly share code, notes, and snippets.

>> Maruku.new("a a: b\n\nccc").to_html
=> "<p>ccc</p>"
>> RDiscount.new("a a: b\n\nc").to_html
=> "<p>a a: b</p>\n\n<p>c</p>\n"
module ApplicationHelper
def file_field(object_name, method, options = {})
options.delete :size
ActionView::Helpers::InstanceTag.new(object_name, method, self, options.delete(:object)).
to_input_field_tag("file", options).
sub('size="30"', '')
end
end
<VirtualHost *:80>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
ServerName blog.andrewbruce.net
ServerAdmin andrew@camelpunch.com
DocumentRoot /websites/blog.andrewbruce.net/current/public
ErrorLog /var/log/apache2/blog.andrewbruce.net-error.log
LogLevel warn
require 'open3'
namespace :db do
desc "Import production database and rewrite hostname"
task :import_production do
remote_hostname = 'blog.andrewbruce.net'
local_hostname = 'blog.andrewbruce.local'
webapp_username = 'joebloggs'
webapp_hostname = 'my-web-app-host.name'
class AvatarsController < ApplicationController
before_filter :new_file_upload, :only => :new
def create
user = User.find params[:user_id]
user.avatar_key = params[:key]
user.save!
flash[:notice] = "Your new avatar is thumbnailing and will be ready soon."
redirect_to user_url(user)
end
require 'spec_helper'
describe Invoice do
describe "arrears" do
before do
@tutorial_passed_1 = Tutorial.make :starts_at => 2.seconds.ago
@tutorial_passed_2 = Tutorial.make :starts_at => 1.second.ago
@tutorial_not_passed_1 = Tutorial.make :starts_at => 1.hour.from_now
@tutorial_not_passed_2 = Tutorial.make :starts_at => 2.hours.from_now
@paid_invoice_with_past_tutorial =
require 'spec_helper'
describe Invoice do
describe "scopes" do
subject { @invoices }
describe "arrears" do
before :all do
@tutorial_passed_1 = Tutorial.make :starts_at => 2.seconds.ago
@tutorial_passed_2 = Tutorial.make :starts_at => 1.second.ago
@tutorial_not_passed_1 = Tutorial.make :starts_at => 1.hour.from_now
task :cruise => [:copy_database_config] do
RAILS_ENV = 'test'
Rake::Task['db:drop'].invoke
Rake::Task['db:create'].invoke
Rake::Task['db:schema:load'].invoke
Rake::Task['spec'].prerequisites.clear
Rake::Task['spec'].invoke
FileUtils.rm_f(File.dirname(__FILE__) + '/../../rerun.txt')
<VirtualHost *:80>
RewriteEngine on
RewriteRule ^/(.*) blah [R=503]
</VirtualHost>
ruby_block "copy S3 objects from production to staging" do
block do
require 'rubygems'
require 'right_aws'
aws_access_key_id = credentials['amazon_access_key_id']
aws_secret_access_key = credentials['amazon_secret_access_key']
target_bucket = 'source'
destination_bucket = 'destination'