Hi there 👋

Welcome to my dev journal. I mostly write about python and machine learning stuff.

Websocket

If you go through weboscket.org, you will see the essential events are onopen, onmessage, onerror, onclose. Naively I assumed that authentication should happen in onopen event. But this resulted in an unanticipated security breach. But first the normal web requests. In a normal requests, I can send custom headers like Authorization: Bearer token. This works, because the browser makes the preflight request, asking the server "I am about to make this request with this header and this method, do you allow it?". At this stage the server can reject this request, if either the method or the header doesn’t exist. ...

June 27, 2026 · 2 min · 400 words · Mohit Sharma

Simple Made Easy

Rewatching the talk by Rich Hickey (creator of clojure)

April 27, 2026 · 1 min · 9 words · Mohit Sharma

Cognitive Load

With the recent update of claude (which is a significant improvement), like many, my programming style has also changed. Unlike the old days (it’s just been a few weeks, and it’s already old), I don’t write code “manually”, like laboriously typing def before every function — I simply ask claude to do it. Even for the smallest of tasks, I would much rather type "please commit the recent changes and push to remote" instead of git add . && git commit -m "(wip)" && git push. In other words, I have completely shifted to “Agentic Coding”. The advantages are clear: I am certainly writing more code and shipping faster, plus while claude is thinking and writing the code, I get mini breaks to scroll through Instagram slop. ...

February 22, 2026 · 3 min · 560 words · Mohit Sharma

Synchronising Clocks

Few days back, I encountered the following error on my website saral.club. botocore.exceptions.ClientError: An error occurred (SignatureDoesNotMatch) when calling the SendEmail operation: Signature not yet current: 20250505T152002Z is still later than 20250505T151830Z (20250505T151330Z + 5 min.) By the looks of it, the error message is descriptive enough to guide you that there is some kind of time mismatch in the signature. Before sending a request to aws, the botocore library signs the request using your access keys. The signature also includes a timestamp. And the error message is saying that the request I am sending is probably 5 minutes later (in future) then the current time (time on aws servers). Of course, the two clocks (one on my server and the other on aws’s server) cannot have the same exact time, so aws allows for some time skew (5 minutes). ...

May 6, 2025 · 3 min · 485 words · Mohit Sharma

Time Saving Yaml Tricks

DRY: Don’t Repeat Yourself If you have a section that’s being repeated multiple times, you can create an anchor and then reference it. You use &name to create an anchor, and then *name to reference it. One example of it is defining environment variables for different services in docker-compose.yaml. env_vars: &env ENVIRONMENT: production LOGLEVEL: info AWS_REGION_NAME: us-east-1 services: api: environment: *env ... ... backend: ... ... environment: *env Reading environment variables While yaml doesn’t read environment variables, but if you pair it with parser, you can read the environment variables. The syntax depends on the parser you are using. The most common places, where I have a need for reading environment variables (or context variables) in yaml file is, cicd pipeline namely github action or circleci and docker-compose. ...

February 12, 2025 · 2 min · 293 words · Mohit Sharma