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 / codility_equi.pl
Created January 10, 2013 13:27
Codility task Equi, solution in perl with score 100 and O(n), see http://codility.com/demo/take-sample-test/
use strict;
use warnings;
use v5.10;
use List::Util qw(sum first);
sub equi {
my (@A) = @_;
my $right = sum(@A);
my $size = scalar @A;
#!/bin/bash
#
# Piano Gripe 3.0 - The Shell Music #
# OBS: Favor nao confundir com axé music ##
# Natal-RN ###
# Autor: Pablo Fernandes ([email protected]) ---------- ####
# ---------------------------------------------- 28.10.2003 #####
# ######
#############################################################################
#
@peczenyj
peczenyj / a.c
Created January 11, 2013 18:19
LOL
#include <stdio.h>
int main (int argc, char const *argv[])
{
int n;
printf("%s: %n ANA\n","hello", &n);
printf("%*s BOB\n", n, "");
return 0;
}
@peczenyj
peczenyj / bool.pl
Last active December 11, 2015 10:49
I want to do the same with ruby but it is impossible. only false and nil can be considered "false" values. it is hard coded in the source of the ruby.
package BooleanClass;
use Moose;
has 'bool_value' => (
is => 'ro',
isa => 'Bool'
);
use overload
'bool' => \&_to_bool;
@peczenyj
peczenyj / gist:4641638
Created January 26, 2013 10:45
Strange error in Perl 5.10 and OpenBSD
FAIL Lazy-Bool-0.04.1 v5.10.0 OpenBSD
...
PERL_DL_NONLAZY=1 /home/cpan/pit/thr/perl-5.10.0/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/Lazy-Bool-Cached.t ..
Dubious, test returned 29 (wstat 7424, 0x1d00)
Failed 11/11 subtests
# Failed test 'use Lazy::Bool::Cached;'
@peczenyj
peczenyj / gist:4697935
Last active December 12, 2015 02:18
perl version of each_cons + a small helper function "of"
use strict;
use warnings;
use English;
use feature 'say';
sub of { [ @_ ] }
sub each_cons(&$$) {
my ($code, $p, $array) = @ARG;
my $n = scalar @{$array};
@peczenyj
peczenyj / deep.purple.pl
Created February 6, 2013 23:19
How to list all Deep Purple albuns from spotify using Perl ?
use strict;
use warnings;
use English;
use JSON;
use LWP::Curl;
use URI::Escape;
use feature 'say';
use open qw<:std :utf8>;
my $search = "Deep Purple";
@peczenyj
peczenyj / starwars.traceroute.txt
Created February 9, 2013 17:13
the starwars traceroute to 216.81.59.173
$ traceroute 216.81.59.173
traceroute to 216.81.59.173 (216.81.59.173), 64 hops max, 52 byte packets
1 192.168.1.1 (192.168.1.1) 1.599 ms 0.899 ms 0.693 ms
2 * * *
3 201.17.0.24 (201.17.0.24) 13.554 ms 15.223 ms *
4 201.17.0.11 (201.17.0.11) 14.616 ms 14.337 ms 12.423 ms
5 embratel-t0-5-0-0-tacc01.rjo.embratel.net.br (200.209.203.37) 11.323 ms 10.444 ms 9.883 ms
6 ebt-t0-12-2-0-tcore01.rjoen.embratel.net.br (200.244.40.162) 121.094 ms 129.549 ms 124.419 ms
7 ebt-bundle-pos1223-intl03.mianap.embratel.net.br (200.230.220.58) 123.225 ms 123.339 ms 135.035 ms
8 ae7.mia10.ip4.tinet.net (199.168.63.185) 138.100 ms 137.263 ms 140.316 ms
@peczenyj
peczenyj / output.txt
Last active December 13, 2015 19:58
why my bb does no work?
1..3
ok 1 - should be 1
not ok 2 - should be 2
# Failed test 'should be 2'
# at untitled line 8.
# got: undef
# expected: '2'
# Looks like you failed 1 test of 3.
ok 3 - should be 3
@peczenyj
peczenyj / chat.pl
Created March 10, 2013 04:44
Exemplo de sala de chat utilizando IO Não bloqueante para o equinocio do SPPM 2013
use strict;
use warnings;
use POSIX;
use IO::Socket::INET;
use IO::Select;
use feature 'say';
use constant TIMEOUT => 0.5;
my $server = IO::Socket::INET->new(