Skip to content

Instantly share code, notes, and snippets.

View maxchang3's full-sized avatar
😰

Max Chang maxchang3

😰
View GitHub Profile
@maxchang3
maxchang3 / bitviz.py
Created April 18, 2024 05:40
Generate binary tree dot language codes by level order. Make binary tree visualization easier.
#!/usr/bin/env python
# https://blog.nanpuyue.com/2019/054.html
# I use ChatGPT to translate the original Rust code into Python and made some modifications.
from typing import List, Optional, Union
from pathlib import Path
import os
class TNode:
@maxchang3
maxchang3 / pdm_auto_activation_for_zsh.sh
Last active March 20, 2024 10:58
PDM Auto Activation for ZSH
# ---------------------------------------------- PDM Auto Activation ---
# @from https://dev.to/moniquelive/auto-activate-and-deactivate-python-venv-using-zsh-4dlm
python_venv() {
MYVENV=./.venv
# when you cd into a folder that contains $MYVENV
[[ -d $MYVENV ]] && source $MYVENV/bin/activate > /dev/null 2>&1
# when you cd into a folder that doesn't
[[ ! -d $MYVENV ]] && deactivate > /dev/null 2>&1
}
autoload -U add-zsh-hook
@maxchang3
maxchang3 / 💻 Recent coding in languages
Last active June 30, 2024 12:23
Max Chang's Language Stats
C++ █████████░░░░░░░░░░░░░░░░░░░░░░░░░░░ 24.17%
JavaScript ████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 21.66%
Typst ████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 21.60%
Python █████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 12.77%
TypeScript ███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 7.84%
C ███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 6.12%
TeX █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 2.27%
PHP █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1.08%
Astro █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0.88%
Vue █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0.67%
⭐ Total Stars: 204
➕ Total Commits: 1,191
🔀 Total PRs: 62
🚩 Total Issues: 34
📦 Contributed to: 10
@maxchang3
maxchang3 / gitcc.sh
Created February 19, 2023 07:10
gitcc (Git Clone Code), a cli simplifies `git clone <repo_url> && code <repo_name>`
#!/bin/bash
SCRIPT_NAME=$(basename "$0")
VERSION="1.0.0"
function usage() {
cat <<EOF
Usage: $SCRIPT_NAME [-d] <repository>
-d Perform a shallow clone with a depth of 1
EOF
// use (16 chars of) 'password' to encrypt 'plaintext'
function encrypt(plaintext, password) {
var v = new Array(2), k = new Array(4), s = "", i;
plaintext = escape(plaintext); // use escape() so only have single-byte chars to encode
// build key directly from 1st 16 chars of password
for (var i=0; i<4; i++)
k[i] = Str4ToLong(password.slice(i*4,(i+1)*4));