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 "bundler/setup" | |
require "rack/streaming_proxy" | |
warn "Sleeping for a bit before starting gimme." | |
sleep 3 | |
warn "Starting gimme." | |
nport = 2727 |
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
decorate: (n, fn) -> | |
target = this[n] | |
unless _.isFunction target | |
throw new Error "Can't decorate #{n}, it's not a Function." | |
unless target.fns? | |
wrap = -> | |
args = Array.prototype.slice.call arguments | |
finish = _.after wrap.fns.length, => wrap.old.apply this, args |
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 "tilt" | |
class Tilt::Whirl < Tilt::Template | |
def evaluate scope, locals, &block | |
file.split(".").reverse.inject data do |input, step| | |
klass = Tilt[step] | |
klass ? klass.new(file) { input }.render(scope, locals) : input | |
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
# Render a template file using Tilt. Templates can | |
# have multiple file extensions, which will be rendered one at a | |
# time. For example, "foo.md.erb" will first be run through ERB, | |
# then through Markdown. | |
def self.render template, context = nil, options = {} | |
context ||= Object.new | |
options.merge! default_encoding: Encoding::UTF_8 | |
file = Dir["app/templates/#{template}.*"].first |
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
# If an AJAX request starts with "/api", transform it into a | |
# cross-site request to the API server and attach an API token. If | |
# it's an AJAX request to the local stack, add X-CSRF. If an AJAX | |
# response status is 403, it means the current API token has expired, | |
# so ask the local stack for a new token and retry the request. | |
apiToken = $("meta[name='api.token']").attr "value" | |
apiURL = $("meta[name='api.url']").attr "value" | |
csrf = $("meta[name=csrf]").attr "value" |
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
def bind superclass | |
klass = Class.new superclass do |c| | |
def c.name | |
superclass.name | |
end | |
def c.inspect | |
name | |
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
fs = require "fs" | |
path = require "path" | |
rimraf = require "rimraf" | |
url = require "url" | |
{exec, spawn} = require "child_process" | |
heroku = (callback) -> | |
exec "heroku config --shell", (err, stdout, stderr) -> | |
console.log "heroku config error: #{err}" if err |
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
namespace :db do | |
desc "Replace the local dev DB with a copy from Heroku." | |
task :pull, [:src, :dest] do |t, args| | |
abort "Only in dev." unless ENV.development? | |
src = args.src || "heroku-app-name" | |
dest = args.dest || "local-db-name" | |
restore = "pg_restore -x -O -d #{dest}" | |
url = "heroku pgbackups:url --app #{src}" |
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
task :quux | |
task :foo do |t| | |
tasks = Rake.application.top_level_tasks | |
args = tasks.slice! (tasks.index(t.name) + 1)..-1 | |
unless args.empty? | |
puts "You passed me some args! \n#{args.inspect}" | |
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
$:.unshift "lib" if File.directory? "lib" | |
project = File.basename File.expand_path(".") | |
require project if File.file? "lib/#{project}.rb" |