Skip to content

Instantly share code, notes, and snippets.

Felipe Cruz felipecruz

View GitHub Profile
View IRPF_domain.py
from decimal import Decimal as D
MAX_TRIBUTAVEL = D("28559.70")
MAX_NAO_TRIBUTAVEL = D("40000.00")
def tabela_imposto(renda):
if renda < D('1903.98'):
View gist:5d93b9aea2de4b1d17baa147231ba7d9
/*
* Cognitivo draft snippet
*/
(function(_w) {
var _name = 'C01',
_script = document.createElement('script'),
_first_script = document.getElementsByTagName('script')[0];
_w[_name] = _w[_name] || function() { (_w[_name].queue = _w[_name].queue || []).push(arguments) }
View cholesky.go
func MatrixCholeskyDecomposition(matrix Matrix) Matrix {
columns := matrix.cols()
rows := matrix.rows()
result_matrix := DenseZeros(rows, columns)
var val float64
for i := 0; i < rows; i++ {
for j := 0; j <= i; j++ {
accumulator := 0.
View gist:1bb22a5ed49187a1630ab100a3420877
// Input:
// Values (stored in array v)
// Weights (stored in array w)
// Number of distinct items (n)
// Knapsack capacity (W)
for j from 0 to W do:
m[0, j] := 0
for i from 1 to n do:
View pylwan.c
#include "Python.h"
#include "lwan/lwan.h"
/*
Compile with:
gcc `python3-config --cflags` -I/usr/local/include/lwan /usr/local/lib/liblwan.a `python3-config --ldflags` server.c -lz -o pylw
Run with:
./pylw wsgi.py
View decomplu.go
func MatrixLUDecomposition(matrix Matrix) Matrix {
columns := matrix.cols()
rows := matrix.rows()
for i := 0; i < columns-1; i++ {
val, pivot_index := PivotIndex(matrix, i, i)
MatrixExchangeRows(matrix, i, pivot_index)
for j := i + 1; j < rows; j++ {
multiplier := -matrix.at(j, i) / val
View plugin_loop.php
<?php
$attributes_str = "small_image";
function IsNullOrEmptyString($value){
return (!isset($value) || trim($value)==='');
}
foreach (explode(",", $attributes_str) as $attr) {
$meta_tag = '<meta name="product:%s" content="%s" />';
$value = $product->getData();
View exemplo.py
# errado - identação de "if not imposto"
salario = int(input('Salario? '))
imposto = 27.
while imposto > 0.:
imposto = input('Imposto ou (0) para sair: ')
if not imposto:
imposto = 27.
else:
imposto = float(imposto)
print("Valor real: {0}".format(salario - (salario * (imposto * 0.01))))
View gist:51caecf9469e13d60568
Verifying that +felipecruz is my blockchain ID. https://onename.com/felipecruz
View python_scope_pattern.py
>>> data = ['aa', 'bb', 'ab', 'bc']
>>> def _filter_native(data):
... sts = ['a', 'b']
... rets = []
... for st in sts:
... rets.append((st, filter(lambda x: x.startswith(st), data)))
... return rets
...
>>> rdds = _filter_native(data)
>>> for st, rdd in rdds:
You can’t perform that action at this time.