Skip to content

Instantly share code, notes, and snippets.

Rondy Sousa rondy

View GitHub Profile
@rondy
rondy / cozinhando_phoenix.md
Last active Aug 29, 2015
Cozinhando Phoenix
View cozinhando_phoenix.md

Cozinhando Phoenix

Ouça a playlist no Rdio.

Lisztomania

Música que mostrou a cara da banda pro mundo. Refrão marcante, meio chiclete. Encaixa em qualquer trilha sonora de comercial modernoso.

If I Ever Feel Better

View search.exs
ExUnit.start
defmodule SearchTokenizerTest do
use ExUnit.Case
test "tokenizes an empty text" do
text = ""
assert Search.tokenize(text) == []
end
View gist:9e9067c1e7888b658523
gpfb() {
git add . && git commit --amend -C HEAD && git push -f
}
# Public: Go to a git branch from a given partial name.
#
# $1 - The branch partial name.
#
# Examples
#
@rondy
rondy / gist:93a9330cc94bc302d361
Created Mar 17, 2015
Preferences.sublime-settings
View gist:93a9330cc94bc302d361
{
"bold_folder_labels": true,
"color_scheme": "Packages/User/Xcode_default.tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_face": "Menlo",
"font_size": 12,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
View capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
View gist:5feb00566aad7aa496ff
RUBY PROFILING
ruby-prof
http://www.dan-manges.com/blog/rails-performance-tuning-workflow
http://snippets.aktagon.com/snippets/255-how-to-profile-your-rails-and-ruby-applications-with-ruby-prof
http://blog.endpoint.com/2012/05/profile-ruby-with-ruby-prof-and.html
https://www.coffeepowered.net/2013/08/02/ruby-prof-for-rails/
https://github.com/ruby-prof/ruby-prof/blob/master/examples/graph.txt
https://github.com/tmm1/stackprof
http://www.confreaks.com/videos/5096-RubyConf2014-real-world-ruby-performance-at-scale
View chain.rb
# encoding: utf-8
module ChainOfResponsibility
attr_writer :successor
def can_handle_request?(request); end
def do_handle(request); end
def handle_request(request)
if can_handle_request?(request)
@rondy
rondy / gist:1233857
Created Sep 22, 2011
Authorization (modular abilities)
View gist:1233857
class User < ActiveRecord::Base
def admin?
role? :admin
end
def role?(role)
roles.include? role
end
@rondy
rondy / gist:1287061
Created Oct 14, 2011
Dynamic scopes injection
View gist:1287061
module BookScopes
def self.extended(base)
base.instance_exec &scope_definitions
end
def self.included(base)
base.class_exec &scope_definitions
end
You can’t perform that action at this time.