Skip to main content

Posts

How to build wordle?

  Following the latest trend in the game, I decided to create my own wordle game. The primary difference between my game and the original is that you have 100 chances to guess the word instead of only 6. Furthermore, you are not limited to a single word every day; you are free to play as much as you wish. Here's how I like to organize my directories and files: Let's begin with a simple class that will house our main logic. The class will be called "wordle," and it will include the following features. - Choose a word at random. Validate the user's input and provide a proper response (green, yellow & grey colours will be used to indicate whether the words are in the right positions represented by 2, 1, 0 respectively). Check the game's progress. The code above is in charge of picking a random word. It's worth noting that the source file and our wordle logic have been separated. This is to reduce code coupling and will be handy if we need to give an al...
Recent posts

Node.js: Thread pool

Let us begin by defining a thread. Wikipedia states that - In computer science, a thread of execution is the smallest sequence of programmed instructions that can be managed independently by a scheduler, which is typically a part of the operating system. The implementation of threads and processes differs between operating systems, but in most cases a thread is a component of a process.   I n Node.js, there are two types of threads: one Event Loop, also known as the main thread, and a pool of k Workers in a Worker Pool, also known as a thread pool. The libuv library maintains a pool of threads that Node.js uses in the background to perform long-running operations without blocking its main thread. To handle "expensive" tasks, Node.js employs the Worker Pool. This includes I/O for which an operating system does not provide a non-blocking version, as well as CPU-intensive tasks in particular. So, in essence, the threads are executed by the processor. Let's say a system or m...

Understanding SAML Metadata

Single sign-on  ( SSO )  is an authentication mechanism that allows a user to log in to numerous linked but separate software systems using a single set of credentials. We have two basic entities when it comes to Single Sign-On (SSO) - Identity Provider (IdP) - This entity is in charge of verifying the user's identity and communicating user information with the Service Provider (SP). In a nutshell, the identity provider delivers identification data.   Service Provider (SP) - This entity is responsible for providing services to the user. From the IdP, it obtains the user's identity. Consider the following scenario to better understand SSO: You've lately started working at XYZ, a new company. You've been given a work email address as well as access to a dashboard. After logging in, you'll see icons for all of the company's external services, including Salesforce, Jira, and others. When you click on the Salesforce icon, a background procedure occurs, and before y...

Node.js: Event Loop

  Coming from the world of PHP, Node.js was a frustrating experience, especially when it came to event loops, callbacks, promises, and so on. It took me a few hours to understand the fundamentals of the Node.js event loop. So, for everyone else out there (who doesn't understand), I'll try to explain it as simply as I can. As the official docs say What is the Event Loop? The event loop is what allows Node.js to perform non-blocking I/O operations — despite the fact that JavaScript is single-threaded — by offloading operations to the system kernel whenever possible. Since most modern kernels are multi-threaded, they can handle multiple operations executing in the background. When one of these operations completes, the kernel tells Node.js so that the appropriate callback may be added to the poll queue to eventually be executed. When Node.js starts, it initializes a single thread known as the event loop. Node.js employs the event loop to handle asynchronous operations within appli...