Skip to content

Instantly share code, notes, and snippets.

View WhiteHotLoveTiger's full-sized avatar

Alex Keeling WhiteHotLoveTiger

View GitHub Profile
function hugo_server() {
WSL2_IPADDRESS=$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
hugo server --bind $WSL2_IPADDRESS --baseURL=http://$WSL2_IPADDRESS -D -F --gc -w
}
@bbarker
bbarker / PythonTyping.md
Created November 7, 2017 16:13
Using mypy in tests

The following test uses mypy to check the correctness of Python code using typing, largely introduced in 3.5 and 3.6. The two tests check all package code and all test code in the tests directory, respectively. Testing frameworks such as 'nose2' will automatically run the tests and will fail if any typing error is detected (see step #3 below for more on this).

Steps to use

  1. Add the file below to your tests directory, which should be at the top-level in your repository alongside your module directory.
  2. Modify the first line in __init__ that sets self.pkgname to match your library's package name. This assumes one package per repo, so the test would need to be changed if this isn't how the repo structure works.
@richmondwang
richmondwang / python_jose_decode_cognito.py
Last active May 30, 2020 03:08
Gist to decode AWS cognito using the python Jose package
# -*- coding: utf-8 -*-
# pip install python-jose
from jose import jwt
token = "<token here>"
key = {
"alg": "RS256",
"e": "AQAB",
"kid": "+Sr66GHFIwrVWzl9N02mrm96OCoYbNktaekEhXs9+eM=", # <-- this should match the `kid` in the token's headers
@rondomondo
rondomondo / check_jwt_sig.py
Last active February 21, 2024 14:55
Two methods/examples of how to decode and verify the signature of AWS cognito JWT web tokens externally. This uses RSA key pair and alternatively PKCS1_v1_5. See https://gist.github.com/rondomondo/efff911f2c41c295e23415e94e12b8d3 for example of signing and verification by downloading an ISSUERS PKI SSL certificate from the signers website, and h…
#!/usr/bin/env python
import os
import time
import json
import base64
import requests
import argparse
from base64 import urlsafe_b64decode, b64decode
from Crypto.Hash import SHA256, SHA512
@tomislacker
tomislacker / buildStatic.sh
Created February 14, 2014 18:09
Building a statically linked suite of git/git binaries for deployment on 32bit hosts
#!/bin/bash
cd $(dirname $0)
LOG_PREFIX=build-static
LOG_STDOUT=${LOG_PREFIX}.stdout
LOG_STDERR=${LOG_PREFIX}.stderr
REMOVE_TARGET_DIR=n
SOURCE_MAKE_CONF=y