Skip to content

Instantly share code, notes, and snippets.

View maciejczyzewski's full-sized avatar

Maciej A. Czyzewski maciejczyzewski

View GitHub Profile
@maciejczyzewski
maciejczyzewski / classifier.py
Created December 28, 2019 10:22
[python] Gender Recognition by Voice (.wav) Using Harmonic Product Spectrum (frequency estimation method)
from os import environ
from sys import argv
from warnings import filterwarnings
from numpy.fft import rfft
from numpy.random import seed
from numpy import log1p, pi, polymul, mean, argmax
from scipy.signal import decimate, bilinear, lfilter, parzen
from soundfile import read as _read_audio
from copy import copy
@maciejczyzewski
maciejczyzewski / list.c
Last active December 11, 2017 10:21
Doubly linked list in C. (dynamic/pointer-based tree) https://en.wikipedia.org/wiki/Doubly_linked_list
#include <stdio.h>
#include <stdlib.h>
#define pf printf
#define oo 0x7FFFFFFF
#define nodeptr struct node_t*
struct node_t {
int val;
nodeptr rr;
@maciejczyzewski
maciejczyzewski / heap.c
Last active December 10, 2017 17:00
Randomized meldable heap in C. (dynamic/pointer-based tree) https://en.wikipedia.org/wiki/Randomized_meldable_heap
#include <stdio.h>
#include <stdlib.h>
#define pf printf
#define nodeptr struct node_t*
struct node_t {
int val;
nodeptr rr;
nodeptr ll;
@maciejczyzewski
maciejczyzewski / __.md
Last active January 12, 2017 21:28
Appendix from https://eprint.iacr.org/2016/468 rewritten to C++
https://dl.dropboxusercontent.com/u/103345209/Computerwissenschaften.pdf
import numpy as np
import pandas as pd
df = pd.read_csv('wach2.csv') # case 1: wach.csv, case 2: wach2.csv
pd.set_option('display.width', 1000)
m1 = 149.8; m2 = 199.6
df.columns = ['m1', 'm2']
m1_avg = df['m1'].mean()
def f(l, o='{}'):
s=[[]]
def x(): s[-1].append([]); s.append(s[-1][-1])
def y(): return -1 if len(s) == 1 else s.pop()
for c in l:
try:
if { o[0]: x, o[1]: y }[c]() == -1: return False
except KeyError: s[-1].append(c)
return s[0] if len(s) == 1 else False
@maciejczyzewski
maciejczyzewski / fiz.py
Created April 12, 2016 21:45
Measuring Gravity with a Pendulum.
import numpy as np
import pandas as pd
df = pd.read_csv('grav.csv')
pd.set_option('display.width', 1000)
def t_avg(row):
return sum(row[0:4]) / 4
df['t_avg'] = df.apply(lambda row: t_avg(row), axis=1)
@maciejczyzewski
maciejczyzewski / ncg.js
Last active February 7, 2021 16:46
Reference Implementation in JavaScript
/* NCG written in 2015 by Maciej A. Czyzewski
To the extent possible under law, the author has dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
See <http://creativecommons.org/publicdomain/zero/1.0/>. */
// Simulating a 16-bit & 32-bit value
function U16(i) { return i & 0xFFFF; } function U32(i) { return i & 0xFFFFFFFF; }
https://dl.dropboxusercontent.com/u/103345209/Ignacy-Krasicki.pdf