I would first revoke and rotate the exposed credentials because removing them from Git history alone doesn't eliminate the security risk.
Then I would use git filter-repo to rewrite the entire repository history, removing the sensitive file or replacing the exposed secret in all historical commits.
Revoke first → Rewrite history → Force push → Verify → Coordinate team → Prevent recurrence.
GitHub's 2018 incident:
GitHub experienced a 43-second network partition in October 2018.
❓What happened?
-> GitHub had MySQL clusters using semi-synchronous replication.
-> A network partition separated its East Coast infrastructure.
-> Its failover system promoted West Coast replicas.
-> The old East Coast primaries had accepted writes that hadn't replicated to the West Coast.
-> Both sides had divergent writes.
-> GitHub decided to keep the West Coast as primary rather than risk losing user data.
🤔Consequences:
-> One busy cluster had 954 unreplicated writes.
-> Recovery took 24 hours and 11 minutes.
-> Database restoration and replica catch-up took hours.
-> Millions of queued events and builds had to be processed afterward.
Lesson: Replication alone doesn't guarantee safe failover. You must design for network partitions, divergent writes, fencing, and recovery.
Output: [1, 10, 9]
Why?
By default, JavaScript's sort() method converts array elements to strings and sorts them alphabetically (lexicographically), not numerically.
Remember:
sort() → Default string-based sorting.
sort((a, b) => a - b) → Numeric ascending order.
sort((a, b) => b - a) → Numeric descending order.
For most REST APIs, I recommend:
Return 401 for both.
Use distinct error codes (TOKEN_EXPIRED, INVALID_TOKEN).
Allow the frontend to refresh the access token when it receives TOKEN_EXPIRED.
Require re-authentication if the refresh token is also expired or invalid.
This provides a clean API contract without compromising HTTP semantics.
@codewithkhalil The color of “Lorem ipsum.” is red, because the inline CSS style="color: red;" overrides the blue color defined in the <style> section.
@Sumits_X I would store userId and role in the JWT because they are useful for authentication and authorization.
However, I would not blindly trust the role stored in the token forever. I would ensure that role changes, token expiration, and authorization checks are handled properly.
Both URLs identify a specific user (52), but they pass the ID differently.
1. Query parameter: ?id=52
https://t.co/vHJJLe42uC
- The user ID is passed as a query parameter.
- Typically used for filtering, searching, sorting, or optional parameters.
- The endpoint remains /users.
Example: /users?id=52&role=admin
Think of it as: "Give me users matching ID 52."
2. Path parameter: /52
https://t.co/EbBcxvlcat
- The user ID is part of the URL path.
- Typically used to identify a specific resource.
- The endpoint represents the individual user.
Example: /users/52/orders
Think of it as: "Give me user number 52."
Both are valid, depends on API design.
What is split-brain?
This is a particularly dangerous failure scenario.
Imagine:
- Primary A becomes unreachable due to a network partition.
- Replica B gets promoted to primary.
- Primary A is still running and accepting writes.
- Both A and B now accept independent writes.
- Now you have two primaries with conflicting data.
This is called split-brain.
The solution is fencing: ensure the old primary is prevented from accepting writes before the new primary takes over.
Step-by-step execution:
Optional.of("x")
Creates an Optional containing "x".
.map(String::toUpperCase)
Applies toUpperCase() to the value.
Result: Optional["X"].
.orElseThrow(IllegalArgumentException::new)
Since the Optional contains a value, it returns "X".
No exception is thrown.
Synchronous vs Asynchronous replication
This is another critical interview topic.
The question is: When should the primary tell the application that a write is successful?
Read ⬇️
I would reduce hallucinations in my RAG pipeline by addressing both retrieval and generation.
First, I would improve retrieval using hybrid search, optimized chunking, metadata filtering, and a reranking model to ensure that only relevant documents reach the LLM.
Second, I would strengthen the system prompt to instruct the LLM to answer strictly from retrieved context and abstain when sufficient information is unavailable.
Third, I would introduce similarity thresholds and a post-generation verification layer to check whether generated claims are actually supported by retrieved documents.
Finally, I would continuously evaluate the pipeline using metrics such as faithfulness, context precision, context recall, and answer relevancy.
My goal would be to make the chatbot evidence-driven rather than simply generating plausible-sounding answers.
There are two mistakes in this SQL query.
1. Incorrect GROUP BY column
You are grouping by emp_count, which is an alias for COUNT(*).
You cannot group by an aggregate result like COUNT(*).
Instead, group by department.
2. Missing HAVING (not WHERE)
If you want to filter based on an aggregate result, use HAVING, not WHERE.
@yatharth170699 PostgreSQL uses MVCC (Multi-Version Concurrency Control). UPDATE creates a new row version instead of overwriting the existing row. Old versions are retained until they are no longer visible to any relevant transaction, after which VACUUM reclaims their space for reuse.