Weekly Post 44

Posted on November 3, 2024

🪔Diwa-l-oween🎃!

A unique year, where Deepavali (Diwali) and Halloween coincided on the same day.

Week of Apple Refreshes

A new Mac mini, iMac, Macbook pro - sporting Apple’s new M4 processor. And Apple intelligence forcing Apple to bump the default RAM to 16GB, which possibly is the biggest news of all.

But what made me sad is that Macbook air also now starts at 16G at their lowest price point. Which meant that I had actually over paid for my 24G model of the air. I know the time spent with my macbook air probably can’t be quantified or equated to. The blow would have softened had they made the decision to also bump air to M4 along with the RAM bump. But it is what it is ☹️

If I hadn’t gotten my macbook air I would have certainly gotten the Mac mini. Since I have mostly been using my macbook air on my desk and less as a portable device.

Lowercasing the tags

I recently discovered something about the way tags were getting created and which were kind of broken at the time I discovered.

So I had a mix of “TTL” and “ttl” causing some issues when clicking on the tags. So it turns out “TTL” gets pointed to a tags page but “ttl” doesn’t. Oddly though both those tags worked locally on my mac. I could see a TTL.html and a ttl.html which contained the posts corresponding to those tags but when I transfered it over to my web server running Debian turns out it treats ttl.html and TTL.html equally overwriting the file. But hakyll’s url scheme is setup such that ttl is directed to ttl.html and errors out.

Till I figure my way around haskell and hakyll my solution at the moment for this is to lowercase all tags using a sed command.

gsed -i -E '/^tags:/ s/[A-Z]/\L&/g' posts/*

gsed - is gnu sed which I am more used to than BSD version of sed and might need it only if you are using macOS and have gsed installed using brew install gnu-sed. I decided not to have sed redirect to gsed.

FastAPI gotcha

I recently worked on migrating auth codebase at work from hug framework to FastAPI.

We had a login API on lower envs. that supports basic auth. All was good until one of the services was authenticating in a rather unusual way. It wasn’t sending over the right headers and it wasn’t sending over the payload in the proper format which triggered a request valdiation error from the framework itself. But what suprised me was it returned the payload as part of the error 🤦‍♂️.

The way to override the default behavior is add this to your main.py:

from api import exception_handler
from fastapi.exceptions import RequestValidationError
from fastapi.requests import PlainTextResponse


app.add_exception_handler(Exception, handler=exception_handler.exception_handler)
@app.exception_handler(RequestValidationError)
async def validation_exception(request, exc):
  return PlainTextResponse("Request is incorrect<or anything you want>", status=400)

Media Consumption

  • Vettaiyan - Rajini’s style is good enough reason to watch this movie. Although I have a small gripe- Why did they have to kill battery
  • Meiyazhagan - Enjoyed this movie.

Through the lens

Fall is here