- Unit tests: Review unit tests first. Unit tests are a fantastic way to grasp how code is meant to be used by others and to learn what the expected behavior is. Are there any test gaps that should be there?
- Method arguments" Make sure arguments to methods make sense and are validated.
- Null References" (Yah yah, we know. Use F# and this goes away. We get it already.) Null references are a bitch and it’s worth looking out for them specifically.
- Conventions Consistency" Make sure naming, formatting, etc. follow our conventions and are consistent. I like a codebase that’s fairly consistent so you know what to expect.
- Disposables: Make sure disposable things are disposed. Look for usages of resources that should be disposed but are not.
- Security: There is a whole threat and mitigation review process that falls under this bucket.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'uri-read' | |
links = URI.parse("http://example.com").read.scan(/href\=\"([a-zA-Z_\.0-9\/\-\! :\@\$]*)\"/) | |
links.each do |link| | |
puts link | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Isso ira criar um arquivo app/models/cards_list_observer.rb | |
# Edite-o para que fique desta maneira: | |
class CardsListObserver < ActiveRecord::Observer | |
def after_create(images) | |
Notifier.cards_selected(images).deliver | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.active_record.observers = :cards_list_observer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! bin/bash | |
# | |
for i in find -name *.php | |
do | |
echo "class $i\n # Try it again \nend" >> "${i%.*}.rb" | |
rm -rf $i | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
require "prawn" | |
class Certificate | |
attr_accessor :path | |
PDF_OPTIONS = { | |
:page_size => "A5", | |
:page_layout => :landscape, | |
:margin => [40, 75] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DiretoriosHelper | |
def diretorio_lista_empresas(usuario) | |
a= Array.new | |
if not usuario.cliente.filial? | |
empresas = usuario.cliente.filiais | |
a << usuario.cliente | |
empresas.each do |empresa| | |
a << empresa | |
end | |
a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_field(field, field_attributes) | |
# Multiple values | |
if is_a_kind_of_collection? field_attributes | |
self.contact.send "#{field}=", parse_multiple_values(field_attributes, field) | |
else | |
parse_single_values field_attributes, field | |
end | |
end | |
private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Gil | |
def self.included(base) | |
base.extend ClassMethods | |
base.include InstanceMethods | |
end | |
module ClassMethods | |
def roles *args | |
ancestors.first | |
end |
o.......Open files, directories and bookmarks....................|NERDTree-o|
go......Open selected file, but leave cursor in the NERDTree.....|NERDTree-go|
t.......Open selected node/bookmark in a new tab.................|NERDTree-t|
T.......Same as 't' but keep the focus on the current tab........|NERDTree-T|
i.......Open selected file in a split window.....................|NERDTree-i|
gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-gi|
s.......Open selected file in a new vsplit.......................|NERDTree-s|
gs......Same as s, but leave the cursor on the NERDTree..........|NERDTree-gs|
O.......Recursively open the selected directory..................|NERDTree-O|