Skip to content

Instantly share code, notes, and snippets.

View felipecruz's full-sized avatar

Felipe Cruz felipecruz

  • Berlin, Germany
View GitHub Profile
@felipecruz
felipecruz / can_you_lead_account_current_ammount_to_inconsistency.java
Created September 21, 2011 20:33
can_you_lead_account_current_ammount_to_inconsistency.java
public class LiveBank implements Serializable{
private Map<Integer, Account> accounts;
private AtomicInteger next_account_number = new AtomicInteger(0);
public LiveBank() {
this.accounts = new HashMap<Integer, Account>(); // concurrent hashmap maybe
}
public Account createAccount() {
@felipecruz
felipecruz / asyncsrv.py
Created March 23, 2011 21:07
python zmq async server example
import zmq
import threading
import time
from random import choice
class ClientTask(threading.Thread):
"""ClientTask"""
def __init__(self):
threading.Thread.__init__ (self)
@felipecruz
felipecruz / Niederlassungerlaubnis.md
Created April 12, 2021 19:19
Niederlassungerlaubnis

Dokumente

  • Altersvorsorge
  • Gesicherter Lebensunterhalt einschließlich Krankenversicherung
  • Keine Straftaten
  • Hauptwohnsitz in Berlin
  • Gültiger Pass, zusammen mit Ihrer Blauen Karte EU
  • 1 aktuelles biometrisches Foto
  • Formular "Antrag auf Erteilung einer Niederlassungserlaubnis"
  • Einkommensnachweise
.data
int_pattern: .ascii "%d\12\0"
string_pattern: .ascii "%s\12\0"
.text
.globl _print_int
_print_int:
pushl %ebp
movl %esp, %ebp
pushl %ebx
@felipecruz
felipecruz / perceptron.py
Last active March 30, 2018 08:53
perceptron implementation for educational purposes
OR = (((0, 0), 0), ((0, 1), 1), ((1, 0), 1), ((1, 1), 1))
AND = (((0, 0), 0), ((0, 1), 0), ((1, 0), 0), ((1, 1), 1))
example = lambda x: x[0]
output = lambda x: x[1]
def train_perceptron(Is, Ws):
print("Xs: {} Ws: {}".format(example(Is), Ws))
learn_rate = 0.1
bias = 0
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'):
/*
* 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) }
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.
// 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:
#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