Skip to content

Instantly share code, notes, and snippets.

View paddy74's full-sized avatar

Patrick Young paddy74

View GitHub Profile
@paddy74
paddy74 / export_gemini_chat.js
Created November 23, 2026 19:47
Gemini Chat Exporter
(async function exportGeminiChat() {
const sleep = ms => new Promise(r => setTimeout(r, ms));
const NONCE = Math.random().toString(36).slice(2, 7) + Date.now().toString(36).slice(-4);
// Helper: Fast SHA-256 for secure contexts (Gemini is always HTTPS)
async function sha256(text) {
try {
const msgBuffer = new TextEncoder().encode(text);
const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
return Array.from(new Uint8Array(hashBuffer)).map(b => b.toString(16).padStart(2, '0')).join('');
@paddy74
paddy74 / Sync-AcronymTables.ps1
Created November 23, 2026 19:45
Sync-AcronymTables.ps1
<#
Core Functional Requirements
1. **Structure & Invocation:**
- The `.ps1` script defines a function (`Sync-AcronymTable`) with a concise comment-based help docstring.
- Executing the `.ps1` file directly invokes the function with all passed arguments.
- Dot-sourcing the `.ps1` file (`. .\Sync-AcronymTables.ps1`) loads the function into the session without executing it.
- Must be compatible with both Windows PowerShell 5.1 and PowerShell 7+.
- Must support standard PowerShell `-WhatIf` (`SupportsShouldProcess`).
2. **Input Handling & Extraction:**
- Accepts one or more Markdown (`.md`, `.markdown`) or YAML (`.yaml`, `.yml`) files.
@paddy74
paddy74 / dry-update.sh
Created June 30, 2025 18:17
Dry dependency update with pnpm
#!/bin/bash
# 1. Ensure dependencies are installed and lockfile is consistent before dry run
# 2. Simulate dependency updates
# 3. Check for known security vulnerabilities
# 4. Simulate deduplication
set -euo pipefail
pnpm install --frozen-lockfile
@paddy74
paddy74 / find_netmask.ps1
Created April 1, 2025 18:03
find_netmask.ps1
function Convert-PrefixToNetmask {
param (
[Parameter(Mandatory = $true)]
[int]$PrefixLength
)
# Create a binary mask string with 1's for the prefix and pad with 0's
$binaryMask = ("1" * $PrefixLength).PadRight(32, "0")
$octets = @()
@paddy74
paddy74 / parse_yaml.md
Last active November 28, 2024 18:14
parse_yaml.sh

It understands files such as:

## global definitions
global:
  debug: yes
  verbose: no
  debugging:
    detailed: no
 header: "debugging started"
@paddy74
paddy74 / urlencode.sh
Last active October 22, 2024 18:37 — forked from sergeiwaigant/url_encode_string_with_linux_tools.md
Simply URL encode string with Linux/Bash/Shell tools
# Reference https://stackoverflow.com/a/34407620/13287790
# Requires `jq`
# $ echo -n "encode this" | jq -sRj @uri
# encode%20this
# MY_VAR=$(urlencode "encode this")
echo -n "${1}" | jq -sRj @uri
@paddy74
paddy74 / clear-aws-env.ps1
Created October 2, 2024 12:46
Clear all AWS related environment variables
# Clear all AWS related environment variables
function awskill {
Remove-Item -Path Env:AWS_DEFAULT_PROFILE -ErrorAction SilentlyContinue
Remove-Item -Path Env:AWS_ACCESS_KEY_ID -ErrorAction SilentlyContinue
Remove-Item -Path Env:AWS_SECRET_ACCESS_KEY -ErrorAction SilentlyContinue
Remove-Item -Path Env:AWS_SECRET_KEY -ErrorAction SilentlyContinue
Remove-Item -Path Env:AWS_SECURITY_TOKEN -ErrorAction SilentlyContinue
Remove-Item -Path Env:AWS_SESSION_TOKEN -ErrorAction SilentlyContinue
}
@paddy74
paddy74 / pip-upgrade.ps1
Last active April 17, 2026 16:31
Upgrade all Python packages in the active environment
# https://github.com/pypa/pip/issues/4551
python -m pip freeze | ForEach-Object{$_.split('==')[0]} | ForEach-Object{python -m pip install --upgrade $_}
@paddy74
paddy74 / git-drop-gone.ps1
Created September 4, 2024 14:47
Remove all local branches that are not on remote
# from https://stackoverflow.com/a/33548037/7706917
#
# Explanation:
# ---
# Switch to the main branch
# $> git checkout main
# Prune remote branches
# $> git remote update origin --prune # Prune remote branches
# Get a verbose output of all branches (git reference)
# $> git branch -vv
@paddy74
paddy74 / haos-privacy-policy.txt
Created March 2, 2024 21:16
Required privacy policy link for HAOS + Google Assist integration
This application is intended for the private use of its developer. Any unauthorized users which connect to this service should have no expectation of privacy or protection of their data.