Skip to content

Instantly share code, notes, and snippets.

View peczenyj's full-sized avatar
💻
coding

Tiago Peczenyj peczenyj

💻
coding
View GitHub Profile

Keybase proof

I hereby claim:

  • I am peczenyj on github.
  • I am pacman (https://keybase.io/pacman) on keybase.
  • I have a public key whose fingerprint is D9D2 107C 74EB 9F34 71A4 B23E 4783 515E 0FBE EDE5

To claim this, I am signing this object:

@peczenyj
peczenyj / gist:8974302
Created February 13, 2014 12:32
example with ruby
2.1.0 :001 > require 'moosex'
=> true
2.1.0 :015 > class B
2.1.0 :016?> include MooseX.init(meta: true)
2.1.0 :017?> has :a
2.1.0 :018?> has [ :b, :c ]
2.1.0 :019?> has d: { doc: "d" }
2.1.0 :020?> has :e, is: :rw, doc: "eeee"
2.1.0 :021?> end
=> nil
@peczenyj
peczenyj / FrequencyIterator.java
Last active January 4, 2016 16:19
Frequency Iterator, lazy, in java, with homemade unit test framework (for fun)
import java.util.Iterator;
import java.util.Queue;
import java.util.LinkedList;
import java.util.NoSuchElementException;
class SingleFrequencyIterator<V> implements Iterator<V>{
private int counter;
private V value;
@peczenyj
peczenyj / frequency_iterator.pl
Last active January 4, 2016 15:09
My example of frequency iterator.
use strict;
use warnings;
package Java::Util::Iterator;
use Moose::Role;
requires 'hasNext', 'next', 'remove';
package Frequency::Iterator::Single;
@peczenyj
peczenyj / frequency_iterator.pl
Last active January 4, 2016 09:39
An example of frequency iterator
use strict;
use warnings;
package Frequency::Iterator;
# ABSTRACT: Module who abstract a frequency iterator
use Exporter 'import';
use Carp qw(croak);
use List::MoreUtils qw(any natatime pairwise);
@peczenyj
peczenyj / output.txt
Created November 15, 2013 18:19
small proxy to dump the in and out bytes for fun and profit. example: riak ping in protocol buffers omiting output to one point to each 128 bytes
$ perl proxy.pl
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF
00000000 00 00 00 01 01 .....
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.
@peczenyj
peczenyj / environment.txt
Last active December 28, 2015 07:38
EDIT: NOT A PROBLEM, I should use TCP_NODELAY with setsockopt. Dammit... Problem: I can't set TCP NODELAY in perl, but I can set with ruby and python. Why? I try with Perl 5.12.2 and 5.18.1!
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
$ perl -v
This is perl 5, version 12, subversion 2 (v5.12.2) built for x86_64-linux
$ python --version
Python 2.7.5+
$ uname -a
use Time::Out qw(timeout);
use DDP;
sub run_with_timeout(&$$) {
my $block = shift;
my $timeout = shift;
timeout $timeout, @_ => sub {
my $pool = shift;
while ( my $s = pop @$pool ) {
$block->($s);
@peczenyj
peczenyj / Makefile
Last active December 27, 2015 10:09
all:
@gcc -Wall a.c -o a.exe
clean:
@rm -rf /
@peczenyj
peczenyj / foo.sh
Created November 4, 2013 12:08
chamando a mesma funcao de forma recursiva
function foo {
read -p "digite a opcao: " OPCAO
case $OPCAO in
a) echo "a" ;;
b) echo "b" ;;
c) foo ;;
*) echo "opcao invalida '$OPCAO'"; exit 1 ;;
esac
}