Skip to content

Instantly share code, notes, and snippets.

View rondy's full-sized avatar

Rondy Sousa rondy

  • Plataformatec
  • São Paulo, SP
View GitHub Profile
@rondy
rondy / cozinhando_phoenix.md
Last active August 29, 2015 14:01
Cozinhando Phoenix

Cozinhando Phoenix

Ouça a playlist no Rdio.

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

@rondy
rondy / search.exs
Last active August 29, 2015 14:07
ExUnit.start
defmodule SearchTokenizerTest do
use ExUnit.Case
test "tokenizes an empty text" do
text = ""
assert Search.tokenize(text) == []
end
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 March 17, 2015 16:05
Preferences.sublime-settings
{
"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":
[
=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')
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
@rondy
rondy / chain.rb
Created September 25, 2015 01:00
# 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 September 22, 2011 02:04
Authorization (modular abilities)
class User < ActiveRecord::Base
def admin?
role? :admin
end
def role?(role)
roles.include? role
end
@rondy
rondy / gist:1287061
Created October 14, 2011 13:16
Dynamic scopes injection
module BookScopes
def self.extended(base)
base.instance_exec &scope_definitions
end
def self.included(base)
base.class_exec &scope_definitions
end
@rondy
rondy / 1_books_controller.rb
Created October 18, 2011 01:47
Scoped filters
class BooksController < ApplicationController
def index
# params = { filters: { genre: "Westerns", sold_out: 1 } }
@books = Book.filtered(params[:filters])
end
end