Skip to content

Instantly share code, notes, and snippets.

View tobias's full-sized avatar

Toby Crawley tobias

View GitHub Profile
# call-seq:
# Webby.site => struct
#
# Returns a struct containing the configuration parameters for the
# Webby site. These defaults should be overridden as needed in the
# site specific Rakefile.
#
def self.site
return @site if defined? @site
@site = OpenStruct.new(
#-*-ruby-*-
SITE.user = 'tobias'
SITE.host = 'handbuiltsoftware.com'
SITE.remote_dir = '/path/to/site/'
task :default => :build
desc 'deploy the site to the webserver'
task :deploy => [:build, 'deploy:ssh']
@tobias
tobias / run_tags.rb
Created January 1, 2009 16:44
A script for generating TAGS from a git hook.
#!/usr/bin/ruby
#-*-ruby-*-
# A script to run ctags on all .rb files in a project. Can be run on
# the current dir, called from a git callback, or install itself as a
# git post-merge and post-commit callback.
CTAGS = '/opt/local/bin/ctags'
HOOKS = %w{ post-merge post-commit post-checkout }
HOOKS_DIR = '.git/hooks'
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("lighthouseapp.com") {
#header {
height: 72px !important;
}
#rheader {
padding-top: 3px !important;
}
#!/opt/local/bin/ruby
KEY_PAIRS = %w{`~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ [{ ]} \| ;: =+ '" ,< .> /?}.collect { |kp| kp.split('') }
KEYS = KEY_PAIRS.flatten
counts = { }
%w{ app lib test }.each do |dir|
Dir.glob("#{dir}/**/*.{rb,sass}").each do |filename|
File.open(filename) do |file|
#in controller
key = store_params(hash_of_params_to_keep)
redirect_to some_path(:params_key => key)
-----------
def store_params(hash_of_params)
key = Time.now.to_s + rand(10000).to_s #or some other unique key
session[:stored_params] ||= {}
#!/opt/local/bin/ruby
def play_alert()
play = 'afplay /System/Library/Sounds/Ping.aiff;'
%x{#{play * 2}}
end
def run_timers(timers)
timers.each do |seconds, times|
times.to_i.times do |index|
#!/usr/bin/ruby
url = ARGV[0]
css_file = ARGV[1]
strip = ARGV[2]
File.open(css_file, 'r') do |f|
while line = f.gets do
match = line.match(/url\((.*?)\)/)
if match
after "deploy", "deploy:notify_campfire"
after "deploy:migrations", "deploy:notify_campfire"
namespace :deploy do
desc 'notifies campfire room of deploy'
task :notify_campfire do
begin
require 'tinder'
rails_env = fetch(:rails_env, "production")
require 'new_relic/recipes'
set :rails_env, RUBBER_ENV
on :load do
set :application, rubber_env.app_name
set :runner, rubber_env.app_user
set :deploy_to, "/mnt/#{application}-#{RUBBER_ENV}"
end