Sometimes when we need to debug functions in Python, we need a way to write some quick timer code to capture the time-delta and to compute the time it took for the function to execute. This article shows you a quick and easy way to humanize a time-interval/time-delta without bringing in additional dependencies or libraries like Arrow or Humanize. 1 ...
Read More »JavaScript: Open Link in New Tab
Major browsers have popup blockers which sometimes prevent sites to open new tabs. This article investigates how popup blockers currently works, what they block and how to overcome problems caused by them. First chapter gives short overview of popup blockers. The rest of article shows multiple ways how to open new tab and how to work around browsers limitations. Popup ...
Read More »How to Split a String by Whitespace in Python: Brute Force and split()
Once again, I’m back with another look at some ways to solve a common Python problem. This time, we’ll be looking at how to split a string by whitespace (and other separators) in Python. If you’re in a rush, here’s the key takeaway. You could write your own whitespace splitting function, but they’re often slow and lack robustness. Instead, you ...
Read More »How to Convert a String to Lowercase in Python
As this series grows, I’ve started poking at seemingly simple problems to expose their complexity. This time, I thought it would be interesting to look at how to convert a string to lowercase. As it turns out, there’s a really straightforward solution (lower()), but I think it’s worth looking at a few homemade solutions first. For instance, we could try ...
Read More »How to Round a Number in Python: Truncation, Arithmetic, and More
Remember learning to round in grade school? Me too! The only problem is I don’t use the idea very often. As a result, I don’t always remember how to round a number in programming contexts like Python. Luckily, I’ve pieced together a little article for myself. Hopefully, you get some value out of it as well. As it turns out, ...
Read More »Automating the Change of WordPress Permalinks
WordPress is powering 35% of website. And while it may not be seen as very complex or interesting, it is one of the most prevalent technologies of our time. And many developers, even if they are not working with PHP, have to support some WordPress installation (e.g. a blog like this one). And unfortunately, there are still basic things that ...
Read More »How to Create a List in Python: Loops, Comprehensions, and More
If you’re working with Python for the first time, you might be interested in learning how to store data. For example, you might want to collect a list of exam scores, so you can average them. If so, the list data structure gets the job done. But, how do you create a list in Python? That’s the topic of today’s ...
Read More »How to Compute Absolute Value in Python: Control Flow, Abs(), and More
As Python is increasingly used for computation, it becomes more important for math related resources to be made available. To aid in that effort, I figured I’d share a few ways to compute absolute value in Python. As it turns out, there are a few ways to compute absolute value in Python. First, there’s the abs() function which comes built ...
Read More »How to Obfuscate Code in Python: A Thought Experiment
As with most articles in this series, I was doing some browsing on Google, and I found that some folks had an interest in learning how to obfuscate code in Python. Naturally, I thought that would be a fun topic. By no means am I an expert, but I’m familiar with the idea. As a result, treat this like a ...
Read More »