Skip to content

Instantly share code, notes, and snippets.

@cmaitchison
cmaitchison / after_commit_with_transactional_fixtures.rb
Last active August 4, 2016 03:30 — forked from charleseff/after_commit_with_transactional_fixtures.rb
testing after_commit hooks with transactional fixtures in Rails 4
require 'active_record/connection_adapters/abstract/transaction'
module ActiveRecord
module ConnectionAdapters
class SavepointTransaction < OpenTransaction
def perform_commit_with_transactional_fixtures
commit_records if number == 1
perform_commit_without_transactional_fixtures
end
alias_method_chain :perform_commit, :transactional_fixtures
@pithyless
pithyless / char_converter.rb
Created September 5, 2012 16:00
Rails middleware to encode characters and avoid exploding controllers
# config/initializers/char_converter.rb
require 'uri'
module Support
class CharConverter
SANITIZE_ENV_KEYS = [
"HTTP_COOKIE", # bad cookie encodings kill rack: https://github.com/rack/rack/issues/225
"HTTP_REFERER",
"PATH_INFO",
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@daniambrosio
daniambrosio / devise.pt-BR.yml
Created October 30, 2011 19:43
pt-BR-Translation-for-Devise-1.4.7
# Additional translations at http://github.com/plataformatec/devise/wiki/I18n
# Este arquivo deve ser colocado em config/locales/devise.pt-BR.yml
pt-BR:
errors:
messages:
expired: "expirou, por favor solicite um novo"
not_found: "não encontrado"
already_confirmed: "já foi confirmado, por favor tente fazer login"
not_locked: "não estava bloqueado"
@jcsrb
jcsrb / gist:1081548
Created July 13, 2011 23:05
get avatar from google profiles, facebook, gravatar, twitter, tumblr
function get_avatar_from_service(service, userid, size) {
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )
// everything else will go to the fallback
// google and gravatar scale the avatar to any site, others will guided to the next best version
@mateusg
mateusg / devise.pt-BR.yml
Last active December 23, 2023 15:15 — forked from alexandreaquiles/devise.pt-BR.yml
pt-BR translations for Devise
# encoding: UTF-8
# pt-BR translations for Devise
pt-BR:
devise:
confirmations:
confirmed: "Sua conta foi confirmada com sucesso. Você está logado."
send_instructions: "Dentro de minutos, você receberá um e-mail com instruções para a confirmação da sua conta."
send_paranoid_instructions: "Se o seu endereço de e-mail estiver cadastrado, você receberá uma mensagem com instruções para confirmação da sua conta."
failure:
already_authenticated: "Você já está logado."
@dcrec1
dcrec1 / matchers.rb
Created September 17, 2010 22:38
Rails3 RSpec matchers
def should_be_delivered_on_creation_with(clazz)
context "on creation" do
it "should be send on an email" do
mailer = mock(clazz)
clazz.should_receive(subject.class.to_s.underscore).with(an_instance_of(subject.class)).and_return(mailer)
mailer.should_receive :deliver
Factory subject.class.to_s.underscore
end
end
end
@dcrec1
dcrec1 / centos
Last active March 24, 2017 11:52
ubuntu/centos nginx
cd /tmp
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm -Uhv rpmforge-release*.rf.i386.rpm
yum install readline-dev htop