Skip to content

Instantly share code, notes, and snippets.

View felipecruz's full-sized avatar

Felipe Cruz felipecruz

  • Berlin, Germany
View GitHub Profile
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
<?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();
{
"id": 1,
"reports": [
{
"longrepr": null,
"when": "call",
"nodeid": "tests/test_domain.py::test_test_report_repository__init",
"duration": 0.0006470680236816406,
"location": [
"tests/test_domain.py",
{
'longrepr':{
'sections':[
],
'reprcrash':{
'path':'/Users/felipecruz/Projects/loogica/neurotic/tests/test_report_plugin.py',
'message':'assert 0 == 1',
'lineno':9
},
# 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))))
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': '/home/meuusuario/projeto/jamboree.db',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}
import timeit
pickle_code = '''
import pickle
data = {"test": "value"}
with open('out.pickle', 'wb') as out:
for i in range(10000):
out.write(pickle.dumps(data, pickle.HIGHEST_PROTOCOL))
Verifying that +felipecruz is my blockchain ID. https://onename.com/felipecruz
@felipecruz
felipecruz / switch_goto_coroutine.c
Last active December 16, 2015 07:39
C - switch/goto coroutine example
#include <stdint.h>
uint8_t next (uint8_t *data) {
static int running = 0;
static uint8_t *current;
switch (running) {
case 0: goto L0;
case 1: goto L1;
}
@felipecruz
felipecruz / url_shortener.py
Created April 11, 2013 23:09
tiny url shortener
import re
'''
pip install flask
pip install coopy
'''
from coopy.base import init_persistent_system
from flask import Flask, request, redirect, jsonify