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 / 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 / _template.ott
Created October 19, 2023 02:06 — forked from rossant/_template.ott
Convert from Markdown to OpenOffice for Linux Magazine
@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 / 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 / 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 / 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 / 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 / pinmux_x_path_checker.sv
Created September 17, 2025 11:08
pinmux_x_path_checker systemverilog
// pragma translate_off
// Checker module: verifies that when pinmux select is high, any X value
// from the module output must propagate to the corresponding GPIO within
// a given cycle latency window. Otherwise, it triggers a fatal error.
module pinmux_x_path_checker #(
parameter int MIN_LAT = 1, // Minimum cycle delay allowed
parameter int MAX_LAT = 8, // Maximum cycle delay allowed
parameter int WIDTH = 1 // Data width (1 = single bit)
)(
input logic clk,
@githubhjs
githubhjs / nfs-mountstats-lite.sh
Last active September 18, 2025 02:18
① mountstats 解析器(無需 sudo) 功能:取樣兩次 /proc/self/mountstats(或用 nfsiostat 若系統有),輸出每個 NFS 掛載點的 ops/s(讀/寫)、avg RTT / avg exe、rpc bklog、以及「初步瓶頸判定」。 把下面存成 nfs-mountstats-lite.sh,給執行權限(不需 sudo):
#!/usr/bin/env bash
# nfs-mountstats-lite.sh -- user-space NFS health snapshot
# 用法:./nfs-mountstats-lite.sh [-i interval_sec] [-c samples]
# 預設 interval=2, samples=3(總觀察 ~4 秒)
set -euo pipefail
INT=2; CNT=3
while getopts "i:c:" o; do
case "$o" in
i) INT="$OPTARG";;
@githubhjs
githubhjs / nfs-watch.sh
Last active September 18, 2025 02:19
② 低權限「一鍵巡檢」面板 把下面存成 nfs-watch.sh(單檔自畫面迴圈),一般使用者可直接跑:
#!/usr/bin/env bash
# nfs-watch.sh -- user-mode NFS watch panel (no sudo)
INT=${1:-2} # 重新整理秒數,預設 2s
have_nfsiostat=0
command -v nfsiostat >/dev/null 2>&1 && have_nfsiostat=1
while true; do
clear
echo "NFS Watch | host=$(hostname) time=$(date '+%F %T') refresh=${INT}s"