Skip to content

Instantly share code, notes, and snippets.

@alexaleluia12
alexaleluia12 / Java.java
Last active February 11, 2024 12:05
Benchmarck (comparação de velocidade) Python, C, Java, Javascript, C++, Kotlin, Go
public class Java {
public static void main(String[] args) {
int count = 0;
for(int i=0; i<1000; i++){
count += i;
}
System.out.println(count); // corrigido conforme comentario
}
}
@alexaleluia12
alexaleluia12 / cleaner.sh
Last active December 30, 2015 12:33
Exclude executable files but not .sh files nor directories
#!/bin/bash
# to get the list of files to exclude
# ls -al | grep ^- | egrep "^[a-z-]+x " | grep -v .sh$ | cut -d' ' -f 9 > arq_exc
# then
for i in $(cat arq_exc); do
rm - $i
done
@alexaleluia12
alexaleluia12 / file.cpp
Created December 30, 2015 13:08
error: cannot convert ‘std::vector<float*>’ to ‘float*’ in assignment
// I want to share a tricky thing that happened with me
// * I was programming in C style using feature of C++ (on g++)
// I have this structure
typedef struct {
vector<float *> * lst_vertices;
vector<int *> * lst_faces;
float referencia[3];// o ponto sobre o qual vai ser realizadas as transformacoes
} Obj3d;
@alexaleluia12
alexaleluia12 / finditer-version.py
Last active June 23, 2021 22:59
token / tokenizer / lexico / tokenizing in python
# Can I use finditer ?
# Yes
# ...
def generate_tokens(pat, text):
scanner = pat.finditer(text)
for i in scanner:
yield Token(i.lastgroup, i.group())
@alexaleluia12
alexaleluia12 / compiler.py
Created January 10, 2016 21:30
compiler / compilador / sintatico / in python
# font
# http://chimera.labs.oreilly.com/books/1230000000393/ch02.html#_writing_a_simple_recursive_descent_parser
"""
grammar
expr ::= expr + term
| expr - term
| term
@alexaleluia12
alexaleluia12 / estudo-yield.py
Created January 23, 2016 15:14
yield python
# mais informações sobre yield generator/coroutine
# http://www.dabeaz.com/generators/
# motivação
# http://www.dabeaz.com/coroutines/Coroutines.pdf pg: 68
"""
>>> gen = foo1(lambda : [1,2,3,6,90])
@alexaleluia12
alexaleluia12 / .gitignore
Created November 4, 2016 12:01
gitignore for adianti framework
*.db
tmp/
app/output/
@alexaleluia12
alexaleluia12 / znfdc.sql
Created February 6, 2017 15:11
zero na frente do cnpj
-- cnpj valido tem tamanho 14
-- usar as funcoes length e concat
--
UPDATE `cliente` ta,
(SELECT cnpj, id from `cliente` where length(cnpj) = 13) tb
SET ta.cnpj = concat('0', tb.cnpj)
where ta.id = tb.id
<?php
// mandar dados do usuario na url para confirmacao de email
// gerar arquivo ini com key mais iv
// ********************************
$fileObj = fopen('senha.ini', 'w');
$sh = openssl_random_pseudo_bytes(32);
$iv = openssl_random_pseudo_bytes(16);
fwrite($fileObj, "senha = " . bin2hex($sh) . PHP_EOL);