Skip to content

Instantly share code, notes, and snippets.

View wiktor-k's full-sized avatar
🇺🇦
Support Ukraine!

Wiktor Kwapisiewicz wiktor-k

🇺🇦
Support Ukraine!
View GitHub Profile

C/C++ performance pitfall: int8_t, aliasing and the ways out

When I was working on a generic port of Google's hashmap to C, I wrote a function that (ignoring irrelevant parts) looked like this:

typedef struct {
    uint8_t *bytes;
    size_t len;
} bytebuf;
@solarkraft
solarkraft / syncthing-automerge.py
Created December 30, 2022 18:00
Monitors a Syncthing-synced directory and tries to merge conflicting files (based on https://www.rafa.ee/articles/resolve-syncthing-conflicts-using-three-way-merge/). Probably adaptable for other directory types, but only tested with Logseq (works for me™️).
import os
import time
import re
import subprocess
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
def get_relative_path(path):
return os.path.relpath(path)
@Higgs1
Higgs1 / key.py
Last active March 22, 2021 07:29
import cryptography
import datetime
import pgpy
pkalg = pgpy.constants.PubKeyAlgorithm.ECDSA
curve = pgpy.constants.EllipticCurveOID.NIST_P384
super_secret_number = 12345
created = 0 # datetime
@bjesus
bjesus / README.md
Last active February 9, 2024 12:46
Weather widget for waybar
@LukeMathWalker
LukeMathWalker / .gitlab-ci.yml
Last active March 29, 2024 16:15
GitLab CI - Rust setup
image: "rust:latest"
default:
before_script:
- rustc --version
- cargo --version
stages:
- test
@jakecraige
jakecraige / pkcs11-ecdh1-derive.go
Last active May 22, 2023 01:13
Example of the differences between deriving a non-sensitive ECDH key with `CKM_ECDH1_DERIVE` with SoftHSM2, AWS CloudHSM and YubiHSM2's PKCS#11 interface
/*
* This script shows an example of how with PKCS#11 ECDH1 key derivation and how it differs when
* communicating with SoftHSM2 vs AWS CloudHSM vs YubiHSM2. This seems to boil down to how they treat
* the `CKA_SENSITIVE` attribute on the derived key.
* - SoftHSM2 does what you expect, if you say it is sensitive it won't allow exporting. If you say
* it's not it will.
* - CloudHSM errors when you attempt to mark the derived key as not-sensitive. It behaves as
* expected when you say it is. AWS docs seem to indicate that the derived key is available on the
* "client" but it's unclear what client they are referring to, and it doesn't seem to be
@roehst
roehst / Direction.idr
Last active December 9, 2018 23:42
Simple verification in Idris
module Main
data Direction = North | South | West | East
turn : Direction -> Direction
turn North = East
turn South = West
turn West = North
turn East = South
# Update at 3am once a week
# Make sure the time on the Mikrotik is correct or update will occur "randomly" or never
/system scheduler
add interval=1w name=Auto-Upgrade on-event="/system package update\r\
\ncheck-for-updates once\r\
\n:delay 1s;\r\
\n:if ( [get status] = \"New version is available\") do={ install }" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-date=jan/01/2017 start-time=03:00:20
/system scheduler
add interval=1w name="Upgrade Router Weekly and Reboot" on-event=\
"/system package update check-for-updates; /system package update download; /system reboot;" policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-date=jan/01/2018 start-time=03:00:00
@ageis
ageis / YubiKey-GPG-SSH-guide.md
Last active March 16, 2024 13:18
Technical guide for using YubiKey series 4 for GPG and SSH

YubiKey 4 series GPG and SSH setup guide

Written for fairly adept technical users, preferably of Debian GNU/Linux, not for absolute beginners.

You'll probably be working with a single smartcard, so you'll want only one primary key (1. Sign & Certify) and two associated subkeys (2. Encrypt, 3. Authenticate). I've published a Bash function which automates this slightly special key generation process.