Skip to content

Instantly share code, notes, and snippets.

@uhlenbrock
uhlenbrock / gist:298662
Created February 8, 2010 22:30
Retrieve archival tweets in json
# TODO: parameterize query
# TODO: paginate google results
require 'rubygems'
require 'mechanize'
require 'json'
tweets = []
a = Mechanize.new do |agent|
@uhlenbrock
uhlenbrock / deploy.rb
Created January 25, 2010 21:47
Simple Capistrano recipe for Jekyll
set :application, 'foo'
set :repository, '_site'
set :scm, :none
set :deploy_via, :copy
set :copy_compression, :gzip
set :use_sudo, false
set :host, '127.0.0.1'
role :web, host
role :app, host
@uhlenbrock
uhlenbrock / template.rb
Created December 18, 2008 19:50
My Rails Template
# TODO
# - authentication for admin
# - hoptoad/exception_notification
# - setup layouts
# - any gems?
# - any plugins?
# - blueprint?
# Delete unneeded files
run 'rm README'
@uhlenbrock
uhlenbrock / blueprint_bookmarklet.js
Created December 17, 2008 16:30
Bookmarklet for BlueprintCSS
/**
* Make this a "bookmarklet"
* 1. Remove the function enclosure
* 2. Remove spaces (http://userjs.up.seesaa.net/js/bookmarklet.html)
* 3. Add to your browser's bookmarks bar
*/
function toggle_showgrid() {
var d = Array.prototype.slice.call(document.getElementsByClassName('container'));
var id = document.getElementById('container');
if (id) { d.push(id); }
class UserMailer < ActionMailer::Base
def signup_notification(user)
setup_email(user)
@subject += "One final step: please activate."
@body[:url] = "http://#{user.site.domain}/activate/#{user.activation_code}"
@body[:code] = user.activation_code
end
end
@uhlenbrock
uhlenbrock / users_controller.rb
Created September 23, 2008 20:54
Sample Functional Tests
class UsersController < ActionController::Base
before_filter :login_required
def show
@user = User.find(params[:id])
end
end
@uhlenbrock
uhlenbrock / user.rb
Created September 23, 2008 20:05
Sample Unit Tests
class User < ActiveRecord::Base
# Validation
validates_presence_of :password_confirmation
# Association
has_many :comments
# Instance Method
def full_name
"#{first_name} #{last_name}"
end
end