Beautiful Language and Beautiful Code


“Dead Poet’s Society” is a classic film, and has become a recent favorite of mine. There’s a scene in particular that I enjoy, where Robin William’s character explains that it’s bad practice to use terms like “very tired” or “very sad”, instead we should use descriptive words like “exhausted” or “morose”! I wholeheartedly agree with …

Read more

Intro to the One-Time Pad Cipher

eyeball art

In cryptography, the one-time pad, or OTP is a way of encrypting information so securely that it’s impossible to be cracked. That said, OTP has a major drawback in that it requires both parties to have access to the same key before a message is encrypted. How the one-time pad cipher works When using the one-time pad, a …

Read more

Building a Red-Black Binary Tree in Python

red black

A red-black tree is a kind of self-balancing binary search tree. Each node stores an extra bit, which we will call the color, red or black. The color ensures that the tree remains approximately balanced during insertions and deletions. When the tree is modified, the new tree is rearranged and repainted to restore the coloring …

Read more

Quick Sort in Golang


Quicksort is an efficient sorting algorithm that’s widely used in production sorting implementations. Like merge sort, quick sort is a divide and conquer algorithm. True to its name, quicksort is one of the fastest sorting algorithms, that said, you need to be careful with the implementation details because if you’re not careful the speed can …

Read more

How to Write Insertion Sort in Go


Insertion sort builds a final sorted list one item at a time. It’s much less efficient on large lists than more advanced algorithms like quicksort or merge sort. Insertion sort is a simple algorithm that works just like you would arrange playing cards in your hands. A slice is first split into sorted and unsorted …

Read more

Merge Sort in Golang with Examples


Merge sort is a recursive sorting algorithm and, luckily for us, it’s quite a bit faster than bubble sort. Merge sort is a divide and conquer algorithm. Divide Divide the input slice into two (equal) halves Recursively sort the two halves Conquer Merge the two halves to form a sorted array Full example of the merge sort algorithm Merge sort actually has two functions involved, the recursive mergeSort function, and the merge function. Let’s write the mergeSort() function first. It’s a recursive function, which means it calls itself, and in this case, it …

Read more

Writing Bubble Sort in Go from Scratch

bubbles in water

Bubble sort is named for the way elements “bubble up” to the top of the list. Bubble sort repeatedly steps through a slice and compares adjacent elements, swapping them if they are out of order. It continues to loop over the slice until the whole list is completely sorted. Full example of the bubble sort algorithm Using the algorithm in code Why use bubble sort? Bubble sort is famous for …

Read more

Check for Standards Before Creating a New One


I recently had a ticket opened on my team’s backlog board requesting the ability to bypass our API’s caching system. For context, our front-end team uses my team’s API to make fairly heavy requests to ElasticSearch, and one of the features of our API gateway is to cache the results of heavy aggregations for ~30 …

Read more

How to Properly Use Defer in Golang

hand signal

What is the “defer” keyword in Go? In the Go programming language, defer is a keyword that allows developers to delay the execution of a function until the current function returns. What throws some people off is that the deferred function’s arguments are evaluated immediately, but the function itself doesn’t fire until the wrapping function …

Read more

Comprehensive Guide to Dates and Times in Go


Keeping track of time in code has long been a developer’s nightmare. While no language or package manages time perfectly, I’m of the opinion that Golang does a pretty good job out-of-the-box. This full tutorial is designed to answer ~90% of the questions you’ll have about managing time in Go. Table of Contents Overview – …

Read more