Skip to content

Instantly share code, notes, and snippets.

View Satal's full-sized avatar

Sam Jenkins Satal

View GitHub Profile
@Satal
Satal / cleanup.sh
Last active February 6, 2026 06:23
Ubuntu Cleanup Script
#Requires -RunAsAdministrator
<#
.SYNOPSIS
Compresses/shrinks a WSL2 virtual disk (VHDX) to reclaim unused space.
.DESCRIPTION
Cleans up inside WSL, trims free space, shuts down WSL, then compacts
the VHDX file using either Optimize-VHD or diskpart as a fallback.
.PARAMETER SkipCleanup
Skip the internal WSL cleanup step (apt clean, temp files, Docker prune).
.PARAMETER Distro
@Satal
Satal / gist:4912d5aa00638d4c31e38f7d088fc595
Created March 26, 2025 10:10
This script allows you to easily resize any window on your screen using a AHK v2 keyboard shortcut.
^+w:: { ; Ctrl + Shift + W
MsgBox("Hover your mouse over the window you want to resize, then press OK.")
; Get the window under the mouse
MouseGetPos(, , &winID)
WinGetPos(&x, &y, &width, &height, "ahk_id " winID)
MsgBox("Current Size:`nWidth: " width "`nHeight: " height)
; Get new width
@Satal
Satal / dockerfile
Created February 18, 2024 11:18
Agency Swarm Dockerfile
# Use the latest Ubuntu image as the base
FROM ubuntu:latest
# Update apt package list and install python3 and pip3
RUN apt-get update && \
apt-get install -y python3 python3-pip git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Set the working directory in the container
@Satal
Satal / .bashrc
Last active September 19, 2026 12:21
A function that will make a directory and then change directory into it
# This goes at the end of .bashrc
# mkcd <dir> — make a directory (and any parents) and cd into it
mkcd() {
if [ $# -ne 1 ]; then
echo "Usage: mkcd <directory>" >&2
return 1
fi
mkdir -p -- "$1" && cd -- "$1"
}
@Satal
Satal / reboot-notify.service
Last active June 12, 2026 19:05
An update script for ubuntu
[Unit]
Description=Notify via Pushover when a reboot is required
Documentation=https://gist.github.com/Satal/f2a9ded88005fe8f573ea2725db0970b
[Service]
Type=oneshot
User=satal
ExecStart=/usr/local/bin/reboot-notify.sh
SyslogIdentifier=reboot-notify
# Install in C:\users\[user]\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
# You may need to run `Set-ExecutionPolicy RemoteSigned` if you get an error about running
# wingetlist requires the Microsoft.WinGet.Client module: Install-Module Microsoft.WinGet.Client -Scope CurrentUser
# -Office also updates Microsoft Office (Click-to-Run) via OfficeC2RClient.exe (no module needed).
# -Store also updates Microsoft Store apps via the MDM WMI bridge (no module needed).
# -WindowsUpdate also checks/installs Windows updates via the PSWindowsUpdate module
# (auto-installed on first use; REQUIRES an elevated / Administrator PowerShell session).
# -All = winget + Office + Store + Windows updates in one go.
function Update-OfficeClickToRun {
@Satal
Satal / Ansible Winrm Variables
Created December 19, 2020 14:01
The variables that need to be set for Ansible to use Winrm
---
ansible_port: 5986
ansible_connection: winrm
ansible_winrm_server_cert_validation: ignore
@Satal
Satal / Usage.cs
Last active August 27, 2024 07:28
XsdValidator
public void MultipleSchemas()
{
var validator = new XsdValidator();
validator.AddSchema(@"SchemaDoc1.xsd");
validator.AddSchema(@"SchemaDoc2.xsd");
var isValid = validator.IsValid(@"ValidXmlDoc1.xml");
}
@Satal
Satal / ShuffleStringExcludeOriginal
Last active December 22, 2015 08:39
Shuffle the characters in a string but excluding the original string that was passed in. The method checks that we have passed in a string of more than two characters as if we have less than two characters it is not possible to return anything but the original string.
public static string ShuffleStringExcludeOriginal(string stringToShuffle)
{
    string shuffled;
 
    if (String.IsNullOrEmpty(stringToShuffle))
    {
        throw new ArgumentNullException("stringToShuffle",
                                        "The stringToShuffle variable must not be null or empty");
    }