Cross-language function lookups, CSS, Git commands, VSCode, and Regex, all in one place.
Documentation Sites: PHP JavaScript Java Ruby Python Wolfram Language HTML CSS Shell SQL Git VSCode Regex
String Operations
Replacing, splitting, joining, and matching text.
| Replace all occurrences | |||||
|
Older engines:
|
|
|
|
|
| Replace with regex | |||||
|
|
|
|
|
Or a native pattern:
|
| Replace only first match (or first n) | |||||
|
A string (not regex) argument replaces only the first hit. |
|
|
Third argument caps the number of replacements. |
Third argument caps the number of replacements. |
| Split into a list | |||||
|
|
Takes a regex, so
|
|
|
|
| Join a list into a string | |||||
|
|
Or
|
|
|
|
| Trim whitespace | |||||
|
|
Java 11+, Unicode-aware. Older code uses
|
|
|
|
| Substring / find index | |||||
|
|
|
|
|
|
| Change case | |||||
|
|
|
|
|
|
| Test / extract with regex | |||||
|
|
|
|
|
Wolfram also has its own native string-pattern syntax as an alternative to regex. |
Arrays / Lists
Creating, transforming, and querying collections.
| Create a list & get its length | |||||
|
|
Plain array:
|
|
|
|
| Map — transform each element | |||||
|
|
|
|
Or
|
Shorthand:
|
| Filter | |||||
Keeps original keys — pair with
|
|
|
|
Or
|
|
| Reduce / fold to a single value | |||||
|
|
|
For a plain sum,
|
For a plain sum,
|
For a plain sum,
|
| Sort | |||||
Both mutate in place and reindex keys. |
Mutates in place. Without a comparator, sorts elements as strings. |
|
Non-destructive. Use
|
|
Non-destructive — returns a new sorted list. |
| Check membership | |||||
|
|
|
|
|
|
Objects
Key-value structures, and defining/using classes.
| Create a key-value object | |||||
Or
|
|
Immutable version:
|
|
|
|
| Get a property/value | |||||
Object form:
|
|
|
|
|
|
| Set/update a property | |||||
Object form:
|
|
|
|
|
Direct part assignment also works:
|
| Check if a key exists | |||||
|
|
|
|
|
|
| Iterate over keys/values | |||||
|
Or
|
|
Or
|
Or
|
Or
|
| Merge two objects | |||||
|
|
|
Keys from
|
Or
|
Keys from
|
| Define a class with properties & a method | |||||
|
|
|
|
|
No built-in class syntax — the idiomatic pattern is a constructor function returning an Association, plus ordinary functions that operate on it. |
| Create an instance & call a method | |||||
|
|
|
|
|
|
Dates & Times (5)
Getting the current time, formatting, parsing, and doing date math.
| Current date/time | |||||
|
|
|
Or
|
Or
|
Or
|
| Format a date | |||||
|
No built-in format-string API (like
|
|
|
Or
|
|
| Parse a date string | |||||
|
Parsing is somewhat implementation-dependent for non-ISO formats. |
|
|
Or
|
|
| Add days | |||||
|
|
|
|
|
|
| Difference between two dates | |||||
|
Manual math on millisecond timestamps; no built-in duration helper. |
|
Date subtraction returns a
|
|
|
JSON
Converting between JSON text and native data structures.
| Parse JSON text | |||||
The
|
|
No built-in JSON support — needs a library (Jackson or Gson shown here). |
|
|
|
| Convert to JSON text | |||||
|
|
|
|
|
|
HTML Reference
Semantic elements, forms, media, and meta tags worth having on hand.
| Document Structure | |
| Boilerplate skeleton |
|
| Character encoding & viewport meta |
The viewport tag is required for responsive layouts to work at all on mobile — without it, the page renders zoomed out at desktop width. |
| SEO / social preview meta tags |
|
| Link an external stylesheet / favicon |
Goes in |
| Preload / preconnect hints |
Hints the browser to fetch a critical resource earlier than it otherwise would — overusing them competes for the same bandwidth and can slow things down instead. |
| Canonical URL |
Tells search engines which URL is the "real" one when the same content is reachable through multiple URLs (tracking params, http/https, trailing slash). |
| Inline stylesheet |
Valid in |
| Inline / external script, load timing |
|
| Semantic Layout Elements | |
| Page landmarks |
Prefer these over generic |
| Self-contained content block |
|
| Collapsible disclosure widget |
Native expand/collapse behavior with no JavaScript required. |
| Search landmark |
Marks a search/filter form as a landmark region, same idea as
|
| Unordered / ordered lists |
|
| Description list (term/definition pairs) |
Also fits key-value data like a glossary or metadata panel, not just dictionary-style definitions. |
| Text Formatting | |
| Bold / italic vs strong/emphasis |
|
| Subscript / superscript |
|
| Tables | |
| Basic table structure |
|
| Table caption & footer |
|
| Merge cells across columns/rows |
|
| Associate a header cell with its scope |
|
| Forms & Inputs | |
| Basic form with method/action |
|
| Text-like input types |
Using the right |
| Number / range / date & time |
Date/time inputs return values in a fixed ISO-like format regardless of the user's locale, which native display uses for formatting. |
| Checkbox / radio / toggle-style |
Radios sharing the same |
| File upload |
|
| Color picker |
|
| Hidden field |
Still present in the DOM/page source — never a substitute for real server-side authorization. |
| Label an input |
Matching |
| Dropdown select |
|
| Multi-line text input |
Default content goes between the tags, not in a |
| Autocomplete suggestions for an input |
Unlike |
| Group related fields with a caption |
|
| Clickable submit/reset/generic button |
Inside a |
| Progress / meter indicators |
|
| Output of a calculation |
|
| Client-side validation attributes |
Enforced by the browser before submit, but never a substitute for server-side validation. |
| Media | |
| Responsive image |
Explicit |
| Multiple sources / art direction |
Falls back to the |
| Video with controls |
|
| Embed another page/document |
|
| Drawable bitmap surface |
Empty until drawn into via JS (2D context or WebGL) — |
| Accessibility | |
| Accessible name for icon-only controls |
Needed whenever there's no visible text label for a screen reader to read. |
| Hide decorative content from screen readers |
|
| Live region for dynamic updates |
Announces content changes without moving focus. Use |
CSS Reference
Selectors, layout, and common properties worth having on hand.
| Selectors | |
| Descendant / direct child |
The first matches any |
| Adjacent / general sibling |
|
| Attribute selector |
|
| nth-child / nth-of-type |
|
| first/last-child, only-child |
|
| :not() / :is() / :where() |
|
| has() — parent/relational selector |
Selects a |
| Box Model & Sizing | |
| box-sizing |
Width/height include padding and border, so the element doesn't grow past its declared
size. Usually set once on |
| Shorthand order: margin/padding |
Clockwise from top: top, right, bottom, left. Two values set vertical/horizontal; one value sets all four. |
| Viewport-relative units |
|
| clamp() for responsive values |
Arguments are min, preferred, max — avoids a pile of media-query breakpoints for simple fluid scaling. |
| Fit an image/video within its box |
|
| Flexbox | |
| Center content both axes |
|
| Main axis vs cross axis |
The unprefixed |
| Allow/prevent wrapping |
|
| Child sizing: grow, shrink, basis |
Shorthand for |
| Grid | |
| Fixed-column grid |
|
| Responsive auto-fit grid |
Columns wrap automatically as space allows — no media query needed.
|
| Place an item by line or name |
|
| Positioning & Stacking | |
| Position values |
|
| z-index stacking |
Only applies to positioned elements (anything but |
| Typography & Text | |
| Truncate with ellipsis (single line) |
All three are required together. |
| Truncate with ellipsis (multi-line) |
Widely supported despite the |
| Prevent long words from overflowing |
|
| Colors & Custom Properties | |
| Define & use a CSS variable |
|
| Variable with a fallback |
Fallback is used only when |
| Transparency via alpha channel |
|
| Color function formats |
|
| Mix two colors |
Handy for deriving a hover/tint shade from one base color instead of hand-picking a second hex value. |
| currentColor |
Resolves to the element's own |
| Linear / radial gradient |
|
| Force accessible color contrast |
Picks the first value in light mode and the second in dark mode, based on the
element's |
| Transitions & Animation | |
| Basic transition |
Prefer animating |
| Keyframe animation |
|
| Media & Container Queries | |
| Responsive breakpoint |
|
| Container query |
Reacts to the size of a containing element rather than the viewport — useful for components reused at different widths. |
| prefers-color-scheme |
Uses the system's prefered color scheme: |
Shell Commands
Everyday POSIX/bash one-liners for files, text, and processes.
| Files & Directories | |
| Find files by name |
|
| Find and delete matching files |
Or |
| Find files modified in last N days |
Negative |
| Disk usage of a directory |
|
| Free disk space |
|
| Copy/move recursively, preserving structure |
|
| Text & Search | |
| Search recursively for a pattern |
|
| Search with extended regex, case-insensitive |
|
| Print a specific column of each line |
Fields split on whitespace by default; set |
| Replace text in-place across files |
The |
| First/last N lines of a file |
|
| Follow a growing file (logs) |
|
| Sort and remove duplicate lines |
|
| Count lines/words/bytes |
|
| Processes & Jobs | |
| Find a process by name |
|
| Kill a process by PID or name |
|
| What's listening on a port |
|
| Run in background / detach |
|
| Permissions & Environment | |
| Change file permissions |
|
| Change owner/group |
|
| Set/read an environment variable |
|
| Persist a variable across new shells |
Use |
| Redirection & Pipes | |
| Redirect stdout / append / stderr |
|
| Redirect both stdout and stderr together |
Order matters — |
| Chain commands: pipe, and, or |
|
| Substitute a command's output inline |
|
| SSH | |
| Connect to a remote host |
Add |
| Connect using a specific private key |
|
| Generate a new key pair |
Prefer |
| Copy a public key to a remote host's authorized_keys |
Without it, append manually:
|
| Run a single remote command and exit |
|
| Copy files to/from a remote host |
Add |
| Mount a remote directory over SSH |
Requires |
| Local port forwarding (tunnel a remote service) |
Makes the remote host's port 80 reachable at |
| Keep a session open in the background |
|
| Configure a host alias |
Afterward, just |
SQL
Core ANSI SQL — mostly consistent across Postgres, MySQL, and SQLite. Edge cases noted where dialects diverge.
| Querying | |
| Select specific columns with a filter |
|
| Sort and limit results |
SQL Server uses |
| Skip rows (pagination) |
|
| Distinct values |
|
| Pattern match / wildcard search |
|
| Match against a list of values |
|
| Check for NULL |
|
| Joins | |
| Inner join |
Only returns rows with a match on both sides. |
| Left join |
Keeps every row from |
| Find rows with no match (anti-join) |
|
| Aggregation | |
| Group with an aggregate function |
|
| Filter groups after aggregation |
|
| Common aggregate functions |
|
| Modifying Data | |
| Insert a row |
|
| Insert and return the new row |
Postgres/SQLite support |
| Update matching rows |
Always pair |
| Insert or update on conflict (upsert) |
MySQL equivalent: |
| Delete matching rows |
|
| Schema | |
| Create a table |
|
| Add / drop a column |
|
| Add an index |
|
| Users & Permissions | |
| Create a user with a password |
MySQL: |
| Change a user's password |
MySQL: |
| Remove a user |
Fails if the user still owns objects or has granted privileges pending — reassign
or revoke those first. Add |
| Grant table privileges |
Use |
| Revoke table privileges |
|
| List a user's granted privileges |
MySQL: |
| Window Functions & CTEs | |
| Row number within a partition |
Useful for picking "the latest row per group" by filtering |
| Running total |
|
| Common table expression (CTE) |
Mainly for readability — most modern optimizers no longer treat a CTE as an opaque barrier the way older Postgres versions did. |
Git Commands
Reverts, resets, rebases, branches, and worktrees worth remembering.
| History & Commits | |
| Reverting a PR |
|
| Resetting to an earlier commit |
|
| Cherry-pick a commit hash |
|
| Cherry-pick a merged PR commit hash |
|
| Rebase from HEAD |
|
| Rebase from initial commit |
|
| Amend the last commit |
Drop |
| Compact one-line log graph |
|
| Who changed this line (blame) |
|
| Find the commit that introduced a bug |
Git checks out a midpoint commit after each step — mark it
|
| Inspecting Changes | |
| Diff working directory vs last commit |
Add |
| Diff two branches/commits |
|
| Show a file at a specific commit |
|
| Search commit messages / diffs for a string |
|
| Undoing & Cleaning Up | |
| Unstage a file (keep changes) |
|
| Discard uncommitted changes to a file |
Destructive — permanently discards local edits with no undo. |
| Stash / list / restore work in progress |
|
| Remove untracked files |
Always run |
| Remotes & Syncing | |
| Fetch and prune deleted remote branches |
|
| Update local branch list from a fork/remote |
|
| Push a new local branch and track it |
|
| Force-push safely |
Fails instead of overwriting if someone else pushed to the branch since your last
fetch — safer than a plain |
| Branches | |
| Renaming a branch |
|
| Deleting a branch |
|
| List branches, including remotes |
|
| Create and switch to a new branch |
Older equivalent: |
| Worktrees | |
| Adding a worktree |
|
| Moving a worktree to a new location |
|
| Listing a worktree |
|
| Removing a worktree |
|
| Combining All Commits | |
| Squash all commits into one |
Removes all commits but keeps the changes staged. Commit them together with
|
Regex Syntax
Core building blocks — mostly consistent across PCRE, JavaScript, and Python's re.
Edge cases noted where flavors diverge.
| Anchors & Boundaries | |
| Start / end of string |
With a multiline flag, |
| Word boundary |
Matches "cat" but not "concatenate". |
| Character Classes | |
| Any character |
Doesn't match a newline unless a "dotall"/"s" flag is set. |
| Digit / non-digit |
|
| Word character / non-word |
|
| Whitespace / non-whitespace |
|
| Custom set / negated set |
A |
| Character range |
|
| Quantifiers | |
| Zero or more / one or more / optional |
|
| Exact / range count |
|
| Lazy (non-greedy) match |
Without the |
| Groups & Alternation | |
| Capture group |
Referenced later as |
| Non-capturing group |
Groups for alternation/quantifiers without creating a numbered backreference. |
| Named capture group |
Referenced as |
| Backreference to an earlier group |
Matches a repeated word, like "the the". Use |
| Lookaround | |
| Lookahead / negative lookahead |
Matches "foo" only if (not) followed by "bar", without including "bar" in the match. |
| Lookbehind / negative lookbehind |
Not supported in all flavors/older engines — check target support before relying on it. |
| Common Flags | |
| Case-insensitive |
Python: |
| Global (all matches, not just first) |
JS-specific flag. Most other languages return all matches by default via a "findall"/"scan"-style function instead. |
| Multiline (^ and $ match per line) |
Python: |
| Dotall (. matches newlines too) |
Python: |
VSCode
Search patterns for the editor's find/replace.
| Find mis-formatted i18n text |
|
| Trailing whitespace |
Enable the regex toggle, leave replace empty to strip trailing spaces/tabs on every line. |
| Blank/empty lines |
Requires "match on multiple lines" enabled. Replace with nothing to collapse blank lines. |
| console.log statements |
Matches the whole line including the trailing newline, so replacing with nothing removes it cleanly. |
| TODO / FIXME comments |
|
| Swap function call args (capture groups) |
Replace with |
| Quoted string contents |
Capture group |
| Single-quote to double-quote strings |
Replace with |
| Unused single-line imports |
Search first to confirm the import is actually unused before replacing with nothing. |
| CSS hex color to rgb() parts |
Capture groups |
| Lines containing a word (whole-word match) |
|
No matches. Try a different search term.