Skip to content

Instantly share code, notes, and snippets.

View githubhjs's full-sized avatar
🎯
Focusing

Chih-Hsueh "Josh" Huang githubhjs

🎯
Focusing
View GitHub Profile
@githubhjs
githubhjs / sys-snapshot.sh
Created September 17, 2025 09:12
60 秒系統快照腳本(拎了就跑), 把下列存成 sys-snapshot.sh 並給執行權限:
#!/usr/bin/env bash
set -euo pipefail
OUT="/tmp/sys_snapshot_$(hostname)_$(date +%F_%H%M%S).log"
{
echo "===== META ====="; date; hostnamectl || true; echo; uptime
echo; echo "===== CPU & MEM ====="; lscpu | egrep 'CPU|Thread|Model|NUMA' || lscpu; echo; free -m
echo; echo "===== LOAD / RUNQ (vmstat 1x10) ====="; vmstat 1 10
echo; echo "===== DISK I/O (iostat -xz 1x10) ====="; iostat -xz 1 10
echo; echo "===== TOP PROCS (CPU) ====="; ps -eo pid,ppid,comm,%cpu,%mem,stat --sort=-%cpu | head -n 30
echo; echo "===== PID I/O/CTX (pidstat -urd 1x5) ====="; pidstat -urd 1 5 || true
@githubhjs
githubhjs / SnakeWPF.ps1
Last active September 10, 2025 07:50
太好了—來一個PowerShell + WPF(你打成 WTF,我就當成是 Snover 那篇文章裡的 WPF 😄)的貪食蛇吧。下面是一支單檔 .ps1 即可執行的版本:有計分、加速、暫停/重新開始、牆壁與自撞判定,畫面用 WPF 的 Canvas 繪製。 直接把整段存成 SnakeWPF.ps1,用 PowerShell(x86/64 皆可)在 STA 模式 執行: powershell -sta -ExecutionPolicy Bypass -File .\SnakeWPF.ps1
# Requires -Version 5.1
param([switch]$VerboseLog)
if ([Threading.Thread]::CurrentThread.ApartmentState -ne 'STA') {
Start-Process powershell "-NoLogo -Sta -ExecutionPolicy Bypass -File `"$PSCommandPath`" $(if($VerboseLog){'-VerboseLog'})"
return
}
Add-Type -AssemblyName PresentationCore, PresentationFramework, WindowsBase
@githubhjs
githubhjs / bsubrepeater.sh
Last active September 5, 2025 09:19
bsubrepeater: repeatedly (re)submit an LSF job when it disappears from bjobs
#!/usr/bin/env bash
# bsubrepeater with audit log: re-submit LSF job when it disappears
set -Eeuo pipefail
DEFAULT_MAX=100000
DEFAULT_INTERVAL=10
VERBOSE=0
LOG_FILE="${BSUBREPEATER_LOG_FILE:-$HOME/.bsubrepeater.log}"
usage() {
@githubhjs
githubhjs / dedup_env_var.zsh
Last active September 3, 2025 09:45
This Zsh function, dedup_env_var, is designed to remove duplicate entries from a colon-separated environment variable, such as $PATH.
#!/bin/zsh
#
# Function: Removes duplicate, colon-separated entries from a specified
# environment variable.
# Usage: dedup_env_var <VARIABLE_NAME>
# Example: dedup_env_var PATH
#
dedup_env_var () {
# Store the first argument (the environment variable's name) in a local variable.
@githubhjs
githubhjs / SortIndexAndTake.scala
Created August 28, 2024 06:31 — forked from chick/SortIndexAndTake.scala
Example of a way of sorting a vector of FixedPoint values, returning the array indices of first N lowest values
package hardwaresort
import chisel3._
import chisel3.experimental.FixedPoint
import chisel3.internal.firrtl.KnownBinaryPoint
import chisel3.iotesters.PeekPokeTester
import chisel3.util.log2Ceil
//scalastyle:off magic.number
/**
@githubhjs
githubhjs / _template.ott
Created October 19, 2023 02:06 — forked from rossant/_template.ott
Convert from Markdown to OpenOffice for Linux Magazine
@githubhjs
githubhjs / twinapps_required_apps.xml
Last active October 19, 2023 09:46 — forked from shakalaca/twinapps_required_apps.xml
給 ZenUI 4.0 之後 (including Asus Rog Phone 3) 應用分身使用的 app (including 野球魂/プロスピA) 支援設定檔
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="twinapps_required_apps">
<item>com.android.vending</item>
<item>com.google.android.gms</item>
<item>jp.naver.line.android|Line: Free Calls &amp; Messages</item>
<item>com.facebook.katana|Facebook</item>
<item>com.facebook.orca|Messenger - Text and Video Chat for Free</item>
<item>com.tencent.mm|WeChat</item>
<item>com.whatsapp|WhatsApp Messenger</item>
@githubhjs
githubhjs / nycu-oauth-document.md
Created October 24, 2022 07:17 — forked from yuchingtw/nycu-oauth-document.md
陽明交通大學 OAuth 服務 - 開發者說明文件

陽明交通大學 OAuth 服務 - 開發者說明文件

這裡會介紹如何透過陽明交通大學 OAuth 服務獲取使用者資訊。本平台是依據 OAuth 2.0 (RFC6749) 的標準開發,目前僅開放 Authorization Code 方式來認證。

開放欄位

  • Email
  • 內容:Email, 帳號名稱
@githubhjs
githubhjs / gitk
Created June 15, 2020 06:40 — forked from RootKiller/gitk
gitk dark theme
set mainfont {{Open Sans} 10}
set textfont {Consolas 9}
set uifont {Tahoma 9 bold}
set tabstop 8
set findmergefiles 0
set maxgraphpct 50
set maxwidth 16
set cmitmode patch
set wrapcomment none
set autoselect 1
[index]
[#1]前言
[#2]游戏
[#3]衍生游戏
[#4]书籍-非小说
[#5]小说
[#6]影视以及动画
[#7]漫画
[/index]
[size=4][b]可以转载、但转载[color=Red]请高亮[/color]注明来源链接以及作者、并在转载后将帖子链接用[color=Red]短消息[/color]发给我[/b][/size]