Skip to content

Instantly share code, notes, and snippets.

@tjmcewan
tjmcewan / bundle-updater.sh
Created March 22, 2010 02:38
pull multiple git repos from the directory above
# pull all git-based projects in the current directory (doesn't hurt non-git directories)
# for TextMate bundles: run this from [~]/Library/Application\ Support/TextMate/Bundles/
for repo in *; do if [ -d "$repo" ]; then cd "$repo"; git pull origin; cd ../; fi done
@tjmcewan
tjmcewan / application_helper.rb
Created February 21, 2011 00:44
env-aware jQuery includes
def jquery_includes
jquery_version = "1.4.4"
jquery_ui_version = "1.8.9"
css_theme = "redmond"
if ::Rails.env == 'production'
proto = request.ssl? ? 'https://' : 'http://'
cdn_url = "ajax.googleapis.com/ajax/libs/jquery"
javascript_include_tag("#{proto}#{cdn_url}/#{jquery_version}/jquery.min.js") +
@tjmcewan
tjmcewan / database.yml
Created April 5, 2011 00:47
Rails agnostic database.yml
<%
app = "awesome_application"
mysql_version = case Rails.version.first.to_i
when 3 then 'mysql2'
when 2 then 'mysql'
else
raise 'Version not supported'
end
%>
@tjmcewan
tjmcewan / gist:973035
Created May 15, 2011 10:41
compass/jammit pre-commit hook
#!/bin/sh
echo "Compiling styles with Compass..."
compass compile --quiet --trace
git add public/stylesheets
echo "Packaging assets with Jammit..."
jammit
git add public/assets
# !/usr/bin/env ruby
#
# A pre-commit hook to test if jammit needs to be run
# In case you don't like on the fly stuff
require 'rubygems'
require "bundler"
Bundler.setup
require 'jammit'
def select_animal(num)
animal = case num
when (1 or 2) then :monkey # 2 & 4 never get reached
when (3 || 4) then :giraffe
end
return animal
end
(1..4).each do |n|
puts select_animal(n)
@tjmcewan
tjmcewan / .bash_profile
Created May 20, 2011 02:52
Rails version-agnostic server & console
# Rails 2 and Rails 3 console
function rc {
if [ -e "./script/console" ]; then
./script/console $@
else
rails console $@
fi
}
# Rails 2 and Rails 3 server
ruby-1.8.7-p334 :001 > task = Task.create(:name => "test")
=> #<Task id: 4364, name: "test", created_at: "2011-06-07 10:38:24", updated_at: "2011-06-07 10:38:24">
ruby-1.8.7-p334 :003 > task.destroy
=> #<Task id: 4364, name: "test", created_at: "2011-06-07 10:38:24", updated_at: "2011-06-07 10:38:47">
ruby-1.8.7-p334 :004 > task
=> #<Task id: 4364, name: "test", created_at: "2011-06-07 10:38:24", updated_at: "2011-06-07 10:38:47">
ruby-1.8.7-p334 :005 > task.present?
=> true
ruby-1.8.7-p334 :007 > task.reload
ActiveRecord::RecordNotFound: Couldn't find Task with ID=4364
class JobDescription
def self.important_bits
chaff do
"""
## Position
You'll have an initial six to nine month negotiated contract, with a view to making you a permanent employee once we establish we're right for each other. You'll be enhancing & maintaining a range of existing projects, including our internal custom built Project Management System (PIMMS), our energy efficiency game website: [Climate Clubs](http://ccv2.heroku.com/), and our waste management tool for SMEs: [WasteNot](http://wastenot.streamline.org.au/) (built for us by :mocra). You'll also help us quickly knock up proof of concept sites (and nurture them into blossoming gardens; cheers @cmaitchison ;-) for the many community education & engagement ideas we have in the icebox.
## We use
Ubuntu/Passenger/Nginx, Heroku, JenkinsCI, Rails, Git, BackboneJS (jQuery), Rspec (Cucumber), whatever you want (except Haskell) :-p
@tjmcewan
tjmcewan / job-app.mdown
Created June 16, 2011 06:15
[JOB] junior/mid dev onsite at ISF, UTS (SYD)

Web Application Developer

Institute of Sustainable Futures @ University of Technology, Sydney

Want to work where you can really make a difference? A position at UTS is one of influence, recognition, reward and work-life balance.

The Institute for Sustainable Futures (ISF) at UTS is a leader in applied sustainability research. Over the last 13 years ISF has worked with numerous government, industry and community organisations, in Australia and