Skip to content

Instantly share code, notes, and snippets.

@jrialland
jrialland / sha256.wgsl
Created March 16, 2025 14:15
sha256 algo in WGSL
struct SHA256_CTX {
data : array<u32, 64>,
datalen : u32,
bitlen : array<u32, 2>,
state : array<u32, 8>,
info : u32,
};
fn sha256_init_ctx(ctx : ptr<function, SHA256_CTX>)
{
@jrialland
jrialland / autoimport.py
Created March 13, 2025 15:39
This code snippet defines a function import_submodules that imports all submodules of a given module recursively, including subpackages.
from types import ModuleType
def import_submodules(module: ModuleType) -> None:
"""
Import all submodules of a module, recursively, including subpackages.
:param module: module (package) to import submodules of
"""
import importlib
import pkgutil
@jrialland
jrialland / resp3.py
Created February 12, 2025 16:33
a quick and dirty resp3 serializer / deserializer
"""
This is a serializer / deserializer for the RESP3 protocol.
protocol spec at https://github.com/antirez/RESP3/blob/master/spec.md
"""
from typing import Generator, BinaryIO, Any
class error_str(str):
pass
@jrialland
jrialland / imgterm.py
Created February 3, 2025 13:44
displays an image in the terminal
"""
try to display an image in terminal using vt100 256 color codes
"""
import os, sys
from PIL import Image
#~dep:colored
from colored import Back, Style
from typing import TextIO
@jrialland
jrialland / proxy.py
Created October 29, 2024 13:44
proxies http and websocket traffic to an upstream server
import re
import requests
import logging
from urllib.parse import urljoin
import asyncio
import websockets
from http import HTTPStatus
from asgiref.typing import (
ASGI3Application,
@jrialland
jrialland / facemesh.py
Created October 30, 2023 13:40
python opencv example
from cvzone.FaceMeshModule import FaceMeshDetector
import cv2
cap = cv2.VideoCapture(0)
detector = FaceMeshDetector(maxFaces=2)
while True:
success, img = cap.read()
img, faces = detector.findFaceMesh(img)
if faces:
print(faces[0])
@jrialland
jrialland / CMakeLists.txt.snippet
Last active April 14, 2023 10:09
Cmake snippet that compiles quickjs as static library
################################################################################
## compile quickjs as a static library
set(QUICKJS_GIT_TAG master)
include(FetchContent)
FetchContent_Declare(
quickjs
GIT_REPOSITORY https://github.com/bellard/quickjs.git
GIT_TAG ${QUICKJS_GIT_TAG}
@jrialland
jrialland / add_cert.sh
Created February 13, 2023 09:27
install a certificate bundle containing multiple certs as trusted certificates
#ADD data/ca-bundle.crt /usr/share/ca-certificates/mycompany/ca-bundle.crt
#RUN << EOF
cd /usr/share/ca-certificates/mycompany
i=1; while openssl x509 -out cert$i.pem; do
echo mycompany/cert$i.pem >> /etc/ca-certificates.conf
i=$((i+1))
done < ca-bundle.crt
update-ca-certificates
#EOF
@jrialland
jrialland / FindLEMON.cmake
Created August 30, 2022 12:39
CMake script for lemon parser generator
# - Find lemon executable and provides macros to generate custom build rules
# The module defines the following variables:
#
# LEMON_EXECUTABLE - path to the LEMON program
# LEMON_VERSION - version of LEMON
# LEMON_FOUND - true if the program was found
#
# If LEMON is found, the module defines the macro:
#
# LEMON_TARGET(<Name> <LEMONInp>)
#include <ESP8266WiFi.h>
extern "C" {
#include "user_interface.h"
#include "wpa2_enterprise.h"
#include "c_types.h"
}
// SSID to connect to
char ssid[] = "TEST_KRA";