How to overwrite HTML with Cypress

Here’s a quick snippet to allow you change the HTML of a page before Cypress fires your tests. In an ideal world you would want to have different server side rendered HTML pages and you would just call page-1.html and page-2.html but in my case the component I’m trying to test inherits a configuration from […]

Migrating from Gatsby to custom Node.js script

Two years ago I created a small site to track what movies and shows I watch. I did it with Gatbsy because well, it was a new thing for me and I wanted to experiment with Jamstack. The idea is to create a new Markdown file for each movie or tv episode watched. A TV […]

How to create custom commands for Mac’s Spotlight

Out of the box doesn’t seem to be possible πŸ™ BUT! I’ve found a workaround that works almost as nicely πŸŽ‰ There are paid apps out there, but we as developers should do it ourselves πŸ‘¨πŸ»β€πŸ’» To learn from it and to feel like a hacker. πŸ’‘ Create a bash script I want to able […]

How to set docs as homepage for Docusaurus

If you’d prefer to show the Docusaurus docs section as a homepage instead of the regular landing page, you can use the snippet below. There are several ways to do this. From a simply server redirect, to the a hacky JavaScript redirect to the much desired official approach down below. Official solution: configure the docs […]

How To Shuffle An Array in JavaScript

Fisher-Yates Algorithm Most of the answers on StackOverflow on how to shuffle an array are not truly random. I wanted to repost this, so we never lose it. Using this algorithm from 1938 we can shuffle an array with more true randomness than other options out there. JavaScript implementation Here’s the JavaScript version of the […]

Get elements by XPath – JavaScript

I was trying to do a querySelector by text, trying to find elements with certain text content of an element. It turns out you can do that with XPath without much effort. With any XPath expression you can think of. Query the elements In my particular use caes, the HTML looks like this: Use your […]

How to sort array of objects by 2 property values – JavaScript

Here’s how to order an array of objects by multiple property values. I want to order my friends: First the oldest. If they have the same age, first the tallest. We’ll use Array.prototype.sort() Result As you can see the friend 4 and 5, who have the same age have been sorted by tallest first.

How to break on LocalStorage changes

If you’re debugging a LocalStorage issue and want to use a call stack to know what or who is triggering a localstorage get or set you can define a proxy function. The following snippet will overwrite the window.localStorage It has the same functions but adds a console.log and debugger before them.

Create a cheap clone of Object – Vue

Here’s an obvious bit of code (obvious when you know about it) πŸ€¦πŸ»β€β™‚οΈ

How to create a clone of a Vue object without the bindings?

« Previous