Skip to content

Instantly share code, notes, and snippets.

View mrjohannchang's full-sized avatar

Johann Chang mrjohannchang

View GitHub Profile
@mrjohannchang
mrjohannchang / _readme.md
Last active April 29, 2025 02:17
Rime 中州韻輸入法 橫式 小鶴雙拼 設定
  1. Install RIME (Squirrel on macOS, Weasel on Windows)
  2. Install 小鶴雙拼
    # Go to the installation folder, then
    ./rime-install double-pinyin
    
  3. Enable the installed 小鶴雙拼 schema from RIME's settings.
  4. Add the following contents to corresponding files, if files are not existed, create them.
  5. From RIME UI, click deploy to make the customized config take effect.
@mrjohannchang
mrjohannchang / find_in_list.h
Last active March 28, 2025 11:23
C23 find in sys/queue
#pragma once
#include <sys/queue.h>
#define find_in_slist(element, list_head, entry_name, comparator) \
({ \
typeof(element) ret = nullptr; \
typeof(element) current_element = nullptr; \
SLIST_FOREACH(current_element, list_head, entry_name) { \
if (comparator(current_element, element)) { \
@mrjohannchang
mrjohannchang / autossh.service
Created August 2, 2024 03:36 — forked from thomasfr/autossh.service
Systemd service for autossh
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
@mrjohannchang
mrjohannchang / arduino-cli-steps.md
Created July 31, 2024 20:06 — forked from Jerrylum/arduino-cli-steps.md
How to use Arduino CLI to program ESP32

Development

Suggested user settings, Arduino CLI is optional.

{
    "arduino.path": "C:\\Users\\jerrylum\\Documents\\Application\\arduino-cli_0.27.1_Windows_64bit",
    "arduino.useArduinoCli": true,
    "arduino.commandPath": "arduino-cli.exe"
}
@mrjohannchang
mrjohannchang / keepawake.ps1
Last active March 13, 2023 00:05 — forked from jamesfreeman959/keepawake.ps1
A very simple PowerShell script to keep a Windows PC awake and make lync think the user is active on the keyboard
# Useful references:
#
# https://superuser.com/questions/992511/emulate-a-keyboard-button-via-the-command-line
# https://ss64.com/vb/sendkeys.html
# https://social.technet.microsoft.com/Forums/windowsserver/en-US/96b339e2-e9da-4802-a66d-be619aeb21ac/execute-function-one-time-in-every-10-mins-in-windows-powershell?forum=winserverpowershell
# https://learn-powershell.net/2013/02/08/powershell-and-events-object-events/
#
# Future enhancements - use events rather than an infinite loop
$wsh = New-Object -ComObject WScript.Shell
while ($true) {
@mrjohannchang
mrjohannchang / swap-caps-lock-and-left-control.reg
Created October 4, 2021 08:18
Swap left control and caps lock on Windows
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,1d,00,3a,00,3a,00,1d,00,00,00,00,00
; Refs:
; https://superuser.com/a/1381836
@mrjohannchang
mrjohannchang / remap-mac-keyboard-modifier-keys-on-windows.reg
Last active July 7, 2021 15:26
Swap left command and left option keys, remap right command to right alt, remap right option to context menu on Windows
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,05,00,00,00,5b,e0,38,00,38,00,5b,e0,38,e0,5c,e0,5d,e0,38,e0,00,00,00,00
; Refs:
; https://superuser.com/a/1202601/270174
; https://stackoverflow.com/questions/40777182/how-to-remap-the-menu-key-on-windows
@mrjohannchang
mrjohannchang / multiprocessing-queue-manager-client.py
Last active July 20, 2021 16:40
Python multiprocessing server client inter-process communication (IPC) over Queue. https://stackoverflow.com/a/62608473/1592410
import multiprocessing
import multiprocessing.managers
import os
import sys
from typing import AnyStr, Union
class QueueManager(multiprocessing.managers.BaseManager):
def get_queue(self, ident: Union[AnyStr, int, type(None)] = None) -> multiprocessing.Queue:
@mrjohannchang
mrjohannchang / fib.go
Last active September 10, 2019 14:35
[Interview] Please modify the program, so the Fibonacci sequence starts from 0 instead of 1.
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ignore
package main
import "fmt"
@mrjohannchang
mrjohannchang / print-asterisk-triangle.py
Last active August 26, 2019 08:29
Print an asterisk triangle without for-loops
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import logging
import os
import sys
def parse_args() -> argparse.Namespace: