Skip to content

Instantly share code, notes, and snippets.

View akunzai's full-sized avatar

Charley Wu akunzai

  • Taipei,Taiwan
  • 11:25 (UTC +08:00)
  • X @akunzai
View GitHub Profile
@akunzai
akunzai / DistributedCacheExtensions.cs
Last active August 20, 2020 01:10
GetOrCreateAync for IDistributedCache
using System;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;
namespace Microsoft.Extensions.Caching.Distributed
{
public static class DistributedCacheExtensions
{
public static async Task<T> GetOrCreateAsync<T>(this IDistributedCache cache,
@akunzai
akunzai / Get-InstalledProgram.ps1
Last active July 17, 2021 17:47
List Installed Programs on Windows
<#
.SYNOPSIS
List Installed Programs on Windows
.EXAMPLE
. ./Get-InstalledProgram.ps1
Get-InstalledProgram | Export-Csv ~/Desktop/InstalledApps.csv -Encoding UTF8 -NoTypeInformation
.EXAMPLE
. ./Get-InstalledProgram.ps1
Get-InstalledProgram -Detail | Format-List
#>
@akunzai
akunzai / README.md
Last active July 15, 2024 15:10
Uninstall pkg package from macOS

Run this script from GitHub Gist directly

sh <(curl -Ls https://gist.github.com/akunzai/dd7c40ca4054db98b97208f0f3907400/raw/uninstall-pkg.sh)

Passing parameters to bash when executing the script fetched by curl

curl -Ls https://gist.github.com/akunzai/dd7c40ca4054db98b97208f0f3907400/raw/uninstall-pkg.sh | sh -s com.xamarin.mono-MDK.pkg
@akunzai
akunzai / Optimize-AssemblyBinding.ps1
Last active October 29, 2022 02:34
Optimize assembly binding redirection in web.config or app.config
# https://learn.microsoft.com/zh-tw/dotnet/framework/configure-apps/redirect-assembly-versions
<#
.Synopsis
Optimize assembly binding redirection in web.config or app.config
.EXAMPLE
. .\Optimize-AssemblyBinding.ps1; sort-binding -path .\web.config
. .\Optimize-AssemblyBinding.ps1; sort-binding -path .\web.config -whatIf
#>
function Optimize-AssemblyBinding(){
Param (
@akunzai
akunzai / .zshenv
Last active September 20, 2025 19:46
My ZSH profile
# https://www.cyberciti.biz/faq/apple-mac-osx-terminal-color-ls-output-option/
export CLICOLOR=1
export EDITOR=vi
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# Avoid the `._*` files in tar
# https://superuser.com/a/61188
export COPYFILE_DISABLE=1
@akunzai
akunzai / settings.json
Last active September 9, 2024 17:38
My Windows Terminal settings
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command":
{
"action": "newTab"
},
@akunzai
akunzai / log4j2.xml
Last active May 14, 2022 07:18
My log4j2.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!--
https://logging.apache.org/log4j/2.x/manual/async.html#AllAsync
Don't forget to set system property
-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
to make all loggers asynchronous.
Levels: OFF,FATAL,ERROR,WARN,INFO,DEBUG,TRACE,ALL
-->
@akunzai
akunzai / logback.xml
Last active June 17, 2025 14:09
My logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="5 seconds"
packagingData="true"
debug="false">
<property name="LOG_PATH" value="${LOG_PATH:-${catalina.base:-/tmp}/logs}" />
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%date %highlight(%-5level) [%logger] - %msg%n}"/>
<property name="FILE_LOG_PATTERN" value="${FILE_LOG_PATTERN:-%date %-5level [%logger] - %msg%n}"/>
<property name="SENDGRID_API_KEY" value="${SENDGRID_API_KEY:-}" />
<property name="LOG_MAIL_FROM" value="${LOG_MAIL_FROM:-}" />
<property name="LOG_MAIL_TO" value="${LOG_MAIL_TO:-}" />
@akunzai
akunzai / sortxml.groovy
Last active March 12, 2019 08:46
XML properties sorter
if (args.length == 0) {
println("Usage: groovy sortxml.groovy messages.xml [key]")
println("read from STDIN: groovy sortxml.groovy - [key]")
System.exit(0)
}
def input = args[0] == '-'
? System.in
: new File(args[0]).newInputStream()
def key = args.size() > 1 ? args[1] : 'key'
@akunzai
akunzai / prop2xml.groovy
Last active March 12, 2019 08:46
Java Properties Converter
if (args.length == 0) {
println("Usage: groovy prop2xml.groovy messages.(properties|xml) [format]")
println("read from STDIN: groovy prop2xml.groovy - [format]")
System.exit(0)
}
def input = args[0] == '-'
? System.in
: new File(args[0]).newInputStream()
def format = args.size() > 1