Skip to content

Instantly share code, notes, and snippets.

@tallgreentree
tallgreentree / chef_server_bootstrap.sh
Created April 17, 2012 20:19
Chef server bootstrap
#!/bin/bash
set -e # Exit on error
set -x # Print each command
# Set up the OpsCode repository
echo "deb http://apt.opscode.com/ `lsb_release -cs`-0.10 main" | tee /etc/apt/sources.list.d/opscode.list
gpg --keyserver keys.gnupg.net --recv-keys 83EF826A
gpg --export [email protected] | tee /etc/apt/trusted.gpg.d/opscode-keyring.gpg
apt-get update
@tallgreentree
tallgreentree / das_download.rb
Created March 21, 2012 15:37
Download all Destroy All Software Screencasts
#! /usr/bin/env ruby
# usage:
# $ das_download.rb email password [download_directory]
require 'mechanize'
# gem 'mechanize-progressbar'
email = ARGV[0] or raise('Please provide the email address for your account')
password = ARGV[1] or raise('Please provide the password for your account')
path = ARGV[2] || './'
@tallgreentree
tallgreentree / template.rb
Created February 9, 2012 14:26
Rails template - has_secure_password-based login system (thanks ryanb!)
# use like so:
# rails new <projectname> -Tm https://raw.github.com/gist/1780315/509575d448ed95784c90abcb1ef82eac0a682714/template.rb
log "Running rvm"
run "rvm use --create --rvmrc 1.9.2@#{app_name}"
log "Removing index.html"
run "rm public/index.html"
generate "controller welcome index"
route 'root :to => "welcome#index"'
@tallgreentree
tallgreentree / nested_form_helper.rb
Created August 2, 2011 12:47
Add Object Link helper function - great for nested form fields.
module NestedFormHelper
def add_object_link(name, form, object, partial, where)
html = render(:partial => partial, :locals => { :form => form}, :object => object)
link_to_function name, %{
var new_object_id = new Date().getTime() ;
var html = jQuery('#{where}').append('#{html.gsub(/\n/, ' ')}');
}
end
end
@tallgreentree
tallgreentree / PHP US States Array
Created October 27, 2010 14:13
Declares an array of US states in PHP. Key is full state name, value is state abbreviation.
$state_arr = array(
'Alabama' => 'AL',
'Alaska' => 'AK',
'Arizona' => 'AZ',
'Arkansas' => 'AR',
'California' => 'CA',
'Colorado' => 'CO',
'Connecticut' => 'CT',
'District of Columbia' => 'DC',
'Delaware' => 'DE',