Skip to content

Instantly share code, notes, and snippets.

View paulohrpinheiro's full-sized avatar
🏠
Working from home

Paulo Henrique Rodrigues Pinheiro paulohrpinheiro

🏠
Working from home
View GitHub Profile
@paulohrpinheiro
paulohrpinheiro / .vimrc
Created October 13, 2014 17:44
My .vimrc file, to program in C and Python.
" cada tab vira quatro espaços em branco
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
" deixa seu arquivo colorido, realçando a sintaxe de
" acordo com a linguagem usada
syntax on
@paulohrpinheiro
paulohrpinheiro / exemplo.csv
Created January 27, 2015 05:48
Python script and CSV example files
Data Vendedor Total
10/10/14 Paulo 10000
10/10/14 João 500000
01/01/15 Lucas 20008373
05/01/15 Mateus 873422,3
10/01/15 Marcos 213643983,98
@paulohrpinheiro
paulohrpinheiro / perl6-chamadas-nativas-first.sh
Last active August 29, 2015 14:27
Criando a primeira chamada nativa.
$ perl6
> use NativeCall
> sub sqlite3_libversion_number() returns Int is native('libsqlite3') { * }
sub sqlite3_libversion_number( --> Int) { #`(Sub+{Native[Sub,Str]}|139826072374712) ... }
> say sqlite3_libversion_number()
3008008
@paulohrpinheiro
paulohrpinheiro / perl6-chamadas-naticas-second.sh
Created August 22, 2015 17:49
Criando uma chamada nativa com nome alternativo.
> our sub Sqlite3VersionNumber is symbol('sqlite3_libversion_number') returns Int is native('libsqlite3') { * }
sub Sqlite3VersionNumber( --> Int) { #`(Sub+{NativeCallSymbol[Str]}+{Native[Sub+{NativeCallSymbol[Str]},Str]}|140598248149192) ... }
> Sqlite3VersionNumber();
3008008
> our sub Sqlite3LibVersion is symbol('sqlite3_libversion') returns Str is native('libsqlite3') { }
sub Sqlite3LibVersion( --> Str) { #`(Sub+{NativeCallSymbol[Str]}+{Native[Sub+{NativeCallSymbol[Str]},Str]}|140598245394280) ... }
> Sqlite3LibVersion()
3.8.8
@paulohrpinheiro
paulohrpinheiro / sqlite-nc.pl
Created August 22, 2015 17:53
Exemplo completo de chamadas naticas em Perl6.
use NativeCall;
constant $LIBNAME = 'libsqlite3';
sub sqlite3_open (Str, Array[OpaquePointer]) returns Int is native($LIBNAME) { * }
sub sqlite3_exec (OpaquePointer, Str, OpaquePointer, OpaquePointer,OpaquePointer) returns Int is native($LIBNAME) { * }
sub sqlite3_errmsg (OpaquePointer) returns Str is native($LIBNAME) { * }
sub sqlite3_close (OpaquePointer) returns Int is native($LIBNAME) { * }
my @handler := CArray[OpaquePointer].new;
@handler[0] = OpaquePointer;
@paulohrpinheiro
paulohrpinheiro / fixtures-first.pl
Last active August 29, 2015 14:27
Fixture simples
#!/usr/bin/env perl
use strict;
use warnings;
use JSON;
my $root_user = {
email => '[email protected]',
name => 'Chail Root Admin',
@paulohrpinheiro
paulohrpinheiro / fixtures-package.pm
Created August 22, 2015 18:57
Módulo Perl para resolver meu problema.
package Util::Password;
use strict;
use warnings;
use Crypt::Eksblowfish::Bcrypt;
use Crypt::Random;
sub Encrypt {
my $password = shift;
@paulohrpinheiro
paulohrpinheiro / fixtures-final.pl
Created August 22, 2015 18:58
Programa final usando o package.
#!/usr/bin/env perl
use strict;
use warnings;
use JSON;
use Util::Password;
my $password = Util::Password::Encrypt('{#MinhaSenhaSuuuuperSegura#}');
@paulohrpinheiro
paulohrpinheiro / sortedcoteiners-first.py
Created August 22, 2015 20:53
Descobre a estrutura de palavras de um texto.
import sys
words = set()
plain_text = list()
codded_text= list()
# read content
plain_text = [l.strip().split() for l in sys.stdin]
# build a word list from content
for line in plain_text: