Skip to content

Instantly share code, notes, and snippets.

@timhughes
timhughes / Makefile
Last active March 29, 2022 10:33
Python Makefile
#
# vim:ft=make
# Makefile
#
.DEFAULT_GOAL := help
.PHONY: test help
_GREEN=$(shell tput setaf 2)
_BLUE=$(shell tput setaf 4)
@timhughes
timhughes / kubernetes_one_liners.md
Last active August 28, 2020 11:59
Kubernetes One Liners
  • get everything in default namespace or remove --namespaced for absolutly everything
kubectl get $(kubectl api-resources --verbs=list --namespaced -o name | xargs |sed 's/ /,/g')
@timhughes
timhughes / firefox_nytimes_fix.md
Last active August 20, 2020 12:16
Fix New York Times website in Firefox
Get a kernel and the dtb files from
https://www.raspberrypi.org/downloads/raspberry-pi-os/
https://github.com/dhruvvyas90/qemu-rpi-kernel
sudo qemu-system-arm -kernel kernel-qemu-4.19.50-buster -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 console=ttyAMA0" -hda raspbian-buster-lite.qcow2 -dtb versatile-pb-buster.dtb -net nic -net user -vnc :0 -net tap,ifname=vnet0,script=no,downscript=no
@timhughes
timhughes / pynetcat.py
Created June 18, 2020 18:13
oneliner python netcat style listening socket server for when nc is not available
python -uc "import sys, socket;from functools import partial; a = socket.create_server(('0.0.0.0', 8888)).accept(); [sys.stdout.buffer.write(bytes(i)) for i in iter(partial(a[0].recv, 1024), b'')]"
@timhughes
timhughes / bootstrap_cmdline.py
Created June 15, 2020 15:23 — forked from elmotec/bootstrap_cmdline.py
Minimal python program with logging and argparse.
#!/usr/bin/env python
# encoding: utf-8
"""Minimal python commad line."""
import sys
import argparse
import logging
@timhughes
timhughes / minio_sts_ldap.py
Created April 24, 2020 16:11
Minio STS LDAP authentication using python
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2020 Tim Hughes <thughes@thegoldfish.org>
#
# Distributed under terms of the MIT license.
"""
@timhughes
timhughes / test_ca.sh
Last active April 23, 2020 16:52
Insecure Test Certificate Authority
# Create unencrypted ca
MYCN=$!
#openssl genrsa -des3 -out myCA.key 2048
openssl genrsa -out myCA.key 2048
openssl req -x509 -new -nodes -key myCA.key -sha256 -days 1 -out myCA.pem -subj "/C=GB/ST=INSECURE/L=INSECURE CA/O=INSECURE CA/CN=MY INSECURE CA/emailAddress=insecure@example.com"
openssl req -new -nodes -keyout ${MYCN}.key.pem -out ${MYCN}.csr -sha256 -days 1 -subj "/C=GB/ST=INSECURE/L=INSECURE CA/O=INSECURE CA/CN=${MYCN}" # -config /etc/pki/tls/openssl.cnf -extensions v3_req
@timhughes
timhughes / conftest.py
Last active April 13, 2020 02:00
Failed example at test isolation
import secrets
from datetime import timedelta
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
from fastapp import settings, crud
from sqlalchemy import create_engine
from sqlalchemy.engine import Engine
from sqlalchemy.orm import Session, sessionmaker