Skip to content

Instantly share code, notes, and snippets.

View skeggse's full-sized avatar
⚠️
Drop ICE

Eli Skeggs skeggse

⚠️
Drop ICE
View GitHub Profile
@skeggse
skeggse / build_exceptions_full.py
Last active March 21, 2024 06:39
No boto3.client handy? Need to catch a boto3 exception? Build the exceptions via two obscure methods!
from typing import Optional
from boto3 import Session
from botocore import UNSIGNED
from botocore.config import Config
from mypy_boto3_servicecatalog.literals import ServiceName
def build_service_exceptions(
service_name: ServiceName, *, session: Optional[Session] = None
Energy Time Mb
(c) C 1.00 (c) C 1.00 (c) Pascal 1.00
(c) Rust 1.03 (c) Rust 1.04 (c) Go 1.05
(c) C++ 1.34 (c) C++ 1.56 (c) C 1.17
(c) Ada 1.70 (v) Ada 1.85 (c) Fortran 1.24
(v) Java 1.98 (v) Java 1.89 (c) C++ 1.34
(c) Pascal 2.14 (c) Chapel 2.14 (c) Ada 1.47
(c) Chapel 2.18 (c) Go 2.83 (c) Rust 1.54
(v) Lisp 2.27 (c) Pascal 3.02 (v) Lisp 1.92
@skeggse
skeggse / notify-dependabot.sh
Created July 12, 2018 18:57
Notify dependabot of a new version of a private npm module
#!/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
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 February 27, 2018 18:28
similar to watch, but with diffs and timestamps (and no cli args)
#!/bin/bash
INTERVAL=1
afile="$(mktemp)"
bfile="$(mktemp)"
function show_diff() {
a="$1"
b="$2"
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)
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 April 17, 2024 21:04
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
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 January 5, 2015 20:39
Simplified xrandr script for horizontal monitor layouts
#!/bin/bash
# arrange outputs in order of name
params=()
prev=''
verbose=0
if [ "$1" == '-v' ] || [ "$1" == '--verbose' ]; then
verbose=1
shift
fi