This file contains hidden or 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
#!/usr/bin/env sh | |
program=$(basename $0) | |
command=$1 | |
help() { | |
echo "Usage: $program <subcommand>" | |
echo "" | |
echo "Subcommands:" | |
echo " create Create an encrypted volume" |
This file contains hidden or 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
Bundler 1.3.5 | |
Ruby 1.9.3 (2013-02-22 patchlevel 392) [x86_64-linux] | |
Rubygems 1.8.23 | |
GEM_HOME | |
Bundler settings | |
frozen | |
Set for your local app (/var/www/app/releases/20130420233758/.bundle/config): "1" | |
path | |
Set for your local app (/var/www/app/releases/20130420233758/.bundle/config): "vendor/bundle" |
This file contains hidden or 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
# Start taps server in one tab | |
taps server mysql://mysqluser@localhost/sourcedb tmpuser tmppass | |
# Create destination postgres database | |
createdb destinationdb | |
# Import into postgres database in another tab | |
taps pull postgres://postgresuser@localhost/destinationdb http://tmpuser:tmppass@localhost:500 |
This file contains hidden or 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
dig +short ns example.com |
This file contains hidden or 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
# where /dev/disk3 is the disk you want to reset | |
# GPT is the GUID partition table | |
# HFS+ is the Apple HFS format | |
diskutil partitionDisk /dev/disk3 GPT HFS+ newDiskName 100% |
This file contains hidden or 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 "active_record" | |
require "lib/duration" | |
class Event < ActiveRecord::Base | |
include Duration | |
end | |
describe Duration do | |
before do | |
ActiveRecord::Base.establish_connection( |
This file contains hidden or 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
class Post < ActiveRecord::Base | |
before_destroy :protect_from_destruction | |
def protect_from_destruction | |
if protected? | |
errors.add(:base, "Whoa this one is important") | |
false | |
end | |
end |
This file contains hidden or 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
# Assuming that :something is trusted | |
Mustache.render("<h1>template</h1> {{ something }}", {:something => "<h2>Testing</h2>" }) | |
# => <h1>template</h1> <h2>Testing</h2> | |
# Desired out is "<h1>template</h1> <h2>Testing</h2>" | |
# Solution, use the triple mustache - {{{ }}} - for content that shouldn't be escapes |
This file contains hidden or 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
// Works in conjunction with the generate_template helper to insert new | |
// objects into a form that has a collection of items. | |
$.fn.appendFromTemplate = function(template) { | |
return this.each(function () { | |
var newId = new Date().getTime(); | |
$(this).append(template.replace(/NEW_RECORD/g, newId)); | |
}); | |
}; |
This file contains hidden or 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
// Bind a checkbox to a with checked and unchecked callback functions | |
// and run the appropriate action on page load: | |
// | |
// Examples | |
// | |
// $("input[type=checkbox][name=thecheckbox]").bindCheckbox({ | |
// checked: function() { | |
// alert("the checkbox is checked!") | |
// }, | |
// unchecked: function() { |
NewerOlder