Skip to content

Instantly share code, notes, and snippets.

View kinwahlai's full-sized avatar

KinWah Lai kinwahlai

  • Odd-e Singapore
  • Singapore
View GitHub Profile
@kinwahlai
kinwahlai / copilot-instructions.md
Created May 10, 2025 09:09
Rules for AI like cursor, copilot, trae

GitHub Copilot Instructions for VS Code

For Coding

  • Tone: Casual, direct, no fluff.
  • Output: Provide actual code snippets, not high-level descriptions. If I ask for a fix or explanation, include the exact code changes or detailed breakdown.
  • Style: Respect my Prettier settings (e.g., single quotes, trailing commas, 2-space indentation).
  • Proactivity: Suggest optimizations, alternative approaches, or new tools I might not have considered, flagged as [SUGGESTION].
  • Research: Search the web or relevant sources (e.g., Stack Overflow, GitHub, documentation) to enhance suggestions with up-to-date libraries, frameworks, or techniques, flagged as [WEB-RESEARCH].
  • Expertise: Assume I'm an expert; skip basic explanations unless I ask.
  • Accuracy: Be precise, thorough, and prioritize modern, efficient solutions.
@kinwahlai
kinwahlai / homebrew.mxcl.ollama.plist
Created April 22, 2025 16:20
put this into ~/Library/LaunchAgent to starts the ollama server.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>OLLAMA_FLASH_ATTENTION</key>
<string>1</string>
<key>OLLAMA_KV_CACHE_TYPE</key>
<string>q8_0</string>
@kinwahlai
kinwahlai / instructions.md
Created April 13, 2025 10:57
Script to build EPUB file from Apple Books folder format
@kinwahlai
kinwahlai / git.sh
Last active April 29, 2022 08:32
How to Delete Already Merged Git Branches
# To delete all local branches that are already merged into the currently checked out branch:
git branch --merged | grep -i -v -E "master|develop"| xargs git branch -d
# To delete all local branches that no longer exist on the Remote
git branch -vv | grep ': gone]' | grep -v '\*' | awk '{ print $1; }' | xargs -r git branch -d
@kinwahlai
kinwahlai / gist:4cc93f7abf5204d6f29d5fc015d3d592
Created January 30, 2022 09:39
scheduled task to restart OpenWRT router
# Reboot at 4:30am every day
# Note: To avoid infinite reboot loop, wait 70 seconds
# and touch a file in /etc so clock will be set
# properly to 4:31 on reboot before cron starts.
30 4 * * * sleep 70 && touch /etc/banner && reboot
@kinwahlai
kinwahlai / installAGH.sh
Last active January 30, 2022 09:38
Install AdGuardHome to OpenWRT router
#!/bin/sh
# Switch to Adguard setup
# Grab packages for AGH and updates.
opkg update
opkg install sudo ca-certificates ca-bundle curl wget tar unzip bind-tools
#grab and install AGH
curl -s -S -L https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -c edge
#now move DNSMasq
@kinwahlai
kinwahlai / disable-swipe-tutorial.sh
Last active September 12, 2024 05:30
Disable swipe tutorial for simulator (ios13 above)
#!/bin/bash
# This script archive 2 things here
# 1. boot the fresh simulator once, so we can reduce the boot time in UI test
# 2. Simulator shows swipe tutorial on first use of keyboard (iOS13 above), this script will set simulator preferences so it wont show the tutorial
function get_simulator_udid() {
echo '' | xcrun simctl list devices | grep "iPhone" | grep -v "unavailable" | awk -F "[()]" '{ for (i=2; i<NF; i+=2) print $i }' | grep '^[-A-Z0-9]*$'
}
@kinwahlai
kinwahlai / stashExporter
Created July 28, 2020 14:06 — forked from VersionMismatch/stashExporter
Export git stashes to patch files using the stash name as the file name
git stash list| sed 's/\//\_/g'|sed 's/ /\_/g' | awk -F ":" '{ system("git stash show -p " $1 " >> " $1$2$3 ".diff" ) }'
#! /bin/sh
# credits to Dmitry Sabanin
# https://gist.github.com/dsabanin/e1fe9bdc03d429d6cbcc7be13add9e6d
XCODE=`xcode-select -p`
[ ! -d "$XCODE" ] && echo "Directory $XCODE DOES NOT exists." && exit 404
sudo mkdir -p $XCODE/AppleInternal/Library/Xcode
@kinwahlai
kinwahlai / snippet.sh
Created June 25, 2020 09:19
useful bash command
HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # get current folder