Skip to content

Instantly share code, notes, and snippets.

@stevenhaddox
stevenhaddox / Capfile
Last active August 29, 2015 14:11 — forked from davidlfox/Capfile
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/rails'
require "capistrano-resque"
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
def _authenticate_oauth_echo
require 'httparty'
# header auth only for now; also lock down the auth provider endpoint so we can't spoof
if(request.env["HTTP_X_AUTH_SERVICE_PROVIDER"] != 'https://api.twitter.com/1/account/verify_credentials.json' || request.env["HTTP_X_AUTH_SERVICE_PROVIDER"].blank?)
return false
else
auth_service_provider = request.env["HTTP_X_AUTH_SERVICE_PROVIDER"]
verify_credentials_authorization = request.env["HTTP_X_VERIFY_CREDENTIALS_AUTHORIZATION"]
end
This is an example of using RVM's Project .rvmrc file
to have it automatically bootstrap your environment, including bundler.
This could be further expanded to do anything you require :)
The important thing to remember is that the purpose of these files is
to allow you to very easily have your 'project context' (aka 'environment')
loaded automatically for you when you enter the project in the shell (cd).
require "rubygems"
require 'directory_watcher'
commands = [
{ :tell => "Firefox", :to => "activate" },
{ :tell => "System Events", :to => "keystroke \"1\" using command down" },
{ :tell => "System Events", :to => "keystroke \"r\" using command down" },
{ :tell => "TextMate", :to => "activate" }
]
export RUBY_HEAP_MIN_SLOTS=1000000
export RUBY_HEAP_SLOTS_INCREMENT=250000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=100000000
export RUBY_HEAP_FREE_MIN=1000000
module Notable
def self.included(base)
base.has_many :notes, :as => :notable
base.accepts_nested_attributes_for :notes
end
end
class User < ActiveRecord::Base
include Notable
end
# File permissions
run "chmod 755 ."
%w(public log tmp).each do |dir|
run "chmod -R 755 #{dir}"
end
# Remove unnecessary files
%w(README public/index.html public/favicon.ico public/robots.txt).each do |file|
run "rm #{file}"