Skip to content

Instantly share code, notes, and snippets.


Eustáquio Rangel taq

View GitHub Profile
# 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 / leaky.rb
Last active Dec 21, 2015
Leaky procs
View leaky.rb
class Printer
@messages = []
def self.print
puts yield
def self.lazy_print(val=nil,&block)
@messages << val || block
taq / gist:5863818
Created Jun 26, 2013
Using Ruby 2.0 TracePoint to simulate an abstract interface
View gist:5863818
module AbstractInterface
class NotImplementedError < StandardError
def initialize(*methods)
super "You must implement the following methods: #{methods.join(', ')}"
def AbstractInterface.check_methods(klass,other,methods)
return if other.class==Module do |tp|
taq / gist:5849586
Last active Dec 18, 2015
Is Microsoft abandoning its mobile operating systems?
View gist:5849586
by Steven J. Vaughan-Nichols,
June 23rd 2013
Summary: In recent weeks Microsoft has been doing some odd things with mobile operating systems, Windows RT, and Windows Phone 8. I think Microsoft is moving towards dropping its mobile OSs in favor of supporting Microsoft applications on other platforms and eventually replacing them with Windows 8.1 on their own devices.
This is not your dad's Microsoft. Microsoft has been refocusing on Web services and devices instead of Windows and software products. One of those changes seems to be that if Microsoft's mobile operating systems can't cut the mustard, Microsoft isn't afraid to cut them off at the knees.
What am I talking about? Let's look at some of Microsoft's mobile news in the last few weeks.
First, some background. Goodness knows Windows 8 has been a market failure, but it's a rip-roaring success compared to Windows RT and Windows Phone 8 (WP8).
taq / gist:5793430
Created Jun 16, 2013
World worst hacker
View gist:5793430
This is a bunch of stuff relating to the localhost ip taken off Apologies to all the non-technically minded people...
<Numi> hey, can you guys just check a site out and tell me if it's up?
<Haddock> depends, what is it?
<Numi> just my apache server, it works for me but seems to be down for anyone else
<Haddock> alright, what's the address?
<Haddock> ......
<Haddock> ...Yeah, it's up.
taq / gist:5699377
Created Jun 3, 2013
Stupid PHP static variables behaviour
View gist:5699377
class A {
public static $name = null;
A::$name = "a";
class B extends A {
B::$name = "b";
taq / gist:5413857
Created Apr 18, 2013
Using the "starship" operator
View gist:5413857
class Pessoa
include Comparable
attr_accessor :nome
def initialize(nome)
self.nome = nome
def <=>(outra)
return -1 if outra.size<self.nome.size
taq / gist:5413841
Created Apr 18, 2013
Overiding == operator in Ruby.
View gist:5413841
class Pessoa
attr_accessor :nome
def initialize(nome)
self.nome = nome
def ==(outra)
outra == self.nome
if ! which md5sum > /dev/null; then
echo Install md5sum
exit 1
if ! which curl > /dev/null; then
echo Install curl
exit 1
taq / enum_perf_big.rb
Created Nov 3, 2012
Ruby 2.0 lazy enumerators bigger collection performance
View enum_perf_big.rb
require "benchmark"
include Benchmark
values = (0..1000).to_a
bm(10) do |bench|"regular") do { |x| x * 10 }.select { |x| x > 30 }
end"lazy") do