This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# download and git methods swiped from http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb | |
require 'open-uri' | |
def download(from, to = from.split("/").last) | |
#run "curl -s -L #{from} > #{to}" | |
file to, open(from).read | |
rescue | |
puts "Can't get #{from} - Internet down?" | |
exit! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run_spellcheck(file,interactive=false) | |
if interactive | |
cmd = "aspell -p ./config/devver_dictionary -H check #{file}" | |
puts cmd | |
system(cmd) | |
[true,""] | |
else | |
cmd = "aspell -p ./config/devver_dictionary -H list < #{file}" | |
puts cmd | |
results = `#{cmd}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
On the page, there will be a number of tabs. Each of the tabs will correspond with a panel. | |
When a tab is selected, it becomes "active" -- the previously active tab becomes inactive. | |
When a tab becomes active, its associated panel is shown. When a tab becomes inactive, its | |
associated panel is hidden. | |
By default, the first tab is active when the tabs are created. | |
*/ | |
var tabs = new $.Widget("ul.tabs"); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Creating a new dialog plugin | |
var dialog = new $.Widget("<div class='dialog'></div>"); | |
dialog.insertInto = "body"; | |
dialog.listen({ | |
open: function() { | |
if(dialog.state == "closed") { | |
dialog.show(); // Triggers another event | |
dialog.state = "open"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Takes a bucket of behaviors and runs them with optional options. | |
// | |
// Example: | |
// $("div").setupExtras({fun: [function(options) { | |
// if(options.fun) console.log("OMG FUN"); | |
// delete options.fun; | |
// }]}, options); | |
// | |
// The purpose of this method is to allow users to extend a plugin | |
// with additional behaviors that are potentially dependent on the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
require 'time' | |
class Time | |
def self.gcalschema(tzid) # We may not be handling Time Zones in the best way... | |
tzid =~ /(\d\d\d\d)(\d\d)(\d\d)T(\d\d)(\d\d)(\d\d)Z/ ? # yyyymmddThhmmss | |
# Strange, sometimes it's 4 hours ahead, sometimes 4 hours behind. Need to figure out the timezone piece of ical. | |
# Time.xmlschema("#{$1}-#{$2}-#{$3}T#{$4}:#{$5}:#{$6}") - 4*60*60 : | |
Time.xmlschema("#{$1}-#{$2}-#{$3}T#{$4}:#{$5}:#{$6}") : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Usage: | |
# rake db:rollback_to_common branch=production | |
# git checkout -m production | |
# rake db:migrate | |
# | |
namespace :db do | |
desc 'Rolls back database to common migration state between current branch and another' | |
task :rollback_to_common do | |
FileUtils.cd(RAILS_ROOT) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AssertionExtensions | |
def method_missing(method_id, *arguments, &block) | |
return super unless method_id.to_s =~ /^assert_(not_)?(.*)$/ | |
method = "#{$2}?" | |
object = arguments.first | |
if $1 | |
arguments.each do |object| | |
assert ! object.send(method), "#{method} is not false for #{object}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.bash_profile | |
export GEMDIR=`gem env gemdir` | |
gemdoc() { | |
local gems=($GEMDIR/doc/$1*/rdoc/index.html) | |
open ${gems[@]: -1} | |
} | |
complete -W '$(`which ls` $GEMDIR/doc)' gemdoc |