Testing Node.js Code with Mocha and Chai

Introduction Writing unit tests is something beginners and seasoned engineers alike typically put off for later phases of development, yet – they’re key to stable and robust software development. The basic premise of test-driven development (TDD) is writing your tests even before you start coding. That’s a great goal to strive for, but it takes […]

Read More

Converting Strings to datetime in Python

Introduction Data can be represented in various forms – and a convinient way to represent dates and times are strings. However, to work with these dates and times in an arhithmetic fashion (such as calculating time differences, adding or removing time, etc.) – we need to convert them to a datetime object. One of the […]

Read More

Locate Empty Directories from Command Line

As a software engineer that lives too much of his life on a computer, I like keeping my machine as clean as possible. I don’t keep rogue downloaded files and removes apps when I don’t need them. Part of keeping a clean, performant system is removing empty directories. To identify empty directories, I use the […]

Read More

How to Extend Prototypes with JavaScript

One of the ideological sticking points of the first JavaScript framework was was extending prototypes vs. wrapping functions. Frameworks like MooTools and Prototype extended prototypes while jQuery and other smaller frameworks did not. Each had their benefits, but ultimately all these years later I still believe that the ability to extend native prototypes is a […]

Read More

Prevent Cross-Site Scripting (XSS) in Spring Boot with Content-Security Policies (CSPs)

Introduction The security of users and their personal data while using a web application is paramount. While this guiding principle has been acknowledged even from the early stages of web development – bad actors find loopholes in applications, and may exploit your users. Many “standard” attacks are well-known and documented, and protection from them isn’t […]

Read More

How to Use window.crypto in Node.js

I’ve been writing a bunch of jest tests recently for libraries that use the underlying window.crypto methods like getRandomValues() and window.crypto.subtle key management methods. One problem I run into is that the window.crypto object isn’t available, so I need to shim it. To use the window.crypto methods, you will need Node 15+. You can set […]

Read More

Convert Fahrenheit to Celsius with JavaScript

The United States is one of the last bodies that refuses to implement the Celsius temperature standard. Why? Because we’re arrogant and feel like we don’t need to change. With that said, if you code for users outside the US, it’s important to provide localized weather data to users. Let’s took at how you can […]

Read More

Create a Thumbnail From a Video with ffmpeg

Creating a thumbnail to represent a video is a frequent task when presenting media on a website. I previously created a shell script to create a preview video from a larger video, much like many adult sites provide. Let’s view how we can create a preview thumbnail from a video! Developers can use `ffmpeg, an […]

Read More