Image for post
Image for post

We all have our unique mental pictures of how we visualize code running. With regards to JavaScript, you might be familiar with the constraint that JavaScript runtime is strictly single-threaded. Using Promises, we seem to overcome some bottlenecks of single-threaded applications. This is usually where misconceptions start to develop, especially that promises enable multi-threaded programming. Let’s bust some misconceptions!

Myth 1: Promises Enable Multi-Threaded JavaScript

Image for post
Image for post

JavaScript runtime is strictly single-threaded, but you have to remember that the JavaScript runtime is only one system (or “Thread”) in a browser or Node.js. Browsers and Node.js …


Countries will soon mandate a right to basic income

Image for post
Image for post

Imagine a world where no one has to worry about their rent, next meal, or bills. It sounds like a utopia, right? That’s because we are conditioned to believe that such dreams are unattainable ideals. In reality, you are owed a basic income for your mere existence as a citizen in a country. Let’s explore why that’s the case.

Life is mixed with luck and misfortunes

Not everyone has the equal ability to compete for the good life. Many people are born into poor families that do not have financial or social means to provide more for their kids. …


Share resources or control number of instances with async-mutex

Image for post
Image for post

JavaScript runtime is single-threaded, but the asynchronous nature of promises introduces the necessity to synchronize access on resources in certain use cases.

Event handlers are asynchronous events that can benefit from mutual exclusion. Events like scroll and button click handlers can fire off multiple events within a second, but sometimes you only need the first event (and the others are undesirable). We need a way to be able to guarantee the order of the asynchronous events.

About async-mutex

async-mutex is an npm package that implements the synchronizing primitives, allowing you to control asynchronous events deterministically.

The synchronizing primitives are Mutex and Semaphore.

  • Mutex (short for mutual exclusion) is a lock. …


A 97-year-old philosopher describes his change of heart

Image for post
Image for post
97-year-old Philosopher Herbert Fingarette in “A 97-Year-Old Philosopher Faces His Own Death” on YouTube.

Herbert Fingarette passed away on November 2, 2018, leaving us with thought-provoking inquiries into Death.

I recently watched a 97-year-old philosopher describe how he feels about his own coming death. Fingarette was an accomplished philosopher and professor of Philosophy at the University of California. He even wrote a book on Death. In the video, he describes that he argued in his book on Death —over 20 years ago — that our fear of death is irrational because when you are dead, you won’t feel sadness, anger, or anything really. You just won’t be.

However, at 97, significantly closer to facing his own mortality, he had a change of heart. He says that while the several other books he wrote made him feel that he was able to rationalize the ideas behind them, the one thing he failed was to rationalize Death itself. He describes how he is afraid of his coming death, and how he wishes he can just stick around, despite how heinous our world seems sometimes. …


A ‘Trojan Horse’-like attack that can have catastrophic consequences

Image for post
Image for post

Hackers are most likely to succeed in compromising user accounts through exploiting the design of internet protocols. In this article, I would like to focus on a feature of HTTP that has proven to also be a liability: cookies.

Cookies can be a liability, but they’re super useful

Yes, cookies are super useful. Websites extensively utilize cookies for session storage. Once you login to a website, the server dispatches some session cookies that your web browser remembers for a certain period of time. Cookies greatly improve user experience. I mean, can you imagine having to login for every single page navigation on a website?

But their usefulness does come at a security price — they enable one of the most common HTTP attacks that are trivial to carry out: Cross-Site Request Forgery (CSRF). Let’s discuss a hypothetical example to illustrate the danger of CSRF attacks. An imaginary payment processor called PurplePay will be used. …


The Fortune Cookie Example

Image for post
Image for post

Why should you rent a whole server for simple requests? For most websites, conventional servers are often idle 99% of the time until someone needs some service to be performed. So why not have the ability to only use a server when needed? This is one of many fundamental motivations behind why serverless architectures were pursued and popularized in recent development world.

  • On-demand processing: You only pay and use a server’s resources for the time that it takes to process your requests. …


The web should be built for the inclusion of all. Smartphone adoption is, needless to say, ubiquitous. If you are designing a website and you are tackling the issue of making your font sizes responsive, then read on! I am going to introduce you to an amazing SASS module named RFS (which stands for response font size).

RFS— the package that makes font responsiveness trivial

Image for post
Image for post

Isn’t that amazing? As the width of the viewport gets smaller, the font size adjusts along with it. This helps provide a linear experience in terms of font sizes regardless of screen size!

The magic behind RFS

In summary, RFS takes your fixed font size unit (px or rem) and applies a linear algorithm of size reduction for screen width sizes of 1200px or lower. Here is a graph illustrating the linear algorithm that is displayed on the github page of RFS. …


Image for post
Image for post

You might have faced issues with npm install automatically picking up a new version of a dependency that broke your build. And you might have also heard of the incident where a programmer deleted several npm packages that millions of people depended on. Fortunately, there are some good practices we can adopt to minimize our exposure to external factors.

npm versioning standard

npm packages follow the major.minor.patch versioning format (e.g., 7.3.4). While the numbers themselves are arbitrary, how they change is not:

  • MAJOR versions are upgraded when a major overhaul of existing interfaces is committed. This often entails backwards incompatibility.


Image for post
Image for post

Python is a versatile language. If you are making use of the Object-oriented (OO) capabilities, you will be happy to learn about magic methods, and how you can leverage them to your advantage. Let’s dive in!

Overriding default logic

Magic methods allow us to override default operator functionality or Class behavior on creation, initialization, and even destruction. A magic method is always prefixed and post-fixed by two underscores __ . If you’ve used Python for OO programming, you have likely used the magic method __init__ almost every time!

Let’s explore several magic methods with some practical examples.

The __new__() method

__new__() is called by python to create an object before __init__() is called to initialize the object. Use of __new__() is not needed in most cases as it can be abused to allow for anti-patterns in development. However, __new__() is specifically useful — and acknowledged by the official python documentation here — when you need to extend the behaviour of immutable types like tuples. …


Image for post
Image for post

Dominant JavaScript libraries like React.js make it seemingly easy to write front-end applications out-of-the-box. Have you ever wondered how React can transform your complex, multi-layered application into static HTML pages that can be accessed from any browser? Web bundlers play a vital role here. Let’s explore web bundlers together through a simple interactive example.

What is Web Bundling?

Web bundling is the process of fetching, resolving, packing, reducing a tree of dependencies into compressed static files that you may readily host on the web. The original pioneering package in web bundling is the famous Webpack. …

About

Ahmed Sakr

23 Years Old • Lebanese • Student

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store