Skip to content

Instantly share code, notes, and snippets.

{
"detail": {
"attributes": {
"hideResponseInput": true,
"img": "static/img/FIDO-U2F-Security-Key-444x444.png",
"webAuthnSignRequest": {
"allowCredentials": [
{
"id": "nPr77L4_***",
"transports": [
@kgaughan
kgaughan / vaultdecrypt.py
Created May 3, 2022 19:09
Decrypting ansible-vault files without ansible-vault
import binascii
import sys
import typing
from cryptography.hazmat.primitives import ciphers, hashes, hmac, padding
from cryptography.hazmat.primitives.ciphers import algorithms
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
def vault_parse(lines: typing.List[str]) -> typing.Tuple[bytes, bytes, bytes]:
@kgaughan
kgaughan / permute.go
Created December 8, 2021 17:04
Permuting a string in Go
package permute
func fact(n int) int {
result := 1
for i := 1; i <= n; i++ {
result *= i
}
return result
}
@kgaughan
kgaughan / index.html
Created June 6, 2021 00:00
YouTube embedded player façade
<!DOCTYPE html>
<html>
<head>
<style>
.facade, .player {
margin: 0 auto;
display: block;
}
.facade {
position: relative;
@kgaughan
kgaughan / luminance.py
Last active June 23, 2023 19:17
Python function to modify luminance of a colour
def modify_luminance(colour, lum=0):
rgb = 0
for i in range(0, len(colour), 2):
component = int(colour[i : i + 2], 16)
modified = round(min(max(0, component + (component * lum)), 255))
rgb = rgb * 256 + modified
return f"{rgb:0>6X}"
@kgaughan
kgaughan / talideon-wallpaper.py
Last active January 5, 2020 00:47
talideon-wallpaper
#!/usr/bin/env python3
#
# talideon-wallpaper
# by Keith Gaughan <http://talideon.com/>
#
# A pipemenu script for Openbox for selecting and setting the current
# wallpaper.
#
# Copyright (c) Keith Gaughan, 2008.
# All Rights Reserved.
@kgaughan
kgaughan / acme-domain-renew.sh
Created September 11, 2019 19:54
Wrapper around acme-tiny for automation
#!/bin/sh -e
while getopts hc:w:t: name; do
case $name in
c)
config_dir="$OPTARG"
;;
w)
challenge_dir="$OPTARG"
;;
@kgaughan
kgaughan / chan.go
Created August 4, 2019 13:46
Iteration benchmark
package iteration
func fiboChan(n int) <-chan int {
c := make(chan int)
go func() {
a := 0
b := 1
for i := 0; i < n; i++ {
a, b = b, a+b
For want of a nail the shoe was lost.
For want of a shoe the horse was lost.
For want of a horse the rider was lost.
For want of a rider the message was lost.
For want of a message the battle was lost.
For want of a battle the kingdom was lost.
And all for the want of a horseshoe nail.
@kgaughan
kgaughan / selfmutex.py
Created March 8, 2019 15:26
Using a python script as its own mutex to prevent it executing concurrently with multiple instances of itself
#!/usr/bin/env python3
import contextlib
import fcntl
import sys
import time
class MutexException(Exception):
"""