Skip to content

Instantly share code, notes, and snippets.

@schleg
schleg / 01. Gemfile
Created May 26, 2011 17:26
Setup for Devise + Omniauth
gem 'pg'
group :development do
gem 'ruby-debug'
end
gem 'rake', '~> 0.8.7'
gem 'devise'
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'omniauth'
gem 'haml'
gem 'dynamic_form'
@schleg
schleg / gist:1053215
Created June 29, 2011 05:33
Ruby AES Encryption using OpenSSL
#!/usr/bin/env ruby
require "openssl"
require 'digest/sha2'
require 'base64'
# We use the AES 256 bit cipher-block chaining symetric encryption
alg = "AES-256-CBC"
# We want a 256 bit key symetric key based on some passphrase
digest = Digest::SHA256.new
@schleg
schleg / redirect_once_to
Created September 3, 2011 22:24
one time redirect
def redirect_once_to(path)
route = ActionController::Routing::Routes.recognize_path(path)
redirect_to path unless route[:controller] == controller_name && route[:action] == action_name
end
@schleg
schleg / Basecamp.rb
Created September 20, 2011 19:23
Basecamp API lib; Rails 3 compatible
require 'net/https'
require 'yaml'
require 'date'
require 'time'
begin
require 'xmlsimple'
rescue LoadError
begin
require 'rubygems'
# app/models/<Your Model>.rb
has_attached_file :<the_image_attribute_name>, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :storage => :s3, :path => ":attachment/:id/:style.:extension", :bucket => '<your_image_bucket>', :s3_credentials => "#{::Rails.root.to_s}/config/amazon_s3.yml"
@schleg
schleg / install.sh
Created August 30, 2012 02:18 — forked from maggit/install.sh
Chef installer for OS X 10.8 Mountain Lion
#!/bin/bash
# This is the current stable release to default to, with Omnibus patch level (e.g. 10.12.0-1)
# Note that the chef-full template downloads 'x.y.z' not 'x.y.z-r' which should be a duplicate of the latest -r
release_version="10.12.0-1"
use_shell=0
# Check whether a command exists - returns 0 if it does, 1 if it does not
exists() {
if command -v $1 &>/dev/null
# verified to work on DigitalOcean Ubuntu 12.10 X32 Server instance
# prerequisites
sudo addroup admin
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline-gplv2-dev libyaml-dev gcc git make zsh
chsh -s /bin/zsh
# oh-my-zsh
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -xvzf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125/
./configure --prefix=/usr/local
make
make install
@schleg
schleg / README.md
Last active August 29, 2015 14:00 — forked from jpantuso/README.md

Deploying Rails to Linode

Installing Ruby Enterprise Edition, Apache, MySQL, and Passenger for deploying Rails 3.0 applications.

Get a Linode, and set it up with Ubuntu 10.04 LTS so that you have till April 2013 to get updates. Once the Linode is formatted, boot it and continue on.

Set up an 'A' record in your DNS, pointing to the IP of your Linode. I'm using demo.napcs.com here.

Initial setup

May 6, 2014 9:27:46 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
May 6, 2014 9:27:47 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
May 6, 2014 9:27:47 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
May 6, 2014 9:27:47 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 637 ms
May 6, 2014 9:27:47 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina