Skip to content

Instantly share code, notes, and snippets.

@jlongman
jlongman / check-pingdom-times.sh
Last active October 21, 2024 14:42
pingdom checks threshold list
#!/usr/bin/env bash
# get your api key from https://my.pingdom.com/app/api-tokens
SECRET="$1"
#
ids=$(curl -s -X GET https://api.pingdom.com/api/3.1/checks -H 'Authorization:Bearer '"${SECRET}"| jq '.checks | .[] | .id ')
echo "| name | threshold |"
for id in $ids; do
curl -s -X GET https://api.pingdom.com/api/3.1/checks/"${id}" -H 'Authorization:Bearer '"${SECRET}"| jq -r '.check | "| \(.name): | \(.responsetime_threshold) ms |"';
done
@jlongman
jlongman / gist:8261ceaf387c6e3222f5f0ed692d5613
Last active May 31, 2024 17:08
CDK without Tags: awk script to hide Tag-only changes in CDK
#!/usr/bin/env
# strict mode
set -euo pipefail
IFS=$'\n\t'
# from https://github.com/aws/aws-cdk/issues/25742
# why am i debugging^Wworking in awk
format_cdk_diff() {
DEBUGGING=$1;
awk 'BEGIN{ inTagBlock=0; previousLine=""; debugging='$DEBUGGING'; }
@jlongman
jlongman / gist:c6234a9041fa9e142685c215a274f4b6
Created April 15, 2023 15:55
One element path 404s in apache log with cloudwatch log insights
fields @timestamp, @message
| parse @message /^(?<local>\S+) (?<remoteA>\S+)(, (?<remoteB>\S+))? - - \[(?<date>[\w:\+\/ -]*?)\] "(?<method>[A-Za-z-]+) (?<path>[\/\w_-]+) (?<protocol>[\/\w0-9\.-]+)" (?<status>[0-9-]+) (?<bytes>[0-9-]*) "(?<url>\S*?)" "(?<web>.*)"$/
| filter path like /^\/\S+\/?$/ and status like /404/
| stats count(*) as hits by path
| sort hits desc
Verifying my Blockstack ID is secured with the address 1NgV5rvZJa6w1cEjEdXkokfS4BAWJv92Bc https://explorer.blockstack.org/address/1NgV5rvZJa6w1cEjEdXkokfS4BAWJv92Bc
@jlongman
jlongman / daturi.py
Last active August 9, 2017 18:24 — forked from josephsu/gist:4481205
decode Data URI to mime and data parts
#!/usr/bin/env python
# Convert a data uri file into the data part
#
# Usage: daturi.py infile
#
# Copy a response from Chrome
# pbaste > foo
# daturi.py foo
# creates foo.mimetype
@jlongman
jlongman / ssh_host.sh
Last active July 10, 2017 16:30
Output .ssh/config HostName entries
#!/bin/sh
# Output the HostName value from ~/.ssh/config
# SOURCE this, don't execute (e.g. "source ssh_host.sh" or ". ssh_host.sh")
# echos $@ if no HostName present
# Useful for shell substitution
# e.g. iperf -u -p 6970 -c $(ssh_host dev_backend)
ssh_host() {
ssh -G "$@" | grep -i '^hostname ' | awk '{print $2}'
}
@jlongman
jlongman / 404-ts-mitm.py
Created June 15, 2017 18:28
mitmproxy mitmdump script that injects 404s for streaming chunks
#!/usr/bin/env python
from mitmproxy import ctx
# an intermittent 404 for .ts files - HLS m3u8 streaming chunks
def start():
return Foo()
class Foo:
MUCHO = 0
@jlongman
jlongman / proxy.pac
Last active June 15, 2017 19:29
Status, stop, reload and separate start of proxy for MacOS
/**
* Created by jonathan.longman on 2017-06-15.
*/
var list = [
"www.foo.com",
"bar.com"
];
// searches as substring now
function FindProxyForURL(url, host) {
for (var i = list.length - 1; i >= 0; i--) {
@jlongman
jlongman / bug.m3u8
Last active June 14, 2017 20:45
m3u8 crafted bug superchunklist
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:10395
#EXTINF:1.0,
fake_10395.ts
#EXTINF:1.0,
fake_10396.ts
#EXTINF:1.0,
fake_10397.ts
@jlongman
jlongman / gist:e1557e478245212694a98bfbbfe2ddcf
Last active May 8, 2017 21:04
jq for selecting key and nested value
# sample data:
echo '{"count": {}, "block":
{
"67.215.237.26": {
"paths": {
"/js/compiled.js": 1,
"/css/global-compiled.css": 1,
"/js/pace.min.js": 1
},
"max_req_per_min": 1,