Skip to content

Instantly share code, notes, and snippets.

# GZIP's headers can only store sizes up to 4GB, so the returned size will be the actual decompressed size modulo 4,294,967,296
# Even Linux's "gzip -l filename.gz" has this limitation.
# The workaround is to decompress the entire file and count the bytes.
def gzip_get_uncompressed_file_size(filename):
import struct
with open(filename, 'rb') as fo:
fo.seek(-4, 2)
r = fo.read()
fo.close()
return struct.unpack('<I', r)[0]
@mike-clark-8192
mike-clark-8192 / rebuild_gvimext.bat
Last active May 16, 2024 01:22
Windows gvim / vim: recompile and reload GvimExt*.dll
@echo off
setlocal
REM === Handy for tweaking the keyboard accelerator (underlined letter) for invoking GVim from the shell right click context menu.
REM === Since Microsoft built the "Restore Previous Version" (shadow volume copy) right-click entry into Windows,
REM === 'v' no longer launches GVIM in a single keystroke. You can easily edit the underlined char in gvimext.cpp, though.
REM === Personally I use 'z': mii.dwTypeData = W(_("Edit with Vim (&z)"));
REM === "Configuration" { ===
set "vim_src_dir=\dev\gh\vim\src"
@mike-clark-8192
mike-clark-8192 / index.html
Last active September 14, 2023 15:37
MediaRecorder Example - Record and Save Audio
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>MediaRecorder Example - Record and Save Audio</title>
<link rel="icon" href="data:,">
</head>
<body>
@mike-clark-8192
mike-clark-8192 / WSCloseCodeToDesc.js
Created January 4, 2024 12:06
WebSocket CloseEvent code to description mapping
const WSCloseCodeToDesc = {
"0-999": {"short":"Not used.","long":"Not used."},
"1000": {"short":"Normal Closure","long":"The connection successfully completed the purpose for which it was created."},
"1001": {"short":"Going Away","long":"The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection."},
"1002": {"short":"Protocol error","long":"The endpoint is terminating the connection due to a protocol error."},
"1003": {"short":"Unsupported Data","long":"The connection is being terminated because the endpoint received data of a type it cannot accept. (For example, a text-only endpoint received binary data.)"},
"1004": {"short":"Reserved","long":"Reserved. A meaning might be defined in the future."},
"1005": {"short":"No Status Rcvd","long":"Reserved. Indicates that no status code was provided even though one was expected."},
"1006": {"short":"Abnormal Closure","long":"Reserved. Indicates that
@mike-clark-8192
mike-clark-8192 / kp_pwg_classic9.txt
Created January 28, 2024 01:05
KeepPass password generator pattern - classic 9 characters
sludS{5}
@mike-clark-8192
mike-clark-8192 / OutlookFadeText.vbs
Created February 12, 2024 02:21
MS Word / Outlook fade text VBA macro
Sub FadeSelectedTextColorInEmail()
Dim objMail As Outlook.MailItem
Dim objDoc As Word.Document
Dim objWordApp As Word.Application
Dim objSelection As Word.Selection
Dim fadeFactor As Single
If TypeName(Application.ActiveInspector.CurrentItem) = "MailItem" Then
Set objMail = Application.ActiveInspector.CurrentItem
If Not objMail.Sent Then
@mike-clark-8192
mike-clark-8192 / install_z_sh.sh
Created February 24, 2024 11:23 — forked from mevanlc/install_z_sh.sh
Helper script to install z.sh (jump around) - https://github.com/rupa/z
#!/bin/sh
SOURCE_URL="https://raw.githubusercontent.com/rupa/z/master/z.sh"
OUTPUT_LOC="$HOME/.z.sh"
usage_doc="Usage: $0 [-h] [-u url] [-o file]
-h this help
-u <url> download from <url>
default: $SOURCE_URL
-o <file> download to <file>
@mike-clark-8192
mike-clark-8192 / Program.cs
Last active March 27, 2024 12:34
İ, ı, I, i: an [overly] exhaustive exploration of sorting and comparing in .NET
using Combinatorics.Collections;
using System.Globalization;
namespace StringComparerTest
{
using ComparerInfo = KeyValuePair<string, StringComparer>;
using StringPermutations = IEnumerable<IEnumerable<string>>;
internal class Program
{
@mike-clark-8192
mike-clark-8192 / reload-profile.ps1
Created May 16, 2024 05:40
PowerShell "reload $profile" "alias" via PSReadLine
function _PSReadLineRewriteCommand {
param($key)
$commandLine = ''
$cursorIndex = 0
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$commandLine, [ref]$cursorIndex)
if ($commandLine -eq 'prof' -or $commandLine -eq 'profile') {
[Microsoft.PowerShell.PSConsoleReadLine]::Delete(0, $commandLine.Length)
[Microsoft.PowerShell.PSConsoleReadLine]::Insert('. $profile')
}
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
Windows Registry Editor Version 5.00
; Created by Sergey Tkachenko
; Tutorial: https://winaero.com/how-to-remove-open-in-windows-terminal-context-menu-in-windows-11/
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked]
"{9F156763-7844-4DC4-B2B1-901F640F5155}"=-
"{02DB545A-3E20-46DE-83A5-1329B1E88B6B}"=-