Skip to content

Instantly share code, notes, and snippets.

View stuaxo's full-sized avatar
💭
 

Stuart Axon stuaxo

💭
 
View GitHub Profile
@stuaxo
stuaxo / pyproject.toml
Last active September 9, 2025 15:59
sqlcmd
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "sqlcmdurl"
version = "0.1.0"
description = "Connect to SQL Server using dj-database-url format"
dependencies = [
"dj-database-url",
@stuaxo
stuaxo / install-aptos-fonts.sh
Created September 2, 2025 23:45
Install the Microsoft Aptos fonts.
#!/bin/bash
# Install the Microsoft Aptos Fonts
# Requires: lynx, unzip, unrtf
set -e
URL='https://download.microsoft.com/download/8/6/0/860a94fa-7feb-44ef-ac79-c072d9113d69/Microsoft%20Aptos%20Fonts.zip'
TEMP_DIR=$(mktemp -d)
cd "$TEMP_DIR"
wget -O aptos.zip "$URL"
@stuaxo
stuaxo / install-old-ppviewer-fonts.sh
Created September 2, 2025 01:53
Install the old powerpoint viewer fonts in debian based distros.
#!/bin/bash
#
# script that paraphtases info from the debian wiki at: https://wiki.debian.org/ppviewerFonts
#
#
set -e
DOWNLOAD_URL="https://archive.org/download/PowerPointViewer_201801/PowerPointViewer.exe"
EXPECTED_CHECKSUM="249473568eba7a1e4f95498acba594e0f42e6581add4dead70c1dfb908a09423"
FONT_DIR="$HOME/.local/share/fonts/ppviewer"
def is_container_type(type_hint: Any) -> bool:
"""\
:return: for containers you might add to a dataclass, like List[...] but types like str.
"""
origin = get_origin(type_hint) or type_hint
if origin is str:
return False
if isinstance(origin, type):
@stuaxo
stuaxo / dataclass_to_pydantic.py
Last active May 12, 2025 09:48
dataclass_to_pydantic
# Extend https://yeonwoosung.github.io/posts/pydantic-vs-dataclass/
# to convert nested dataclasses.
from functools import lru_cache
from dataclasses import fields, _MISSING_TYPE, is_dataclass
from typing import Any, Optional
import pydantic
@stuaxo
stuaxo / v4l2-scrcpy.md
Last active April 23, 2025 01:20
V4L2 from SCRCPY

Packages needed

$ sudo apt install v4l2loopback-dkms v4l2loopback-utils

Create virtual device

$ sudo modprobe -v v4l2loopback exclusive_caps=1 card_label="Virtual Webcam"
@stuaxo
stuaxo / aws-env.sh
Created April 11, 2025 12:06
aws-env
aws-env() {
export AWS_REGION=$(aws configure get region)
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
export AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id)
export AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key)
echo "AWS environment variables set:"
echo "AWS_REGION=$AWS_REGION"
echo "AWS_ACCOUNT_ID=$AWS_ACCOUNT_ID"
echo "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID"
echo "AWS_SECRET_ACCESS_KEY=********"
@stuaxo
stuaxo / parquet_schema.py
Created June 26, 2024 13:32
Output data types of the columns in a parquet file
DATA_FILE = "your-file.parquet"
import pandas as pd
# Read the Parquet file
df = pd.read_parquet(DATA_FILE)
def df_schema(df):
# Print the column names and their types
for column in df.columns:
@stuaxo
stuaxo / addvenvkernel.sh
Last active January 31, 2025 12:49
Create a Jupyter Kernel for for the current virtualenv.
#!/bin/bash
#
# Creates a Jupyter kernel for a virtual environment.
#
# Usage:
# ./create_kernel.sh [venv_name]
#
# Arguments:
# venv_name Optional. Name of the virtual environment to create kernel for.
# If not provided, uses currently activated environment.
@stuaxo
stuaxo / utm-linux-vm-playbook.md
Last active August 10, 2023 17:19
Ubuntu VM in a Mac Host [QEmu with UTM frontend]