Skip to content

Instantly share code, notes, and snippets.

View nicksonthc's full-sized avatar
💭
人生是"一无所有"到"一无所有"的过程 , I ship app that i can't fix

Nickson Tan Hoo Chuan nicksonthc

💭
人生是"一无所有"到"一无所有"的过程 , I ship app that i can't fix
View GitHub Profile
@nicksonthc
nicksonthc / costing.md
Last active August 12, 2025 06:53
software-pricing.md

Example Pricing Structure

Item First Order Repeat Order
NRE (one-time software development) RM 120,000
Software replication fee RM 15,000 – RM 30,000 (10-30%)
Installation & commissioning Included RM x/day
Feature enhancement (Engineering Days) × (Daily Rate)

@nicksonthc
nicksonthc / sqlmodel-sqlalchemy-field.py
Created August 1, 2025 09:04
Common Sqlmodel Field Options
from sqlmodel import SQLModel, Field
from sqlalchemy import Column, String, Integer, DateTime, Enum as SQLEnum
from datetime import datetime
from enum import Enum
class StationStatus(str, Enum):
AVAILABLE = "available"
BUSY = "busy"
MAINTENANCE = "maintenance"
@nicksonthc
nicksonthc / cloudflared.md
Last active July 21, 2025 01:54
home-pc-reverse-proxy-be
  1. Malaysia Unifi/Time Traditional Port Forwarding (Doesn't Work with CGNAT): Client Browser → Internet → ISP CGNAT → Your Router → Your PC
  • Client tries to connect TO your home PC
  • CGNAT blocks this because multiple customers share the same public IP
  • Your router can't receive the connection
  1. Cloudflare Tunnel (Works with CGNAT):
  • Your PC → ISP CGNAT → Internet → Cloudflare Edge → Vercel
@nicksonthc
nicksonthc / ecr-describe.sh
Last active July 9, 2025 04:31
aws-ecr-describe-image-sort-desc
aws ecr describe-images \
--repository-name cube-ihub-tc-web \
--query "sort_by(imageDetails,&imagePushedAt)[::-1].[imageTags[0], imagePushedAt]" \
--output table
@nicksonthc
nicksonthc / nash-equilibrium-concepts.R
Created March 23, 2025 14:51
nash equilibrium concepts
# Load required libraries
library(ggplot2)
library(ggrepel)
# 1. Uniqueness: Visualizing multiple Nash equilibria
game_data <- data.frame(
Strategy_A = c("Up", "Down", "Up", "Down"),
Strategy_B = c("Left", "Left", "Right", "Right"),
Payoff_A = c(3, 2, 1, 4),
Payoff_B = c(3, 4, 2, 1)

Strictly Dominant Strategy (严格占优策略) Definition A strategy is strictly dominant if, no matter what the opponent chooses, it always yields a better outcome than any other strategy.

Chinese: 一个策略如果在任何情况下——不管对手选择什么——都能给某一方带来比其他策略更好的结果,那么这个策略就是严格占优策略。

Memory Aid Chinese: 不管对手咋样,我这招永远最强。 English: Picture you’re in a game and you’ve got a “super move.” No matter what your opponent picks, your “super move” always wins big.

@nicksonthc
nicksonthc / tech_top_news_2024.py
Created December 31, 2024 15:50
2024 Tech Top News Headlines
[
"Apple Unveils Vision Pro Augmented Reality Headset, Pioneering New AR Era",
"Generative AI Technologies Revolutionize Industries from Content Creation to Software Development",
"U.S. Government Moves Toward Potential TikTok Ban Over National Security Concerns",
"Nvidia Leads the AI Boom with Record Sales and Innovations in GPU Technology",
"U.S. CHIPS Act Fuels Semiconductor Industry Growth and Innovation",
"New Quantum Computing Breakthrough Could Revolutionize Cryptography and AI",
"Leading Tech Firm Reveals Groundbreaking Foldable Smartphone with Next-Gen Display Technology",
"Countries Worldwide Implement Stricter Data Privacy Laws Amid Growing Cybersecurity Concerns",
"Web3 Technology Gains Momentum with Increased Adoption in Finance, Gaming, and Supply Chain",
@nicksonthc
nicksonthc / fastapi-redis.py
Created April 11, 2024 16:12
FastAPI with asyncio Redis and Lifespan Example
from contextlib import asynccontextmanager
from datetime import datetime
from fastapi import FastAPI, Request
import fastapi
from fastapi.datastructures import State
from fastapi.responses import JSONResponse
import redis.asyncio as redis
class Redis:
redis_client: redis.Redis = None
@nicksonthc
nicksonthc / string_to_date.py
Created October 19, 2022 08:55
Python string year month day to date object
format = '%Y-%m-%d %H:%M:%S'
strFrom = f"2022-10-10 00:00:00"
strTo = f"2022-10-10 23:59:59"
dtFrom = datetime.strptime(strFrom,format)
dtTo = datetime.strptime(strTo,format)
@nicksonthc
nicksonthc / axios_get_with_params.js
Last active October 19, 2022 08:56
Axios Get Request With Params
// Client - Axios Get Request With Params
const host = '127.0.0.1:5000/test'
const queryParams = {
para1: test1,
para2: test2,
para3: "desc",
};