Skip to content

Instantly share code, notes, and snippets.


Mike Riebart

View GitHub Profile
Riebart /
Created Apr 13, 2017
A bash function that sends a pushbullet notification when a command completes
function pb_notify {
start=`date +%s%N`
end=`date +%s%N`
start_ms=`echo $start | head -c 13`
end_ms=`echo $end | head -c 13`
if which bc >/dev/null 2>&1
dt=`echo "scale=3;$dt_ms/1000.0" | bc`
Riebart /
Last active Sep 15, 2017
Collect a list of IPv4 addresses into contiguous range blocks.
#!/usr/bin/env python
Given a list of IP addresses (or IP address ranges), one per line (with ranges given as "IP1-IP2"),
return a list of IP address ranges that represent the smallest possible list of IP address ranges
that does not contain any addresses not represented in the input list.
Only supports IPv4.
import sys

Keybase proof

I hereby claim:

  • I am Riebart on github.
  • I am riebart ( on keybase.
  • I have a public key whose fingerprint is 277C D4E5 2742 A486 CAB0 C857 98B6 9479 9B76 0FBE

To claim this, I am signing this object:

from random import random
def accumulate(iterator):
total = 0
for item in iterator:
total += item
yield total
# Generate a list of a bunch of values with random offsets so we can bucket them.
# Only step at most 10ms per 'packet', because we want a representative sample size.
Riebart / vscode_context.reg
Created Nov 10, 2017
Registry entries for Explorer context menus. Useful for non-admin installs
View vscode_context.reg
Windows Registry Editor Version 5.00
@="Open with Code"
Riebart /
Created Jan 10, 2018
EC2 user data for setting up an EC2 instance with SSM and deploying into an ECS cluster.
# Install the SSM agent:
# Ref:
cd /tmp
sudo yum install -y
sudo start amazon-ssm-agent
echo ECS_CLUSTER="ECS_CLUSTER_NAME" >> /etc/ecs/ecs.config
export PATH=/usr/local/bin:$PATH
Riebart /
Created Apr 26, 2018
Read in a file, and respond to any query received with the contents of that file in the CNAME target.
from __future__ import print_function
from scapy.all import *
domain_name = ""
dns_server_ip = ''
bpf_filter = 'dst port 53 and ip dst {0}'.format(dns_server_ip)
def dns_respond(pkt, rcode=0):
if (DNS in pkt and pkt[DNS].opcode == 0 and pkt[DNS].ancount == 0):
print('Responding to query for "%s" from "%s"' % (pkt[DNSQR].qname, pkt[IP].src))
Riebart /
Last active Jun 27, 2018
Ad hoc stuffing timeseries into InfluxDB for visualization with Grafana with subsecond resolution timestamps.
influxId=$(docker run --rm -d -p 8086:8086 -p 2003:2003 -e INFLUXDB_GRAPHITE_ENABLED=true influxdb)
grafanaId=$(docker run --rm -d -p 3000:3000 grafana/grafana)
echo "Sleeping while the containers spool up..." >&2
sleep 10
influxIp=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${influxId})
Riebart / script.ps1
Last active Oct 22, 2021
Generate code signing certificate and key using Powershell
View script.ps1
# Generate a new certificate with key, marked exportable (the default), suitable for code signing.
# The certificate is stored in the personal certificate store.
New-SelfSignedCertificate -Subject "CN={YOUR NAME}" -KeySpec "Signature" -KeyUsage "DigitalSignature" -KeyUsageProperty "Sign" -Friendlyname "Code Signing" -NotAfter $([datetime]::now.AddYears(5)) -Type "CodeSigningCert" -CertStoreLocation cert:\currentuser\my -KeyAlgorithm RSA -Keylength 4096 -HashAlgorithm "SHA256" -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider"
# To Sign a Powershell script with a certificate
# - Find the key, which you can usually do with the thumbprint and knowing where it was stored
# - This may or may not work for you, depending on whether or not you have access to a functioning timestamp server
# - Regardless of the timestamp, the signature will still work, just won't say when it was signed.
$cert = (ls cert:currentuser\my\0BD717BC985949E736067A15CC7502A1EAE6D031)
Riebart /
Last active Sep 3, 2021
Python script to invoke an AWS API Gateway endpoint that requires IAM authentication. Uses boto for signing the request, and requests for issuing it.
#!/usr/bin/env python3
Provides a simple Python wrapper for invoking an API Gateway endpoint using IAM signed requests.
python3 GET \ | jq .