Skip to content

Instantly share code, notes, and snippets.

View gongfan99's full-sized avatar

Fan Gong gongfan99

  • Kitchener, Ontario
View GitHub Profile
@gongfan99
gongfan99 / earbud.py
Last active October 25, 2025 02:37
create the earbud model with build123d
# %%
from typing import Iterable
from build123d import *
from OCP.BRepBuilderAPI import BRepBuilderAPI_Sewing
from OCP.TopAbs import TopAbs_SHELL
from OCP.TopoDS import TopoDS
from ocp_vscode import Camera, set_defaults, show
set_defaults(reset_camera=Camera.CENTER, helper_scale=5, axes=True, axes0=True)
@gongfan99
gongfan99 / gist:8ed7603b451e87682cb4dd7ea940d6b5
Last active October 5, 2025 23:57
Demonstrate the Gordon surface with build123d - an airliner fuselage
"""
Simple example demonstrating Gordon curve interpolation with build123d.
"""
# %%
from build123d import *
from ocp_vscode import show_all, show, Camera, set_defaults
set_defaults(reset_camera=Camera.KEEP, helper_scale=5)
# %%
@gongfan99
gongfan99 / tailwind.config.mjs
Created July 28, 2024 00:38
add utopia and primary/secondary color to tailwind.config.mjs
/** @type {import('tailwindcss').Config} */
/*********************************************************
* You need to first install "npm i utopia-core"
* Then you will be able to use the following:
* font-size: e.g. text-u-6, text-u-0, text-u--2
* spacing: e.g. w-u-3xl, w-u-m, w-u-3xs, w-u-s-l, w-u-500-600
* color: e.g. bg-pri-100, bg-pri-500 (bg-pri), bg-pri-900
* bg-sec-100, bg-sec-500 (bg-sec), bg-sec-900
********************************************************/
@gongfan99
gongfan99 / find-hotels-within-500-meters.js
Created May 27, 2023 16:47
Find all hotels within 500 meters from my location with Node.js
import { createPool } from 'mysql2/promise'
import 'dotenv/config'
const pool = createPool({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
waitForConnections: true,
connectionLimit: 5,
@gongfan99
gongfan99 / save-embeddings-as-BLOB-in-MySQL.py
Created May 27, 2023 03:53
save embeddings as BLOB in MySQL with Python
import numpy as np
import mysql.connector
cnx = mysql.connector.connect(
host="HOST",
port=3306,
user="USERNAME",
password="PASSWORD",
database="DATABASE NAME",
pool_name="mypool",
@gongfan99
gongfan99 / save-embeddings-as-BLOB-in-MySQL.js
Last active September 17, 2023 04:49
save embeddings as BLOB in MySQL with Node.js
import { createPool } from 'mysql2/promise'
import 'dotenv/config'
const pool = createPool({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
waitForConnections: true,
connectionLimit: 5,