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
# 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 |
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
# an example Monit configuration file for collectiveidea's fork of delayed_job. | |
# See: http://stackoverflow.com/questions/1226302/how-to-monitor-delayedjob-with-monit/1285611 | |
# | |
# To use: | |
# 1. replace {app_name} and {environment} as appropriate | |
# 2. copy to your repository under config/delayed_job.monitrc | |
# 3. add this to your /etc/monit/monitrc: | |
# | |
# include /var/www/apps/{app_name}/current/config/*.monitrc | |
# 4. reload monit when you deploy to pick up any changes to your monitrc files: sudo monit reload |
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
if RAILS_ENV != 'development' | |
require 'cache_money' | |
config = YAML.load(IO.read(File.join(RAILS_ROOT, "config", "memcached.yml")))[RAILS_ENV] | |
$memcache = MemCache.new(config) | |
$memcache.servers = config['servers'] | |
$local = Cash::Local.new($memcache) | |
$lock = Cash::Lock.new($memcache) | |
$cache = Cash::Transactional.new($local, $lock) |
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
$ cat test.rb | |
class Person | |
end | |
Person.new | |
$ cat test.rb | irb | |
>> class Person | |
>> end | |
=> nil | |
>> |
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
def random_password(size = 8) | |
chars = (('a'..'z').to_a + ('0'..'9').to_a) - %w(i o 0 1 l 0) | |
(1..size).collect{ chars[rand(chars.size)] }.join | |
end |
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
begin | |
# check if memcached is running; if it is, use that instead of the default memory cache | |
Timeout.timeout(0.5) { TCPSocket.open("localhost", 11211) { } } | |
config.cache_store = :mem_cache_store, %w(localhost:11211), { :namespace => 'OI', :timeout => 60 } | |
$stderr.puts "Using memcached on localhost:11211" | |
rescue StandardError | |
config.cache_store = nil | |
$stderr.puts "memcached not running, caching to memory" | |
end |
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
# If your workers are inactive for a long period of time, they'll lose | |
# their MySQL connection. | |
# | |
# This hack ensures we re-connect whenever a connection is | |
# lost. Because, really. why not? | |
# | |
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar) | |
# | |
# From: | |
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/ |
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
require 'open-uri' | |
# url dsl -- the ultimate url dsl! | |
# | |
# You just can't beat this: | |
# | |
# $ irb -r url_dsl | |
# >> include URLDSL | |
# => Object | |
# >> http://github.com/defunkt.json |
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
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: redis-server | |
# Required-Start: $syslog | |
# Required-Stop: $syslog | |
# Should-Start: $local_fs | |
# Should-Stop: $local_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: redis-server - Persistent key-value db |
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
HANDY ONE-LINERS FOR RUBY November 16, 2005 | |
compiled by David P Thomas <davidpthomas@gmail.com> version 1.0 | |
Latest version of this file can be found at: | |
http://www.fepus.net/ruby1line.txt | |
Last Updated: Wed Nov 16 08:35:02 CST 2005 | |
FILE SPACING: |