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 […]

Creating a To Do list WordPress theme

You might not know this about me but I used to be a WordPress developer, I used to get paid to exclusively develop Themes and Plugins at the company I worked for. It has been a while and I’ve lost the edge when it comes best practices and latest news. Specially around PHP and MySQL. […]

How to export Chrome CSS code coverage

Google Chrome allows you to export the code coverage as JSON but not as the file. At least not that I could find how to do it. It was easier, however, to find how to generate a new CSS file based on the JSON export. Use this small PHP script to output the used CSS […]

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 create gradient text in CSS

I wanted to add a css text gradient to some parts of my site. It’s well supported in modern browsers. Found this awesome pen and had to import it into my site 😍 How does it look? mix-blend-mode Part of the magic here is this CSS property (MDN Docs), which is well supported: Then combine […]

How to sort by multiple fields in GraphQL

Wasn’t quick to find the official documentation for this, so here it is in case you’re wondering. Single field sorting Multiple field sorting You can define an array of values for both order an fields. My full working query for printing a list of TV Shows ordered by season and then by the episode number.

How to have default values with “read” in Bash

I am slowly discovering the powerful Bash. Here’s something you’ll need eventually when working with Bash scripts and user input. How do you prompt the user to enter something in a Bash script? Of course you can print it later with: How do you set a default value? This syntax checks if name is empty. […]

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 create a blog with Gatsby

This passed weekend I spent some time playing with Gatsby. Gatsby is a blazing fast modern site generator for React. ⭐️ My TV Shows Review What was my plan? Use the provided repo to create the site to quickly have a production-ready setup and add little customizations. If you know me I love lifelogging. I […]