Skip to content

Instantly share code, notes, and snippets.

View CJHwong's full-sized avatar
🧠

Hoss CJHwong

🧠
View GitHub Profile
@CJHwong
CJHwong / find-old-remote-branch.sh
Created February 6, 2025 15:52
Git: Find Old Remote Branches
git fetch --all --prune && git for-each-ref --format=$'%(committerdate:unix)\t%(refname:lstrip=2)\t%(committername)' refs/remotes/ | awk -F'\t' -v cutoff=$(date -v-3m +%s) '
$1 < cutoff {
committer = $3;
branches[committer] = branches[committer] "\n - " $2;
}
END {
for (c in branches) {
print c ":" branches[c];
print "==========================";
}
@CJHwong
CJHwong / README.md
Last active March 27, 2024 17:22
MySQL Schema Diagram Generator
@CJHwong
CJHwong / README.md
Last active March 22, 2025 10:54
Gems - A Gemini Gem Manager in your MacBook powered by Gemma

Gems - A Gemini Gem Manager in your MacBook powered by Gemma

Gems is a zsh script designed to simplify interacting with local Large Language Models using Ollama. It allows you to execute LLM commands with pre-defined prompts, making it easier to perform specific tasks without writing new prompts every time.

Inspired by the workflow described in this Hacker News post by eliya_confiant: https://news.ycombinator.com/item?id=39592297.


Features

ALL_FILES=$(git ls-files)
echo "filename,commit_ct,last_updated_at"
while IFS= read -r FILENAME
do
COMMIT_CT=$(git --no-pager log --pretty=tformat:"%h" ${FILENAME} | wc -l | sed 's/ //g')
LATEST_UPDATED_AT=$(git --no-pager log -1 --pretty="format:%ci" $FILENAME)
echo "${FILENAME},${COMMIT_CT},${LATEST_UPDATED_AT}"
done < <(printf '%s\n' "$ALL_FILES")
@CJHwong
CJHwong / mysql_table_ext.py
Created November 2, 2020 03:44
Extract partial info from a table of mysqldump backup SQL file.
import argparse
import codecs
import csv
def extract_table_sql(table_name, source_dir, target_dir):
TABLE_STRUCTURE_START = '-- Table structure for table'
TARGET_TABLE_STRUCTURE_START = f'{TABLE_STRUCTURE_START} `{table_name}'
backup_sql = codecs.open(f'{source_dir}/backup.sql', 'r', encoding='utf-8', errors='replace')
@CJHwong
CJHwong / dump.py
Last active February 5, 2017 22:03
Convert data in SQLite to JSON
import sqlite3
import json
def dump_from_sqlite():
conn = sqlite3.connect('db.sqlite')
c = conn.cursor()
c.execute("SELECT name FROM sqlite_master WHERE type='table';")
for t in c.fetchall():
c.execute("SELECT * FROM " + t[0])
@CJHwong
CJHwong / .vimrc
Last active August 29, 2015 14:00
set shell=bash
"======Color Scheme======
"set rtp+=~/.vim/bundle/vim-colorschemes
set rtp+=~/.vim/bundle/vim-colors-solarized/
set t_Co=256
set background=dark
colorscheme solarized
"=====Vim Environment====
set tabstop=4 shiftwidth=4 expandtab