Tags #php #kotlin #bash #go #sql #rust #typescript #html #java #python #files #utils #strings #http #concurrency #async #json #arrays #security #types #crypto #database #dates #format
Kotlin Coroutines — suspend Function Basics
`suspend fun` can be paused and resumed without blocking a thread. Call only from another `suspend` function or a coroutine builder (`launch`, `runBlocking`, `async`).
Kotlin withContext — Switching Dispatchers
`withContext(dispatcher)` suspends the calling coroutine, runs the block on the given dispatcher, returns the result. Use `Dispatchers.IO` for blocking I/O, `Default` for CPU work, `Main` for UI updates.
SQL NULLS FIRST / NULLS LAST
Control where NULLs land in an `ORDER BY`. PostgreSQL/Oracle default NULLs to LAST in ASC, FIRST in DESC; MySQL/SQL Server flip it. Be explicit if it matters.
Kotlin val vs var — Prefer Immutability
`val` is read-only (can't reassign the reference); `var` is mutable. Default to `val` everywhere — Kotlin's style guide recommends it, and a Compiler warning fires if a `var` is never reassigned.
Go Variadic Functions
`...T` in the last parameter slot accepts zero or more T values. Pass a slice by suffixing with `...` to spread it. Used everywhere from `fmt.Println` to custom builders.
Kotlin Nullable Types — String? and the ? Operator
Kotlin distinguishes `String` (never null) from `String?` (may be null) in the type system. The compiler refuses to compile code that could deref a possibly-null value — the famous "no more NullPointerException" feature.
Kotlin Lambdas and Function Types
Kotlin functions are first-class values. A lambda is `{ args -> body }`; its type is `(InputTypes) -> ReturnType`. Single-argument lambdas can use the implicit `it` parameter.
Go Pointers — When and Why
Use pointers when you want to mutate the callee's value, share a large struct without copying, or distinguish "no value" via nil. Go has no pointer arithmetic — much safer than C.
Kotlin when Expressions — Powerful switch
Kotlin's `when` is an expression (returns a value), supports ranges, type checks, multiple values per branch, and arbitrary boolean conditions. Replaces nested if/else AND traditional switch.
Go defer / panic / recover
`defer` runs a statement when the enclosing function returns — LIFO order. `panic` aborts; `recover` (inside a deferred func) catches a panic and converts it back to a normal return. Use sparingly.
Go Methods and Receivers
Methods are functions with a receiver argument. Use pointer receivers when you mutate, when the struct is large, OR for consistency (mixing pointer + value receivers on the same type is a common bug source).
Go Multiple Return Values + Named Returns
Go functions can return multiple values — most idiomatically a `(result, error)` pair. Named returns let you document the meaning of each value AND enable naked returns in short functions.
HTML Picture Element — Art Direction
`<picture>` lets you serve DIFFERENT images at different breakpoints — not just different sizes of the same crop. Perfect for a wide desktop banner that becomes a square mobile poster.
Rust Move vs Borrow — the Core Rule
Rust's ownership model: passing a value transfers ownership (move); taking a `&value` lets you read without taking ownership; `&mut value` lets you modify without taking ownership. Only one mutable borrow OR many immutable borrows at a time.
Rust Slice Pattern: Borrow Without Copy
A slice (`&[T]`) is a borrowed view into a contiguous sequence. Pass `&v[..]` or just `&v` instead of `v.clone()` when the function only needs to read.
Rust Trait with Default Methods
A trait can supply default implementations — implementors override only the bits they need. Like abstract base classes, but with structural typing and zero runtime cost.
TypeScript useMediaQuery — Responsive Hook
Subscribe to a CSS media query (e.g. dark mode, viewport size) from React. Re-renders when the match changes. SSR-safe — returns `false` on the server.
Python TypedDict for JSON API Shapes
When you parse JSON, you want types — but creating a class for every payload is overkill. TypedDict gives you the static-checking benefits without the runtime overhead, and `total=False` marks every field optional.