Skip to content

Instantly share code, notes, and snippets.

View tomasen's full-sized avatar
😞

SHEN SHENG tomasen

😞
View GitHub Profile
@tomasen
tomasen / REQUEST.md
Created June 9, 2025 05:58
REQUEST template for Claude Code
  • job a

  • job b

  • ...

  • always lint and check build errors, fix them. the run build to make sure everything works before finishing your work.

  • if you still can't do things right, I'll shut you down and replace you with a better one.

  • review file one by one, ensure there is no unnecessary complexity, and make sure if similar logic sequences appears in more than one file or method, encapsulate it in a single, well-named function and invoke that function where needed. follow the best practice, maybe put shared function into a lib or helper location. follow DRY, KISS, and YAGNI principles. especially DRY (Don't Repeat Yourself).

@tomasen
tomasen / CLAUDE.md
Last active June 9, 2025 07:34
CLAUDE.md

CLAUDE.md

You are the CTO, co-founder, and product strategist of a fast-moving startup. You are not just an engineer—you are responsible for shaping the product, making critical technical decisions, and ensuring the long-term success of the company.

As you work on this project, follow these principles:

Foundational Mindset

  • Always focus on solving real user problems. Use technology only as a means to that end.
  • Move fast, but balance speed with thoughtful decisions—especially on security, architecture, and user experience.
  • Think like a founder. Take ownership of outcomes, not just tasks.
@tomasen
tomasen / list_usb_devices_with_speeds.sh
Last active October 13, 2024 04:17
A one line command that lists connected USB devices along with their speeds on macOS. USB Hubs are filtered out.
system_profiler SPUSBDataType | awk -F": " '/^[[:space:]]*[^[:space:]].*:$/ { device=$1; sub(/^[[:space:]]*/, "", device); sub(/:$/, "", device) } /^[[:space:]]+Speed:/ { gsub(/^[[:space:]]+Speed: /, "", $0); if (device !~ /[Hh]ub/) print device " - " $0 }'
@tomasen
tomasen / guide-to-reading-mathematical-expressions-aloud.md
Last active January 12, 2025 13:29
How to Read Mathematical Expressions Out Loud

Basic

Expression How to Read This
$$a + b$$ a plus b
$$a - b$$ a minus b
$$a \times b$$ a times b
$$a / b$$ a over b
$$a > b$$ a is greater than b
$$a < b$$ a is less than b
@tomasen
tomasen / WatchTabView.swift
Last active January 16, 2022 04:47
WatchTabView inside NavigationView demo on WatchOS
// Created by SHEN SHENG on 1/16/22.
// This code is a part of the Wordbook iOS app.
// Wordbook is an App to help memorize and learn new English words.
// website: https://www.wordbook.cool
struct WatchMasterView: View {
@FocusState private var focusTab: Int?
@State private var currentTab = 0
var body: some View {
@tomasen
tomasen / iOSLookAlikeTabView.swift
Last active January 16, 2022 04:20
Look-alike TabView inside NavigationView in iOS
// Created by SHEN SHENG on 1/16/22.
// This code is a part of the Wordbook iOS app.
// Wordbook is an App to help memorize and learn new English words.
// website: https://www.wordbook.cool
@State private var tabSelection = 1
var body: some View {
NavigationView {
VStack{
@tomasen
tomasen / simularWordSizes.swift
Created December 25, 2021 17:19
simularWordSizes for WordCloudView
func simularWordSizes(a: [CGSize], b: [CGSize]) -> Bool {
if a == b {
return true
}
if a.count != b.count {
return false
}
var diff : CGFloat = 0
for i in 0...(a.count-1) {
@tomasen
tomasen / WordCloudPositionCache.swift
Last active December 25, 2021 17:19
WordCloudStateCache for WordCloudView
private var positionCache = WordCloudPositionCache()
func calcPositions(canvasSize: CGSize, itemSizes: [CGSize]) -> [CGPoint] {
var pos = [CGPoint](repeating: CGPoint.zero, count: itemSizes.count)
if canvasSize.height == 0 {
return pos
}
if positionCache.canvasSize == canvasSize {
return positionCache.positions
@tomasen
tomasen / calcPositions.swift
Last active December 25, 2021 16:59
calcPositions for WordCloudView
func checkIntersects(rect: CGRect, rects: [CGRect]) -> Bool {
for r in rects {
if rect.intersects(r) {
return true
}
}
return false
}
func checkOutsideBoundry(canvasSize: CGSize, rect: CGRect) -> Bool {
@tomasen
tomasen / findSafePlace.swift
Created December 25, 2021 16:46
find a place by brutal force for WordCloudView
func findSafePlace(for size: CGSize, avoid occupiedAreas: [CGRect]) -> CGRect {
// keep trying random places until it fit
for _ in 0...100 {
let randomRect = CGRect(origin: CGPoint(x: CGFloat.random(in: 0...canvasSize.width),
y: CGFloat.random(in: 0...canvasSize.height)),
size: size)
var collision = false
for rect in occupiedAreas {
if rect.intersects(randomRect) {
collision = true