View notify-dependabot.sh
#!/bin/bash | |
# this script requires curl, jq, and npm to be available in the PATH | |
# it also requires a github access token (with org read access) to be in ~/.dependabotrc.json in | |
# this form: | |
# {"github_token":"<token>"} | |
if [[ "$#" -lt 1 ]]; then | |
echo "usage: $0 <package_name>" >&2 | |
exit 1 |
View dataset-map.py
import tensorflow as tf | |
dataset = tf.data.Dataset.from_generator(lambda: None, tf.float32) | |
# raises no errors | |
dataset.map(lambda i: (i, tf.zeros(tf.float32))) | |
zeros = tf.zeros(tf.float32) | |
# raises KeyError: 'zeros:0' | |
dataset.map(lambda i: (i, zeros)) |
View wdiff.sh
#!/bin/bash | |
INTERVAL=1 | |
afile="$(mktemp)" | |
bfile="$(mktemp)" | |
function show_diff() { | |
a="$1" | |
b="$2" |
View check_grad.py
import scipy.optimize | |
# let check_grad work for x0: ndarray, like the documentation says it should | |
# see also: http://stackoverflow.com/q/15040263 | |
def check_grad(func, grad, x0, *args, **kwargs): | |
return scipy.optimize.check_grad(lambda xh: func(xh.reshape(x0.shape), *args), | |
lambda xh: grad(xh.reshape(x0.shape), *args).flatten(), | |
x0.flatten(), **kwargs) |
View compare-structure.js
var hasOwn = Object.prototype.hasOwnProperty; | |
var indexOf = Array.prototype.indexOf; | |
function isObjectEmpty(obj) { | |
for (var key in obj) { | |
return false; | |
} | |
return true; | |
} |
View crypto-pbkdf2-example.js
var crypto = require('crypto'); | |
// larger numbers mean better security, less | |
var config = { | |
// size of the generated hash | |
hashBytes: 32, | |
// larger salt means hashed passwords are more resistant to rainbow table, but | |
// you get diminishing returns pretty fast | |
saltBytes: 16, | |
// more iterations means an attacker has to take longer to brute force an |
View quick-display.sh
#!/bin/bash | |
# arrange outputs in order of name | |
params=() | |
prev='' | |
verbose=0 | |
if [ "$1" == '-v' ] || [ "$1" == '--verbose' ]; then | |
verbose=1 | |
shift | |
fi |
View append.js
function append(dest) { | |
for (var i = 1, n = arguments.length; i < n; i++) { | |
var src = arguments[i], offset = dest.length; | |
dest.length += src.length; | |
for (var j = 0, l = src.length; j < l; j++) { | |
dest[offset++] = src[j]; | |
} | |
} | |
return dest; | |
} |
View async-hash-bench
concurrent=1 algo=sha256 type=asc encoding=ascii len=2 api=legacy: 0.000098569 | |
concurrent=1 algo=sha256 type=asc encoding=ascii len=2 api=stream: 0.0000081394 | |
concurrent=1 algo=sha256 type=asc encoding=ascii len=2 api=digest: 0.000032721 | |
concurrent=1 algo=sha256 type=asc encoding=ascii len=1024 api=legacy: 0.030183 | |
concurrent=1 algo=sha256 type=asc encoding=ascii len=1024 api=stream: 0.0044764 | |
concurrent=1 algo=sha256 type=asc encoding=ascii len=1024 api=digest: 0.019793 | |
concurrent=1 algo=sha256 type=asc encoding=ascii len=102400 api=legacy: 1.5514 | |
concurrent=1 algo=sha256 type=asc encoding=ascii len=102400 api=stream: 0.36778 | |
concurrent=1 algo=sha256 type=asc encoding=ascii len=102400 api=digest: 1.2178 | |
concurrent=1 algo=sha256 type=asc encoding=ascii len=1048576 api=legacy: 2.0210 |
NewerOlder