Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 514Hockey_README.md
Last active December 15, 2024 20:09
HomeAssistant and Montreal Rink Conditions

Adding YOUR Montreal hockey rink

Ability to see the state and condition of ice rinks in Montreal.

Screenshot 2024-12-15 at 2 22 46 PM

The left is a typical rink widget, the right has an additional row for debugging.

Setup

@jlongman
jlongman / 1st-intermission.yaml
Created January 12, 2025 21:06
Team Tracker NHL Intermission Timers
---
alias: Canadiens 1st Intermission Timer Trigger
description: "Trigger the Canadiens Timer when the 1st period ends"
triggers:
- trigger: template
value_template: >-
{{ is_state_attr('sensor.team_tracker_canadiens', 'clock', 'End of 1st') }}
conditions: []
actions:
- action: timer.start