Skip to content

Instantly share code, notes, and snippets.

View taq's full-sized avatar

Eustáquio Rangel taq

View GitHub Profile
@taq
taq / 0001-Construtor.patch
Created December 21, 2023 19:16
Pull request patch file example
From f0af0ed80173a0a3ff0ed1316bdb09ba64b518f0 Mon Sep 17 00:00:00 2001
From: Eustaquio Rangel <taq@eustaquiorangel.com>
Date: Thu, 21 Dec 2023 16:12:23 -0300
Subject: [PATCH] Construtor
---
test.rb | 3 +++
1 file changed, 3 insertions(+)
diff --git a/test.rb b/test.rb
@taq
taq / test.rb
Created December 21, 2023 19:08
Pull request example with constructor
class Test
def initialize
puts 'Inicializando um teste ...'
end
end
@taq
taq / test.rb
Created December 21, 2023 19:04
Pull request example first file
class Test
end
@taq
taq / gist:5793430
Created June 16, 2013 20:59
World worst hacker
This is a bunch of stuff relating to the localhost ip taken off bash.org. Apologies to all the non-technically minded people...
#60852
<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?
<Numi> http://127.0.0.1
<Haddock> ......
<Haddock> ...Yeah, it's up.
@taq
taq / inquirer_bench.rb
Created March 13, 2023 23:06
Comparação com o ActiveSupport::StringInquirer
require 'active_support/string_inquirer'
require 'benchmark'
# classe
class ClientExternalData
# o método com o inquirer/method_missing
def identifier
ActiveSupport::StringInquirer.new('uuid')
end
@taq
taq / gist:1759632
Created February 7, 2012 13:18
Apple’s great GPL purge
From http://meta.ath0.com/2012/02/05/apples-great-gpl-purge/, with access forbidden right now:
Apple obligingly allows you to browse and download the open source software they use in OS X. Since they have listings for each version of OS X, I decided to take a look at how much software they were using that was only available under the GNU public license. The results are illuminating:
10.5: 47 GPL-licensed packages.
10.6: 44 GPL-licensed packages.
10.7: 29 GPL-licensed packages.
This clearly supports the idea that Apple is aggressively trying to remove all GPL-licensed software from OS X. While the removal of Samba and GCC got some attention, the numbers show that there’s a more general purging going on.
@taq
taq / gist:1ef38725c39c041f59701f29a83c7fa3
Created October 11, 2016 22:28
Git alias to create a new remote branch based on the current branch
Just insert on .gitconfig:
nrb = "!f() { git push -u origin $(git rev-parse --abbrev-ref HEAD):$1; }; f"
And then, when on a local branch and want to push to a new remote branch called, say, 'test':
$ git nbr test
Total 0 (delta 0), reused 0 (delta 0)
To <your remote here>
* [new branch] work -> test
@taq
taq / gist:5863818
Created June 26, 2013 00:46
Using Ruby 2.0 TracePoint to simulate an abstract interface
module AbstractInterface
class NotImplementedError < StandardError
def initialize(*methods)
super "You must implement the following methods: #{methods.join(', ')}"
end
end
def AbstractInterface.check_methods(klass,other,methods)
return if other.class==Module
TracePoint.new(:end) do |tp|
@taq
taq / enum_perf_small.rb
Created November 3, 2012 19:43
Ruby 2.0 lazy enumerators small collection performance
require "benchmark"
include Benchmark
values = (0..100).to_a
bm(10) do |bench|
bench.report("regular") do
values.map { |x| x * 10 }.select { |x| x > 30 }
end
bench.report("lazy") do
@taq
taq / lazy.rb
Created November 3, 2012 19:39
Natural numbers enumerator on Ruby 2.0 using lazy evaluation
natural_numbers = Enumerator.new do |yielder|
number = 1
loop do
yielder.yield number
number += 1
end
end
p natural_numbers.lazy.select { |n| n.odd? }.take(5).to_a # => [1, 3, 5, 7, 9]
p natural_numbers.lazy.map { |n| n*2 }.take(5).to_a # => [2, 4, 6, 8, 10]