Skip to content

Instantly share code, notes, and snippets.

View ewjoachim's full-sized avatar
🐍
👨‍💻

Joachim Jablon ewjoachim

🐍
👨‍💻
View GitHub Profile
@ewjoachim
ewjoachim / pro
Last active January 17, 2024 15:17
Disable ubuntu asking for Pro in update-manager
#!/bin/bash -eu
# Need jq (should be quite rewritable without jq)
# Place it as something named `pro` in your path before `/usr/bin`
# e.g.`/usr/local/sbin/pro` or `~/.local/bin/pro` if that's in your path
if [ "${1:-} ${2:-}" = 'security-status --format=json' ]; then
/usr/bin/pro security-status --format=json | jq -cM '.packages = []'
exit 0
fi
exec /usr/bin/pro "$@"
@ewjoachim
ewjoachim / card-id-cache.py
Created September 18, 2022 14:58
Pinentry wrapper for MacGPG2 that lets you save the yubikey PIN to the Mac Keychain
#!/usr/bin/env python3
import pathlib
import re
import subprocess
import sys
import threading
import traceback

Integrate Yubikey with libpam

Note: All examples use Ubuntu 19.10

Objectives:

Add additonal security

If used as a second auth factor, this would secure the laptop a bit more. This might also make the laptop unusable if the key is lost.

@ewjoachim
ewjoachim / MPMP5.ipynb
Created April 29, 2020 18:40
Matt Parker's Maths Puzzle 5 - Coin puzzle
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ewjoachim
ewjoachim / test.json
Created April 25, 2020 14:26
Testing shield
{"schemaVersion":1, "label":"ARM wheel", "message":"1.2.3", "color":"green"}
@ewjoachim
ewjoachim / decorator.py
Created April 24, 2020 16:19
Generically wrapping exceptions
import contextlib
import functools
from typing import Awaitable, Callable, Coroutine, Dict, Type
ExceptionMapping = Dict[Type[Exception], Type[Exception]]
CoroutineFunction = Callable[..., Awaitable]
@contextlib.contextmanager
[
{
"os": "linux",
"language": "python",
"dist": "xenial",
"cache": {
"pip": true
},
"script": [
"tox -e $TOX_ENV"
@ewjoachim
ewjoachim / with_global.py
Last active April 24, 2020 16:22
Workable gettext
# workalendar/i18n.py
import gettext
import collections
_ = lambda x: x
def get_translation_for_language(language: str) -> gettext.Translations:
@ewjoachim
ewjoachim / signature_verification.py
Created January 8, 2020 23:40
GitHub Token scanning ECDSA signature check using Python
#!/usr/bin/env python3
import base64
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.hashes import SHA256
from cryptography.hazmat.primitives.asymmetric.ec import ECDSA
def check_signature(payload, public_key, signature):
@ewjoachim
ewjoachim / http-payload.txt
Created January 8, 2020 19:22
Implementation of token scnanning from GitHub
POST /your/token/endpoint HTTP/1.1
Host: yourhost.com
User-Agent: curl/7.54.0
Accept: */*
Content-Type: application/json
GITHUB-PUBLIC-KEY-IDENTIFIER: 90a421169f0a406205f1563a953312f0be898d3c7b6c06b681aa86a874555f4a
GITHUB-PUBLIC-KEY-SIGNATURE: MEQCIAfgjgz6Ou/3DXMYZBervz1TKCHFsvwMcbuJhNZse622AiAG86/cku2XdcmFWNHl2WSJi2fkE8t+auvB24eURaOd2A==
[{"type":"github_oauth_token","token":"cb4985f91f740272c0234202299f43808034d7f5","url":" https://github.com/github/faketestrepo/blob/b0dd59c0b500650cacd4551ca5989a6194001b10/production.env"}]