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 / stop-old-containers.sh
Created June 1, 2017 13:27
Stop docker containers older than 1 day old
#!/bin/bash -eux
yesterday=$(date -d yesterday +%s)
# dnsdock should not be stopped : we limit to the containers created after it
docker ps --filter since=dnsdock -q --format "{{.ID}} {{.CreatedAt}}" | while read line
do
# line looks like:
# 123456789abcdef 2017-01-01 00:00:00 +02:00 CEST
set $line
id=$1
@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"}]
@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
@ewjoachim
ewjoachim / clmystery.py
Last active November 25, 2021 22:35
CLMystery as a python "one-liner" (well, one expression)
"Yay" if __import__("hashlib").md5((next((n & g).pop() for g, n in
(
(g, set(dr["Owner"] for dr in v if all(el in t.lower().split() for el in
[
dr["Color"].lower(), dr["Make"].lower(),
dr["Height"].split("'")[0] + "'",
]) and
dr["License Plate"].startswith(__import__("re")
.search(r'starts with "([A-Z0-9]+)"', t).group(1)) and
dr["License Plate"].endswith(__import__("re")

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 / 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 / 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