Skip to content

Instantly share code, notes, and snippets.

View akunzai's full-sized avatar

Charley Wu akunzai

  • Taipei,Taiwan
  • 14:50 (UTC +08:00)
  • X @akunzai
View GitHub Profile
@akunzai
akunzai / gitlab-artifacts-cleanup.py
Last active May 2, 2023 10:40 — forked from Pingu501/gitlab-artifacts-cleanup.py
GitLab Artifacts Clean-Up
#! /usr/bin/env python3
# encoding: utf-8
"""
This is a small python script to clear up old gitlab build artifacts.
"""
import argparse
import datetime
import functools
import json
@akunzai
akunzai / build-protoaculous.sh
Created September 2, 2022 02:34
Bundles up the latest from prototypejs and scriptaculous into a single file
#!/bin/sh
# Origin: https://github.com/inderpreet99/protoaculous-bundler
# Requirements: curl,unzip,perl,npx
PROTOTYPE_VER="1.7.3.0"
SCRIPTACULOUS_VER="1.9.0"
[ -f "prototype.$PROTOTYPE_VER.js" ] || curl -so prototype.$PROTOTYPE_VER.js https://ajax.googleapis.com/ajax/libs/prototype/$PROTOTYPE_VER/prototype.js
[ -f "scriptaculous-js-$SCRIPTACULOUS_VER.zip" ] || curl -sO http://script.aculo.us/dist/scriptaculous-js-$SCRIPTACULOUS_VER.zip
unzip -q -o scriptaculous-js-$SCRIPTACULOUS_VER.zip
@akunzai
akunzai / web.config
Last active January 5, 2023 22:05
ASP.NET Web application security configurations
<!-- The following configuration should also work with Azure App Service -->
<configuration>
<system.web>
<!-- Disable X-AspNet-Version Header -->
<httpRuntime enableVersionHeader="false" />
<!-- File upload size limit (KB), avoid DoS attack -->
<httpRuntime maxRequestLength="4096" />
<!-- Disable debug & trace in Production -->
<compilation debug="false" />
<trace enabled="false" />
@akunzai
akunzai / MiddlewareDiagnosticObserver.cs
Last active May 17, 2022 13:48
Analysis ASP.NET Core middleware pipeline
using System;
using System.Collections.Generic;
using System.Reflection;
using Microsoft.AspNetCore.Http;
public class MiddlewareDiagnosticObserver : IObserver<KeyValuePair<string,object?>>
{
public void OnCompleted()
{
// Do nothing
@akunzai
akunzai / akunzai.omp.json
Last active July 24, 2023 15:15
My oh-my-posh profile
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"style": "plain",
"template": " NET {{ .Full }}",
"type": "dotnet"
@akunzai
akunzai / MicrosoftDateTimeJsonConverter.cs
Last active February 22, 2021 16:49
System.Text.Json deserialize legacy JSON date workaround
using System.Buffers;
using System.Buffers.Text;
using System.Globalization;
using System.Reflection;
using System.Text.RegularExpressions;
namespace System.Text.Json.Serialization
{
// https://github.com/dotnet/runtime/issues/30776
public class MicrosoftDateTimeJsonConverter : JsonConverterFactory
@akunzai
akunzai / JsonExtensions.cs
Last active March 22, 2021 22:42
System.Text.Json.JsonElement extensions
#if NETSTANDARD2_1
using System.Buffers;
#else
using System.IO;
#endif
using System.Linq;
namespace System.Text.Json
{
public static class JsonExtensions
@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