Skip to content

Instantly share code, notes, and snippets.

@sphr2k
sphr2k / .DS_Store
Last active April 3, 2024 13:47
Cloudflare Access Launcher Logos
@sphr2k
sphr2k / bt.sh
Created March 28, 2024 17:56
Linux I/O tracing / performance analysis
#! /usr/bin/env bash
# Check if a device argument is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 /dev/<device>"
exit 1
fi
# Assign the first argument to DEVICE variable
DEVICE=$1
@sphr2k
sphr2k / kb-remap.py
Created December 26, 2023 16:05
macOS Keyboard Remap
#! /usr/bin/env python
import shlex
import subprocess
import re
import csv
from io import StringIO
from dataclasses import dataclass
from typing import List, Dict, Any, Match, Optional
@sphr2k
sphr2k / base64_helper.py
Last active December 15, 2023 18:00
Python Base64 helper functions
import base64
from typing import Union
def base64_encode(data: Union[str, bytes]) -> str:
"""
Encodes a string or byte string to a Base64 string.
:param data: The string or byte string to encode. If `data` is a string, it is encoded as UTF-8.
:return: A Base64 encoded string.
"""
@sphr2k
sphr2k / .gitignore
Last active December 15, 2023 17:49
Parse Google CT log list into Pydantic schema
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
@sphr2k
sphr2k / ffjoin
Last active September 29, 2024 11:18
Join MP4 files using ffmpeg (w/ fzf multi-select)
#!/usr/bin/env python3.11
"""Join MP4 video files using ffmpeg."""
import logging
import re
import shutil
import subprocess # noqa: S404
from rich.logging import RichHandler
from rich.console import Console
import tempfile
@sphr2k
sphr2k / install-winget.ps1
Created November 6, 2023 14:03
WinGet for Windows Server 2022
$progressPreference = 'silentlyContinue'
$latestRelease = $(Invoke-RestMethod https://api.github.com/repos/microsoft/winget-cli/releases/latest).assets.browser_download_url
$latestWingetMsixBundleUri = $latestRelease | Where-Object {$_.EndsWith(".msixbundle")}
$latestWingetMsixBundle = $latestWingetMsixBundleUri.Split("/")[-1]
$latestWingetLicenseUri = $latestRelease | Where-Object {$_.EndsWith("_License1.xml")}
$latestWingetLicense = $latestWingetLicenseUri.Split("/")[-1]
Write-Information "Downloading winget to artifacts directory..."
@sphr2k
sphr2k / get-token.py
Last active July 1, 2023 17:59
OIDC Example
#! /usr/bin/env python3
from keycloak import KeycloakOpenID
from dotenv import dotenv_values
import json
from rich.console import Console
from rich.panel import Panel
from rich.syntax import Syntax
## Load config from .env
#!/usr/bin/env bash
# This script was generated by bashly 1.0.5 (https://bashly.dannyb.co)
# Modifying it manually is not recommended
if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
printf "bash version 4 or higher is required\n" >&2
exit 1
fi
version_command() {
@sphr2k
sphr2k / shell-setup.md
Last active June 17, 2023 11:52
Kubernetes & Docker Shell Setup