Skip to content

Instantly share code, notes, and snippets.

View venik's full-sized avatar
💭
"AppxManifest.xml failed with error: The operation completed successfully."

Sasha Nik venik

💭
"AppxManifest.xml failed with error: The operation completed successfully."
View GitHub Profile
@venik
venik / latex
Last active October 17, 2017 03:40
S_{N} = S_{N-2} + S_{N-1}
A = \left[\begin{array}{cc} 0 & 1\\ 1 & 1 \end{array}\right]
A \left[\begin{array}{cc} S_{N-2} \\S_{N-1} \end{array}\right] =
\left[\begin{array}{cc} 0 & 1\\ 1 & 1 \end{array}\right] \left[\begin{array}{cc} S_{N-2} \\S_{N-1} \end{array}\right] =
\left[\begin{array}{cc} S_{N-1} \\ S_{N} \end{array}\right]
\left[\begin{array}{cc} 0 & 1\\ 1 & 1 \end{array}\right] \left[\begin{array}{cc} 0 & 1\\ 1 & 1 \end{array}\right] \left[\begin{array}{cc} S_{0} \\S_{1} \end{array}\right] =
@venik
venik / fib.py
Last active October 17, 2017 03:34
#!/usr/bin/env python
# Sasha Nikiforov
import numpy as np
import numpy.linalg as lg
from functools import reduce
# Not super optimal way to calculate N-th Fibonacci - taken
# from stackoverflow
@venik
venik / rsafrompub.ts
Created September 12, 2017 23:02
jsrsasign doesnt support creating RSA object from public in the ASN.1 form, one needs to extract modulus and exponent manually (typescript)
function getRsaFromPubKey(pubKeyB64: string): RSAKey {
const pubKeyDecoded = b64tohex(pubKeyB64);
// jsrsasign cannot build key out of PEM or ASN.1 string, so we have to extract modulus and exponent
// you can get some idea what happens from the link below (keep in mind that in JS every char is 2 bytes)
// https://crypto.stackexchange.com/questions/18031/how-to-find-modulus-from-a-rsa-public-key/18034#18034
const modulus = pubKeyDecoded.substr(50, 128);
const exp = pubKeyDecoded.substr(182, pubKeyDecoded.length);
return KEYUTIL.getKey({n: modulus, e: exp});
@venik
venik / diff.ts
Created August 31, 2017 07:28
Deep diff between two typescript objects with lodash, returns the difference
difference(newObject: any, baseObject: any) {
function changes(newObject: any, baseObject: any) {
return _.transform(newObject, function(result, value, key) {
if (!_.isEqual(value, baseObject[key])) {
result[key] = (_.isObject(value) && _.isObject(baseObject[key])) ? changes(value, baseObject[key]) : value;
}
});
}
const rval = changes(newObject, baseObject);
@venik
venik / build_tf.sh
Last active February 22, 2024 06:12
Bash script for local building TensorFlow on Mac/Linux with all CPU optimizations (default pip package has only SSE)
#!/usr/bin/env bash
# Author: Sasha Nikiforov
# source of inspiration
# https://stackoverflow.com/questions/41293077/how-to-compile-tensorflow-with-sse4-2-and-avx-instructions
# Detect platform
if [ "$(uname)" == "Darwin" ]; then
# MacOS