Sid Verma Taglines are hard

Hi. I’m Siddhartha Verma. Most people call me Sid.

I currently live in Gurgaon, India – where I work as a Software Engineer at Tower Research Capital.

I like to write code, climb hills, and watch movies.

I’m not sure what sent you this way, but feel free to say hi. There’s a good chance we’ll find something interesting to talk about.



Or, you can just check out my scantily updated blog below.

Link etiquettes for web developers.

This post might seem like nitpicking, or unnecessary to a lot of people, but it’s frustrating when links don’t work how they’re expected to.

  • DO NOT use <span> or <div> tags and then proceed to handle their click events. Use proper <a> tags. This breaks so many things!
    • People can’t use them if they have disabled javascript or it just failed to load.
    • Ctrl-click will not open a new tab unless you explicitly handle the situation. (More on that below)
    • Even then, you just dumbed down your users’ context menus. No Open link in new tab, or Copy link address.
    • The same situation on mobile. Long click will copy the text instead of showing helpful actions.
    • The javascript might break, throw an unexpected error, or burn down your house, rendering that “link” useless.
  • Even when you are using <a> tags:
    • If possible, execute whatever JS you want, and then let the link do its job. Don’t preventDefault() and open the link through javascript.
    • If you really have to open it through JS, take care of Ctrl-clicks. And Cmd-clicks in case of macOs. Old browsers might make this difficult.
  • Put mailto: links only where the email-id is the visible text too. [email protected] is so much better than Contact Email. Not everyone has email clients configured, and opening bulky clients when clicking a link is just bad UX. Or people might just want to note down the address, to contact later.

Wi-Fi positioning woes

Alice lives in India. She has super-cheap cellular internet (less than $0.2/GB on some networks). Cheap enough for it to be her daily driver, using a number of portable Wi-Fi routers, which just sit on her desk. And since it is so cheap and portable and convenient and long-lasting, she just carries it everywhere in her purse, wherever she travels.

Alice also faces an a peculiar amount of problems with her GPS. She could be at a crowded bus station, trying to get an Uber, or stuck in a storm, again trying to get a cab, her phone just fails to locate her correctly long enough for the app to work. Either it’ll just be showing her previous location at the far away house, or it will keep fluctuating and jumping between her actual position, and her house. People around her sometimes get affected too. Maybe it’s a curse.

For most people, device positioning is synonymous with GPS. But these days, GPS is the last thing a smartphone checks when trying to locate itself. GPS takes some time to obtain a good fix, and drains a lot of battery. In contrasts, a lot of your phone radios are less power-hungry and always on. Mostly, it’s a combination of cellular, bluetooth and Wi-Fi. Basically, the signal strength from different cell towers help triangulate your approximate location. Some BLE devices can also advertise their location to nearby devices.

Apart from these, Companies lik eGoogle/Apple/Microsoft/Skyhook maintain a huge list of (Wi-Fi SSID + MAC) => Location combinations to find your location. You might have noticed your phone telling you to switch on Wi-Fi for more accurate positioning at somep point. This is why. This method quite is power efficient, and quick. And in most cases, very accurate.

Note: This is one of the primary uses of Google Location Service on Android.

In out character’s case though, Alice’s wifi router normally always resides on her desk, at her home. The device has the MAC Address AB:CD:EF:GH:IJ:KL. It’s boring SSID is Alice's Wifi. Now, a lot of smartphones around her will be reporting this MAC+SSID combination to some server, along with their location. Her, her guests, her neighbours, almost everyone. They don’t need to be connected to the network. Her router getting scanned is enough.

So, when travelling with the said hotspot on in her purse, if she tries using some location-requiring app, her phone gets wrong/conflicting location data. Depending on the neighboring conditions (the GPS strength, other Wi-Fi networks nearby, etc), she may see her actual location, or her far-away home, or even jumping between the currnt position and her home.

If you find yourself in such a situation and own the culprit router, just change the network name. This should solve the problem for you and people around you. Also, if you don’t have control over the router, try switching your phone from from A-GPS to GPS-only temporarily. It might be slow and power-hungry, but is accurate. Disabling your Wi-Fi doesn’t always prevent it from scanning for networks.

Example of Android's location settings

BTW, this is also how your PCs sometimes know their location. Eg— when you visit Google Maps on the desktop.

STDIN inputs via Sublime Text (sort of)

I love Sublime Text. I really do. I can put a ring on it if it had any corporeal form. I’ve been using it so much, that trying to work on anything else is kind of a pain. And yet, when dealing with STDIN inputs, the magic falters. This method describes a workaround to give inputs without a prompt.

Recently, I tried my hand on Competitive Programming, and though I didn’t get really good at it, I did encounter a frustation. Entering the same input again and again after every change I make to the code. I wanted a simpler method.

Here’s what a friend of mine came up with: Enter the input in comments.


#include <stdio.h>
int main() {
  int n,i;
  char s[10];
  for(i=0;i<n;i++) {
} }

gives the output:


I wrote up a quick and really dirty plugin to do it for Python, and though it was rather clunky, I had a rough idea of what I wanted, and how to do it. Pipes! Good ol’ pipes!

Now, what I had was a clunky implementation which just executes the following command:

$ echo "input" | python

I started jotting down a list of things I needed to add to the plugin. The first thing was to make the execution asynchronous. I couldn’t let the whole editor hang when a program’s under execution. Also, to be able to kill programs. And proper error reporting, platform independency, etc.

It turns out all these things were already implemented, in the default build system of Sublime Text itself. I decided to merge my plugin it.

Apart from things like input extraction, handling filenames, the behavious of things in Windows, etc, the main trick was changing

self.proc = subprocess.Popen(["/bin/bash", "-c", shell_cmd], 


echo_input = subprocess.Popen('echo "' + user_input + '"', 

self.proc  = subprocess.Popen(["/bin/bash", "-c", shell_cmd], 
                              stdin=echo_input.stdout, #Input

A few other fixes, and the whole thing was running smooth as butter. No more rapid switching between the Console and Sublime Text to execute a program.

The plugin has now been nicely packaged and uploaded. It can easily be installed via Package Control, and the source is available on Github.