Skip to content

Instantly share code, notes, and snippets.

View dwabnitz's full-sized avatar

dwabnitz dwabnitz

View GitHub Profile
@dwabnitz
dwabnitz / customdomain.rb
Created October 22, 2009 19:18 — forked from speedmax/customdomain.rb
rack middleware to resolve a custom domain to an original subdomain in a multi-tenant application
require 'net/dns/resolver'
# Custom Domain
#
# Require net-dns gem
#
# A Rack middleware to to resolve the custom domain to original subdomain
# for your multi telent application.
#
# It's all transperant to your application, it performs cname lookup and
@dwabnitz
dwabnitz / sync.rake
Created October 22, 2009 19:21 — forked from speedmax/sync.rake
synchronize local and production servers
# app:sync
# Local and production synchronization
# - require yaml_db plugin
namespace :app
namespace :sync do
task :all => [:files, :db]
task :files do
`rsync -azv user@host:'/apps/myawesomeapp/shared/files/' #{Rails.root + 'files'}`
@dwabnitz
dwabnitz / gist:244614
Created November 28, 2009 19:30 — forked from dhh/gist:45076
Basecamp-style subdomains in rails
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName example.com
# ServerAlias *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
@dwabnitz
dwabnitz / subdomain_accounts.rb
Created November 28, 2009 20:20 — forked from robbyrussell/subdomain_accounts.rb
handle subdomain based accounts in rails
#
# Inspired by
# http://dev.rubyonrails.org/svn/rails/plugins/account_location/lib/account_location.rb
#
module SubdomainAccounts
def self.included( controller )
controller.helper_method(:account_domain, :account_subdomain, :account_url, :current_account, :default_account_subdomain, :default_account_url)
end
protected
@dwabnitz
dwabnitz / statham_sanitizer.rb
Created December 12, 2009 08:40 — forked from vigetlabs/statham_sanitizer.rb
html sanitizer for use in rails - whitelisting
module HTML
class StathamSanitizer < WhiteListSanitizer
protected
def tokenize(text, options)
super.map do |token|
if token.is_a?(HTML::Tag) && options[:parent].include?(token.name)
token.to_s.gsub(/</, "&lt;")
else
@dwabnitz
dwabnitz / deploy.rb
Created March 25, 2010 11:57 — forked from codeprimate/deploy.rb
Capistrano Deploy Recipe for Git and Phusion Passenger
# Capistrano Deploy Recipe for Git and Phusion Passenger
#
# After issuing cap deploy:setup. Place server specific config files in
# /home/#{user}/site/[staging|production]/shared
# Set :config_files variable to specify config files that should be
# copied to config/ directory (i.e. database.yml)
#
# To deploy to staging server:
# => cap deploy
# => Deploys application to /home/#{user}/site/staging from master branch
@dwabnitz
dwabnitz / rails_test_box_prepackaged
Created May 8, 2010 08:56 — forked from jeroenvandijk/rails_test_box_prepackaged.sh
Instructions for setting up a prepackaged rails test environment
# MAKE SURE YOU HAVE VIRTUAL BOX INSTALLED http://www.virtualbox.org/wiki/Downloads
#
# Copy paste this file in your terminal
# The following will create a dir which contains the rails repo.
# You can start edit this later on. It will also create a Gemfile and a Vagrantfile.
# It will run bundle and it will # download and activate the virtualbox that contains
# everything you need to start # testing.
mkdir rails_test_box
cd rails_test_box
@dwabnitz
dwabnitz / revised-font-stack.css
Created August 2, 2010 20:40 — forked from jonbuda/revised-font-stack.css
A Revised Web Font Stack Selection
/*
A Revised Font Stack
from A Way Back
http://www.awayback.com/revised-font-stack/
*/
/*
@dwabnitz
dwabnitz / nokogiri
Created August 24, 2011 19:42 — forked from softprops/nokogiri
# using rvm with ruby-1.8.7-p249
# latest version 2.7.88
brew install libxml2
# installing libxslt from source code
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar xvfz libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/Cellar/libxslt/1.1.26 --with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.8