Skip to content

Instantly share code, notes, and snippets.

@nachmore
nachmore / interactive.py
Last active July 16, 2023 05:09
Create an interactive Python shell at a specific line
import pdb
pdb.set_trace
# b: set a breakpoint
# c: continue debugging until you hit a breakpoint
# s: step through the code
# n: to go to next line of code
# l: list source code for the current file (default: 11 lines including the line being executed)
# u: navigate up a stack frame
@nachmore
nachmore / aws-cost-anomaly-detector-sample.sns
Created July 15, 2021 15:15
Sample SNS message sent from AWS Cost Anomy
{
"Records": [
{
"EventSource": "aws:sns",
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:us-east-1:[account-id]:CostAnomalyQueue:f6df06cb-a1be-48be-b560-85876b7821b2",
"Sns": {
"Type": "Notification",
"MessageId": "31236cc0-d7be-55ec-a6f7-35aaf7b15d43",
"TopicArn": "arn:aws:sns:us-east-1:[account-id]:CostAnomalyQueue",
@nachmore
nachmore / flapping-crash.js
Created July 14, 2021 14:01
Javascript function (in AWS Lambda form) that crashes ever other minute. Useful for testing Alarms.
exports.handler = async () => {
// causes a crash every other minute by returning an invalid value
return (new Date().getMinutes() % 2) ? () => {} : 1;
};
@nachmore
nachmore / all-variables.js
Last active July 13, 2021 07:07
Traverse a Javascript object. Particularly useful for dump(this) to grab everything.
dump = (target, match_re, depth, seen) => {
if (depth === undefined) depth = 0
if (seen === undefined) seen = [target]
Object.keys(target).forEach((i, idx) => {
value = target[i] ?? "null";
isObject = (value === Object(value));