Skip to content

Instantly share code, notes, and snippets.

View michaelsanford's full-sized avatar

Michael Sanford michaelsanford

View GitHub Profile
@michaelsanford
michaelsanford / ask.md
Last active July 12, 2022 19:25
StackOverflow Review Comments

Hi! Welcome to Stack Overflow! Please see the [Tour], [ask], and how to create a [mcve]. You should show some code of what you've tried.

@michaelsanford
michaelsanford / prune-teams-cache.ps1
Last active July 12, 2022 19:17
Prune Microsoft Teams Caches
$teams_active = (Get-Process -Name Teams -ErrorAction SilentlyContinue).length -gt 0
if ($teams_active) {
Write-Host "Quitting Teams"
Stop-Process -Name Teams | Wait-Process
}
Set-Location "${env:APPDATA}\Microsoft\Teams"
$caches = @("Application Cache\Cache","blob_storage","Cache","databases","GPUcache","IndexedDB","Local Storage","tmp","Cache","backgrounds")
@michaelsanford
michaelsanford / batch-delete-github-workflow-runs.ps1
Created October 13, 2021 04:16
Batch Delete GitHub Workflow Runs
$user = "your user/org"
$repo = "repo"
(gh api repos/$user/$repo/actions/runs | ConvertFrom-Json).workflow_runs |
%{ $_.id } |
%{ gh api repos/$user/$repo/actions/runs/$_ -X DELETE }
@michaelsanford
michaelsanford / show-dead-path-folders.ps1
Created September 23, 2021 21:18
Show Directories in $Env:Path that no longer exist
$Env:Path -Split ";" | ForEach-Object { if ($false -eq (Test-Path $_)) { Write-Output $_} }
@michaelsanford
michaelsanford / Facebook.js
Created August 15, 2021 04:28
Clean up your online life
// https://www.facebook.com/pages/?category=liked&ref=bookmarks
// Scroll down to load all the items
[...document.querySelectorAll("[aria-label=Liked]")].forEach(e => e.click())
@michaelsanford
michaelsanford / inspect-request.java
Created February 26, 2020 18:17
Log a request payload
@POST
@Path("/")
public Object something(String json)
{
Logger logger = Logger.getLogger(this.getClass().getName());
logger.log(Level.INFO, json);
return Response.ok().build();
}
@michaelsanford
michaelsanford / periodic-docker-maintenance.ps1
Created December 11, 2019 14:18
PowerShell script to execute Docker maintenance, optionally non-interactively
<#
.Synopsis
Runs periodic maintenance on Docker for Windows.
It must be run as an Administrator!
.Description
Intended to be run interactively or as a periodoc service, this will execute configurable docker prune
within the VM and then stop and compact the virtual machine hard disk before restarting Docker.
When run as a service, logs are sent to the Windows Event Log. Otherwise, progress is logged to the console.
.Parameter VHDX
Required. The complete path to your DockerDesktop virtual hard disk file, i.e., 'F:\Docker\DockerDesktop.vhdx'
@michaelsanford
michaelsanford / bash_colours.sh
Last active November 21, 2019 23:38
Bash colour code quick reference
#!/usr/bin/env bash
####
# Invoke with
# $ bash_colours [limit]
###
if hash tput >/dev/null 2>&1; then
bound=${1:-255}
for (( i = 0; i < bound; i++ )); do
Get-ChildItem -File *.png | Foreach { cwebp.exe -short -noalpha -lossless $_.Name -o ($_.BaseName + ".webp") }
@michaelsanford
michaelsanford / pizza.js
Last active January 27, 2017 16:12
Will there be pizza? 👍🏽🍕
(() => {
"use strict";
/**
* Attendees to JS-Montreal often don't know if there will be pizza or not. This aims to make it more clear.
* Traditionally, pizza is available if the meetup starts at 6 PM, but not if it starts at 7.
*
* @see https://www.meetup.com/js-montreal/
*/