Skip to content

Instantly share code, notes, and snippets.

@mevanlc
mevanlc / TextYankPost-debug.vim
Created September 14, 2025 22:54
vim TextYankPost debug
function! s:LogTextYankPost() abort
let l:logfile = expand('$HOME/.vimlog')
let l:ts = strftime('%Y-%m-%d %H:%M:%S')
let l:lines = []
call add(l:lines, '==== TextYankPost { ====')
call add(l:lines, 'timestamp: ' . l:ts)
" safe gets with defaults
let l:inclusive = get(v:event, 'inclusive', 0)
@mevanlc
mevanlc / XML 1.0 ENBF Spec.md
Created September 12, 2025 02:47
XML 1.0 ENBF Spec

6 Notation

The formal grammar of XML is given in this specification using a simple Extended Backus-Naur Form (EBNF) notation. Each rule in the grammar defines one symbol, in the form

symbol ::= expression

Symbols are written with an initial capital letter if they are the start symbol of a regular language, otherwise with an initial lowercase letter. Literal strings are quoted.

@mevanlc
mevanlc / uninstall_bitdefender.sh
Created September 11, 2025 13:06
uninstall bitdefender
#!/bin/bash
# uninstall_bitdefender.sh
# Purpose: Remove Bitdefender Antivirus for Mac files as outlined in the vendor PDF.
# Works in Recovery mode (preferred when Finder removal fails) and can also run in normal macOS.
# Usage:
# 1) Recovery mode (recommended if Finder method failed):
# chmod +x uninstall_bitdefender.sh
# ./uninstall_bitdefender.sh --volume "Macintosh HD"
# 2) Normal mode (may fail due to protections, but safe to try):
# sudo ./uninstall_bitdefender.sh
@mevanlc
mevanlc / what_is.sh
Created September 6, 2025 23:03
what_is.sh that command?
#!/usr/bin/env bash
# what_is.sh - Inspect how Bash would resolve a command name.
# Modes:
# (A) Source to define the function: . what_is.sh
# Then use: what_is <cmd>
# (B) Source-and-run once: . what_is.sh <cmd>
# (C) Execute (cannot see live aliases/functions in this shell):
# ./what_is.sh <cmd>
what_is() {
@mevanlc
mevanlc / wget_ucd.sh
Created October 12, 2024 22:43
wget a version of the Unicode Standard data files (UCD)
#!/bin/bash
wget -o wget.log -r -np -nH --cut-dirs=2 -P out/ --show-progress \
--reject "index.html*" --reject-regex '\?C=.*' \
https://www.unicode.org/Public/zipped/16.0.0
@mevanlc
mevanlc / powershell-design-pattern.md
Last active September 26, 2024 19:12
PowerShell: Avoiding double-confirmations in Cmdlets that use SupportsShouldProcess

(The content of this article is licensed under "CC-BY" which allows you to share, adapt, remix, and republish this work. All that's required is attribution like this: "© CC-BY <link to where you obtained this article>"). More info at: https://creativecommons.org/licenses/by/4.0/

PowerShell: Avoiding double-confirm prompts in Cmdlets

A PowerShell Design Pattern: Handling Confirmation Prompts in Cmdlets


When writing custom PowerShell Cmdlets, a common scenario arises when your Cmdlet has the SupportsShouldProcess = $true attribute set to leverage PowerShell’s -Confirm infrastructure. This attribute enables built-in confirmation prompts that ask the user to verify potentially impactful actions before proceeding.

git ls-files -z | gxargs -0 dirname | grep -Fxv . | grep -v / | sort -u | gxargs gdu -h --max-depth 0 | sort -h
@mevanlc
mevanlc / gist:948d5277e85575def5bd1800a5603de6
Last active January 1, 2024 11:17
EBNF for broken `::` comments in dosbatch (SSCCE)
<file> ::= ( <statement> | <comment> | <block> )+
<statement> ::= <anytext>+ "\n"+
<comment> ::= "::" <anytext>+ "\n"+
<block> ::= "(" "\n"+ ( <comment> <statement> | <statement> | <block> )+ ")" "\n"+
<anytext> ::= #"[a-z0-9 ]"
<blockerror> ::= "{" "\n"+ ( <comment> <statement> | <statement> | <block> )+ "}" "\n"+

see https://mdkrajnak.github.io/ebnftest/

@mevanlc
mevanlc / global_local_inner_outer.sh
Created December 20, 2023 09:48
Testing the usage of global and local variables inside and outside functions in a number of combinations
#!/bin/sh
decl_outside="assigned outside a function"
echo "printing from outside: \$decl_outside: value before assignment INSIDE a function: [$decl_outside]"
INSIDE1() {
echo "printing from INSIDE1(): \$decl_outside: value before assignment by INSIDE1(): [$decl_outside]"
decl_outside="assigned by INSIDE1()"
echo "printing from INSIDE1(): \$decl_outside: value after assignment by INSIDE1(): [$decl_outside]"
@mevanlc
mevanlc / install_z_sh.sh
Last active February 24, 2024 11:23
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>