How to be an asshole, programmatically

So, your users are becoming more sophisticated and they are starting to use adblocking browser extensions. This rightfully pisses you off as it renders you analytically impotent and therefore incapable of making savvy, data-driven, business decisions. Leaving you at the mercy of your competitors.

It’s time to fight back.

Our starting point is your standard Google Analytics code block.

<!doctype html>
<html>
<script
async
src="https://www.googletagmanager.com/gtag/js?id=ASSHOLE">
</script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'ASSHOLE');
</script>
</html>

This isn’t working correctly. Your user’s adblocker is disallowing requests to the remote script. It’s most likely doing this…


It’s not unusual for me to search the web for how to do something in Python and end up using a third party library only to find out later that the standard library included a module that did more or less what I wanted. Here are a couple of less known modules that might come in handy.

textwrap

This module has some functions for easily wrapping and indenting plain text. Its useful when you’re one of those weirdos that likes to wrap everything you print to the terminal at 80 characters. E.g.

>>> import textwrap >>> text = 'Lorem ipsum dolor…

Vitor Pereira

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store