Skip to content

Instantly share code, notes, and snippets.

View rodrigopinto's full-sized avatar

Rodrigo Pinto rodrigopinto

  • Berlin, Germany
  • 18:40 (UTC +02:00)
View GitHub Profile
@nbibler
nbibler / gist:5307941
Last active August 26, 2024 20:44
A .powrc file which works with RVM's .rvmrc or .ruby-version (+ .ruby-gemset) configuration files.
if [ -f "$rvm_path/scripts/rvm" ]; then
source "$rvm_path/scripts/rvm"
if [ -f ".rvmrc" ]; then
source ".rvmrc"
fi
if [ -f ".ruby-version" ]; then
rvm use `cat .ruby-version`
fi
it "instantiates record with params" do
# require 'pry'; binding.pry
url = mock_model(Url)
post :create, :original_url => "http://example.org"
Url.should_receive(:new).with({"original_url" => "http://example.org"}).and_return(url)
end
anonymous
anonymous / .tmux.conf
Created January 2, 2013 19:05
set -g default-terminal "screen-256color"
set -g status-bg black
set -g status-fg white
setw -g mode-mouse on
set-option -g base-index 1
set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix
set -g status-keys vi
set-window-option -g utf8 on
@caike
caike / a_smell.rb
Created November 28, 2012 15:43
Tell, Don't Ask.
class SomeClass
def some_method(obj)
if obj.foo
obj.bar
end
end
end
class SomeOtherClass
@mergulhao
mergulhao / gist:4158386
Created November 28, 2012 01:16
Cursor rápido no Mac OSX
# Basta rodar os 2 comandos abaixo no console e reiniciar.
# Mais coisas legais em https://gist.github.com/2260182
defaults write NSGlobalDomain KeyRepeat -int 0.02
defaults write NSGlobalDomain InitialKeyRepeat -int 12
@caike
caike / spec_helper.rb
Created October 25, 2012 15:09
missing translations
##
# Raises error if missing translation key
##
config.before(:all, type: :controller) do
@_i18n_exception_handler = I18n.exception_handler
I18n.exception_handler = lambda { |*args| raise args.first.to_s }
end
config.after(:all, type: :controller) do
I18n.exception_handler = @_i18n_exception_handler
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

module DelayedJob
module Matchers
def enqueue_delayed_job(handler)
DelayedJobMatcher.new handler
end
class DelayedJobMatcher
def initialize(handler)
@handler = handler
@attributes = {}
@kaievns
kaievns / gist:3158011
Created July 22, 2012 02:38
Paperclip mongoid support that works with mongoid 3
#
# Save this into your `lib/mongoid/paperclip.rb` file
#
#
require "paperclip"
module Paperclip
class << self
@IanVaughan
IanVaughan / uninstall_gems.sh
Created June 9, 2012 20:37
Uninstall all rbenv gems
#!/usr/bin/env bash
uninstall() {
list=`gem list --no-versions`
for gem in $list; do
gem uninstall $gem -aIx
done
gem list
gem install bundler
}