Skip to content

Instantly share code, notes, and snippets.

@atifaziz
atifaziz / Unprotect-ProtectedData.ps1
Created March 31, 2017 06:25
Decrypting DPAPI-protected Base64 data from PowerShell
Add-Type -AssemblyName System.Security;
[Text.Encoding]::ASCII.GetString([Security.Cryptography.ProtectedData]::Unprotect([Convert]::FromBase64String((type -raw (Join-Path $env:USERPROFILE foobar))), $null, 'CurrentUser'))
// https://groups.google.com/forum/#!topic/jayrock/6sDhtNuzc1k
using System;
using System.Collections;
using System.Linq;
using System.Net;
using Jayrock.Json.Conversion;
static class Program
{
# MIT License
#
# Copyright (c) Microsoft Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@atifaziz
atifaziz / globlin.py
Last active June 12, 2026 11:03
Python script to filter paths on standard input by pattern
#!/usr/bin/env python3
# MIT License
#
# Copyright (c) Microsoft Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@atifaziz
atifaziz / main.py
Last active April 28, 2026 16:42
Demonstration of controlled & concurrent processing of JSON messages while reading synchronously from a file queue
# /// script
# requires-python = ">=3.12"
# dependencies = []
# ///
import asyncio
from functools import partial
import json
import os
import sys
@atifaziz
atifaziz / docoptapp.cs
Last active April 23, 2026 14:35
File-based C# application using docopt.net for CLI parsing
#:package docopt.net@0.8.3
#nullable enable
using DocoptNet;
static int Main(ProgramArguments args)
{
Console.WriteLine("Parsed arguments:");
foreach (var (name, value) in args)
Console.WriteLine($" {name} = {value}");
@atifaziz
atifaziz / txtfeol.sh
Created December 18, 2025 13:13
Bash script to lint Git-tracked text files for final newline character
#!/usr/bin/env bash
#? Lint Git-tracked text files for final newline character
set -eo pipefail
declare -i errcnt=0
declare -i total=0
declare -i done=0
while IFS= read -r file; do
@atifaziz
atifaziz / coci.sh
Last active December 12, 2025 16:19
Bash script to ask Copilot to suggest Git commit messages based on staged changes
#!/usr/bin/env bash
set -eo pipefail
prompt=$(cat <<'EOF'
Suggest 3 one-liner & brief Git commit messages, each formatted EXACTLY as:
MESSAGE:Text of the commit message
Examples:
@atifaziz
atifaziz / linqish.py
Last active November 26, 2025 08:33
LINQ-like pipeline module for Python (for illustration only)
# Copyright (c) 2025 Atif Aziz
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the “Software”), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
@atifaziz
atifaziz / Makefile
Created September 9, 2025 08:09
make excuse
.PHONY: excuse
EXCUSES = \
"It works on my machine." \
"That's a hardware problem." \
"Must be a caching issue." \
"Have you tried turning it off and on again?" \
"It's not a bug, it’s a feature." \
"Works fine in production." \
"The tests are flaky, ignore the red." \