Skip to content

Instantly share code, notes, and snippets.

View BaksiLi's full-sized avatar
✍️
Wired-in ∨ Studying

Baksi BaksiLi

✍️
Wired-in ∨ Studying
View GitHub Profile
@BaksiLi
BaksiLi / monitor.sh
Created November 25, 2024 15:34
User-aware process control monitor (SIGSTOP/SIGCONT)
#!/bin/bash
set -euo pipefail
# Configuration
SCRIPT_NAME="./evil-process"
LOG_FILE="./process_monitor.log"
CHECK_INTERVAL=5
# Target users to monitor
TARGET_USERS=("root" "admin")
@BaksiLi
BaksiLi / download_video.py
Created October 21, 2024 14:20
Download Bauer****d Training App Videos
import os
import asyncio
import aiohttp
import argparse
from tqdm import tqdm
async def download_video(session, url, file_path):
if os.path.exists(file_path):
print(f"[!] Skipping: {file_path} (already downloaded)")
return
@BaksiLi
BaksiLi / sse_visualise.wl
Created November 19, 2023 21:12
Visualise Shanghai Composite Index since Covid-19
(*Shanghai Composite Index*)
data1 = FinancialData[
"^000001", {{2019, 12, 1}, {2021, 3, 22}, "Week"}];
data2 = FinancialData[
"^000001", {{2021, 3, 23}, {2022, 3, 5}, "Week"}];
data3 = FinancialData[
"^000001", {{2022, 3, 6}, {2022, 12, 4}, "Week"}];
data4 = FinancialData[
"^000001", {{2022, 12, 5}, {2023, 11, 1}, "Week"}];
dataset = {data1, data2, data3, data4};
@BaksiLi
BaksiLi / print256colours.sh
Created August 12, 2023 14:32 — forked from HaleTom/print256colours.sh
Print a 256-colour test pattern in the terminal
#!/bin/bash
# Tom Hale, 2016. MIT Licence.
# Print out 256 colours, with each number printed in its corresponding colour
# See http://askubuntu.com/questions/821157/print-a-256-color-test-pattern-in-the-terminal/821163#821163
set -eu # Fail on errors or undeclared variables
printable_colours=256
@BaksiLi
BaksiLi / install_compsnip.zsh
Created August 12, 2023 06:54
Zinit Install GitHub completion or Gist snippets
local GH_RAW_URL='https://raw.githubusercontent.com'
install_completion(){ zinit for as'completion' nocompile id-as"$1" is-snippet "$GH_RAW_URL/$2"; }
local GHG_RAW_URL='https://gist.githubusercontent.com'
install_gist_snippet() {
local url="$2"
if [[ $url != $GHG_RAW_URL* ]]; then
url="$GHG_RAW_URL/$url"
fi
if [[ $url != *raw ]]; then
@BaksiLi
BaksiLi / zinit_remove.zsh
Created August 11, 2023 15:28
Remove Zinit folders
# ZINIT_HOME="/home/username/.local/share/zinit/zinit.git"
zinit_remove() {
local target_dir
case "$1" in
-s|--snippets)
target_dir="${ZINIT_HOME:s/zinit\.git/snippets}"
;;
-p|--plugins)
function ipinfo() {
ip_address=${1:-$(curl -s ipinfo.io/ip)}
while (( "$#" )); do
case $1 in
-h|--help)
echo "Command: ip-info IP_ADDRESS\n"
echo "Default: your ip address"
echo "Option -s or --simple"
echo "==>Print only Your address"
@BaksiLi
BaksiLi / load_func.sh
Last active August 12, 2023 06:58
Add import (`load_func`) online scripts to zsh/bash
load_func() {
local CMD_NAME="$1"
local SCRIPT_URL="$2"
local SAFETY_CHECK="${3:-true}"
local script=$(curl -fsSL $SCRIPT_URL)
if [[ "$SAFETY_CHECK" == "true" && $script =~ "rm " ]]; then
echo "Failed to load command $CMD_NAME: Harmful command detected in script."
return 1
else
@BaksiLi
BaksiLi / install_zellij.sh
Created August 9, 2023 10:48
Install Zellij (latest release) on Linux (incl. Ubuntu) and Darwin
#!/bin/bash
# Get the architecture of the machine
arch=$(uname -m)
os=$(uname -s)
# Download the Zellij binary
if [ "$os" == "Darwin" ]; then
filename="zellij-${arch}-apple-darwin.tar.gz"
url="https://github.com/zellij-org/zellij/releases/latest/download/$filename"
@BaksiLi
BaksiLi / git_user_switcher.zsh
Created July 7, 2023 05:39
zsh function for switching git users (for team, multiple accounts etc.)
function git_user_switcher() {
# Define an associative array to store the user settings
typeset -A -g git_users
# Add the users to the dictionary
# Format: username "name email gpg_key"
git_users=(
adam "adam [email protected]"
)