Marcus

Marcus is a fullstack JS developer. He’s passionate about the hapi framework for Node.js and loves to build web apps and APIs. Creator of Futureflix and the “learn hapi” learning path.


Remove All Whitespace From a String in JavaScript

String replacements in JavaScript are a common task. It still can be tricky to replace all appearances using the string.replace() function. Removing all whitespace can be cumbersome when it comes to tabs and line breaks. Luckily, JavaScript’s string.replace() method supports regular expressions. This tutorial shows you how …

Continue Reading

Ubuntu/Debian — How to Test a Cron Job

Cron jobs are a nice way to automatically run scheduled tasks. The cron service in Linux systems is the typical approach when scheduling commands on the operating system. {{outline}} Testing a Cron Job Recently the certbot from Let’s Encrypt didn’t automatically renew SSL certificates anymore. We used a …

Continue Reading

Generate a Random Number in Range With JavaScript/Node.js

JavaScript has built-in methods to generate a single, random number. You can leverage this feature to create your own method generating a random number in a range between two other numbers. {{outline}} Random Integer Between X and Y (Exclusive Y) Let’s say you want to generate an integer in …

Continue Reading

Node.js — Run Async Functions in Batches

When working with arrays of data, you may need to run an asynchronous operation on each item. The Promise.all() method provides a convenient interface to run a list of promises in parallel, but it has some limitations. Using Promise.all() may overload the available resources, especially when reaching out …

Continue Reading

learn hapi — Bringing Back JWT Claims in the JWT Payload

The recent tutorials in this series on JSON web tokens introduced a handful of code changes. For example, you switched the packages creating JWTs from jsonwebtoken to node-jose to support encrypted and nested tokens. A downside of this switch: the JWT-related claims were added jsonwebtoken automatically when creating a new …

Continue Reading
Page 1 of 36

Explore the Library

Find interesting tutorials and solutions for your problems.