Skip to content

Instantly share code, notes, and snippets.

@vcheckzen
vcheckzen / find_ancestor_children.sh
Last active March 10, 2024 19:18
Find ancestor and descendant of a process on Linux.
#!/bin/sh
find_ancestors() {
pid=$1
while [ "$pid" -ne 0 ]; do
echo "$pid"
pid=$(awk '{print $4}' /proc/"$pid"/stat 2>/dev/null)
done
}
@vcheckzen
vcheckzen / override_ntp_cpd_server.sh
Created June 27, 2024 18:02
Android set NTP and CPD servers.
#!/bin/sh
# NTP
adb shell settings put global ntp_server ntp.aliyun.com
# CPD
adb shell settings put global captive_portal_http_url http://connect.rom.miui.com/generate_204
adb shell settings put global captive_portal_https_url https://connect.rom.miui.com/generate_204
adb shell settings put global captive_portal_use_https 1
adb shell settings put global captive_portal_detection_enabled 1
@vcheckzen
vcheckzen / config.json
Created July 21, 2024 18:33
SingBox Http Client
{
"inbounds": [
{
"type": "mixed",
"listen": "::",
"listen_port": 10000
}
],
"outbounds": [
{
@vcheckzen
vcheckzen / reverse.sh
Created August 13, 2024 16:49
Reverse lines
#!/bin/sh
reverse_all() {
input_file="$1"
# shellcheck disable=SC2016
sed '2,$G;h;$!d' "$input_file"
}
reverse_inner_group_by_prefix() {
input_file="$1"
@vcheckzen
vcheckzen / patch.sh
Last active August 31, 2025 02:48
Patch bins to write syslog to another place rather than /dev/log
#!/bin/sh
# https://unix.stackexchange.com/questions/277202/use-a-different-socket-than-dev-log-system-wide
# https://blog.daveeddy.com/2018/09/26/logging-for-runit-on-void-linux-with-svlogger/
# Define the new and old log paths
NEW_LOG_PATH="/ved/log"
OLD_LOG_PATH="/dev/log"
# Function to patch binaries