Skip to content

Instantly share code, notes, and snippets.

View akunzai's full-sized avatar

Charley Wu akunzai

  • Taipei,Taiwan
  • 15:17 (UTC +08:00)
  • X @akunzai
View GitHub Profile
@akunzai
akunzai / Test-TlsCiphers.ps1
Last active May 19, 2025 18:48
Uses OpenSSL to detect remote server support cipher suites
#Requires -Version 5.1
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[string]$RemoteAddress,
[Parameter(Mandatory=$false)]
[string]$OpenSslPath = 'openssl',
@akunzai
akunzai / README.md
Last active May 25, 2025 17:32
readme.com exporter

ReadMe.com 文件匯出工具

這是一個 Bash 腳本,用於從 ReadMe.com 匯出指定專案版本的文件內容,並將其轉換為本地儲存的 Markdown 檔案及圖片

  • 依分類匯出所有文件。
  • 下載文件中引用的圖片(包含 ReadMe 特有的 [block:image] 格式及標準 Markdown 圖片語法)。
  • 將圖片儲存在各分類對應的 images 子目錄下。
  • 自動更新 Markdown 文件中的圖片連結為相對路徑。
  • 支援透過 .env 檔案或環境變數設定 API 金鑰和專案版本。
  • 可選擇是否匯出隱藏文件。
@akunzai
akunzai / cleanup-podman-images.sh
Created April 1, 2025 07:34
Clean up old Podman images while keeping the newest version of each image
#!/bin/sh
# Show usage information
show_help() {
cat << EOF
Usage: $(basename "$0") [OPTIONS] [IMAGE_PATTERN]
Clean up old Podman images while keeping the newest version of each image.
Options:
--dryrun Show what would be removed without actually removing anything
@akunzai
akunzai / 10-nginx-uid-or-gid.sh
Created September 9, 2024 16:04
Nginx container modify UID or GID
#!/bin/sh
USERID=$(id -u)
if [ "${USERID}" = "0" ] && [ -n "${NGINX_UID}" ] && [ "${NGINX_UID}" != "0" ]; then
usermod -u "${NGINX_UID}" nginx
if [ -n "${NGINX_GID}" ] && [ "${NGINX_GID}" != "0" ]; then
groupmod -g "${NGINX_GID}" nginx
fi
# Ensure the nginx user is able to write to container logs
@akunzai
akunzai / prometheus_tagets.py
Created July 19, 2024 09:53
List Prometheus targets status
#!/usr/bin/env python3
import json
import sys
import urllib.request
from urllib.error import URLError
import textwrap
def fetch_targets(prometheus_url):
try:
with urllib.request.urlopen(f"{prometheus_url}/api/v1/targets") as response:
@akunzai
akunzai / ForwardedHeadersMiddleware.cs
Last active January 10, 2024 10:37
Handle `X-Forwarded-*` headers for OWIN
public class ForwardedHeadersMiddleware : OwinMiddleware
{
public ForwardedHeadersMiddleware(OwinMiddleware next) : base(next)
{
}
public override Task Invoke(IOwinContext context)
{
if (string.Equals(context.Request.Headers["X-Forwarded-Proto"], "https",
StringComparison.OrdinalIgnoreCase))
# https://github.com/colinmollenhour/docker-openmage/blob/main/8.2/apache/Dockerfile
# https://github.com/OpenMage/magento-lts/tree/main/dev/openmage
ARG PHP_VERSION=8.2
ARG OPENMAGE_VERSION=20.3.0
FROM alpine as unzipper
ARG OPENMAGE_VERSION
RUN set -eux; \
apk add curl unzip; \
mkdir -p /usr/src/openmage; \
@akunzai
akunzai / ListOfEnumStringConverter.cs
Last active November 10, 2023 14:59
JsonConverter for list of enum string
using System.Reflection;
namespace System.Text.Json.Serialization;
/// https://learn.microsoft.com/dotnet/standard/serialization/system-text-json/converters-how-to
public class ListOfEnumStringConverter : JsonConverterFactory
{
public override bool CanConvert(Type typeToConvert)
{
if (!typeToConvert.IsGenericType)
@akunzai
akunzai / README.md
Last active September 18, 2024 19:25
a mini HTTP server to inspect requests

Run this script from GitHub Gist directly

npx https://gist.github.com/akunzai/e245cb079d90bf102b8a7bf60ef07536