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
/**
* @param {Object.<string, boolean>} data
* @return {number}
*/
function hello(data) {
var q = 0;
if (data.a) {
if (data.b && data.c) {
q = 1
} else if (data.d) {
@skeggse
skeggse / play-store-reviews.js
Created December 12, 2013 09:21
Simple (and pretty bad) scraper for Google Play Store reviews.
var scan = (function(window, document) {
/**
* Scans through all the pages and maps all the reviews.
*
* TODO: automatically switch to date-ordered reviews, and page backwards to
* beginning.
*
* @param {function(?Error, Object, Array)} callback The callback when all reviews have
* been found.
*/
@skeggse
skeggse / stupid-test.conf
Created December 13, 2013 03:49
Upstart apparently not working logically
script
VALUE="PONG"
echo "START" >> /var/log/stupid-test.log
if [ "$VALUE" == "PONG" ]; then
echo "GOOD PONG" >> /var/log/stupid-test.log
fi
if [ "$VALUE" != "PONG" ]; then
echo "BAD PONG" >> /var/log/stupid-test.log
fi
if [ "$VALUE" == "PING" ]; then
@skeggse
skeggse / identity-regex
Created January 27, 2014 22:41
A regular expression which finds javascript functions that return their first value. Doesn't handle comments.
function\s*[^\(]*\(\s*([\$a-z][\$a-z0-9]*)\s*\)\s*\{\s*return\s+\1\s*;?\s*\}
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)
@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 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 / 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
@skeggse
skeggse / md5.sh
Created April 9, 2014 20:15
recursive md5 implementation with md5sum fallback, bash only
#!/bin/bash
if [ "$#" -eq 0 ]; then
md5sum "$@"
exit 0
fi
recursive=0
exclude=0
sum=0