Skip to content

Instantly share code, notes, and snippets.

@gengwg
gengwg / itemgetter.md
Created May 10, 2025 00:55
python itemgetter with examples.

The itemgetter function from Python's operator module creates a callable that retrieves items from objects using indices (for sequences like lists/tuples) or keys (for mappings like dictionaries). It is efficient and commonly used with functions like sorted(), max(), and min() for clean, readable code.

Importing itemgetter

from operator import itemgetter

Examples

  1. Basic Usage with a List
@gengwg
gengwg / scale2025.md
Created May 7, 2025 03:09
notes for the **System & Reliability @scale Conference**, structured for clarity and impact:

Core Principles for Scaling Systems

  1. Embrace Failure as Inevitable

    • Design for graceful degradation, automatic recovery, and chaos testing.
    • Example: "Like brushing your teeth" – build resilience into daily workflows.
  2. Simplify to Scale

    • Zoom out: Prioritize high-impact components.
    • Declutter services: Eliminate redundant systems to reduce failure points.
  3. Co-Design Physics and Software

JP MORGAN
- trader hdedge
- quant research
software developer
1. large book index words/pages
- indexs wors page # increasing order
O(N)
Sorting (ONlgN)
list scan pages no need to sort-
@gengwg
gengwg / pip-timeline.md
Created April 25, 2025 07:23
Sharing as a data point for people who are going through the same experience/curious what it's like.

Sharing as a data point for people who are going through the same experience/curious what it's like.

Timeline:

google

  • Aug 9 - Got a calendar event titled "ER Connect". This was where they mentioned that I had to choose between PIP or Severance.
  • Aug 11 - Deadline for signing Acceptance. Signed and accepted the package a few minutes before the deadline.
  • Aug 19 - Official last day of work. Lose access to workplace, email, office buildings.

Here's how to undo your last commit (that accidentally included __pycache__) and prevent it from being tracked in the future:


1. Undo the Last Commit (But Keep Changes)

git reset --soft HEAD~1
  • This will:
    • Remove the commit (fd8b15c)
@gengwg
gengwg / change-vscode-run-python-shortcut.md
Created April 23, 2025 17:43
Change the Shortcut for "Run Python File in Terminal" in VSCode
  1. Open VS Code Keyboard Shortcuts

    • Press Ctrl + K then Ctrl + S (Windows/Linux)
    • OR Cmd + K then Cmd + S (Mac)
      (This opens the keyboard shortcuts editor.)
  2. Search for the Python Run Command

    • Type in the search bar:
      Python: Run Python File in Terminal
      
@gengwg
gengwg / google-levels.txt
Created April 22, 2025 20:03
Software Engineer Career Ladder at Google
Software Engineer Career Ladder at Google
Here’s an understanding of the software engineer career ladder at Google:
Software Engineer I (Level 2)
SWE-I refers to a fresh out of college software engineer or an intern still pursuing a four-year bachelor’s degree in an engineering program.
Software Engineer II (Level 3)
Google entry-level software engineer is a designated Level 3 coding engineer with an undergraduate degree in a computer-related field. It is also common for an SWE-II to have a Master’s degree. However, since they possess 0 to 1 year of industry experience, they are assigned an entry-level position. On average, they earn a base salary of $130,041 per year.
Software Engineer III (Level 4)
@gengwg
gengwg / google_leetcode.txt
Created April 22, 2025 20:03
google leetcode
388 Longest Absolute File Path 34.7% Medium
340 Longest Substring with At Most K Distinct Characters 38.5% Hard
308 Range Sum Query 2D - Mutable 19.8% Hard
418 Sentence Screen Fitting 27.2% Medium
361 Bomb Enemy 38.0% Medium
281 Zigzag Iterator 48.3% Medium
298 Binary Tree Longest Consecutive Sequence 39.8% Medium
425 Word Squares 41.7% Hard
346 Moving Average from Data Stream 57.4% Easy
163 Missing Ranges 27.7% Medium
@gengwg
gengwg / if-vs-etf.md
Created April 18, 2025 03:25
differences between index funds and ETFs

Here’s a clear breakdown of the differences between index funds and ETFs (even when tracking the same stocks), along with guidance on choosing the best option for your goals:


Key Differences

Feature Index Fund (Mutual Fund) ETF (Exchange-Traded Fund)
Trading Priced once daily (after market close). Traded like stocks (intraday pricing).
Minimum Investment Often requires $1k–$3k initial buy-in. Buy any number of shares (no minimum).
Expense Ratios Slightly higher (e.g., 0.04–0.15%). Often lower (e.g., 0.03–0.10%).
@gengwg
gengwg / portfolio-45.md
Created April 17, 2025 18:26
Balanced Portfolio Allocation for Investors Aged 40–50: Optimizing Growth and Stability with SCHO, BND, VTI, and FZILX

For a 40–50-year-old investor with a moderate risk tolerance and a focus on balanced growth and capital preservation, here’s a recommended portfolio allocation using your selected funds:


Suggested Allocation

Asset Class Fund(s) Percentage Rationale
Domestic Stocks VTI 40% Core U.S. equity exposure for growth and diversification.
International Stocks FZILX 20% Diversifies globally, capturing growth in developed/emerging markets.
Broad Bonds BND 30% Stabilizes the portfolio with investment-grade U.S. bonds (mix of durations).