Skip to content

Instantly share code, notes, and snippets.

View kmatt's full-sized avatar
😐

Matt Keranen kmatt

😐
  • SE US
View GitHub Profile
@kmatt
kmatt / void-wsl.txt
Last active January 16, 2026 12:15
Install Void Linux on WSL2
# Based on https://gist.github.com/kmatt/71603170556ef8ffd14984af77ff10c5
# prompt ">" indicates Powershell commands
# prompt "$" are Linux shell commands
# https://docs.microsoft.com/en-us/windows/wsl/install-win10
> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# install https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
@kmatt
kmatt / pv_dump.sh
Created May 24, 2012 20:07
Monitoring dump and restore with pv
# dump
pg_dump testdb | pv -c -s $(psql -tc "SELECT pg_database_size('testdb')") -N dump | gzip > testdb.sql.gz
# restore
pv testdb_20120501.sql.gz | zcat | psql testdb
" Based on https://thegreata.pe/articles/2020/07/11/vim-syntax-highlighting-for-sql-strings-inside-python-code/
if exists('g:enable_sql_python_string') && g:enable_sql_python_string
let s:bcs = b:current_syntax
unlet b:current_syntax
syn include @SQL syntax/sql.vim
syntax region sqlPythonString
\ matchgroup=SpecialComment
\ start=~\z('''\|"""\)\_s*\(ALTER\|BEGIN\|CALL\|COMMENT\|COMMIT\|CONNECT\|CREATE\|DELETE\|DROP\|END\|EXPLAIN\|EXPORT\|GRANT\|IMPORT\|INSERT\|LOAD\|LOCK\|MERGE\|REFRESH\|RENAME\|REPLACE\|REVOKE\|ROLLBACK\|SELECT\|SET\|TRUNCATE\|UNLOAD\|UNSET\|UPDATE\|UPSERT\|WITH\)~
@kmatt
kmatt / EnableRDP.ps1
Created August 21, 2025 21:43 — forked from asheroto/EnableRDP.ps1
Enable RDP on a computer with PowerShell.
# Warning
Clear-Host
Write-Output "Run this script on the computer you want to access via RDP"
Write-Output ""
# Ask
Write-Output "Remote address can be an IP address or network with CIDR"
Write-Output "Example: 192.168.0.5 or 192.168.0.0/24"
Write-Output ""
$RemoteAddress = Read-Host "Remote Address"
@kmatt
kmatt / zeddiff.md
Created July 10, 2025 17:11
Side-by-side diff in Zed
@kmatt
kmatt / slugifile.sh
Last active July 1, 2025 19:49
Slug filenames in directory
#!/bin/bash
if [ "$#" -eq 0 ]; then
echo "Usage: $0 FILENAME | 'WILDCARD' (in single quotes)"
exit
fi
slug() {
# Replace non-alpha characters and rename file
f=$(basename "$1")
@kmatt
kmatt / fedora-wsl.txt
Last active April 9, 2025 03:48
Fedora on WSL2
# This will likely become unneeded with https://fedoraproject.org/wiki/Changes/FedoraWSL
## From https://fedoramagazine.org/wsl-fedora-33/
## prompt ">" indicates Powershell commands
# https://docs.microsoft.com/en-us/windows/wsl/install-win10
> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
@kmatt
kmatt / gistbackup.sh
Created January 10, 2025 05:30
Download all Gists using Github CLI
# Download all Gists
for i in $(gh gist list -L 1000 | cut -f1); do echo "ID: $i"; gh gist view $i > $i; done
# Rename each file with a slug of the first line / description
for f in *; do mv -v $f $(gawk 'NR==1{gsub(/[^[:alnum:]]/, "-"); gsub(/-+/, "-"); print $0 "_" FILENAME}' $f); done
#
# This shell prompt config file was created by promptline.vim
#
function __promptline_host {
local only_if_ssh="0"
if [ $only_if_ssh -eq 0 -o -n "${SSH_CLIENT}" ]; then
if [[ -n ${ZSH_VERSION-} ]]; then print %m; elif [[ -n ${FISH_VERSION-} ]]; then hostname -s; else printf "%s" \\h; fi
fi
}