Notes for Week 8 of 2021
In my last pre-lockdown week, I was focused on moving forward some backend functionality. I went into a rabbit hole of different sync algorithms and making next.js work well with replicated databases.
Random
- Vercel can deploy multiple projects on the same domain
- Bitcoin source code is hosted by Microsoft in an organization that contains 29 people. Well, I guess it’s larger than FED Board, but still…
- Django’s
auto_now
orauto_now_add
will not create the default on the database level, at least not in MySQL (using the DEFAULT CURRENT TIMESTAMP); this has to be added manually - Making Jest and next.js work together can be tricky, here is a good summary guide
- There is a draft for UUID v6 that essentially makes UUIDv1 usable as sortable database keys
- TIL another date/time quirk: unix epoch time does not account for leap seconds and instead, two seconds have the same timestamp. Interestingly enough, the spec defines the day as exactly 86400 seconds, but leap seconds may not be only added, but also subtracted. Sounds like a good start for some Y2K-style mania, hope I’ll retire by then
- The storage in browsers matured greatly. Instead of the original 5MB limit from few years back, you can now store up to 2 GBs of data (1GB in Chrome). There is now also an API for requesting data persistence
- M1 notebooks have wear & tear on their internal on-chip M.2 NVMe SSDs. I suffer from it because of MacOS X bug: if connected monitor works in non-native resolution,
WindowServer
process leaks memory, happily eating double-digit GBs. Current workaround: shut computer down overnight. Has other advantages. - Swap usage on MacOS can be retrieved using
sysctl vm.swapusage
Replicated Databases
- In Prisma ORM, you can create multiple clients against different databases sharing the same schema by passing the connection string to a
PrismaClient
import { PrismaClient } from '@prisma/client'
const client1 = new PrismaClient({
datasources: {
mydb: {
url: 'postgres://user:password@host/dbname'
}
}
}
const client2 = new PrismaClient({
datasources: {
mydb: {
url: 'postgres://user:password@differenthost/dbname'
}
}
}
- Shopify wrote down considerations for using read-only replicas
- When planning region build-out, I found useful Wondernetwork’s distance between cities, measured by ping times
Recommended Readings From This Week
- Bitcoin and Buying Things: Even original crypto fans start to be confused about what is crypto for
- Differential Synchronization: Neat algorithm for document synchronization
- Generating UUIDs at scale on the Web: Pitfalls of UUIDs/GUIDs
- Antonin’s guide to Showmax Engineering: CTO of Showmax on building a team
- Keeping Developers Happy with a Fast CI: Shopify’s strategy for improving CI run times
- Shopify: You know which stock outperformed Tesla in the last 5 years?
- I helped build ByteDance’s censorship machine: What I find fascinating on China is the mutual influence of the language and the censorship
- When explaining vector clocks and DynamoDB to a friend, I found the cse452 presentation that provides a good explanation and a visualisation of how vector clocks work
Published in Weekly Notes and tagged Weekly Notes