Our product endpoint read Postgres on every hit -- p99 180ms, DB at 80% CPU. A Redis cache-aside layer cut p99 to 9ms. Then a hot key expired and thousands of concurrent misses stampeded the DB at once. Fix: singleflight collapses them into one query. #Golang#Backend
Day 25/60: my live stock-ticker widget recomputed each day's span (prior days at or below today) by scanning backward every tick. O(t) per tick, O(t^2) total, it stuttered. Fix: a decreasing monotonic stack of [price, span] pairs, amortized O(1) per next(). #JavaScript#DSA
Day 25/60 Rust DSA: Daily Temperatures (LeetCode 739).
My "scan forward for the next warmer day" was O(n^2) on a long series. A decreasing monotonic stack of indices fixes it: a warmer day pops every colder index and records i - popped. One O(n) pass.
#RustLang#DSA
Day 25/75 Go DSA: best contiguous PRODUCT of growth factors. I reused max-only Kadane and got 3 on [-2,3,-4] -- but -2*3*-4 = 24. Two negatives multiply positive, so the running MIN is a candidate for the next max. Track curMax AND curMin, swap on x<0. O(n).
#Golang#Dsa
Day 25/75 C++: a revenue report resummed each [l,r] slice per request -- O(n) each, p99 tripped the timeout, and the data never changed.
Fix: build prefix[] once in O(n), answer sumRange as prefix[r+1]-prefix[l] in O(1). Leading zero, long long.
#CPP#DSA#Algorithms
Day 25/75 Java: the best contiguous window of daily P&L. My brute force summed every window from scratch, O(n^2), and timed out across thousands of tickers. Kadane carries one value: best window ending here. Reset it the moment the running sum goes negative. O(n). #Java#DSA
Day 25/75 DSA: my dashboard showed each product's share of all OTHER sales by dividing the grand product by each price. A clearance SKU priced at 0 returned inf and a ZeroDivisionError. Fix is product-except-self: prefix times suffix product, no division, O(n). #Python#DSA
Day 25/365: our booking system double-booked a room. The bug? It ran merge intervals to check capacity, fusing overlapping meetings into one busy span. Merge tells you WHERE time is busy, not HOW MANY things run at once. Capacity = peak overlap, not merged union.
#DSA
Your degraded mode is only graceful if you've load-tested it under the exact conditions that trigger it. Most teams discover their fallback path hits the same bottleneck during the outage, not before. Test the shed, not just the switch. #SRE#GracefulDegradation#Programming
A Terraform module passed validate and plan, then shipped a security group that no longer allowed 443. A refactor dropped the rule. Static checks prove the code is well-formed, not that it behaves. Terratest applies on a sandbox and asserts 443 is really there. #Terraform
Day 25/60: API pentesting on an authorized orders/users service via the OWASP API Top 10. BOLA test = list order ids as user A, request them as user B, watch for a 200. Fix is server-side: scope the lookup to the logged-in user so unowned ids return 404. #Pentesting#Apisecurity
Day 25/60 cloud security: AWS IAM Identity Center replaces IAM users with federated login. One IdP, temp credentials, auto-deprovisioning when people leave. If you have static access keys older than 90 days, SSO is your fix. #CloudSecurity#AWS#CyberSecurity#Security#SysAdmin
Our payments worker died at 02:14 Sat. We found out at 09:40 from a customer. Only monitoring was a dashboard nobody had open at 2am.
systemctl is-active said up. ss -ltn showed nothing listening. curl -f caught the 500 the old check passed.
Run it from a systemd timer.
#Bash
Day 25/90 Python security: a teammate's "AES encryption" was raw AES-ECB with a hardcoded key. Identical plaintext blocks became identical ciphertext blocks, the ECB penguin in our cache. Fix: AESGCM, fresh random nonce per message, auth tag catches tampering.
#Python#InfoSec
"Slow Wi-Fi and an unknown device." Before panic: netsh wlan show interfaces reads the live Authentication + Cipher. WPA2-Personal + CCMP is the floor; WEP/TKIP is broken. WPA3-SAE resists the offline guessing WPA2 allows. Connected != secure. #Cybersecurity#Infosec#Blueteam
Swapped std::map for std::unordered_map to speed up a hot lookup. Lookups got faster; the nightly report started shuffling its rows.
map is a sorted tree and iterates in order. unordered_map is a hash table with NO order guarantee, and rehash reshuffles it.
#Cpp#CPlusPlus
My Rust config loader called .unwrap() on fs::read_to_string and serde_json::from_str. The first malformed JSON a user shipped panicked the whole binary.
Both return Result. Propagate with ? and a bad config becomes a readable error instead of a crash.
#Rust#RustLang
Our Go service died with: fatal error: concurrent map writes. Not a panic -- a runtime abort recover can't catch. Two HTTP handlers wrote the same cache map at once. go run -race named the line. Fix: sync.Mutex, Lock + defer Unlock around every access.
#Golang#LearnGo
A memory leak in C#: our dashboard climbed to 900 MB. The dump showed 40,000 closed chart panels still alive.
Each subscribed to a long-lived event with += and never -=. The feed's invocation list rooted every one. The GC can't collect what an event references.
#CSharp#DotNet