How to Reverse Order in Prisma for Fetching Data

When working with Prisma, a powerful database toolkit, you might find the need to reverse the order of your fetched data. This is particularly useful when you want to display the newest items first, similar to how Twitter operates. In this blog post, we will explore how to achieve this using Prisma’s orderBy functionality. Let’s consider a scenario where we have a Tweets table and want to fetch the tweets in reverse order, from newest to oldest....

How to Revert a File to a Previous Version on a Mac

If you’re working on a Pages document on your Mac and accidentally made a mistake that you want to undo, it can be frustrating. Luckily, there is a feature on macOS that allows you to revert a file to a previous version. In this blog, we will guide you through the process of reverting a file on a Mac using the Pages application as an example. Recognizing the Issue Suppose you made some changes to the cover of your Pages document the previous evening, but forgot to revert it before saving and quitting the application....

How to run a Web Server on an Arduino

In this tutorial, I will guide you on how to start a Web Server on an Arduino device with WiFi connectivity, such as the Arduino MKR WiFi 1010. By connecting to an existing WiFi network, you can interact with the Arduino using your browser via HTTP. This opens up a wide range of possibilities, from simple checks of sensor data to performing actions based on HTTP requests. To start, let’s use the code from the tutorial “Connect to a WiFi network using an Arduino”:...

How to Run JavaScript Snippets Easily

When it comes to testing or experimenting with JavaScript code, there are several convenient tools that I rely on. These tools make it easy to run little snippets of JavaScript and quickly see the results. One simple method is to open a Chrome or Firefox DevTools window and type your code there. This is perfect for trying out a line or two, but can be cumbersome if you need to spend more time on the code....

How to Save Text to a File in Node.js

If you’re looking to save some text to a file using Node.js, the process is quite straightforward. By following a few simple steps, you’ll be able to accomplish this task quickly and efficiently. To begin, you’ll need to make sure that the necessary Node.js file system module (fs) is imported. This module provides all the functionality required to interact with the file system. Once you have the module imported, you can proceed with the implementation....

How to Save Time with Text Expanding

Optimizing Routine Communication Tasks I always strive to make my communication tasks more efficient, especially when it comes to handling a high volume of emails. Recently, I found myself inundated with 67 new messages when I woke up after a good night’s sleep. This surge in email activity was a direct result of launching my JavaScript Full-Stack Bootcamp, The JS Bootcamp. While it’s exciting to receive inquiries and sign-up notifications, it also means I need to respond promptly to a wide range of questions....

How to Securely Store Passwords in a Database

When it comes to storing passwords in a database, it’s crucial to prioritize security. Storing passwords as plaintext is a big no-no, as it exposes the passwords and puts your users at risk. Instead, you should store password hashes - irreversible strings derived from the original passwords that provide a level of security without compromising user data. To achieve this in a Node.js environment, you can make use of the bcrypt library....

How to Select Elements Without a Class in CSS

If you’re looking to target elements in an HTML document that don’t have a specific class assigned to them, CSS provides a straightforward solution. By using the :not(.class) selector, you can easily select elements without that class. Let’s delve into the details and see how it works. The :not(.class) Selector The :not(.class) selector is a CSS pseudo-class that allows you to target elements that don’t have a specific class applied to them....

How to Select the First Child Element with CSS

Problem: I encountered a situation in my markdown file where I needed to style the first ul element, which happened to be the table of contents. However, I couldn’t assign a class or an id to specifically target it with CSS. In order to address this, I explored ways to select it using a suitable CSS selector. The HTML structure looked like this: <div id="content"> <ul> ...table of contents </ul> ....

How to Self-Host Plausible Analytics

I decided to self-host my website analytics. In this blog, I will walk you through the process of self-hosting Plausible analytics and explain why I made this decision. Why Self-Host? The cost and control are the two main factors that motivated me to self-host Plausible analytics. Hosted solutions can be quite expensive when you have a significant number of pageviews. By self-hosting, I am able to save on costs and have full control over my analytics data....