Skip to content

Instantly share code, notes, and snippets.

View rinaldifonseca's full-sized avatar

Rinaldi Fonseca rinaldifonseca

View GitHub Profile
@rinaldifonseca
rinaldifonseca / gist:2232387
Created March 29, 2012 01:52 — forked from jrochkind/gist:2161449
A Capistrano Rails Guide

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

@rinaldifonseca
rinaldifonseca / resque.rake
Created March 7, 2012 21:27 — forked from denmarkin/resque.rake
My rake task for clearing Resque queues and stats
# see http://stackoverflow.com/questions/5880962/how-to-destroy-jobs-enqueued-by-resque-workers - old version
# see https://github.com/defunkt/resque/issues/49
# see http://redis.io/commands - new commands
namespace :resque do
desc "Clear pending tasks"
task :clear => :environment do
queues = Resque.queues
queues.each do |queue_name|
puts "Clearing #{queue_name}..."
@rinaldifonseca
rinaldifonseca / gist:1974802
Created March 4, 2012 21:12 — forked from wisq/gist:1507733
Why I love zsh (and hate being forced to use bash)

Why I love zsh (and hate being forced to use bash)

  • Smarter completion:
  • cd tab completion -- directories only
  • bash can do this, but needs the bash-completion package, usually comes separately
  • zsh always comes with completions, why doesn't bash?
  • Filename correction during completion
  • if dir1/x exists and dir2 exists, then "dir/x<TAB>" completes to dir1/x
  • if name1 is a file and name2 is a directory with files in it, "name/<TAB>" completes to "name2/"
@rinaldifonseca
rinaldifonseca / config.ru
Created March 2, 2012 14:03
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
# Be sure to have rails and thin installed.
require "rubygems"
# We are not loading Active Record, nor the Assets Pipeline, etc.
# This could also be in your Gemfile.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
require "rails"
@rinaldifonseca
rinaldifonseca / gist:1781970
Created February 9, 2012 18:49 — forked from jittuu/gist:792715
Test Omniauth Facebook Callback Controllers in Devise with rspec
require 'spec_helper'
describe Users::OauthCallbacksController, "handle facebook authentication callback" do
describe "#annonymous user" do
context "when facebook email doesn't exist in the system" do
before(:each) do
stub_env_for_omniauth
get :facebook
@rinaldifonseca
rinaldifonseca / 0-readme.md
Created January 28, 2012 19:21 — forked from burke/0-readme.md
ruby-1.9.3-p0 cumulative performance patch.

Patched ruby 1.9.3-p0 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p0 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84).

Huge thanks to funny-falcon for the performance patches.

@rinaldifonseca
rinaldifonseca / gist:1612916
Created January 14, 2012 21:12
rails csrf-token
form_authenticity_token.to_s
headers: {
'X-Transaction': 'POST Example',
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
},
@rinaldifonseca
rinaldifonseca / dnsd.rb
Created December 18, 2011 12:10 — forked from peterc/dnsd.rb
Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# By Peter Cooper
#
# MIT license
#
# * Not advised to use in your production environment! ;-)
# * Requires Ruby 1.9
# * Supports A and CNAME records
# * See http://www.ietf.org/rfc/rfc1035.txt for protocol guidance
# * All records get the same TTL
require 'net/http'
require 'uri'
postData = Net::HTTP.post_form(URI.parse('http://rinaldifonseca.com'), {'param'=>'postValue'})
class AddPriceToLineItems < ActiveRecord::Migration
def change
add_column :line_items, :price, :decimal, :precision => 8, :scale => 3
end
end