Hasty Briefsbeta

Bilingual

Small programming tricks

5 hours ago
  • Small nuggets of programming knowledge can greatly boost productivity without needing deep supporting knowledge.
  • Examples include using fzf for fuzzy command history search, atuin for SQLite-based history, and per-directory history.
  • SELECT without FROM can be used in databases to test functions or check how operators work.
  • EXPLAIN ANALYZE in PostgreSQL/MySQL runs queries to provide detailed performance insights.
  • Regular expression word boundary assertions (\b) simplify matching word beginnings/ends.
  • Using logarithms in metrics (e.g., Math.floor(Math.log10())) helps understand value distributions.
  • Modern JS features like Array.flatMap, Object.entries, and Promise.withResolvers are useful.
  • In Node.js, reusing an https.Agent can reduce latency by keeping connections open.
  • git log -S or -G (pickaxe) finds commits that added/removed/moved a string, ideal for old codebases.
  • git checkout - switches back to the previous branch, akin to cd -.
  • Glob patterns like **/*.md can replace many find commands, with shopt -s globstar in bash.
  • Ripgrep (rg) is recommended over grep, ack, or ag for better performance.
  • Enable zsh's advanced autocompletion by setting FPATH and running compinit.
  • Company-specific knowledge (e.g., debugging tips, who to ask, manual scaling triggers) is also high-leverage.
  • Sharing one trick daily on Slack (technical and company-specific) helped engineers, sparking useful discussions.