Skip to content

Instantly share code, notes, and snippets.

View akunzai's full-sized avatar

Charley Wu akunzai

  • Taipei,Taiwan
  • 18:07 (UTC +08:00)
  • X @akunzai
View GitHub Profile
@se35710
se35710 / find-java.ps1
Last active August 2, 2025 05:58
PowerShell script to locate Java on Windows, optionally sets JAVA_HOME and JRE_HOME.
<#
.SYNOPSIS
Locates Java versions and optionally sets JAVA_HOME and JRE_HOME.
.DESCRIPTION
The Find-Java function uses PATH, JAVA_HOME, JRE_HOME and Windows Registry to retrieve installed Java versions.
If run with no options, the first Java found is printed on the console.
.PARAMETER Vendor
Selects Java vendor, currently supports Oracle, OpenJDK and IBM. Defaults to Any.
.PARAMETER Architecture
What processor architecture to match. Valid options are 32, 64, Match and All. Match detects what integer size is used for the PowerShell process, and matches the architecture. If Wow64 is available, 64 bit versions of Java are selected first.
@mosquito
mosquito / README.md
Last active October 14, 2025 19:22
Add doker-compose as a systemd unit

Docker compose as a systemd unit

Create file /etc/systemd/system/[email protected]. SystemD calling binaries using an absolute path. In my case is prefixed by /usr/local/bin, you should use paths specific for your environment.

[Unit]
Description=%i service with docker compose
PartOf=docker.service
After=docker.service
@davidfowl
davidfowl / HostedService.cs
Created July 17, 2017 09:31
A base class that allows writing a long running background task in ASP.NET Core 2.0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
namespace WebApplication24
{
public abstract class HostedService : IHostedService
@StevenACoffman
StevenACoffman / Docker Best Practices.md
Last active July 16, 2025 13:09
Docker Best Practices

Mistakes to Avoid: Docker Antipatterns

Whichever route you take to implementing containers, you’ll want to steer clear of common pitfalls that can undermine the efficiency of your Docker stack.

Don’t run too many processes inside a single container

The beauty of containers—and an advantage of containers over virtual machines—is that it is easy to make multiple containers interact with one another in order to compose a complete application. There is no need to run a full application inside a single container. Instead, break your application down as much as possible into discrete services, and distribute services across multiple containers. This maximizes flexibility and reliability.

Don’t install operating systems inside Docker containers

It is possible to install a complete Linux operating system inside a container. In most cases, however, this is not necessary. If your goal is to host just a single application or part of an application in the container, you need to install only the essential

@pabloab
pabloab / landscape-sysinfo-alternative.sh
Last active October 21, 2023 18:36
[landscape-sysinfo alternative ], more cross-linux
#!/bin/bash
# Simple motd script for any systemd Linux (tested on Debian)
# Inspiration: https://superuser.com/questions/919962/landscape-sysinfo-for-centos
# Inspiration 2: https://github.com/thusoy/headsup/blob/master/headsup.py
os-name=$()
os-kernel=$()
date-today=$()
system-load=$()
processes=$(cat /proc/loadavg | cut -d"/" -f2| cut -d" " -f1)
@joeytwiddle
joeytwiddle / async-await-forEach-alternatives.md
Last active September 12, 2025 19:54
Do not use forEach with async-await

Do not use forEach with async-await

TLDR: Use for...of instead of forEach() in asynchronous code.

For legacy browsers, use for(...;...;...) or [].reduce()

To execute the promises in parallel, use Promise.all([].map(...))

The problem

@doggy8088
doggy8088 / settings.json
Last active July 16, 2025 00:42
Will 保哥的 VSCode 使用者設定檔
{
"explorer.openEditors.visible": 0,
"workbench.colorTheme": "Default Light+",
"workbench.iconTheme": "vscode-simpler-icons",
"workbench.sideBar.location": "right",
// 需下載安裝 Fira Code 字型 (安裝 OTF 格式)
// https://github.com/tonsky/FiraCode/releases
// 需下載客製化過的 Microsoft YaHei Mono 字型
@akunzai
akunzai / Microsoft.PowerShell_profile.ps1
Last active September 7, 2024 12:20
My PowerShell profile
# https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_profiles
# PowerShell < 6 on Windows: $Home\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
# PowerShell >= 6 on Windows: $Home\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
# PowerShell on Linux/macOS: ~/.config/powershell/Microsoft.PowerShell_profile.ps1
# https://learn.microsoft.com/dotnet/core/tools/dotnet-environment-variables#dotnet_cli_ui_language
$env:DOTNET_CLI_UI_LANGUAGE = 'en-us'
# https://github.com/PowerShell/PSReadLine
if (Get-Command 'Set-PSReadlineKeyHandler' -ErrorAction SilentlyContinue) {
@natemcmaster
natemcmaster / README.md
Last active April 2, 2024 18:27
runtimeconfig.json schema

This defines the schema for .NET Core's runtimeconfig.json file.

Usage in an editor

Using Visual Studio, you can get auto-completion if you import the schema in your .JSON file like this:

{
  "$schema": "https://gist.githubusercontent.com/natemcmaster/0bdee16450f8ec1823f2c11af880ceeb/raw/runtimeconfig.template.schema.json"
}
@popstas
popstas / docker-logs-localtime
Last active November 14, 2024 06:03
docker-logs-localtime - Replace all UTC dates in docker logs output to local dates in pipe
#!/usr/bin/env node
// replace all UTC dates to local dates in pipe
// usage: docker logs -t container_name | docker-logs-localtime
// install:
// curl https://gist.githubusercontent.com/popstas/ffcf282492fd78389d1df2ab7f31052a/raw/505cdf97c6a1edbb10c3b2b64e1836e0627b87a0/docker-logs-localtime > /usr/local/bin/docker-logs-localtime && chmod +x /usr/local/bin/docker-logs-localtime
// alternative: https://github.com/HuangYingNing/docker-logs-localtime
const pad = d => (d > 9 ? d : '0' + d);