Skip to content

Instantly share code, notes, and snippets.

@gil27
gil27 / NERDTree.mkd
Created February 20, 2023 14:06 — forked from m3nd3s/NERDTree.mkd
My Vim Cheat Sheet

NERDTree

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|

@gil27
gil27 / gil.rb
Created October 9, 2015 14:18
playing around with modules
module Gil
def self.included(base)
base.extend ClassMethods
base.include InstanceMethods
end
module ClassMethods
def roles *args
ancestors.first
end
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
@gil27
gil27 / diretorios_helper.rb
Last active August 29, 2015 14:01
Dois métodos, mesmo Gil
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
@gil27
gil27 / certificate.rb
Last active August 29, 2015 13:57 — forked from fnando/certificate.rb
Gerar Certificados para a Flexa
#encoding: utf-8
require "prawn"
class Certificate
attr_accessor :path
PDF_OPTIONS = {
:page_size => "A5",
:page_layout => :landscape,
:margin => [40, 75]

General

  1. 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?
  2. Method arguments" Make sure arguments to methods make sense and are validated.
  3. 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.
  4. 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.
  5. Disposables: Make sure disposable things are disposed. Look for usages of resources that should be disposed but are not.
  6. Security: There is a whole threat and mitigation review process that falls under this bucket.

WPF + ReactiveUI

@gil27
gil27 / dont
Last active January 4, 2016 20:19
Seus problemas acabaram
#! bin/bash
#
for i in find -name *.php
do
echo "class $i\n # Try it again \nend" >> "${i%.*}.rb"
rm -rf $i
done
config.active_record.observers = :cards_list_observer
# 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
@gil27
gil27 / get_page_links
Created October 13, 2012 04:19
Get all links from a page using ruby