Skip to content

Instantly share code, notes, and snippets.

View taq's full-sized avatar

Eustáquio Rangel taq

View GitHub Profile
@taq
taq / leaky.rb
Last active December 21, 2015 03:19
Leaky procs
class Printer
@messages = []
def self.print
puts yield
end
def self.lazy_print(val=nil,&block)
@messages << val || block
end
# Use it like `export PS1="\h:\w[\$(ahead_behind)]$"`
function ahead_behind {
curr_branch=$(git rev-parse --abbrev-ref HEAD);
curr_remote=$(git config branch.$curr_branch.remote);
curr_merge_branch=$(git config branch.$curr_branch.merge | cut -d / -f 3);
git rev-list --left-right --count $curr_branch...$curr_remote/$curr_merge_branch | tr -s '\t' '|';
}
@taq
taq / refine.rb
Created December 26, 2013 12:15
Ruby 2.1 refinements
module TimeExtensions
refine Fixnum do
def min2sec; self * 60; end
end
end
class Minutes
using TimeExtensions
def self.to_sec(min)
@taq
taq / gist:10663010
Created April 14, 2014 16:26
Vim plugins
ack.vim
bufexplorer
camelcasemotion
csv.vim
ctrlp.vim
emmet-vim
L9
nerdcommenter
nerdtree
syntastic
@taq
taq / nginx
Created April 21, 2014 00:47
Nginx Ubuntu service
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@taq
taq / gist:ae0e323786a41cfc237c
Created September 17, 2014 10:38
Plugins do Vim que eu uso
ag.vim
bufexplorer
camelcasemotion
ctrlp.vim
emmet-vim
L9
limelight.vim
nerdcommenter
nerdtree
syntastic
@taq
taq / circular.rb
Created February 17, 2015 14:54
Ruby 2.2.0 circular reference problem
class FooBar
def foo
"I'm in foo!"
end
def bar(foo = foo)
puts foo
end
end
@taq
taq / keybase.md
Created May 27, 2015 10:27
keybase.md

Keybase proof

I hereby claim:

  • I am taq on github.
  • I am taq (https://keybase.io/taq) on keybase.
  • I have a public key whose fingerprint is 840B 7492 E475 8DB6 B5DE 81D0 6611 4C70 E7F6 C0C0

To claim this, I am signing this object:

@taq
taq / sṕreadsheet_test.rb
Last active January 14, 2016 12:04
Minitest without before_all
require "minitest/autorun"
require "minitest/spec"
require "spreadsheet"
describe 'spreadsheet' do
before do
@doc ||= Spreadsheet.open "spreadsheet.xls"
puts "document object id: #{@doc.object_id}"
end
@taq
taq / spreadsheet_test.rb
Created November 24, 2015 19:03
Minitest with before_all
require "minitest/autorun"
require "minitest/spec"
require "spreadsheet"
describe 'spreadsheet' do
def self.before_all
@doc ||= Spreadsheet.open "spreadsheet.xls"
end
before do