Skip to content

Instantly share code, notes, and snippets.

View RagingTiger's full-sized avatar
🐅

Raging Tiger RagingTiger

🐅
View GitHub Profile
@RagingTiger
RagingTiger / a_models_recall.py
Last active November 24, 2023 10:25
Example Solution from Bnomial: A Model's Recall
"""
bnomial: 10/16/2023
A team built a binary classification model. They named the classes A and B.
After finishing training, they evaluated the model on a validation set, and
here is the confusion matrix with the results:
A B
┌────┬────┐
A│ 52 │ 7 │
@RagingTiger
RagingTiger / git-reset-author.sh
Created July 5, 2023 14:36 — forked from bgromov/git-reset-author.sh
Git: reset author for ALL commits
#!/bin/sh
# Credits: http://stackoverflow.com/a/750191
git filter-branch -f --env-filter "
GIT_AUTHOR_NAME='Newname'
GIT_AUTHOR_EMAIL='new@email'
GIT_COMMITTER_NAME='Newname'
GIT_COMMITTER_EMAIL='new@email'
" HEAD
@RagingTiger
RagingTiger / config-ubuntu.md
Last active December 15, 2023 18:45
Setting up a new Ubuntu machine

About

A simple install script for setting up a fresh Ubuntu environment.

Usage

Download the script:

cd /tmp && \
curl -o config-ubuntu.sh https://gist.githubusercontent.com/RagingTiger/93c50d0d65ab5e81aba6188e58f7ca59/raw/config-ubuntu.sh || \
wget https://gist.githubusercontent.com/RagingTiger/93c50d0d65ab5e81aba6188e58f7ca59/raw/config-ubuntu.sh
@RagingTiger
RagingTiger / tianji_horse_race_problem.py
Created May 26, 2023 19:23
Sun Bin's, the descendant of Sun Tzu, generalized solution for how General Tianji should race his horses against the King of Qi.
"""
References:
+ Shu, J. (2012). On Generalized Tian Ji's Horse Racing Strategy.
Interdisciplinary Science Reviews, 37, 187 - 193.
+ Leng, M., & Parlar, M. (2006). Game-theoretic analysis of an ancient Chinese
horse race problem. Comput. Oper. Res., 33, 2033-2055.
"""
def get_horses(n):
for horse in range(1, n+1):
@RagingTiger
RagingTiger / save_compress_split.sh
Created May 20, 2023 13:24
Save a docker image into a compressed and multi-part file.
docker save $1 | gzip | split -b 1GB - img.gz.
@RagingTiger
RagingTiger / split_directory.sh
Created May 8, 2023 03:21
Split a directory of 1000 files into 10 directories of 100 files.
for number in $(seq 1 10); do mkdir "Part_${number}" && mv "$(ls *.mp4 | head -n 100)" "Part_${number}"; done
@RagingTiger
RagingTiger / config_git_credentials.sh
Last active December 15, 2023 18:46
Configure Git credentials for when using multipe GitHub accounts.
git_config_author(){
git config --local user.name "${1}"
git config --local user.email "${2}"
}
git_config_sshkey(){
# get ssh hosts
local ssh_hosts="$(grep "github.com-[a-Z]*" ~/.ssh/config | \
awk '{print $2}' | sed 's/github\.com-//g' | tr '\n' ' ')"
@RagingTiger
RagingTiger / multiple_ssh_setting.md
Last active May 8, 2023 02:31 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@RagingTiger
RagingTiger / sample.py
Created March 22, 2023 16:36 — forked from svpino/sample.py
Web Scraping using Bright Data Scraping Browser and Playwright
import re
import asyncio
from playwright.async_api import async_playwright
USERNAME = "TYPE YOUR USERNAME HERE"
PASSWORD = "TYPE YOUR PASSWORD HERE"
HOST = "zproxy.lum-superproxy.io:9222"
URL = "https://www.svpino.com/" # USE YOUR URL HERE
backup(){
# target sink
local target="${1:-"/Volumes/${YOUR_VOLUME}"}"
# target sources
local sources=$HOME
# check volume mounted
if mount | grep -q "on ${target}"; then
rsync -havP --exclude={Desktop,Downloads,Library,Movies,Pictures,Public,.Trash} \