How to subtract dates in Node.js

Need to subtract dates in Node.js? No problem, let’s use Java for that. After installing GraalVM using SDKMAN: $ sdk install java 20.0.1-graal as well as installing GraalVM’s Node.js runtime using gu1: $ gu install nodejs we can now perform some black magic: // index.js // "Import" LocalDate & ChronoUnit from ☕️ const LocalDate = Java.type("java.time.LocalDate"); const ChronoUnit = Java.type("java.time.temporal.ChronoUnit"); const firstDate = LocalDate.of(2023, 7, 20); const secondDate = LocalDate.of(2023, 8, 4); console....

July 20, 2023 · 1 min · Abdelrahman Abdelhafez

Record your terminal using your terminal

asciinema agg

July 10, 2023 · 1 min · Abdelrahman Abdelhafez

The Sierpiński triangle

Recently I’ve watched a video showing how to draw an approximation of the Sierpiński triangle on paper using the following steps1: Plot three points to form an equilateral triangle Randomly select any point inside the triangle and consider that your current position Randomly select any of the triangle’s vertices Move half the distance from your current position to the selected vertex Plot the current position Go to step 3 I found it absolutely fascinating, and at the same time I was extremely skeptical....

January 1, 2023 · 3 min · Abdelrahman Abdelhafez