If you’ve worked in Go, you’ve likely seen iota. Here’s how the Go docs explain it: Within a constant declaration, the predeclared identifier iota represents successive untyped integer constants. – The Go Docs That sort of makes sense, but let me put it into plain English. iota is used when declaring a list of constants, […]
Latest
Save your shell history to log files
Every command I enter on my computer is written to a log file. These logs have come in handy countless times; I tell anyone who will listen to save their logs too. My inspiration for doing this came from this atomic object post many years ago, and I am so glad I followed their advice. […]
Javascript map function
The javascript map() function takes in a callback function, applies that callback function to each element of an array, and returns a new array containing the results. Many languages have a map function, and they all behave roughly this way. Javascript map basics map() accepts a single callback function, and passes each element of the […]
Javascript forEach
Javascript’s forEach method is one of its basic array methods, and it’s used all the time. It does as its name suggests, and performs a function for each element of an array: In the function above, I only accessed one argument, item. However, forEach actually makes 3 arguments available to its callback function if you […]
Python for loops
For loops in Python are one of many features that make Python so popular; they’re as close to plain English as you can get when writing software. They generally look like this: What is an iterable? According to the Python docs an iterable is: An object capable of returning its members one at a time. […]
Pointers in Go
If you’re used to working in dynamic languages like Javascript, Ruby, or Python, Golang feels very different. One of the big differences is the explicit use of pointers. You might find yourself asking these questions: I have practical answers! Golang ampersand & and asterisk * Obtain an address with & Let’s start with &. It […]
Python List Comprehensions
List comprehensions provide you with a “concise way to create lists”, according to the official docs, but they do a lot more than that. They’re a great feature of Python; let’s do a few examples to illustrate why. List comprehension as a map function The example above is the same as using a map function […]
Git log customization
The git log command outputs a lot of useful information—message, author, date, hash, branch—but its default format leaves something to be desired. Mostly, it just takes up too much screen space. Here’s an example, using the popular Python package flask: The default git log above has all the information we want, but just two commits […]
Copy and paste from the command line
We use copy and paste all the time, so why not use them from the command line? I do it all the time, so let’s do a quick run down. First, the commands: Copy something from the web and paste it to a file This is my most frequent usage of either of these commands, […]
Git commit and commit message best practices
I’ve seen lots of advice about git commits and messages over the years—some good, some not so good. This post will go through what works for me. Note: I’m no git workflow expert, these are just my personal opinions developed over ~10 years working at startups. Commit Best Practices: Commit Message Best Practices: Let’s go […]