Skip to content

Instantly share code, notes, and snippets.

View Chihsiao's full-sized avatar
🐟
Fish-touching

Akira Yamazaki Chihsiao

🐟
Fish-touching
View GitHub Profile
#!/usr/bin/env bash
set -euo pipefail \
${DEBUG:+-x}
executable="${1:?no executable}"
shift
if [ "${executable%/*}" != "$executable" ]
then
#!/usr/bin/env bash
: "${REMOTE:=lsw}"
: "${CMD64_SH:=cmd64.sh}"
eval_in_remote() {
# shellcheck disable=SC2029
ssh "$REMOTE" "$CMD64_SH" "$(base64 -w0 - <<< '
'"${DEBUG:+set -x}"'
'"$1"'
#!/usr/bin/env bash
set -euo pipefail \
${DEBUG:+-x}
declare -a -- STYX_FREERDP_FLAGS=()
declare -A -- STYX_DRIVES=()
conf_file="$1"
shift
@echo off
chcp 65001 > nul
set "HOME=%HOMEDRIVE%%HOMEPATH%"
C:\msys64\msys2_shell.cmd -defterm -here -no-start -ucrt64 %*
rem New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\msys64\default_shell.cmd" -PropertyType String -Force
#!/usr/bin/env bash
set -euo pipefail \
${DEBUG:+-x}
readarray active_rdp_sessions <<< "$(query session | sed 's/^>/> /; s/^ /- /' \
| awk 'NR > 1 && $2 ~ /^rdp-/ && $5 == "Active" { print $1"\t"$2"\t"$3"\t"$4 }')"
for line in "${active_rdp_sessions[@]}"; do
IFS=$'\t' read -r cur_flag session username session_id <<< "$line"
- name: Install Docker on RHEL
hosts: rhel_servers
become: true
tasks:
- name: Ensure required packages are installed
ansible.builtin.dnf:
state: present
name:
- dnf-plugins-core
import time
import warnings
from typing import Sequence, Union, Iterable
import numpy as np
import pypdf
_PDF_FILTER_WITH_LOSS = [
"DCTDecode", "DCT",
"JPXDecode",
from typing import Union, Tuple, Iterable, Iterator
class LeveledKV:
Key, Value = str, Union[str, 'LeveledKV']
Entry = Tuple[Key, Value]
def __init__(self):
self._store = dict()
@Chihsiao
Chihsiao / fetch-derps.sh
Created September 30, 2024 12:30
Fetch JSON derp map and convert it into YAML format which headscale accepts
#!/usr/bin/env bash
curl -L -- "${1-https://controlplane.tailscale.com/derpmap/default}" \
| jq 'walk(if type == "object" then with_entries(.key |= ascii_downcase) else . end)' \
| yq -p json -o yaml '.regions |= with_entries(.key |= (tonumber // .))' > derps.yaml
@Chihsiao
Chihsiao / clash-verge.script.js
Created September 26, 2024 13:51
Clash Verge Helper
const __QURE_ROOT = 'https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/';
const __RIS = new Map(Array.from('ABCDEFGHIJKLMNOPQRSTUVWXYZ').map((ch) =>
[ch, String.fromCodePoint(ch.charCodeAt() - 0o101 + 0x1F1E6)]));
function flagOf(regionCode) {
return Array.from(regionCode).map((c) => __RIS.get(c)).join('');
}
function main(config, profileName) {