Skip to content

Instantly share code, notes, and snippets.

View awoimbee's full-sized avatar

Arthur Woimbée awoimbee

View GitHub Profile
@awoimbee
awoimbee / tumbleweed_pamu2f.md
Last active May 5, 2024 15:33
OpenSuse Tumbleweed sudo via Yubikey
@awoimbee
awoimbee / deferred.ts
Last active April 27, 2023 15:15
Deferred values with pulumi-kubernetes
import * as pulumi from "@pulumi/pulumi";
import assert from "node:assert/strict";
// Short solution:
type DeferredOutput<T> = pulumi.Output<T> & {
resolve: (value: pulumi.Input<T>) => void,
reject: (reason?: any) => void;
}
export function deferredOutput<T>() {
@awoimbee
awoimbee / arduino-leonardo-atmega32u4-pwm-fan.ino
Created November 6, 2022 20:49
Arduino leonardo (atmega32u4) pwm fan control
// CPU freq
#define F_CLK ((long)16000000)
// Standard fan PWM frequency is 25kHz
#define PWM_FREQ ((long)25000)
// e.g. PWM range is reversed on my TFC1212DE
#define REVERSE_PWM 0
/* Takes a percentage and returns the corresponding OCR1 register value */
word percent_to_ocr1(word percentage) {
if (REVERSE_PWM) {
@awoimbee
awoimbee / log.log
Created December 8, 2021 11:08
terraform azure ad user password bug debug log
2021-12-08T12:00:18.528+0100 [DEBUG] Adding temp file log sink: /tmp/terraform-log3879843825
2021-12-08T12:00:18.528+0100 [INFO] Terraform version: 1.0.11
2021-12-08T12:00:18.528+0100 [INFO] Go runtime version: go1.17.3
2021-12-08T12:00:18.528+0100 [INFO] CLI args: []string{"/usr/bin/terraform", "apply"}
2021-12-08T12:00:18.529+0100 [INFO] CLI command args: []string{"apply"}
-----------------------------------------------------
2021-12-08T12:00:19.843+0100 [DEBUG] created provider logger: level=debug
2021-12-08T12:00:19.843+0100 [INFO] provider: configuring client automatic mTLS
2021-12-08T12:00:19.863+0100 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/azuread/2.0.1/linux_amd64/terraform-provider-azuread_v2.0.1_x5 args=[.terraform/providers/registry.terraform.io/hashicorp/azuread/2.0.1/linux_amd64/terraform-provider-azuread_v2.0.1_x5]
@awoimbee
awoimbee / Dockerfile
Last active November 6, 2021 01:56
Optimized multi-stage dockerfile for python poetry
# syntax = docker/dockerfile:1.0-experimental
## NOTE : This image uses BuildKit, see
## https://docs.docker.com/develop/develop-images/build_enhancements/
## for more information.
## TLDR: Use docker build with DOCKER_BUILDKIT=1 in the environment
FROM python:3.9-slim-buster AS base
LABEL authors="<arthur.woimbee@gmail.com>"
@awoimbee
awoimbee / test_headscale.sh
Last active October 1, 2021 14:02
Test headscale locally
if [ ! command -v wg ]; then
sudo pacman -S wireguard-tools --noconfirm --needed
fi
if [ ! -f ./private.key ]; then
wg genkey > private.key
wg pubkey < private.key > public.key # not needed
fi
if [ ! -f derp.yaml ]; then

Keybase proof

I hereby claim:

  • I am awoimbee on github.
  • I am awoimbee (https://keybase.io/awoimbee) on keybase.
  • I have a public key whose fingerprint is 16F3 CEBD A13A 3ABF ABF8 0273 3B73 7EBF 9495 F3B0

To claim this, I am signing this object:

@awoimbee
awoimbee / faster_random_poisson.py
Created May 15, 2020 17:32
poisson random numbers with numba
# from https://scicomp.stackexchange.com/questions/27330/how-to-generate-poisson-distributed-random-numbers-quickly-and-accurately
# cupy is much, much faster than this
import numpy as np
from numba import jit
from math import *
import random
@jit()
def poissrnd(mean: float) -> int:
@awoimbee
awoimbee / rgb2yuv_yuv2rgb.py
Last active June 2, 2023 14:33
OpenCV's RGB2YUV & YUV2RGB conversions for Numpy, for values between [0, 1] or [0, 255]
# The coefficients were taken from OpenCV https://github.com/opencv/opencv
# I'm not sure if the values should be clipped, in my (limited) testing it looks alright
# but don't hesitate to add rgb.clip(0, 1, rgb) & yuv.clip(0, 1, yuv)
#
# Input for these functions is a numpy array with shape (height, width, 3)
# Change '+= 0.5' to '+= 127.5' & '-= 0.5' to '-= 127.5' for values in range [0, 255]
def rgb2yuv(rgb):
m = np.array([
[0.29900, -0.147108, 0.614777],