Skip to content

Instantly share code, notes, and snippets.

#!/bin/env python
"""
USAGE: jpsearch [--unquoted|-u] [-f|--filename <json-file>] <JMESPath>
Reads json from standard input, or the file
if given. Then searches that as instructed
by the JMESPath; and prints the result. If
the result is a string and --unquoted is given
the string is printed without quotation. See
also http://jmespath.org/
"""
@bhyde
bhyde / keybase.md
Created February 9, 2017 15:24
Link to Github <-> Keybase

Keybase proof

I hereby claim:

  • I am bhyde on github.
  • I am bhyde (https://keybase.io/bhyde) on keybase.
  • I have a public key ASB6SG9PWyOBE1e1WA21mCNHl-7FixKCgJLi0f1vKZMn0Qo

To claim this, I am signing this object:

@bhyde
bhyde / install-s6.sh
Last active April 2, 2017 01:12
Install script for the s6 supervision suite.
#!/bin/bash
# Based on https://raw.githubusercontent.com/cburki/docker-s6builder/master/scripts/build.sh
# hence GNU GENERAL PUBLIC LICENSE Version 3
set -o errexit
trap 'echo ERROR: exiting on error' ERR
SRC_DIR=/tmp/$(basename $0)-$$
trap 'rm -rf $SRCDIR' EXIT
mkdir -p ${SRC_DIR}
#!/bin/bash
# Run the AWS cli on an ec2 instance with the security credentials of that instance
set -e
export IAM_ROLE=$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/)
export AWS_ACCESS_KEY_ID=$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${IAM_ROLE} |/usr/bin/jq -r .AccessKeyId)
export AWS_SECRET_ACCESS_KEY=$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${IAM_ROLE} |/usr/bin/jq -r .SecretAccessKey)
export AWS_SECURITY_TOKEN=$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${IAM_ROLE} |/usr/bin/jq -r .Token)
export AWS_DEFAULT_REGION=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/[a-z]$//')
# cat <<EOF
# IAM_ROLE $IAM_ROLE
@bhyde
bhyde / README.org
Last active June 25, 2017 18:46
outshine-lang.py reworked for quelpa

This is a minor rework of outshine-lang so I can load it in my init file.

I do that via use-package + quelpa

Quelpa is a kind of virtual package repo that fetchs from files, github, etc.

So in my init file I find:

(use-package outshine
@bhyde
bhyde / decorative_case.py
Last active June 28, 2017 19:47
Decorative dispatch table
class Dispatcher(object):
def __init__(self):
self.table = {}
def choice(self, key=None):
def decorator(fn):
self.table[key or fn.func_name] = fn
decorated_fn = fn
return decorated_fn
return decorator
@bhyde
bhyde / dump_tracebacks.py
Created August 31, 2017 21:44
pyrasite script to dump thread tracebacks, merging those with identical tracebacks
# pyrasite script to dump all thread tracebacks, grouping
# together threads with identical tracebacks.
# pyrasite <pid> dump_tracebacks.py
# The report is appended to /tmp/report.txt
import os
import traceback
import sys
@bhyde
bhyde / s3_bucket_logging.py
Created January 5, 2018 17:09
context manager for boto3 ClientError
@contextmanager
def ignoring_aws_client_error(code-text):
try:
yield
except ClientError as e:
if e.response['Error']['Code'] == code-text:
pass
raise
<html>
<body>
<p>That site is currently on vacation.</p>
<body>
</html>
<img src='https://radblast.wunderground.com/cgi-bin/radar/WUNIDS_map?station=BOX&brand=wui&num=10&delay=50&type=N0R&frame=0&scale=1&noclutter=1&showstorms=99&mapx=400&mapy=240&centerx=400&centery=240&transx=0&transy=0&showlabels=1&severe=0&rainsnow=1&lightning=1&smooth=0&rand=26011761&lat=0&lon=0&label=you'>
<img '<img src=https://forecast.weather.gov/meteograms/Plotter.php?lat=42.3833&lon=-71.0667&wfo=BOX&zcode=MAZ015&gset=20&gdiff=10&unit=0&tinfo=EY5&ahour=0&pcmd=11101111110000000000000000000000000000000000000000000000000&lg=en&indu=1!1!1!&dd=&bw=&hrspan=48&pqpfhr=6&psnwhr=6'>