Add Search to Your Static Site with Lunr.js (Hugo, Vanilla JS)

Add Search to Your Static Site with Lunr.js (Hugo, Vanilla JS)

Jun 30 2020 — Introduction If you DuckDuckGo or bing! the phrase “add search to static site”, you will find hundreds of articles explaining how a client-side search product like Lunr.js can be integrated with Hugo, Eleventy or Gatsby. Given this fact, I feel compelled to explain why I created this blog post when it appears that this question has been sufficiently answered. I decided to document my Hugo/Lunr.js solution because unlike other guides I found while researching this subject, my implementation:

An Introduction to Decorators in Python

An Introduction to Decorators in Python

Feb 27 2020 — Decorators can be a daunting topic when first encountered. While the Zen of Python states “There should be one– and preferably only one –obvious way to do it”, there are many, equally valid ways to implement the same decorator. These different methods can be categorized as either function-based, class-based, or a hybrid of both. In this post I will explain the design and behavior of Python decorators and provide examples of decorators that I frequently use in my own code.

Hugo: Add Copy-to-Clipboard Button to Code Blocks with Vanilla JS

Hugo: Add Copy-to-Clipboard Button to Code Blocks with Vanilla JS

Nov 13 2019 — Hugo includes a built-in syntax-highlighter called Chroma. Chroma is extremely fast since it is written in pure Go (like Hugo) and supports every language I can think of. Chroma’s speed is especially important since syntax highlighters are notorious for causing slow page loads. However, it lacks one vital feature — an easy way to copy a code block to the clipboard. I decided to document my implementation using only vanilla JS since every blog post I found for this issue relied on jquery to parse the DOM, which is completely unnecessary at this point.

Error Handling in Python: Result Class

Error Handling in Python: Result Class

Feb 06 2019 — In a previous post, I explained how concepts from functional programming can be incorporated with object-oriented code to improve the tedious and mandatory task of error handling and input validation through the use of the Result class. That post explained how to implement the Result class in C#. Since I have been writing mostly Python code lately, I created a new implementation and documented its use. Due to Python’s duck-typing, this implementation is (IMO) more natural and makes reasoning about the code it supports much easier.