So you want to let users upload files directly to Cloudflare R2 from their browser? Great idea! Presigned URLs are the way to do it. You follow the documentation, you generate a presigned URL, and… 403 Forbidden . Let me show you how to fix all of this. Step 1: Use the Right Library Don’t use the official AWS SDK. It doesn’t work in Cloudflare Workers because it needs Node.js…
I recently built a SQL practice platform for my DBMS course at IITM BS Degree . About 50-100 students were hitting it simultaneously during peak exam prep. I chose Neon as the backend database, mostly because I was curious about their serverless Postgres offering. Here’s what I learned after a week of actual traffic. Let me be clear about what this actually tested: student queries…
FastAPI expects array parameters in the standard key=v1&key=v2 format. However, many frontend client generators like my favourite, Orval , default to key[]=v1&key[]=v2 . If you cannot change the client configuration, FastAPI will fail to validate these lists. The fix is to add a middleware that strips the brackets from keys before the request reaches the routing layer. The Code This middleware…
If you share a link that lets people subscribe to an .ics feed in Google Calendar, you’ve probably seen this pattern: 1 https://calendar.google.com/calendar/render?cid=webcal://your-feed.ics It works, but there’s a catch: If the user is logged into multiple Google accounts, Google just picks one. No warning. No choice. Easy way to end up adding the calendar to the wrong account. Here’s the fix.…
There’s something oddly comforting about a shell function that takes care of boring things for you. This venv() helper does exactly that. It checks whether you’re already in an environment, spins up a fresh one if needed, installs your dependencies, and activates it. To use this venv function, you’ll need to add it to your shell’s configuration file. If you’re using zsh, add the following function…
I have a confession to make. Before I was a student at IIT Madras, I hated it. For years, the letters “I-I-T” were a trigger, a symbol of a world I wasn’t welcome in: a club with gates so high I couldn’t even pretend to scale them. It left a bitter taste in my mouth. This wasn’t an abstract dislike; it was a deeply personal one, forged in the crucible of teenage grief and…
I wanted to share a small project I’ve been working on - a simple jigsaw puzzle embed that you can add to any website. What It Does It’s a straightforward tool that lets you embed customizable jigsaw puzzles into your web pages. You can: Use any image as the puzzle Choose the background color Set the difficulty by adjusting the number of pieces When someone completes the puzzle, it…
I’m excited to share a project I’ve been working on - a TypeScript port of the a0lite chess engine. The original a0lite was created as a minimalist neural network chess engine, designed to be simple and easy to understand rather than maximize playing strength. You can play against the engine by sending it a challenge here . Please note that the bot can only play 3 simultaneous…
Have you ever wanted to send desktop notifications from your command line on macOS? This can be particularly useful when you want to be notified when a long-running process completes. For example, you could append ; notify "Task completed!" to any command. While there are several ways to do this, I find using AppleScript through the osascript command to be the simplest approach. Here’s a…
If you’ve ever worked on a project in Google Colab and tried to provide download links for files using FileLink , you might have encountered some issues. Specifically, you might have noticed that the links often point to localhost:8080 , making them useless for actual downloads. This can be frustrating, especially when you just want a simple way for users to download files generated by your…
Ever stumbled upon a weird problem and couldn’t quite figure out where things went wrong? I’ve been there, and so has a friend of mine while tackling a HackerRank challenge. The task seemed simple: take a mathematical expression as input and print out the result with three decimal places. However, getting there wasn’t as straightforward as expected. Let’s walk through what…
Featured Photo by Javier Allegue Barros . Imagine landing on a blog where every “Read This Next” suggestion feels like it was handpicked just for you. That’s the kind of reading journey I want for you on my blog. I’ve been experimenting, trying to develop a system that not only understands the content of my posts but also why they might resonate with you, the reader. This…
I want to share something cool I learned about logarithms. If you’ve found logarithms a bit tricky, like I did, you’ll love this trick! It’s a neat way to see logarithms in action and made things click for me. Someone asked me how I would go about approximating the number of digits in $2^{32}$. I found this discussion on StackExchange. To quote the top answer: A general formula…
Featured Photo by Simon Berger I’ve realized something important about myself lately: I need to make it easy for me to publish my stuff. If I have to do a lot of steps to get my text online, I lose motivation and give up. That’s why I switched from my custom PHP site to a hugo site with a ready-made theme on Cloudflare pages. Now I just have to git push and it’s done. I used to…
Editor’s Note Welcome to the inaugural issue of my newsletter! Launching this newsletter has been a long time coming. While my blog has been the primary platform for sharing my thoughts and polished work, I’ve held off on creating a newsletter until now. In this space, I aim to offer you a closer look behind the scenes, sharing the journey of how certain projects and transitions came…
Featured Photo by energepic.com I’ve had a love-hate relationship with Bootstrap for a long time. While I love how fast it lets me get going, I absolutely hate the cookie cutter vibe of most of the stuff that I end up making with it. Bootswatch is awesome, and I know that I could customize my theme with SASS variables, but that adds a build step, which is additional complexity that I want to…
When beginning to use the terminal, we might accidentally delete our .bashrc file. What is the .bashrc file? The .bashrc file is a configuration file used by the bash shell. It contains all the environment variables, user defined functions, aliases and other config including the prompt layout. It is a full-fledged shell script, so we can have custom commands in it as well, which runs all the…
Cover Photo by Pixabay This article requires JavaScript. Sorry... Has this ever happened to you? You’ve just received a massive JSON file that looks like it was designed to confuse you. Or maybe you entered a command, and you got so much JSON that it looks incomprehensible. Important : Level up your jq skills with this accompanying FREE practical project on DataWars — enhance your skills…
To all those who ask why I haven’t been putting more posts out, this is for you Dear Members of the Cult of Not Done, I present to you a manifesto of not done. This was inspired by Kio Stark and Bre Pettis , and written over five days because it was, obviously, not done. The Cult of Not Done Manifesto There are four states of being. Not knowing, action, refinement, and completion. Accept…
Dear past me, I know you’ve just launched your first desktop application. It’s a nightmare isn’t it? Well you’re in for a bigger one. Your boss calls you, and they need a new feature immediately. You bang it out and send out the update. Oh yeah, that’s right. You didn’t include an update mechanism. Please use one, you’ll save yourself a lot of pain. You…
I was returning from Saturday brunch with my friend a month or so ago. We took the metro back from the restaurant, and it was quite crowded. While disembarking from the metro, my leg slipped (or maybe I was pushed, I don’t know), and got lodged in the gap between the train and the platform. In my vigorous attempts to free myself, I twisted one knee and scraped the other. Thankfully, I…
When I was a kid, I observed that most sheets of paper have a sort of “direction” inside them. It’s not possible to tell by looking, but there’s a simple experiment to show: Rip the same sheet of paper left and right, then up and down. One of the two will have a smooth, straight, nice-looking rip, while the other will have a rough, uneven edge. Later, as a teenager, I…
The term Natural Selection is often misused, with people saying things like: natural selection at its finest or he’s about to win a Darwin Award when they see people doing things that are questionable. Not only is this a huge festering pool of negativity, but it actually totally misses the point of natural selection. Natural selection is the process by which those animals and plants which…
Following an interesting discussion on programming.dev after the last article , I thought it would be good to add some extra notes regarding Webfinger. Webfinger provides a standard API for discovering the user profile details and avatar from the username, no matter the software running on the node. The standard Webfinger endpoint is /.well-known/webfinger . It must always be queried with at least…
My first encounter with the .well-known directory was when Let’s Encrypt first hit the scene and I was learning about VPS-es and how Linux on the server worked. I noticed that it used certain URLs like .well-known/acme-challenge/3d2f4b8c9d0a4f8b9e6f7d8c9e0a4f8b . This led me down a nice rabbit hole about the ACME protocol, but that’s a story for another time. Years later, when…
Assuming that the IP addresses are in a file called list.txt in a format such as below: 1 2 3 4 5 6 7 8 9 104.28.29.66 92.40.175.51 116.255.32.201 91.150.51.170 108.167.20.103 5.187.159.175 166.198.250.121 74.78.184.213 ... A prerequisite for this is the geoiplookup command, which is available in the geoip-bin package on most distros. Run the following command to get the frequency distribution: 1…
The following script can be used to start list the running containers inside a particular network along with their ips. 1 2 3 #! /usr/bin/zsh echo 'Image\tHostname\tIP' ; for N in $( docker ps -q ) ; do echo ' $( docker inspect -f '{{.Config.Image}}\t{{ .Config.Hostname }}\t' ${ N } ) $( docker inspect -f '{{range $i, $value := .NetworkSettings.Networks}}{{if eq $i…
Given a yaml-like file containing key-value pairs like this: 1 2 3 key1 : value1 key2 : value2 key3 : value3 The following function will load it and return the data as a Lua table. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 function read_yaml_file ( filename ) local file = io.open ( filename , 'r' ) if not file then return nil , 'Failed to open file: ' .. filename end local data = {} for line in…
The following script can be used to start a container inside a particular network. Usage example: 1 2 ./start-in-network redis ./start-in-network vad1mo/hello-world-rest 5050 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #!/usr/bin/zsh if [ $# -eq 0 ] then echo 'syntax: ./start-in-network container-name [container port binding]' echo 'You must provide at least container name' exit 1 fi…
Create a file ~/.ssh/config If you have 2 keys, for example: id_rsa for your personal, and id_work for your work, set the config as: 1 2 3 4 Host github-work HostName github.com IdentityFile ~/.ssh/id_work IdentitiesOnly yes Now, when cloning or adding remote, change the github.com in the clone url is changed to github-work 1 git clone git@github-work:username/whatever.git Read Next I’m…
Many people who know me ask me why I haven’t got a personal website or blog. I often don’t know what to tell them. It’s certainly not for a lack of trying. Here’s one of the very first blogs I started to help my 7th grade classmates learn programming which they weren’t able to understand in school: I fumbled around various other blogs, but never managed to be able to…
There is a bug in WSL2 that causes the clock inside the VM to drift behind the actual clock on the machine. This can lead to many unexpected issues, ranging from harmless (git commit messages having old timestamps) to severe (SSL connection failures). We can sync the VM clock using the command 1 sudo hwclock -s We can also add the command as a cron job every 5-10 minutes to make sure that the…
Hi There, I’m Ishan. I was fascinated by coding from a young age. I taught myself how to code from the ground up, and I have never stopped learning and exploring new possibilities. Over the past ten years, I have worked on various projects that challenged me to grow as a coder and a problem-solver. I have learned how to build software that is reliable, scalable and performant, and that…
Quickly and easily generate a key pair for passwordless connection. Also works perfect as git deploy keys! Generate the keys DO NOT DO THIS AS ROOT Run the command to generate the keys 1 $ ssh-keygen -P '' -t rsa -b 4096 -m pem -f my-key-pair -b flag sets the bits, 4096 is recommended -m pem is needed to generate a file in RSA Private Key format, not in OpenSSH Private Key format -f specifies the…
Setting up a local Postgres development environment 1. Install Postgres Download the installer from EnterpriseDB Run the installer Install Postgres into C:\xampp\pgsql{version_number} folder 2. Enable PostGres modules for PHP Open php.ini file located in C:\xampp\php. Uncomment the following lines in php.ini 1 2 extension=php_pdo_pgsql.dll extension=php_pgsql.dll 3. Install Adminer Download…
Given a list of items and a separator, render it in a single line, with separators between. 1 2 3 4 5 6 7 $items = [ 'apples' , 'oranges' , 'bananas' ]; $separator = ' / ' ; Method 1: Basic foreach This approach is the one that comes to mind first, but it is incorrect because it will emit an additional separator after the last element. 1 2 3 foreach ( $items as $value ) { echo $value . $separator…
A note to the reader This post is a legacy post. The legacy posts that are available on this website were written many years ago. These posts are made available here for archival purposes only . They reflect the age I was, and the level of knowledge that I had when I wrote them, and they may contain outdated information , so please keep that in mind as you proceed to read this article. Original…
A note to the reader This post is a legacy post. The legacy posts that are available on this website were written many years ago. These posts are made available here for archival purposes only . They reflect the age I was, and the level of knowledge that I had when I wrote them, and they may contain outdated information , so please keep that in mind as you proceed to read this article.…
A note to the reader This post is a legacy post. The legacy posts that are available on this website were written many years ago. These posts are made available here for archival purposes only . They reflect the age I was, and the level of knowledge that I had when I wrote them, and they may contain outdated information , so please keep that in mind as you proceed to read this article.…
This is a legacy script from when I was 13 years old. Please don’t give me a hard time 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 #!/bin/bash function speedTest { # ripped off from http://freevps.us/downloads/bench.sh local the_speed = $( wget -O /dev/null 'http:// $1 ' 2> & 1 | awk '/\/dev\/null/ {speed = $3 $4} END…
I’ve been trying to be more regular about showing my work . This newsletter is part of that endeavour. I know I have an aversion to sharing incomplete work because I worry about what people will think. This is where I try to change that. What will you get by subscribing? Once a week max. No spam, I promise! Catch up on any new blog content since the last issue. Expect sneak peeks, early…