Quick Tips Tutorials
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 likegetRandomValues()
andwindow.crypto.subtle
key management methods. One problem I run into is that thewindow.crypto
object isn't available, so I need to shim it.To use thewindow.crypto
...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...
Detect System Theme Preference Change Using JavaScript
JavaScript and CSS allow users to detect the user theme preference with CSS'
prefers-color-scheme
media query. It's standard these days to use that preference to show the dark or light theme on a given website. But what if the user changes their preference...Skip or Only Run a Test with JavaScript Mocha
Whenever I start to feel anxiety about a big change I'm making, I start writing more unit tests. I'll write down my fear and then write a test that attacks, and eventually relaxes, that fear. There are two actions that I've been frequently using...
Determine Default App for File Type from Command Line
One quality of life improvement any developer can make for themselves is ensuring different file types open in the app they're most proficient in. If you know me, you know I prefer accomplishing as much as possible from the command line. The
duti
utility...Set Brave as Default Browser from Command Line
I've been a huge fan of the Brave web browser for years. They're crypto-friendly, provide native ad-blocking features, and even provide Tor integration. Whenever I set up new systems, I automate Brave as the default browser.You can use the following shell command to set...
CSS :autofill
Autofilling HTML
input
elements is a frequent user action that can drastically improve user experience. Hell, we all autofill for our passwords and address information. But what control do we have wheninput
elements have been autofilled?To add custom CSS styles to inputs whose...CSS :out-of-range
One aspect of web development I've always loathed was working with forms. Form elements have been traditionally difficult to style due to OS and browser differences, and validation can be a nightmare. Luckily the native HTML APIs added methods for improving the form validation situation.With...
git Force Push
Rebasing is a frequent task for anyone using git. We sometimes use rebasing to branch our code from the last changes or even just to drop commits from a branch.Oftentimes when trying to push after a rebase, you'll see something like the following:Commonly developers...
JavaScript Event.defaultPrevented
Whether you started with the old
on_____
property oraddEventListener
, you know that events drive user experiences in modern JavaScript. If you've worked with events, you know thatpreventDefault()
andstopPropagation()
are frequently used to handle events. One thing you probably didn't know: there's adefaultPrevented
...