I am Learn.i.ng

Deploying Node.JS application with PM2

A process manager ensures that your application runs efficiently on the server. In this post, I will explain how to deploy your Node.JS project to production using PM2. PM2 is a daemon process manager with a built-in load balancer that keeps your application running even when you are not logged into the server. Prerequisites A Node.JS project Linux-based web server. I recommend using Ubuntu although the screenshots used are from …  continue reading

Some handy PHP functions

One beautiful thing about PHP is how you can start building with basic knowledge then you refactor your codebases as you learn more. In this post, I will show how to use some functions that will reduce the number of lines you need to type to achieve your goals.

list($name, $gender, $age) = ["John Doe", "Male", 42];

How to efficiently loop through PHP array elements

Use case: you have an array of images to which you want to prepend a path to get the full URL to be sent as an API response.

$images = array("image1.png", "image2.png", "image3.png", "image4.png", "image5.png");

A traditional way of doing things will be looping through each element of the array, prepending the path to each element, pushing the modified element to another array and returning that array.

How to use soft delete

`I want to let users delete their accounts but I really don’t want to delete the data from the database. How do I do that?` While this may not be ethical, it depends on your terms of service and the laws governing your location/app. However, an ideal use case would be to have sufficient data for analytics. To answer the question, a simple way to accomplish that is to use …  continue reading