Skip to content

Instantly share code, notes, and snippets.

View wasdee's full-sized avatar
🏠
Working from home

Nutchanon Ninyawee wasdee

🏠
Working from home
View GitHub Profile
@wasdee
wasdee / env_sub.sh
Created September 21, 2024 17:36
env sub to any file
bash -c 'eval "echo \"$$(cat ~/temp.yml)\"" > ~/kong.yml
@wasdee
wasdee / full.md
Last active September 20, 2024 17:11
emoji prefix ai instruction

Emoji Prefix Convention

Emoji Prefix

🌟ADD

Use when you add something entirely new. E.g. 🌟ADD: Add Git ignore file

💡IMPROVE

Use when you improve/enhance piece of code like refactoring etc. E.g. 💡IMPROVE: Remote IP API Function

#!/bin/bash
set -euo pipefail
# Directory setup
APP_DIR="${HOME}/Applications"
ICON_DIR="${HOME}/.local/share/icons"
DESKTOP_DIR="${HOME}/.local/share/applications"
BIN_DIR="${HOME}/.local/bin"
@wasdee
wasdee / AsyncTyper.py
Created July 6, 2023 08:26
asynctyper
from functools import wraps
from typing import Callable
import typer
from asyncio import run
class AsyncTyper(typer.Typer):
def async_command(self, _func: Callable = None, *args, **kwargs):
def decorator(async_func):
@wraps(async_func)
@wasdee
wasdee / start.sh
Last active April 27, 2023 06:45
dvc get started
dvc init
dvc remote add -d storage s3://yyy
dvc remote modify storage endpointurl https://xxx.r2.cloudflarestorage.com/
# global
dvc remote modify --global storage endpointurl https://xxx.r2.cloudflarestorage.com/
dvc remote modify --local myremote account_name 'myaccount'
dvc remote modify --local myremote account_key 'mysecret'
@wasdee
wasdee / scr.bat
Last active April 16, 2023 15:17
windows robocopy
@REM normal copy
robocopy "Source Directory" "Destination Directory" /e /w:5 /r:2 /COPY:DATSOU /DCOPY:DAT /MT:24
@REM normal move
robocopy "Source Directory" "Destination Directory" /e /w:5 /r:2 /COPY:DATSOU /DCOPY:DAT /MT:24 /MOVE
@REM nfs copy
robocopy "Source Directory" "Destination Directory" /e /w:5 /r:2 /COPY:DATO /DCOPY:DAT /MT:24 /MOVE
@wasdee
wasdee / keybase.proof
Created February 9, 2023 01:05
keybase.proof
### Keybase proof
I hereby claim:
* I am wasdee on github.
* I am circleoncircles (https://keybase.io/circleoncircles) on keybase.
* I have a public key ASB2UB20JJrBpl-ONIch2glYEuGmKrii__0scS1G-y-5bAo
To claim this, I am signing this object:
@wasdee
wasdee / cmd.sh
Created December 24, 2022 09:14
check if cmd exist bash
# check if use firewalld
if [ -x "$(command -v firewall-cmd)" ]; then
firewall-cmd --permanent --add-masquerade
fi
#!/usr/bin/env bash
now=$(date +"%Y_%m_%d-%H_%M_%S")
top -b -n 120 > "top-120iters-$now.txt"
# this takes 120 iterations of top, which is 120*3 seconds = 6 minutes
@wasdee
wasdee / cmd.sh
Last active December 22, 2022 06:07
conda export env
# https://docs.conda.io/projects/conda/en/latest/_downloads/843d9e0198f2a193a3484886fa28163c/conda-cheatsheet.pdf
conda env export --from-history > environment.yml
# to restore, must use with env cmd group https://github.com/conda/conda/issues/6827#issuecomment-365614464
conda env create --file environment.yml
conda create -n env_name --file environment.yml #ERROR