Skip to content

Instantly share code, notes, and snippets.

View ipmb's full-sized avatar

Peter Baumgartner ipmb

View GitHub Profile
@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 / 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*)
@ipmb
ipmb / pg_chown.py
Last active August 18, 2021 22:12
change ownership of all items in public schema using Python/psycopg2
import psycopg2
NEW_USER = "fred"
types = {"c": "TABLE", "t": "TABLE", "r": "TABLE", "S": "SEQUENCE", "i": "INDEX", "v": "VIEW"}
with psycopg2.connect(**kwargs) as conn:
conn.autocommit = True
with conn.cursor() as curs:
for kind, name in types.items():
curs.execute(
@ipmb
ipmb / s3_upload.sh
Last active April 25, 2021 22:48
testing s3 upload credentials from your shell
pip install awscli # if you don't have it installed already
export AWS_ACCESS_KEY_ID=your-access-key # starts with AK
export AWS_SECRET_ACCESS_KEY=your-secret-key
echo "hello world" | aws s3 cp - s3://your-bucket-name/test.txt
aws s3 cp s3://your-bucket-name/test.txt - # this should output "hello world"
@ipmb
ipmb / cloudformation_template.json
Created February 3, 2021 16:15
Snippet of Cloudformation template to enable load balancer logging
{
"Mappings": {
"LBAccountId": {
"af-south-1": {
"AccountId": "098369216593"
},
"ap-east-1": {
"AccountId": "754344448648"
},
"ap-northeast-1": {
@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 / check.sh
Last active November 11, 2020 16:35
pipenv version test
$ chmod +x install.sh
$ docker build -t pipenv .
$ docker create --name pipenv pipenv
$ docker cp pipenv:/pipenv .
$ diff pipenv/2018.11.14/Pipfile pipenv/2018.05.18/Pipfile && echo "no difference"
2d1
< name = "pypi"
5,6c4
<
< [dev-packages]
Error: Error in function call
on .terraform/modules/client_vpc/terraform-aws-vpc-2.39.0/main.tf line 20, in locals:
20: vpce_tags = merge(
21: var.tags,
22: var.vpc_endpoint_tags,
23: )
|----------------
| var.tags is empty map of string
| var.vpc_endpoint_tags is empty map of string