Skip to content

Instantly share code, notes, and snippets.

@cavi21
cavi21 / deploy.rb
Created November 21, 2009 16:13 — forked from mrichman/deploy.rb
set :application, "myapplication"
set :repository, "user@example.com:git/#{application}.git"
set :server_name, "www.example.com"
set :scm, "git"
set :checkout, "export"
set :deploy_via, :remote_cache
set :branch, "master"
set :base_path, "/path/to/www"
set :deploy_to, "/path/to/www/#{application}"
set :apache_site_folder, "/etc/apache2/sites-enabled"
#
# = Capistrano Passenger deploy tasks
#
# Provides tasks for deploying a Rails application with Passenger (aka mod_rails).
#
# Category:: Capistrano
# Package:: Passenger
# Author:: Simone Carletti <weppos@weppos.net>
# Copyright:: 2007-2008 The Authors
# License:: MIT License
@cavi21
cavi21 / README.md
Created April 20, 2010 21:26 — forked from jimeh/README.md

Rails Setting model

This is a semi-quick key/value store I put together for a quick way to store temporary data related to what's in my database, in a reliable way. For example, I'm using it to keep track of where a hourly and a daily crontask that processes statistics left off, so it can resume only processing and summarizing new data on the next run.

Code quality most likely is not great, but it works. And I will update this gist as I update my project.

How It Works

The settings table has two columns, a key and a value column. The value column is serialized, so you can technically store almost anything in there. Memcache is also used as a caching layer to minimize database calls.

module ApplicationHelper
# Access Levels
ACCESS_LEVELS = { :private => 0, :friends => 1, :public => 2 }
# Access levels i18n translation
def access_levels
ACCESS_LEVELS.collect{|k,v| [I18n.t("access." + k.to_s), v]}
end
end
@cavi21
cavi21 / command.sh
Created May 21, 2012 16:37 — forked from schisamo/command.sh
Ubuntu 10.04 + Ruby 1.9.2p180 chef bootstrap file
knife ec2 server create -G default -I ami-61be7908 -f m1.small \
-S schisamo -x ubuntu -d ubuntu10.04-ruby192
@cavi21
cavi21 / omniauth.rb
Created July 14, 2012 19:13 — forked from madhums/omniauth.rb
OmniAuth configuration for rails 2.3.x
#config/initializers/omniauth.rb
require 'openid/store/filesystem'
ActionController::Dispatcher.middleware.use OmniAuth::Builder do #if you are using rails 2.3.x
#Rails.application.config.middleware.use OmniAuth::Builder do #comment out the above line and use this if you are using rails 3
provider :twitter, 'key', 'secret'
provider :facebook, 'app_id', 'secret'
provider :linked_in, 'key', 'secret'
provider :open_id, OpenID::Store::Filesystem.new('/tmp')
end
@cavi21
cavi21 / gist:4288059
Created December 14, 2012 19:43 — forked from pioz/gist:967559
require 'rubygems'
require 'activemerchant'
ActiveMerchant::Billing::Base.mode = :test
paypal_options = {
:login => 'xxx',
:password => 'yyy',
:signature => 'zzz'
}
::PAYPAL_EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)
ec2-authorize default -p 2003
var jq = document.createElement('script');
jq.src = "http://code.jquery.com/jquery-latest.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery.noConflict();
#!/usr/bin/env ruby
# Pass in the name of the site you wich to create a cert for
domain_name = ARGV[0]
if domain_name == nil
puts "Y U No give me a domain name?"
else
system "openssl genrsa -out #{domain_name}.key 1024"
system "openssl req -new -key #{domain_name}.key -out #{domain_name}.csr -subj '/C=US/ST=NJ/L=Monroe/O=MyCompany/OU=IT/CN=#{domain_name}'"