Skip to content

Instantly share code, notes, and snippets.

View CJHwong's full-sized avatar
🧠

Hoss CJHwong

🧠
  • GoFreight
  • Taipei
View GitHub Profile
@CJHwong
CJHwong / README.md
Last active March 27, 2024 17:22
MySQL Schema Diagram Generator
@CJHwong
CJHwong / README.md
Last active October 8, 2024 07:27
Creating a Quick Action for Sending Selected Text to Large Language Models on macOS

Introduction

This instruction explains how to create a Quick Action in macOS that can send selected text directly to your preferred large language model.

The workflow is inspired by this Hacker News post of eliya_confiant: https://news.ycombinator.com/item?id=39592297.

Prerequisites

To follow this guide, you will need the following tools:

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