Skip to content

Instantly share code, notes, and snippets.

View gist:578d2295a13a246c9a061143ced0ab22
#!/usr/bin/env python3
import requests
import json
import sys
import os
import socket
# --- settings ---
takeshy / firehose-cloudwatch-logs-processor-elasticsearch_by_cloudwatch_subscription.js
Created Feb 23, 2020
kinesys firehose by cloudwatch subscription to elasticsearch
View firehose-cloudwatch-logs-processor-elasticsearch_by_cloudwatch_subscription.js
For processing data sent to Firehose by Cloudwatch Logs subscription filters.
Cloudwatch Logs sends to Firehose records that look like this:
"messageType": "DATA_MESSAGE",
"owner": "123456789012",
"logGroup": "log_group_name",
"logStream": "log_stream_name",
louispan /
Last active Jun 20, 2022
Install Cabal, GHC, or GHCJS with one Nix command
# install nix (5.5 mins)
curl | sh
# open a new shell to source nix
# query available haskell compilers
nix-env -qaP -A nixpkgs.haskell.compiler [QUERY]
# install ghc (2.5 mins, cached binary)
noamtamim /
Last active Sep 27, 2022
Markdown with PlantUML

How to use PlantUML with Markdown

PlantUML is a really awesome way to create diagrams by writing code instead of drawing and dragging visual elements. Markdown is a really nice documentation tool.

Here's how I combine the two, to create docs with embedded diagrams.

Step 0: Setup

Get the command-line PlantUML from the download page or your relevant package manager.

pirate /
Last active Sep 17, 2022
Backup a docker-compose project, including all images, named and unnamed volumes, container filesystems, config, logs, and databases.
#!/usr/bin/env bash
### Bash Environment Setup
# set -o xtrace
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
johnhw /
Last active Sep 22, 2022
1 million prime UMAP layout
### JHW 2018
import numpy as np
import umap
# This code from the excellent module at:
import random
mrthomaskim / install-Python-AmazonLinux-20171023.log
Created Jun 13, 2018
Amazon Linux AMI, pyenv, virtualenv, Python, ... Hello, World!
View install-Python-AmazonLinux-20171023.log
### prerequisites
sudo yum groupinstall "Development Tools"
git --version
gcc --version
bash --version
python --version # (system)
sudo yum install -y openssl-devel readline-devel zlib-devel
sudo yum update
### install `pyenv`

The below instructions describe the process for MITM'ing a target device over HTTPS using nginx. It tries to go over every aspect of intercepting traffic, including hosting a Wifi access point.


The goal is to get a target device (such as an iPhone, Wii U, or another computer) to trust our local nginx server instead of the remote trusted server. This is going to be done by importing a custom CA root certificate on the target that corresponds with the nginx server's certificate.

Client (Trusted Device) <--> MITM Server (nginx) <--> Remote (Trusted) Server


These instructions are being performed on a PureOS machine, which is Debian based. They should also work in other environments with slight modifications

mrw34 /
Last active Sep 16, 2022
Enabling SSL for PostgreSQL in Docker
set -euo pipefail
openssl req -new -text -passout pass:abcd -subj /CN=localhost -out server.req -keyout privkey.pem
openssl rsa -in privkey.pem -passin pass:abcd -out server.key
openssl req -x509 -in server.req -text -key server.key -out server.crt
chmod 600 server.key
test $(uname -s) = Linux && chown 70 server.key
docker run -d --name postgres -e POSTGRES_HOST_AUTH_METHOD=trust -v "$(pwd)/server.crt:/var/lib/postgresql/server.crt:ro" -v "$(pwd)/server.key:/var/lib/postgresql/server.key:ro" postgres:12-alpine -c ssl=on -c ssl_cert_file=/var/lib/postgresql/server.crt -c ssl_key_file=/var/lib/postgresql/server.key