Friday, February 16, 2018

MongoDB Transactions and ACID compliance

MongoDB is a most popular NoSql database amongst all other NoSql databases. There is a main difference between SQL and NoSQL is that SQL supports transactions and NoSQL do not. Databases are selected depending upon the business requirements, development feasibility, scalability, and agility.

Transactions are important. Any database needs to offer transactional guarantees to enforce data integrity. But they don’t all do it in the same way – different database technologies follow different mechanism.Transactions in a database is a sequence of operations performed as a single logical unit of work. A logical unit of work must conforms  four properties of ACID to qualify as a transaction. The properties are called the atomicity, consistency, isolation, and durability. 

Thursday, October 19, 2017

Coding from the passion!

I have been writing computer programs from the second year of my bachelor study. Now, it has been over 6 years since then. I did not have CSE as major in the University. That's why writing code was my hobby, passion, art whatever you say. I feel most excitement when my code works and gives me output as I expect. Therefore, programming started to be considered as a creative field for me where I can show up or create most challenging things. I know every programmer feel the things same as I do.

As programming is an art and creative things derive from passion, Programmer always love to work in good environment with latent peoples and with challenging exciting projects. But, Traditional full-time job sometimes becomes boring and even bitter in some cases. These days remote work is being more popular among software developers for its various advantages.

Friday, July 14, 2017

JavaScript Best Practices Checklist / Important Things

Learning new things every day is a great habit that makes people great and ideal human being. As a developer, it is a part of our job. Developers are always accustomed to learn new things regularly. Sometimes, it becomes part of our daily work and sometimes it happens for more curious minds who advance always themselves with new technology and best practices.

Best practices is a significant coding style for every professional software developer. Your code is not enough good when machine can only read it and other developers can not. Your code should be human readable too. That's why ideal developers follow best practices for their coding style. It makes their code more sophisticated, readable, elegant, and comprehensive for every other developer.

In this article, I will point out a few important JavaScript best practices that you can remember easily.

1. Avoid polluting global scope. Always use IIFE (Immediately-Invoked Function Expression)
(function () {
   var foo = 12;
   console.log(foo);
   // 12
})();
 
 More Examples:
 
const getName = function () { }()     // ✗ avoid 
 
const getName = (function () { }())   // ✓ ok 
const getName = (function () { })()   // ✓ ok 

2. Use "use strict" to protect version compatibility and unexpected error. Best to use inside IIFE
(function () {
   "use strict";
   var foo = 40;
   console.log(foo);
   // 40
})();
 

Tuesday, April 4, 2017

How to make image slider in AngularJS from scratch

Hi, I hope you like angular and seeking to make an image slider, right? I will show you how to make image slider in AngularJS from scratch.
I was searching for a good slider in AngularJS that will be able to show my products with three images in a row or carousal but one image in the middle will be some bigger or some different style look. I did not find proper library that can meet my exact need. Finally, I decided to make the slider from scratch that will fulfill my requirements.

I will share with you the tricky ways in AngularJS that I followed to make the slider. You can also make your own slider if you can understand my tricky rules. That's actually very easy thing when you know JavaScript well and set necessary algorithm. I will make a slider that will display three image in a row and will pass by one image when click on next or previous and it will come the next images repeated after it  finishes the view. The slider will look like the following.


I have followed a basic project structure for angular slider project. Here is my folder and files structure.

Sunday, October 16, 2016

Comparing Nodejs v6 Vs PHP7 Performance Benchmarking

I will show you a comparison of performance between Nodejs and PHP. This is my PC configuration.



I will compare
===================
The version of NodeJS:  v6.4.0
The version of PHP   : PHP 7.0.8


Nodejs Code:

app.js
var http = require('http');
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
});
server.listen(8000);


PHP code

index.php

<?php

echo "Hello world";

Running the server:
===============
I have used node built-in http server to run the nodejs code
node app.js 
 the node server is running on http://localhost:8000

And I have used php built-in server to run the php code

php -S localhost:8080

the php server is running on http://localhost:8080


Benchmarking:
==================
I did benchmark with siege, and ran them on the same machine. To install siege on Ubuntu, you can run sudo apt-get install siege . First, I have run this test on node server


siege -q -c 100 -b -t 60s http://localhost:8000/

and got this result for Node:

Transactions:              572363 hits
Availability:              100.00 %
Elapsed time:               59.29 secs
Data transferred:            6.55 MB
Response time:                0.01 secs
Transaction rate:         9653.62 trans/sec
Throughput:                0.11 MB/sec
Concurrency:               99.83
Successful transactions:      572363
Failed transactions:               0
Longest transaction:            0.04
Shortest transaction:            0.00

Afterwards, I have ran the same test on php  server  by the following command


siege -q -c 100 -b -t 60s http://localhost:8080

and got this result for PHP:

