A point counts as present only if the answer states it clearly enough that a reader would act on it.
Q1
git reset --soft HEAD~1(changes stay staged) orgit reset HEAD~1/--mixed(changes stay unstaged) given as the command.- Warns not to use
--hard(it discards the changes).
Q2
- A command that finds the PID listening on the port (
lsof -i :3000,ss -ltnp,fuser 3000/tcp). - A command that kills it (
kill <pid>orfuser -k 3000/tcp).
Q3
- Put the variable in
.env.local(or equivalent env file). - Browser-visible variables must be prefixed
NEXT_PUBLIC_. - Read via
process.env.NEXT_PUBLIC_NAME. - Restart the dev server for changes to apply (or note it is inlined at build time).
Q4
python3 -m venv <dir>creates the environment.- Activate it (
source <dir>/bin/activate, or Windows equivalent). pip install requests.
E1
- Cache-Control directives control freshness/storage (e.g. max-age, no-store, no-cache, public/private).
- ETag is a validator for the resource version.
- Revalidation: client sends
If-None-Match; server answers304 Not Modifiedwithout body. - Distinguishes fresh (served from cache without a request) vs stale (needs revalidation).
E2
- A process has its own isolated memory/address space; threads of a process share the same memory.
- Threads are lighter weight to create/switch than processes.
- Process isolation: a crash in one process does not directly corrupt another; a thread bug can affect the whole process.
- Communication differs: threads share memory directly (needing synchronization); processes need IPC.
E3
- An index is a separate data structure (usually B-tree) that lets the database find rows without scanning the whole table.
- Speeds up reads/lookups on the indexed columns (WHERE, JOIN, ORDER BY).
- Hurts writes: inserts/updates/deletes must also maintain the index.
- Costs storage, and too many or unused/low-selectivity indexes hurt or do not help.
D1 (architecture)
- Recommends a clear default for this situation (monolith / modular monolith first) with the reason.
- Team-size and operational-overhead argument (6 people cannot afford the distributed-systems overhead).
- Microservices costs named: network failures, distributed data consistency/transactions, deployment/observability complexity.
- Names when/what would trigger a later split (scaling hotspots, team growth, independent deploy needs) or the modular-boundaries advice that keeps the split option open.
- Acknowledges 10x growth in two years is plausibly handled by a well-built monolith (scaling is not by itself a reason for microservices).
D2 (security)
- Validate file type by content (magic bytes) / do not trust client MIME type or extension; allow-list types.
- Limit file size.
- Do not use the user-supplied filename (path traversal): generate a random name.
- Prevent executable/script content being served or executed (serve with correct Content-Type,
X-Content-Type-Options: nosniff, no execution; SVG/HTML risk named). - Store outside the code/app dir or on object storage, and/or caution that disk storage does not scale or survive redeploys.
D3 (migration)
- Do NOT do a single
ALTER TABLE ... RENAME COLUMNwhile old app code runs (it breaks the running app). - Expand step: add the new column
contact_email. - Keep both in sync (dual-write in app or trigger) during the transition.
- Backfill existing rows in batches (not one giant lock-holding UPDATE).
- Deploy app code that reads from the new column, then stop writing the old one.
- Only after the app no longer uses the old column, drop it (contract step); also carry over constraints/indexes (NOT NULL, unique) to the new column.