Skip to content

Instantly share code, notes, and snippets.

@netzpirat
netzpirat / deploy.rb
Created May 14, 2009 10:06
Capistrano recipe to sync rails database and files within a multi stage environment
set :sync_directories, ["public/assets", "public/galleries"]
set :sync_backups, 3
.gradle
gradle-wrapper.*
gradlew*
**/build
gradle-run.dump
**/*$py.class
wget -P /tmp http://rubyforge.org/frs/download.php/64475/ruby-enterprise-1.8.7-20090928.tar.gz
cd /tmp/ruby-enterprise-1.8.7-20090928
./installer --auto=/opt/ruby-enterprise
Then, ruby enterprise will be available: /opt/ruby-enterprise/bin/ruby
@mikhailov
mikhailov / redis_usage.rb
Created January 18, 2010 06:52
Rails on Redis - is all about high performance
# app/controllers/posts_controller.rb
class PostsController < ApplicationController
def index
@posts.all_cached # Retrive only at once by every 5 minutes
expires_in 5.minutes, :private => false, :public => true
end
end
# app/models/post.rb
Class Post
@netzpirat
netzpirat / kickstart.rb
Created January 28, 2010 14:20
Make an initial HTTP request to start Phusion Passenger after deployment
namespace :deploy do
desc "Send initial HTTP request to start Phusion Passenger application spawner"
task :kickstart, :roles => :web do
servers = find_servers_for_task(current_task)
servers.each do |server|
run_locally "wget http://#{server.host} -O - > /dev/null"
end
end
diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb
index bb9e1dc..68a898d 100644
--- a/app/controllers/invitations_controller.rb
+++ b/app/controllers/invitations_controller.rb
@@ -1,20 +1,16 @@
class InvitationsController < ApplicationController
+ before_filter :require_analyst
+
def new
@invitation = Invitation.new
# Ruby 1.8.7 and Rails 3.0pre
$ sudo gem install unicorn
$ rails blog -m http://www.lycom.de/files/rails-templates/rails187.txt && cd blog
$ unicorn # similar to the command "rails server"
@rgo
rgo / capistrano_db_dump_and_clone_to_local.rb
Created March 1, 2010 12:04
Capistrano: Dump and clone to local database
# Directly copied from eycap-0.5.2 (thanks!)
#
# With these tasks you can:
# - dump your production database and save it in shared_path/db_backups
# - dump your production into your local database (clone_to_local)
#
# Tested and fixed by fjguzman
Capistrano::Configuration.instance(:must_exist).load do
namespace :db do
@netzpirat
netzpirat / mass_mailer.rb
Created March 18, 2010 23:56
Send email to all email addresses from a MySQL table
#!/usr/bin/env ruby
#
# Send mass emails to the users of my small private email server
# with TLS.
#
# Queries the MySQL database for my vhost users and sends an
# email with ActionMailer to them.
#
# Install dependencies with `gem install mysql actionmailer`
#
@LRDesign
LRDesign / deploy.rb
Created March 21, 2010 18:22 — forked from netzpirat/deploy.rb
Capistrano recipe to sync rails database and files, using remote database.yml instead of local for remote credentials
set :sync_directories, ["public/assets", "public/galleries"]
set :sync_backups, 3