Skip to content

Instantly share code, notes, and snippets.

View seven1m's full-sized avatar

Tim Morgan seven1m

View GitHub Profile
#!/bin/sh
cd backend && make test
if [ $? -ne 0 ]; then
echo 'There was an error -- aborting commit.'
exit 1;
fi
@seven1m
seven1m / gitcal
Created September 30, 2010 20:53
Creates iCalendar (ical) format output containing commits from a Git repo.
#!/usr/bin/env ruby
# Creates iCalendar (ical) format output containing commits from a Git repo.
# Save as a file and import into Google Calendar or iCal on Mac.
# Publish on a webserver and link to Google Calendar directly.
# Install & Use:
# gem install grit icalendar
# chmod +x gitcal
# ./gitcal /path/to/repo > commits.ical
@seven1m
seven1m / post-commit
Created October 2, 2010 02:10
git post-commit hook for use with gitcal
#!/bin/sh
# git post-commit hook
# uses gitcal (see http://gist.github.com/605303) to publish an icalendar format file to a server
# once on the web, you can easily link Google Calendar and see your commit log on GCal!
~/bin/gitcal | ssh [email protected] "sh -c 'cat > /var/www/htdocs/commits.ical'"
Index: History.txt
===================================================================
--- History.txt (revision 26)
+++ History.txt (working copy)
@@ -1,3 +1,7 @@
+== 0.3.2 2010-10-18
+* 1 minor enhancement:
+ * Removed Object#returning in favor of Ruby's built-in Object#tap.
+
== 0.3.1 2008-04-03
class Person < ActiveRecord::Base
default_scope where(:deleted => false)
end
Person.all
# => SELECT "people".* FROM "people" WHERE ("people"."deleted" = 'f')
Person.unscoped { Person.all }
# => SELECT "people".* FROM "people"
class Person < ActiveRecord::Base
cattr_accessor :current_site_id
default_scope where(:site_id => Person.current_site_id)
end
Person.current_site_id = 1
Person.all
# => SELECT "people".* FROM "people" WHERE ("people"."site_id" IS NULL)
class Person < ActiveRecord::Base
cattr_accessor :current_site_id
default_scope lambda { where(:site_id => Person.current_site_id) }
end
Person.current_site_id = 1
Person.all
# => SELECT "people".* FROM "people" WHERE ("people"."site_id" = 1)
Person.current_site_id = 2
# patch for Webrat::Selenium support on Rails 3
# mongrel_rails won't run a Rails 3 app
module Webrat
module Selenium
module ApplicationServers
class Rails < Webrat::Selenium::ApplicationServers::Base
def start_command
"cd #{::Rails.root} && rails server -d --port=#{Webrat.configuration.application_port} --environment=#{Webrat.configuration.application_environment} --pid #{pid_file}"
end
# RVM support in Rails 3 app for multiple gemsets with Passenger
# config/setup_load_paths.rb
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
require 'oauth'
require 'oauth/consumer'
require 'oauth/signature/rsa/sha1'
APP_URL = 'http://example.com'
OAUTH_KEY = 'key'
OAUTH_SECRET = 'secret'
OAUTH_APP_NAME = 'MyAppName'
get '/auth' do