Skip to content

Instantly share code, notes, and snippets.

Andrew Stepanov standy66

  • MIPT
  • Moscow, Russia
Block or report user

Report or block standy66

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
standy66 /
Created Jan 21, 2019
Voice-Processing I/O MacOS example
#include <iostream>
#include <cmath>
#include <fstream>
#include <AudioToolbox/AudioToolbox.h>
// Files with raw float32 data
std::ifstream ifile("ifile.f32");
std::ofstream file("file.f32");
View i7_6700k_openssl_speed.txt
OpenSSL 1.0.2g 1 Mar 2016
built on: reproducible build, date unspecified
options:bn(64,64) rc4(16x,int) des(idx,cisc,16,int) aes(partial) blowfish(idx)
compiler: cc -I. -I.. -I../include -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -m64 -DL_ENDIAN -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wa,--noexecstack -Wall -DMD32_REG_T=int -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
md2 0.00 0.00 0.00 0.00 0.00
mdc2 0.00 0.00 0.00 0.00 0.00
md4 127034.79k 377429.23k 859238.66k 1
View asus_rt87u_openssl_speed.txt
OpenSSL 1.0.2k 26 Jan 2017
built on: reproducible build, date unspecified
options:bn(64,32) rc4(ptr,char) des(idx,cisc,16,long) aes(partial) idea(int) blowfish(ptr)
compiler: arm-brcm-linux-uclibcgnueabi-gcc -I. -I.. -I../include -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -ffunction-sections -fdata-sections -O3 -Wall -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DAES_ASM -DBSAES_ASM -DGHASH_ASM
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
md2 0.00 0.00 0.00 0.00 0.00
mdc2 2197.96k 2339.09k 2417.00k 2428.89k 2446.42k
md4 11506.71k 38225.13k 93329.90k 151152.50k 184607.98k
md5 8904.43k 27768.25k 67982.16k 104957.58k 124709.36k
standy66 /
Created Mar 28, 2018
PyPy vs CPython extension call overhead
Original code:
Compare speed of a cython wrapper vs a cffi wrapper to the same underlying
C-code with a fast function and a longer-running function.
This should run anywhere that has cffi and cython installed.
$ python3.6 -V
Python 3.6.2 (default, Jul 17 2017, 16:44:45)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Based on example here:
import numpy as np
import math
import collections
NEG_INF = -float("inf")
standy66 /
Last active Aug 20, 2017
tf variable scope example
with tf.name_scope("subgraph_1"):
with tf.variable_scope(tf.get_variable_scope(), resue=False):
y_1 = output(x_1)
with tf.name_scope("subgraph_2"):
with tf.variable_scope(tf.get_variable_scope(), reuse=True):
y_2 = output(x_2)
import sys, re, pymystem3
mystem = pymystem3.Mystem()
def stem(s):
return [(e['text'].strip(), \
e['analysis'][0]['lex'] \
if 'analysis' in e and len(e['analysis']) > 0 else '', \
re.match('^([A-Z]+)', e['analysis'][0]['gr']).group(0) \
if 'analysis' in e and len(e['analysis']) > 0 else '', \
standy66 /
Created Jul 13, 2017
Python sawtooth wave generator
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import Audio
from scipy.signal import spectrogram
sample_rate = 8000
t = np.arange(0, 10, 1.0/sample_rate)
x = t % (2 / sample_rate)
plt.figure(figsize=(16, 6), dpi=200)
standy66 /
Created Jul 12, 2017
A small snippet that helps reconstruct audio from spectrogram in Python
from scipy.signal import stft, istft
def reconstruct(spectrogram, sample_rate, nperseg, iters=100):
length = istft(spectrogram, sample_rate, nperseg=nperseg)[1].shape[0]
x = np.random.normal(size=length)
for i in range(iters):
# Code based on the answer here:
X = stft(x, sample_rate, nperseg=nperseg)[2]
Z = spectrogram * np.exp(np.angle(X) * 1j)
x = istft(Z, sample_rate, nperseg=nperseg)[1]
View gist:519658b471d32d3a65d61002ea612c3b
%\usepackage[utf8]{inputenc} % older versions of ucs package
\usepackage[utf8x]{inputenc} % more recent versions (at least>=2004-17-10)
\sloppy % Hyphenation is a problem..
You can’t perform that action at this time.