Skip to content

Instantly share code, notes, and snippets.

@huynhbaoan
huynhbaoan / sample
Created April 22, 2026 10:16
My post
#!/usr/bin/env python3
from __future__ import annotations
import json
import subprocess
import sys
from datetime import datetime
from urllib.request import Request, urlopen
awk '/BEGIN CERTIFICATE/{n++}{print > ("cert" n ".pem")}' /Users/P009979/Downloads/ami-trustedchain
for f in cert*.pem; do echo "===== $f ====="; openssl x509 -in "$f" -noout -subject -issuer -serial -fingerprint -sha256; done
#!/usr/bin/env python3
import argparse
import gzip
import re
from pathlib import Path
HEADER_RE = re.compile(r"###(\d{4})###")
def main():
ap = argparse.ArgumentParser(description="Merge QR frames (###0000###...) into base64, decode, and decompress.")
#!/usr/bin/env python3
"""
Generate numbered QR PNGs from an existing base64 file (single line or multi-line).
Workflow (you already have the .b64):
1) This script reads the .b64 text, strips ALL whitespace (handles Qrox+ newline/space behavior too),
2) Splits into chunks (default 2000 chars total payload INCLUDING header),
3) Prefixes each chunk with a fixed header: ###0000### (10 chars),
4) Generates QR images (Version 40, Error L) with screen→phone friendly sizing.
openssl s_client -connect ret-client-sit4.efx.extnp.national.com.au:443 \
-servername efx.internal-scs </dev/null 2>/dev/null \
| openssl x509 -noout -subject -issuer -ext subjectAltName -dates
' Returns every hyperlink in the cell (Address or SubAddress), newline-separated.
Function GetAllURLs(cell As Range) As String
Dim h As Hyperlink, out As String, one As String
If cell Is Nothing Then Exit Function
' Case 1: Rich text hyperlinks (pasted from web, like ServiceNow)
If cell.Hyperlinks.Count > 0 Then
For Each h In cell.Hyperlinks
one = h.Address
If one = "" Then one = h.SubAddress ' internal/bookmark/mailto
### === Custom Dev Additions === ###
# Ensure GPG agent runs and caches passphrase for 9 hours
export GPG_TTY=$(tty)
if command -v gpgconf >/dev/null 2>&1; then
gpgconf --launch gpg-agent
fi
# SSH helper: sj <jumpbox> <p|d> <host>
sj() {
#!/bin/bash
# Input PKCS#12 file
P12_FILE="$1"
if [[ ! -f "$P12_FILE" ]]; then
echo "❌ Usage: $0 site.p12"
exit 1
fi
#!/bin/bash
# Input PKCS#12 file
P12_FILE="$1"
if [[ ! -f "$P12_FILE" ]]; then
echo "❌ Usage: $0 site.p12"
exit 1
fi
#!/bin/bash
# === Configuration ===
SMTP_SERVER="smtp.example.com"
SMTP_PORT="25" # Use 25 for no encryption. Use 587/465 only with TLS support (see note below)
EHLO_DOMAIN="myhost.example.com"
MAIL_FROM="sender@example.com"
RCPT_TO="recipient@example.com"
SUBJECT="Netcat Test Email"
BODY="Hello,\r\n\r\nThis is a test email sent using netcat from a Bash script.\r\n\r\nRegards,\r\nNetcat Tester"