Sid Verma Taglines are hard

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

I currently live in Jaipur, India and have been working with CultureAlley since June 2015.

I usually play with Javascript and Python, but you can also find me fiddling with other languages at various times.

Feel free to get in touch with me, if you feel like it.

EmailWork EmailTwitterKeybase


Or, you can just check out my blog below.

Link etiquettes for web developers.

I never thought I’d need to write this post, but I see too many websites which make me frustrated when links don’t work as links are expected to.

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 hates her smartphones. She has gone through three phones in the past two years, and just her luck, that her GPS never works correctly. Whether she’s waiting at a crowded bus station on a clear day, trying to get an Uber, or stuck somewhere in a storm, again trying to get an Uber, her phone just fails to locate her correctly long enough to order a cab. And sometimes, her bad luck seems to be contagious to those around her too, with everyone complaining about their location being off by hundreds of miles, somewhere near Alice’s house.

Obtaining a device’s location is complicated. These days, smartphones take a lot of variables into account, which include GPS satellites, cell towers, bluetooth, and Wi-Fi to pinpoint the user in a fast and battery-efficient way. Basically, signal strength from different cell towers help triangulate your approximate location. Some BLE devices can advertise their location to nearby devices. Apart from that, Google/Apple/Microsoft maintain a huge list of (Wi-Fi SSID + MAC) => Location combinations to triangulate it even further. These methods are quite battery efficient (unlike GPS), and quick (unlike GPS).

Sometimes, due to these portable hotspots, your device might receive wrong/conflicting location data. And depending on your surroundings (GPS signal strength, number of Wi-Fi hotspots around you), you, and other people around you might see the device’s location constantly jumping between two points, or in some cases, a completely the wrong location.

So, the next time you see your location off by quite a distance, or just jumping around, try switching from A-GPS to GPS-only temporarily. It might be slow and power-hungry, but is accurate.

Example of Android's location settings

BTW, this is also how your PCs sometimes know their location. Eg- when you visit Google Maps.

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.