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 / 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 adam@baksili.codes"
)
@BaksiLi
BaksiLi / undock.sh
Last active August 10, 2023 06:45
Docker command to kill and remove a container with its image
alias undock='f() {
if sudo docker kill $1; then
echo "[+] Successfully killed: $1"
else
echo "[-] Failed to kill: $1"
fi
if sudo docker rm $1; then
echo "[+] Successfully removed: $1"
else
@BaksiLi
BaksiLi / gist:c6a371bf770e8dd8a2c703ae5087d31e
Created February 17, 2023 02:53
Anki Python debug script to move "[sound:xxx]" between fields
note_type = 'Basic'
regex = r'\[sound:.*\]'
field_from = 'Back'
field_to = 'Pronunciation'
model = mw.col.models.by_name(note_type)
notes = mw.col.models.nids(model)
for nid in notes:
note = mw.col.get_note(nid)