Skip to content

Instantly share code, notes, and snippets.

View sn1p3r46's full-sized avatar
💭
Lost in Coding

Alexander Ows sn1p3r46

💭
Lost in Coding
View GitHub Profile
@sn1p3r46
sn1p3r46 / README.md
Last active November 18, 2017 00:43
Raspberry Pi debian locales fix

Simple list of commands useful to fix locales on raspberry pi. In fact after a fresh install often perl is complaining about misconfigured locales. \

alternatively one can fill the /etc/default/locale with

LANG=en_US.UTF-8
LC_TIME=it_IT.UTF-8
LANGUAGE=en_US:en
LC_ALL=en_US.UTF-8
@sn1p3r46
sn1p3r46 / matrix_mul.py
Last active January 18, 2018 00:24
Recursive Matrix Multiplication
#!/usr/bin/python3
# ref http://www.cs.mcgill.ca/~pnguyen/251F09/matrix-mult.pdf
import numpy as np
def matrix_mul(A,B):
if A.shape == (1,1):
return A.dot(B)
@sn1p3r46
sn1p3r46 / app.py
Created June 19, 2018 01:04
Example of Flask admin making use of foreign keys and image upload. Just for illustrative proposes!
from flask import Flask, url_for
from flask_admin import Admin, form
from flask_sqlalchemy import SQLAlchemy
from flask_admin.contrib.sqla import ModelView
from jinja2 import Markup
"""
This just an illustrative example, take it as a concept example,
nothing more, it is not secure and does not handle image deletion.
Hereby more complete examples:
@sn1p3r46
sn1p3r46 / micordata.py
Last active March 31, 2020 11:42
Python Implementation of: "Fast Generation of Accurate Synthetic Microdata" https://crises-deim.urv.cat/web/docs/publications/lncs/443.pdf
import numpy as np
def compute_mean(v):
return sum(v)/len(v)
def subtract_mean_to_col(M, idx):
M[:, idx] = M[:, idx] - compute_mean(M[:, idx])
def alg_two(n=None, m=None, A=None):
#1
@sn1p3r46
sn1p3r46 / node_calls_python.js
Last active December 13, 2018 14:14
nodejs execFile python script reads the parameter and sends it back through the stdout
const { execFile } = require('child_process');
var js = JSON.stringify({a:"fiore", b:[1,2,3], c:{}, d:[]});
execFile('/tmp/comm.py', [js], { encoding: 'utf8' }, (error, stdout) => {
if (error) {
throw new Error(error);
}
console.log(stdout);
});