Skip to content

Instantly share code, notes, and snippets.

💭
alive

Eli Skeggs skeggse

💭
alive
Block or report user

Report or block skeggse

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
@skeggse
skeggse / notify-dependabot.sh
Created Jul 12, 2018
Notify dependabot of a new version of a private npm module
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))
@skeggse
skeggse / wdiff.sh
Created Feb 27, 2018
similar to watch, but with diffs and timestamps (and no cli args)
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 keybase.md

Keybase proof

I hereby claim:

  • I am skeggse on github.
  • I am skeggse (https://keybase.io/skeggse) on keybase.
  • I have a public key whose fingerprint is 3754 051A 7F17 3E73 7CD2 E9FF 66FD 1B30 8DBC C990

To claim this, I am signing this object:

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;
}
@skeggse
skeggse / crypto-pbkdf2-example.js
Last active Feb 5, 2020
Example of using crypto.pbkdf2 to hash and verify passwords asynchronously, while storing the hash and salt in a single combined buffer along with the original hash settings
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
@skeggse
skeggse / quick-display.sh
Created Jan 5, 2015
Simplified xrandr script for horizontal monitor layouts
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;
}
@skeggse
skeggse / async-hash-bench
Created Jul 25, 2014
Asynchronous hash benchmarks
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
You can’t perform that action at this time.