Exploring alternate worlds: How to spoof your geolocation

I was recently working on a project at work which grabs a visitor's geolocation and displays certain information relevant to where they are in the world. However, as with every project, there were things that needed to be debugged. The problem, however, was that everything was working just fine for me, using my own geolocation. And as any developer knows, it's exponentially more difficult to debug a problem when you can't fucking replicate it!

Enter: Geolocation Spoofing

Luckily for me, after a bit of searching the old Google, I found some information that saved me from having to drive 850mi with my laptop to debug the issue! I'm not entirely sure if this information applies to any other browser(s), but for my testing purposes, the problem was browser-agnostic, so it didn't matter what browser I used to debug/test the solution.

In Chrome, you can manually set your geolocation to a set of latitude/longitude coordinates (thank goodness!). Here's how:

Step 1: Open DevTools

Step 2: Click the three dots

Step 3: Go to More Tools -> Sensors

Step 4: Select "Other" and enter the lat/lng you want to use

How to write clever code

First, you start with something simple…

In order to start writing code as cleverly as we can, we first need a basic concept to work from. In the case of this example, we’ll be writing a simple function which evaluates a parameter and returns a value based on that parameter (with a default return value option). Short and to the point.

function doStuff($data) {  
  if ($data == 'val1') {
    $result = 'Value One';
  } elseif ($data == 'val2') {
    $result = 'Value Two';
  } else {
    $result = 'Unknown Value';
  }
  return $result;
}

…and you make it better

Obviously, this just won’t do… If we’re going to establish our credibility as a programmer, we are duty-bound to find some clever trick to make our code stand out among the crowd… Luckily, we know one such trick!

function convoluteStuff($data) {
  switch(true) {
    case $data == 'val1':
      $result = 'Value One';
    break;
    case $data == 'val2':
      $result = 'Value Two';
    break;
    default:
      $result = 'Unknown Value';
    break;  
  }  
  return $result;
}

MOAR CLEVERER!!!

While the above example does, indeed, show off our innate ability to add unnecessary complexity to even the simplest tasks (I mean, who likes “if” statements, anyway?), it doesn’t go far enough. It lacks a certain elegance, so to speak.

We need to really tout our abilities, here… Our code needs to be so clever, that we can puff out our chests and elevate our noses at those who don’t immediately grasp its function.

function cleverStuff($data) { 
  return $data == 'val1' ? 'Value One' : ($data == 'val2' ? 'Value Two' : 'Unknown Value');
}

Now this… THIS is clever code! Notice how we abandoned the structural breakup of indentations altogether and went straight to using convoluted ternary combinations? This is the work of a genius! The fact that you can't simply glance at it to understand what it's doing is the key. After all, the idea of coding is to make your code so obnoxious that anyone who has to maintain it after you curses you with plague and pestilence, right?

Hello World!

Current Usage

Despite the myth that “Hello World!” is the first thing to be output by all computers, its prevalence in nearly all facets of technology is undeniable; as anyone who has used WordPress can attest. A “hello world” program is often used as a simplistic introduction to programming languages, as it’s generally quite self-explanatory, and simple enough that even those with little or no programming experience can understand its function. However, do not mistake its simplicity for a lack of utility. The program needs a functioning language compiler and run-time in order to accomplish its task. This makes it ideal for a quick and easy sanity test for new systems.

A Brief History

Early on in the history of computing, it was necessary (as it is now) to run sample programs to test the viability of newly developed systems and technologies. The key difference, however, was that in technological antiquity, the emphasis was placed on persuading a target audience that computers were the way of the future. This is evident in the first run programs used in early systems pre-1970’s. John Presper Eckert and John Mauchly first used their ENIAC for ballistics calculations, while Alan Turing used the Manchester Mark 1 to compute Mersenne primes, and John von Neumann used the EDVAC to run a custom merge-sort algorithm.

After the adoption of digital computers by the United States government and large corporations, their usefulness was self-evident. This eventually led to first-run programs being less about enticing adoption, and more about quick and easy testing of system architecture. The first known case of “Hello World” being used to serve this purpose was in Brian Kernighan’s A Tutorial Introduction to the Language B, in which it’s found as an example of using external variables.

main() {  
  extrn a,b,c;
  putchar(a); putchar(b); putchar(c); putchar('!*n');
}
a 'hell';
b 'o, w';
c 'orld';

Kernighan later (1974) wrote a similar function in the budding new language “C”, which he included in an internal memo at Bell Labs called Programming in C: A Tutorial. This example, however, is more widely referred to as the “first” usage of a hello world program, and used as the basis for other language variations today.

main() {
  printf("hello world");
}

Conclusion

While it may seem almost trivial, the “Hello World!” program represents a paradigm shift in society’s day-to-day operations. We as a society have accepted our technological future, and (for better or worse) embraced it with open arms. So the next time you’re shopping for a computer, consider the lengths that people like John von Neumann would’ve gone to in 1945 to prove to you that digital computers would soon replace tabulating machines.