Skip to content

Instantly share code, notes, and snippets.

View ipmb's full-sized avatar

Peter Baumgartner ipmb

View GitHub Profile
@ipmb
ipmb / ratelimit.nginxconf
Last active April 5, 2024 00:46
Nginx reverse proxy with rate limiting
upstream myapp {
server 127.0.0.1:8081;
}
limit_req_zone $binary_remote_addr zone=login:10m rate=1r/s;
server {
listen 443 ssl spdy;
server_name _;
@ipmb
ipmb / settings.py
Last active November 24, 2023 20:25
Django logging example
import logging.config
import os
from django.utils.log import DEFAULT_LOGGING
# Disable Django's logging setup
LOGGING_CONFIG = None
LOGLEVEL = os.environ.get('LOGLEVEL', 'info').upper()
logging.config.dictConfig({
@ipmb
ipmb / transfer.tf
Created December 18, 2020 23:10
AWS Transfer Server with Elastic IP in terraform
variable "TRANSFER_HOST_KEY" {}
locals {
transfer = {
az_count = 2
}
}
resource "aws_eip" "transfer" {
count = local.transfer.az_count
@ipmb
ipmb / Dockerfile
Last active June 13, 2023 14:19
amazon-ssm-agent Dockerfile
FROM golang:1.12-alpine as builder
ARG VERSION=2.3.930.0
RUN set -ex && apk add --no-cache make git gcc libc-dev curl bash && \
curl -sLO https://github.com/aws/amazon-ssm-agent/archive/${VERSION}.tar.gz && \
mkdir -p /go/src/github.com && \
tar xzf ${VERSION}.tar.gz && \
mv amazon-ssm-agent-${VERSION} /go/src/github.com/amazon-ssm-agent && \
cd /go/src/github.com/amazon-ssm-agent && \
echo ${VERSION} > VERSION && \
gofmt -w agent && make checkstyle || ./Tools/bin/goimports -w agent && \
@ipmb
ipmb / aws_dump_log_stream.sh
Last active March 6, 2023 15:01
aws_dump_log_stream.sh
#!/bin/bash
if [ $# -lt 2 ]; then
echo "Usage: $0 <log_group_prefix> <log_stream_name>"
exit 1
fi
LOG_GROUP_PREFIX=$1
LOG_STREAM_NAME=$2
import json
import random
import http.client
# make call to cat facts API
# https://cat-fact.herokuapp.com/facts
conn = http.client.HTTPSConnection("cat-fact.herokuapp.com")
conn.request("GET", "/facts")
response = conn.getresponse()
@ipmb
ipmb / dejunk-twitter.txt
Created July 26, 2022 16:25
uBlock Origin custom filters to dejunk twitter
twitter.com##[aria-label$="Trending now" i]
twitter.com##article [aria-label^="Recommended Topic" i]:upward(article)
@ipmb
ipmb / docker-exec-ecs.sh
Last active June 2, 2022 17:30
docker exec on AWS ECS with SSM
#!/bin/bash
# USAGE: CLUSTER=mycluster SERVICE=myservice ./docker-exec-ecs.sh
set -euf -o pipefail
TASK_ARN=$(aws ecs list-tasks --cluster=$CLUSTER --service=$SERVICE \
| jq -r .taskArns[0])
if [ "$TASK_ARN" = "null" ]; then
echo "Could not find any running tasks for $SERVICE on cluster:$CLUSTER."
exit 1
fi
@ipmb
ipmb / 0_default_tree.md
Last active May 17, 2022 00:37
Django Logging Variations

Default Django Logging Tree

app.py

#!/usr/bin/env python
import os

import django
import logging_tree
@ipmb
ipmb / sandbox.sb
Created March 18, 2022 16:06
Playing around with sandbox-exec for local development
(version 1)
(allow default)
(debug deny)
(define (home-subpath home-relative-subpath)
;; should be able to use something like (param "HOME_DIR") here, but it's not working for me
(subpath (string-append "/Users/pete" home-relative-subpath)))
;; can't write anywhere or read /Users by default
(deny file-write*)