Transactions:              443534 hits
Availability:              100.00 %
Elapsed time:               59.49 secs
Data transferred:            4.65 MB
Response time:                0.01 secs
Transaction rate:         7455.61 trans/sec
Throughput:                0.08 MB/sec
Concurrency:               99.74
Successful transactions:      443534
Failed transactions:               0
Longest transaction:            0.08
Shortest transaction:            0.00

Finally, we can see that NodeJS is more faster than PHP.

Thursday, September 1, 2016

What is Module in AngularJS

AngularJS is one of the most popular JavaScript MVC framework now in the field of web application development. It is used mostly to develop Single Page Application (SPA). Understanding Module in AngularJS is very important to develop your application efficiently, Most importantly when you need to write modular code.

Sunday, August 21, 2016

Notification Schema Design in MongoDB

 I was searching for a best solution to design a notification schema in No-SQL database. I was using MongoDB and Mongoose ORM in Node app. I had to maintain the idea of scalability. That's why I tried to keep my schema in a single collection instead of using multiple collections.

Monday, August 15, 2016

Nodejs Route Prefixing in Expressjs


Routing is an important part of modern web applications. we do route for various features development. Routing is actually handling the receiving request and providing response properly. Routing is a getway to receive request from various sources into your application and responding to that request with required data.

Sunday, August 14, 2016

How to integrate Paypal payment API with Laravel 5.2?


Toady I will discuss about Paypal payment API to integrate with Laravel 5.2 . Paypal has an official payment SDK to work with PHP. Let's see how we can work with this SDK and make payment in Larvel.

Friday, November 13, 2015

How to make read more and read less in angularjs for a large description?


Hi,
I will write today about a cool functions to make read more and read less system for your large description in AngularJS.  I have observed that it require many coding to make read more function in php, or other language that provide backend query in database to show additional text in read more. But it is very easy now to handle in front end MVC. I am talking about AngularJS. You can handle this in AngularJS very smothly.

Friday, October 24, 2014

How to delete browser Cookies and Cache

It usual that you need to delete your browser's Cookies and cache to improve your browser sppeed and other important reason. So, I will let you know how you can delete your browser's cookies and cache.

If you are using mozilla firefox, first open your browser and if it is already opened just go to the process. Find in your keyboard . Keep pressed Ctrl+Shift and press Delete key. It will appear a window. select Time range to clear and options that you want to delete and then press clear now. wait for few seconds and you will understand your cookies and cache has been deleted. you can see the image bellow for proper understanding.

Wednesday, October 22, 2014

How to hide IP address

There are different ways to hide your ip address when you browse internet. Today, I will tell you about two ways of ip hiding.
One method is by using software. There are many ip hiding software on the internet. Some of them are "Hide IP Easy", "Platinum Hide IP", "Hide IP All" etc. You can use this very easily. But I will show you another method of ip hiding and that is manually hiding your IP. So, Let's see how to hide ip address in Mozilla Firefox.

Tuesday, October 21, 2014

How to show product stock availability in category page in Opencart cms

Today I will show you how to display product stock availability in category page in Opencart cms. There are few code that  you need to add in the several page.

First Step:

========

Go to category.php  in catalog/controller/product and place this code:

$this->data['text_stock'] = $this->language->get('text_stock');


After this code:

$this->data['text_limit'] = $this->language->get('text_limit');

Wednesday, October 15, 2014

Default .htaccess file of Opencart cms

Hello,
Today I will share with you the default .htaccess file of Opencart cms. I know you may need sometime it because it doesn't display in some server. so it is hard know know for you about the default .htaccess file of Opencart cms when you will plan to change anything in the server or move files from one server to another.

Monday, October 13, 2014

How to display another website in iframe for full height and width

I know you are thing of how you can show another website in your website for full height and width in html code <iframe></iframe> . The main code for iframe is bellow


    <iframe src="www.anothersite.com" width="" height=""></iframe>

Here is the confusion how you will place the and width. you know you website is 1000px width for example and 1400 px height. definitely, you will go to give this height and width in <iframe> . yes, thta will work. but problem is for other pages. When the user will go to other pages, they see those pages in this specified height and width and there will show a scroller in the right side as your specified height has crossed other pages. Or, you will see there are a lot of white space in your bottom if the height of other pages don't cover full height you mentioned in the <iframe>. so, you are confused. here is the solution that will rid you of this problem. just give the  height="100%" and width="100%", it will solve your problem. it will get automatically height and width of per pages. So,  no worries. user will enjoy your website from another server without any problem.

.htaccess 301 or 301 redirect problem and alternative solution

Recently, I transferred an Opencart webshop from one server to another server. After Transferring the project I had some pages to redirect . I tried many times in .htaccess. the code that I used to do this is bellow:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

Redirect 301 /onepage.htm http://mt-example.com/mynewpage

But I failed, it did not work properly. I had another suggestion from forum site and that was as follows: