Skip to content

Instantly share code, notes, and snippets.

View peczenyj's full-sized avatar
💻
coding

Tiago Peczenyj peczenyj

💻
coding
View GitHub Profile
@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
}
@peczenyj
peczenyj / a.pl
Created November 4, 2013 11:12
Teste comparando Moose (virtual memory size 50204 kb) e Moo (virtual memory size 31364 kb) através do modulo Memory::Usage
use strict;
use warnings;
use feature 'say';
use Memory::Usage;
my $mu = Memory::Usage->new();
$mu->record('starting work');
package Foo;
@peczenyj
peczenyj / gist:7237916
Created October 30, 2013 18:49
youtube.com error message
500 Internal Server Error
Sorry, something went wrong.
A team of highly trained monkeys has been dispatched to deal with this situation.
If you see them, show them this information:
CkGlKqTxgvnj8qwrZk2-uUhfJUJZhAosQVThK4q_qqNuQeg-FKXqX_F-fLj9
5VnDkqOpPuBSVRl6xQNiyLB5ZOHQvchhR_Cctoy_KxCqhpKgkHj7WGRBLmsD
QH2RXP4uFBgF_bJIJBahOASIe_xmDe405Uyt8-5hEEARgb34CGysBBIdxHmI
@peczenyj
peczenyj / gist:6046886
Last active December 20, 2015 01:09
Isto é deveria sanitizar o seu imput
Crianças, aprendam:
Se vcs colocarem isto nos comentarios do site da ISTO É
<script>
$(document).ready(function(){
$('#materiaTopo').html('Mal feito isso aqui hein?');
$('#divCompleta').html('<img src="http://www.acunetix.com/wp-content/uploads/2012/10/PTMFOG0000001530.png" />');
alert('Eu sou terrivel... ');
});