Skip to content

Instantly share code, notes, and snippets.

@addame
addame / deploy.rb
Created January 25, 2009 02:55 — forked from tbalthazar/deploy.rb
# use the ubuntu machine gem
require 'capistrano/ext/ubuntu-machine'
# #######################################
# HOSTING PROVIDER CONFIGURATION
# Those tasks have been tested with severa hosting providers
# and sometimes tasks are specific to those providers
set :hosting_provider, "slicehost" # currently supported : ovh-rps, ovh-dedie, slicehost
RE="ruby-enterprise-1.8.6-20081215"
PREFIX=/opt/$RE
VERSION=2.0.6
GEM_PATH="$PREFIX/lib/ruby/gems/1.8/gems/passenger-$VERSION"
DOMAIN=odpiralnicasi.com
APP_ROOT=/srv/oc
# install Apache2
apt-get install -qq apache2 apache2-prefork-dev
#!/bin/bash
# Unattended REE/Passenger installation
# Source: http://weblog.brightlight-ict.nl/2008/12/unattended-passenger-ruby-enterprise-installation-on-ubuntu-8/
# 15/03/09 Updated to use latest r.e.e. and passenger 2.1 and rewrote bits thanks to the comments left on my blog. Thanks guys
if [ "$(whoami)" != "root" ]; then
echo "You need to be root to run this!"
exit 2
fi
require "openssl"
require "net/smtp"
Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
check_auth_args user, secret, authtype if user or secret
sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
# alternative Block execution on empty Enumerable
# see : http://blog.sponagl.de/2009/1/23/alternative-block-execution-on-empty-enumerable
# 1.
ary = []
ary.each do |i|
puts i
# download, from_repo, and commit_state methods swiped from
# http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"
# This is a script to install both ruby 1.8.7 and 1.9.1, with suffixed binaries and symlinks
mkdir -p /usr/local/src ; cd /usr/local/src
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p160.tar.bz2
tar -xjvf ruby-1.8.7-p160.tar.bz2
cd ruby-1.8.7-p160
./configure --prefix=/usr --program-suffix=18 --enable-shared
make && sudo make all install
cd /usr/local/src
# Drop this file in config/initializers to run your Rails project on Ruby 1.9.
# This is three separate monkey patches -- see comments in code below for the source of each.
# None of them are original to me, I just put them in one file for easily dropping into my Rails projects.
# Also see original sources for pros and cons of each patch. Most notably, the MySQL patch just assumes
# that everything in your database is stored as UTF-8. This was true for me, and there's a good chance it's
# true for you too, in which case this is a quick, practical solution to get you up and running on Ruby 1.9.
#
# Andre Lewis 1/2010
# encoding: utf-8
#!/bin/sh
# Author: Carl Youngblood, 2010
# Based on http://www.novell.com/coolsolutions/feature/15380.html
### BEGIN INIT INFO
# Provides: bluepill
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
@addame
addame / will_paginate.rb
Created November 23, 2011 14:28 — forked from leifcr/will_paginate.rb
Extends will_paginate to play well with Twitter's Bootstrap (http://twitter.github.com/bootstrap/). Suggested location: config/initializers/will_paginate.rb
# https://gist.github.com/1305042
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= BootstrapLinkRenderer
super.try :html_safe
end
class BootstrapLinkRenderer < LinkRenderer