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
#Deploy and rollback on Heroku in staging and production | |
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag'] | |
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag'] | |
namespace :deploy do | |
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU' | |
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU' | |
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag] | |
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on] |
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
class Lisp | |
def initialize | |
@env = { | |
:label => lambda { |(name,val), _| @env[name] = val }, | |
:quote => lambda { |sexpr, _| sexpr[0] }, | |
:car => lambda { |(list), _| list[0] }, | |
:cdr => lambda { |(list), _| list.drop 1 }, | |
:cons => lambda { |(e,cell), _| [e] + cell }, | |
:eq => lambda { |(l,r), _| l == r }, | |
:if => lambda { |(cond, thn, els), ctx| eval(cond, ctx) ? eval(thn, ctx) : eval(els, ctx) }, |
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
sudo iptables -F | |
sudo iptables -I INPUT -i lo -j ACCEPT | |
sudo iptables -I INPUT -i tun0 -j ACCEPT | |
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT | |
sudo iptables -A OUTPUT -o eth0 -p tcp --dport 1194 -m state --state ESTABLISHED -j ACCEPT | |
sudo iptables -A INPUT -i eth0 -p tcp --dport ssh -m state --state NEW,ESTABLISHED -j ACCEPT | |
sudo iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT | |
sudo iptables -A INPUT -j DROP | |
sudo iptables -A OUTPUT -j DROP | |
sudo iptables -A FORWARD -j DROP |
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
# encoding : utf-8 | |
require 'openssl' | |
require 'digest/sha1' | |
require 'base64' | |
module Aws | |
extend self | |
def signed_url(path, expire_date) | |
digest = OpenSSL::Digest::Digest.new('sha1') | |
can_string = "GET\n\n\n#{expire_date}\n/#{S3_BUCKET}/#{path}" |
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
class Enum < Hash | |
def initialize(*members) | |
super() | |
@rev = {} | |
members.each_with_index {|m,i| self[i] = m } | |
end | |
def [](k) | |
super || @rev[k] # || raise ArgumentError, "#{k} is not a member of this enum" | |
end | |
def []=(k,v) |