Skip to content

Instantly share code, notes, and snippets.

# kt
## Source file
cat hello.kt <<EOF
fun main() {
println("Hello, Kotlin!")
}
EOF
## Compile
[user]
name = FATESAIKOU
email = [email protected]
[core]
editor = vim
pager = delta
[interactive]
diffFilter = delta --color-only
[delta]
navigate = true
@FATESAIKOU
FATESAIKOU / gist:7e43cda9f9d7475f60c8be2f8f75253f
Created May 3, 2025 10:21
Monitor arbitrary port(example: mcphost)
# install mitmproxy
$ pipx install mitmproxy
# edit iptable
$ sudo iptables -t nat -A OUTPUT -p tcp --dport 11434 -j REDIRECT --to-port <mitmproxy listen port>
# launch mitmproxy
$ mitmproxy --mode reverse:http://127.0.0.1:<ollama port> --listen-port <mitmproxy listen port>
# change ollama default port
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
set -g default-terminal "screen-256color"
# General configuration.
# $ tmux show-options -g
set -g history-limit 5000
set -g base-index 1
set -g display-time 5000
set -g repeat-time 1000
set -g status-keys vi
#set -g status-utf8 on
#!/usr/bin/env bash
# Usage: nohup bash -c "cd /home/fatesaikou/testSH && ./selfCheckSwitchableSshTunnel.sh localhost 2223 localhost 2222 sshproxy fws.csie.io 22" 1>>/home/fatesaikou/testSH/selfCheckSwitchableSshTunnel.log 2>&1 &
REVERSE_REMOTE_HOST=$1
REVERSE_REMOTE_PORT=$2
REVERSE_LOCAL_HOST=$3
REVERSE_LOCAL_PORT=$4
USER=$5
HOST=$6
@FATESAIKOU
FATESAIKOU / uselessFancyScript.sh
Last active August 31, 2024 07:09
an useless little fancy script
#!/usr/bin/env bash
WINDOW_SIZE=$(tput cols)
PREFIX_SIZE=$(echo -n -e "[$(date)]: $RANDOM\t" | expand | wc -m)
SUFFIX_SIZE=$(echo -n -e "|" | wc -c)
BAR_SIZE=$(( (WINDOW_SIZE - PREFIX_SIZE - SUFFIX_SIZE) / 2 ))
while true;
do
randnum=$RANDOM;
@FATESAIKOU
FATESAIKOU / moniternetwork
Created August 25, 2024 06:01
Script to mention you fixing the network issue
#!/usr/bin/env bash
conn_fail_threshold=5
conn_fail_cnt=0
while true;
do
curl -m1 'https://www.google.com' 1>/dev/null 2>&1
if [ $? -ne 0 ];
then
@FATESAIKOU
FATESAIKOU / encryptAndDecrypt
Created August 12, 2024 06:27
Encrypt and Decrypt with openssl
#!/usr/bin/env bash
PASSWORD=$1
# encryption
echo "Hello, world!" | openssl enc -aes-256-cbc -pbkdf2 -iter 10000 -a -salt -pass pass:"$PASSWORD" > helloWorld.crypted
# decryption
cat helloWorld.crypted | openssl enc -d -aes-256-cbc -pbkdf2 -iter 10000 -a -pass pass:"$PASSWORD" # Output "Hello, world!" here
@FATESAIKOU
FATESAIKOU / myAutossh.sh
Last active January 10, 2023 11:03
my autossh
#!/usr/bin/env bash
PORT=$1
AUTOSSH_CMD="ssh -Nf -D$PORT [email protected]"
# SSH clean up function
function stopNfSSHs() {
pids=( $(ps -ef | grep '[s]sh -Nf' | awk '{print $2}') )
if [ "${#pids[@]}" -gt 0 ]; then
echo "Tunnel stop ${pids[@]}"
#!/usr/bin/env bash
TUTORID=$1
START=$2
curl 'https://www.cambly.com/api/reservations' \
-H 'authority: www.cambly.com' \
-H 'accept: application/json, text/javascript, */*; q=0.01' \
-H 'accept-language: zh-TW,zh;q=0.9,ja-JP;q=0.8,ja;q=0.7,en-US;q=0.6,en;q=0.5' \
-H 'cache-control: no-cache' \