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 /
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 /
Created July 12, 2018 18:57
Notify dependabot of a new version of a private npm module
# 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 = None, tf.float32)
# raises no errors i: (i, tf.zeros(tf.float32)))
zeros = tf.zeros(tf.float32)
# raises KeyError: 'zeros:0' i: (i, zeros))
skeggse /
Created February 27, 2018 18:28
similar to watch, but with diffs and timestamps (and no cli args)
function show_diff() {
import scipy.optimize
# let check_grad work for x0: ndarray, like the documentation says it should
# see also:
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 / crypto-pbkdf2-example.js
Last active May 21, 2024 09:21
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 /
Created January 5, 2015 20:39
Simplified xrandr script for horizontal monitor layouts
# arrange outputs in order of name
if [ "$1" == '-v' ] || [ "$1" == '--verbose' ]; then