Skip to content

Instantly share code, notes, and snippets.

@fxn
fxn / gist:1520171
Created December 26, 2011 00:52
Coprimality test with a regular expression
See https://github.com/fxn/math-with-regexps.
@ChuckJHardy
ChuckJHardy / app.rake
Created May 29, 2011 12:34
Rake Task for Database Population
------------ From Rake Task
namespace :app do
# Checks and ensures task is not run in production.
task :ensure_development_environment => :environment do
if Rails.env.production?
raise "\nI'm sorry, I can't do that.\n(You're asking me to drop your production database.)"
end
end
anonymous
anonymous / gist:977645
Created May 17, 2011 23:24
=head1 NAME
smtptls-forward
=head1 DESCRIPTION
This plugin forwards the mail via SMTP TLS to a specified server, rather than
delivering the email locally.
This is very similar to the smtp-forward queue plugin. In fact it is just a
@derekcollison
derekcollison / Cloud Foundry Production Updates
Created April 16, 2011 17:11
How to update your application in Cloud Foundry without dropping user requests..
# vmc update is great for test and development, however it stops your old app and stages and starts the new one,
# resulting in dropped requests.
# If you want to update an application without dropping user requests, see below.
# NOTE: This change assumes your application can share services, etc with the new version.
# Assume my app is named foo
vmc push foo-v2 --url foov2.cloudfoundry.com
@wbailey
wbailey / databases.rake
Created February 11, 2011 08:58
ActiveRecord migrations outside of Rails
require 'yaml'
require 'logger'
require 'active_record'
namespace :db do
def create_database config
options = {:charset => 'utf8', :collation => 'utf8_unicode_ci'}
create_db = lambda do |config|
ActiveRecord::Base.establish_connection config.merge('database' => nil)