Skip to content

Instantly share code, notes, and snippets.

@btoone
btoone / deploy.rb
Created August 17, 2011 14:48
Example Capistrano configuration for multi stage deployment
# app/config/deploy.rb
# Most of the changes specific to your environment will be set in
# the `app/config/deploy/[env].rb` files.
# define multiple deployments
set :stages, %w(production staging)
set :default_stage, "staging"
@btoone
btoone / gist:1151748
Created August 17, 2011 15:17
Ubuntu Packages for Rails Hosting

One command to rule them all

sudo aptitude install apache2 apache2-prefork-dev autoconf bison build-essential \
clang curl dnsutils git-core imagemagick libc6-dev libcurl4-openssl-dev libffi-dev \
libmagickwand-dev libmysqlclient16 libmysqlclient16-dev libreadline6-dev libsqlite3-0 \
libsqlite3-dev libssl-dev libxml2 libxml2-dev libxslt-dev libxslt1.1 libxslt1-dev \
libyaml-dev mysql-client mysql-server openssl sqlite3 wget zlib1g zlib1g-dev 
@btoone
btoone / ubuntu-lucid-setup-rails.md
Created November 17, 2011 14:06
Ubuntu Lucid Setup Guide for Rails

This note will walk you though setting up and securing a Ubuntu 10.04 LTS then deploying a Rails application with mulit-stage deployment.

TODO:

  • Add section for NGINX setup

Server Setup

@btoone
btoone / gist:2230355
Created March 28, 2012 20:41
Load yaml from a string
require 'yaml'
y = <<-YAML
:one:
:two:
:development:
:adapter: mysql2
:host: 127.0.0.1
:database: app_development
:username: root
require 'rubygems'
require 'active_record'
require 'mysql2'
require 'net/ssh/gateway'
gateway = Net::SSH::Gateway.new(
'remotehost.com',
'username'
)
@btoone
btoone / parse-json.rb
Created March 30, 2012 22:02
Parse JSON
require 'json'
json = '{
"description":"the description for this gist",
"public":true,
"files":{
"file1.txt":{
"content":"String file contents"
}
}
@btoone
btoone / credentials.yml
Created April 3, 2012 01:54
Prototype for a gist library using httparty
:username: caspyin
:password: PASSWD
@btoone
btoone / curl.md
Last active May 14, 2024 19:32
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
# Use .htaccess to redirect subdomains
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.yourwebsite.com
RewriteCond %{HTTP_HOST} ([^.]+)\.yourwebsite.com
RewriteRule ^(.*)$ /path_to_your_site/httpdocs/work_out.php?url=%1
RewriteEngine On
# Remove the www
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/ [R=301,L]