In this tutorial, we learn about how to set up a simple restful API with Node.js, Express, and MongoDB.
Before we start, we need to have NPM and Node.js installed on our machine. We relying on NPM Node Package Manager to manage all the packages and modules for Node.js.
Run the command below to verify you have NPM and Node installed. Make sure you see the version of node and npm return on command prompt.
node -vnpm -v
Once we have the npm installed, setting up a Node.js app can be very fast. …
Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle. It is also called “Ring Buffer”.
One of the benefits of the circular queue is that we can make use of the spaces in front of the queue. In a normal queue, once the queue becomes full, we cannot insert the next element even if there is a space in front of the queue. …
You are given an array of
lists, each linked-list is sorted in ascending order.
Merge all the linked-lists into one sorted linked-list and return it.
Input: lists = [[1,4,5],[1,3,4],[2,6]]
Explanation: The linked-lists are:
merging them into one sorted list:
Input: lists = 
Input: lists = []
k == lists.length
0 <= k <= 10^4
0 <= lists[i].length <= 500
-10^4 <= lists[i][j] <= 10^4
lists[i]is sorted in ascending order.
Often we may need to create or download bulk records in our application. In this tutorial, we will learn how to import and export Excel/CSV file into database in Laravel 8.0 using MaatWebsite 3.1. Grab the base source code from previous tutorial.
Run the command below to download and install the require package.
composer require maatwebsite/excel
Add the ServiceProvider and alias in config/app.php
'providers' => [
* Package Service Providers...
]'aliases' => [
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
Now, use the following command to publish the package configuration file.
php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config
Continuing from the previous post, we are going to create the frontend to allow users to create, update, and view the product details using Laravel 8 Eloquent.
In Laravel 8, frontend pages are stored in the resources/views directory. Let’s create a folder called product inside the resources/views directory. Next, Create four Blade view files as below. Since our previous tutorial was integrated with an admin template. Hence, we will create the product folder inside the admin folder.
Copy the code snippet below to index.blade.php as template.
PRODUCT | SGWEBFREELANCER
@endsection@section('content') <div class="row"> <div class="col-md-12"> <div class="card"> <div…
In the previous tutorial, we have set up an admin panel with Laravel 8. In this tutorial, we’ll be learning how to create a CRUD app with Laravel 8 to create, update, and delete records from a MySQL database.
Instead of writing raw SQL queries to do CRUD, we will be using Laravel 8 Eloquent to program the CRUD and manage the persistent data. Laravel Eloquent is an Object Relational Mapper (ORM) which helps in communication with the database. Each database table will have a corresponding “Model”.
Firstly, run the command below to create a Product model and controller using…
In the previous post, we have learned how to set up the Laravel v8 web application. This tutorial will show you the step by step to integrate admin template to Laravel v8 web application.
First of all, download a Bootstrap Admin Template. Unzip the template file, we will be using the assets and examples folders.
Step 1: Copy the assets folder and paste it into your Laravel web project public folder.
Step 2: Go to resources-> views create two folder layouts and admin.
Step 3: Create a file name dashboard.blade.php inside admin folder.
Step 4: Copy a html file from…
This tutorial guide you step by step to build a Laravel v8 web application.
First of all, install the composer with the command below.
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
After that, verify that your workstation has installed composer by run the composer command as below.
Next, we can install Laravel using composer. Run the command below.
composer global require "laravel/installer"
Ensure you set the composer path to $PATH.
Now we can start to create a Laravel project. Run the command below.
laravel new oems
Laravel comes with its own server, to verify we have successfully…
This tutorial guide you step by step on how to set up Celery 5.0 and AWS SQS to process asynchronous tasks in Django.
Your application may serve the long-running process. Instead of blocking the response, the request should be handle in the background. To achieve this, we will be using Celery and AWS SQS. Celery is an open-source asynchronous task queue which is based on distributed message passing. Celery uses AWS SQS a message broker to communication between the Celery Worker and the application. When the job is complete, the results are sent back to the backend. …
This tutorial will guide you step by step on how to dockerize Django, NGINX and PostgreSQL using Docker compose file. We have learnt how to set up Django with NGINX web server. Now we have a problem, containers are ephemeral, nothing in a container is persisted when a container is removed or dies. This shouldn’t be the case, we need to persist our data into a database; we need to keep the logs for debugging purpose. In this tutorial, we will learn about using docker volume to keep our data persistent.
We need to add a new service to the…
SGWebfreelancer is a software developer with 6 years experiences.