Skip to content

Instantly share code, notes, and snippets.

View wenijinew's full-sized avatar
🏠
Start the journey of Spacemacs

Bruce Wen wenijinew

🏠
Start the journey of Spacemacs
View GitHub Profile
@wenijinew
wenijinew / gpg_cmds.md
Last active February 1, 2024 07:30
GPG Commands
@wenijinew
wenijinew / progress_bar.sh
Created October 3, 2023 11:20
Progress Bar in Bash
#!/usr/bin/bash
# source: https://stackoverflow.com/questions/238073/how-to-add-a-progress-bar-to-a-shell-script/68298090#68298090
percentBar () {
local prct totlen=$((8*$2)) lastchar barstring blankstring;
printf -v prct %.2f "$1"
((prct=10#${prct/.}*totlen/10000, prct%8)) &&
printf -v lastchar '\\U258%X' $(( 16 - prct%8 )) ||
lastchar=''
printf -v barstring '%*s' $((prct/8)) ''
printf -v barstring '%b' "${barstring// /\\U2588}$lastchar"
@wenijinew
wenijinew / generate_random_colors.py
Created September 25, 2023 19:11
Generate Random Colours
def generate_random_colors(
min_color=0,
max_color=231,
base_colors_total=7,
lighter_colors_total=24,
plot=False,
):
"""Generate random color hex codes.
Firstly, it will generate random integer from min_color (0-(255 - lighter_colors_total - 1)) to max_color (0-(255 - lighter_colors_total)).
@wenijinew
wenijinew / generate_xadic_colors.py
Created September 18, 2023 18:57
Generate arbitray Nadic Colors
def generate_xadic_colors(hex_color, n_colors=7, plot=False, verbose=False):
""" "Convert."""
hls_color = hex2hls(hex_color)
triadic_colors = []
for offset in range(0, 360, 360 // n_colors):
triadic_colors.append(
((hls_color[0] + offset / 360) % 1.0, hls_color[1], hls_color[2])
)
_colors = [hls2hex(hls_color) for hls_color in triadic_colors][0:n_colors]
if verbose:
@wenijinew
wenijinew / generate_lighter_colors.py
Created September 18, 2023 18:48
Generate Lighter Colors
def generate_lighter_colors(base_color, n_color):
"""Given base color, return 'n' color hex codes from base color to lightest
color."""
color_rgb = tuple(int(base_color[1:][i : i + 2], 16) for i in (0, 2, 4))
color_rgb_ligher = tuple(
[c for c in range(color, 255, (255 - color) // n_color)][0:n_color]
for color in color_rgb
)
lighter_colors = [
@wenijinew
wenijinew / .tmux.conf
Last active February 25, 2024 21:58
Tmux Configuration
set -g TMUX_PLUGIN_MANAGER_PATH "$GITHUB_REPO_ROOT"
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'wenijinew/glamour.tmux'
@wenijinew
wenijinew / git_ignore_patterns.csv
Last active March 2, 2023 06:29
Git Ignore Patterns
Pattern Description
Blank Line Match no files - can serve as a separator for readability.
Lines starting with hash(#) Comment by default.
Trailing spaces being ignored unless they are quoted with backslash (\).
! Negates the pattern.
\ escape sensitive chars(E.g. # or ! or trailing spaces).
Ends with slash(/) match directory and any paths under it.
No slash(/) match pathname relative to .gitignore file or the top-level of the work tree if not from .gitignore.
* match anything except slash(/)
? match any one char except slash(/)
#!/usr/bin/env python
import getopt, sys
ABNORMAL_STATE=2
EMPTY=""
def hello(name):
print("Hello, ", name)