What I Learnt This Week part 2
Week 2
This is my brain dump for this week on things I learned, tech-related or otherwise.
Tech
- Google authenticator uses time-based one-time passwords and HMAC-based one-time passwords for authenticating users. TOTP uses the current time as well as a secret key to generate a unique 6-digit OTP (hashing, truncating and padding) which can be used to securely log in. TOTP is built on top of HOTP and requires two main parameters, the current Unix time and an interval which is used to refresh the OTP. This method, being quite effective, also poses some security concerns including phishing attacks as well as stealing of the shared secret (which is stored both locally and on the server) which would allow an attacker to generate a valid OTP. The limited time frame mitigates these risks to some extent.
- UUIDs are the most widely used id for rows in a table for a database. However, Btree indexing works best when the primary key is time-sorted or auto-increasing ids, so uuids which can be randomly generated, might not be ideal. UUID v7 produces time-sorted values, where newer generated UUIDs are greater than older ones (based on time).
- handles large-scale storage req using dataset partitioning, with a consistent hashing approach. Each partition is further physically replicated on many nodes. Concurrent updates are reconciled using a last write wins model, where the key with the latest version of the data is chosen as the right value. This is a simple but effective approach since every update is timestamped.
- uses an object-to-relational mapper (ORM) to map the model defined in Django to the relational data structures used by the underlying database. The database is configurable so this strategy ensures dynamic mapping while keeping the object model consistent. To perform this Django has to run database migrations every time there is a change in the data model to synchronize all changes made to the underlying database.
Otherwise
- There are special Hajj flights (twice a year) that take hordes of people to Mecca in Saudi Arabia as a religious pilgrimage for Muslims. It is a belief that every Muslim adult who is of age and has the financial means (it is EXPENSIVE btw) must perform Hajj at least once in their lives. People save up for their whole lives to perform Hajj and many elderly people attend. Special arrangements are made by airlines. I loved these two videos highlighting the entire process from an airline pov Departure and Back Home. The Indonesian custom of dressing up in the finest and brightest clothes after the pilgrimage as a sign that you completed Hajj really spoke to me and the pride on their faces on their return home is one of accomplishment and fulfillment which is amazing to see.
Previous Jul 6, 2024
« What I Learnt This Week part 1
« What I Learnt This Week part 1