Generate large files in Unix ad hoc

A neat trick to generate large files ad hoc is to run one of the simplest Unix commands ever: yes. When executed, it regurgitates an infinite stream of ys (suffixed with newlines): $ yes y y y y ... Piping its output into a file for approximately 10 seconds on a Mac Mini (M1, 2020) yields an 18-GB file containing 9.6 billion lines! $ yes >> yes.log ^C $ ls -lh total 37664520 -rw-r--r-- 1 abdelrahman staff 18G Dec 28 17:16 yes....

December 28, 2022 · 1 min · Abdelrahman Abdelhafez

Your network packets were in my living room

As of today, I’m serving this blog from my HP Slim Desktop at home! So if you’re reading this, that means that your browser just fetched this very page from a small computer that sits on my desk inside my apartment in Düsseldorf, Germany. A lifelong dream come true 🙈 Update (December 28th, 2023): Because I’m redoing my networking setup at home, the blog is temporarily not being served from the HP machine....

October 30, 2022 · 1 min · Abdelrahman Abdelhafez

Logic programming in JavaScript

Have you ever contemplated the possibility of having your computer solve your problems for you, without you having to tell it how? If your answer is a frantic “yes!”, you’re in luck: this is a thing, and this thing is called logic programming. We start writing our logic pragram by declaring the facts that we know. Let’s consider a typical, red-haired, magical family: % main.pl % Facts father(arthur, ron). % Arthur is a father of Ron father(arthur, ginny)....

May 30, 2022 · 3 min · Abdelrahman Abdelhafez