Go has a few for loop options: Classic for loop This format is common in many languages: The one difference in Go is the lack of opening parentheses around the init statements, which are required in other languages like Javascript, Java, or C. For loop using range Golang doesn’t have a for in loop, but […]
Archives for May 2023
Bash ampersand (&)
The single ampersand & is used to run commands asynchronously in the background. From the bash docs: If a command is terminated by the control operator ‘&’, the shell executes the command asynchronously in a subshell. This is known as executing the command in the background, and these are referred to as asynchronous commands. The […]
Python double slash operator
Python’s double slash (//) operator performs floor division. What exactly is floor division? Floor division is a normal division operation except that it returns the largest possible integer. This integer is either less than or equal to the normal division result. – Educative.io In code, it looks like this: Some languages perform floor division by […]
Is Comcast throttling me? The technical details
In case you aren’t one of the three people in the world who read the first post in this series, Is Comcast throttling me?, let me bring you up to speed: This post is about how I reached the conclusion in #5 from a technical standpoint, including code snippets. If you just want the results, […]
How to kill a process
The easiest way: use pkill to kill a running process by name. Let’s say you have a background task running: Those sleep commands will run for 60 seconds and 600 seconds, respectively. Kill a process by name If we want to kill them sooner, we can just pkill them by name: pkill works similar to […]
Golang Ellipsis
Golang’s ellipsis-…-has a few different uses. Defining variadic function parameters What is variadic? It is a function “of unknown arity”. In plain English, that means “a function that can take an unknown number of arguments”. A commonly-used function with variadic function parameters is Go’s builtin log.Printf. This is its signature: The signature of Printf says […]