Tuesday, 29 May 2018

010 Node.js Timer

Timer functions are globals, there is no need to call require('timers').


setTimeout : Established a function to be called after a mentioned milliseconds. 
Example
setTimeout(function()

    console.log("setTimeout: 2000 millisecond completed!..");
}, 2000); 
output :




setInterval : Same function like setTimeout, but it callback repeatedly after every passing of the specified duration. 

Example
setInterval(function()
 {  
    console.log("setInterval: 2000 millisecond completed!.."); 
 }, 2000); 
output :











setImmediate : It is used to execute setImmediate.

Example 
setImmediate(function(){
    console.log("SETIMMEDIATE");
});

output :
 SETIMMEDIATE
clearTimeout : It prevents object created by setTimeout.


Example
 
var timerObj = setTimeout(function(str1, str2) {
  console.log(str1 + " " + str2);
}, 2000, "Hello.", "world");

clearTimeout(timerObj);

output :


clearImmediate: Method can be used to cancel the execution of the callback and created by setImmediate
Example
 
var myObj = setImmediate(function(str1, str2) {
  console.log(str1 + " " + str2);
},  "Hello.", "world");

clearTimeout(myObj);
 
output :
Hello. world 

 
clearInterval : It is used to stop an intervalObject, as created by setInterval.
Example
var myTimerInterval = setInterval(function(str1, str2) {
  console.log(str1 + " " + str2);
}, 1000, "Hello.", "World");

clearInterval(myTimerInterval);


output :

009 Node.js Console

The console module provides a debugging console that is similar to the JavaScript console mechanism works in web browsers.

  • console.log([data][, ...])
          Prints to stdout with newline. Multiple arguments can be passed,first used as the primary message and all additional used as substitution values.

Example (main.js)

console.log('hello world');
console.log('hello %s', 'world');


Output :











  • console.info([data][, ...])
         The console.info() function is alias for console.log().
Prints to stdout with newline with Optional Multiple arguments.


Example (main.js)

console.info('Hi,I am learing node.js');

Output :









  • console.error([data][, ...])
         Prints to stderr with newline. Multiple arguments can be passed ,first used as the primary message and all additional used as substitution values.




Example (main.js)

console.error(new Error('Hi,I am learing node.js'));

Output :












  • console.warn([data][, ...])
          The console.warn() function is alias for console.error().
Prints to stderr with newline. Multiple arguments can be passed,
first used as the primary message and all additional used as substitution values.

Example (main.js)

console.warn('Hi,I am learing node.js');

Output :








  • console.dir(obj[, options])
       Uses util.inspect on obj and prints resulting string to stdout.

 





  • console.time(label)
        Starts a timer that can be used to compute the duration of an operation.

 




  • console.timeEnd(label)
Finish timer. Example (main.js)

console.time('myTimeExample');

//Your Statement

console.timeEnd('myTimeExample');


Output :










  • console.trace(message[, ...])
      Print to stderr 'Trace :', followed by the formatted message and stack trace to the current position with util.format().

Example (main.js)

console.trace("I am learning nodejs");

Output :








  • console.assert(value[, message][, ...])
 Similar to assert.ok(), but the error message is formatted as util.format(message...).
 


  • console.dirxml(...data)
      This method calls console.log() passing it the arguments received. Please note that this method does not produce any XML formatting.




023 Weekend Tour Nabadwip and Mayapur


Nabadwip : Nabadwip is famous  among the Bengali religious people. This is a place where Bhakti movement starts in 16 century. Nabadwip is situated and the Western side of Bhagirathi ,in the district of Nadia, West Bengal ,India. Nabadwip  is the birthplace of Lord Sri Chaitanya. Lord  Sri Chaitanya start the vaisnava idea in 16 century from here. Nabadwip meaning collection of 9 island in Bengali. The main attraction of this place is Janmasthan  of Lord Sri Chaitanya. Other attraction is Radha Rani Temple,Sonar Gopal , Surabhi Kung math ,Mahaprabhu Mandir,Hari Sabha Mandir




Nabadwip is a holy place, several  holy festival  are celebrated in Nabadwip. Rath Yatra, Dol Yatra, Gaur Purnima  are the well-known festival of  Nabadwip. Nabadwip is just 115 kilometre from Kolkata. You will get  several train from Sealdah for Nabadwip Dham. Getting at Nabadwip Dham, you have to take auto to go  Nabadwip Ghat. Then you have to cross river Bhagirathi to reach  Nabadwip. Bus service is also available for Nabadwip. From Esplanade , you will get buses for almost  each hour.










There are several private hotels in Nabadwip. You can book, guest house of
Nabadwip Municipality or ISKCON guest house.
Please keep in mind, Nabadwip is a holy place of traditional Hinduism.


Mayapur : Mayapur is situated just opposite side of the river Bhagirathi. You need to cross the river by ferry. Mayapur is famous for ISKON Temple. This is headquarter of ISKCON. The Radha Krishna idol  is the main attraction of Mayapur. By reaching there you will feel peace of mind and you will feel relaxed. Mayapur has its own rhythm, most of the visitor pray to Lord Krishna in the greeny and peaceful environment. Devotee form all around the world comes here to visit Lord Krishna. Mayapur celebrates several festival like Dol Jatra ,Rash  Jatra etc. Mayapur have several private hotels to stay, Hotel private restaurant to eat, beside this there are other option  Gaurav and Geeta Bhawan  in the ISKCON complex. You can take accommodation and fooding from  there. The ISKCON complexes is very large, you can visit by walk. You will see well maintained cow and can purchase elements  made from cow milk such as Ghee, Yogurt, Go-ark (distiled cow urine) and others. .This is called "Goshala" , that contain almost 200 cow and bulls.






Ballal Dhipi : Ballal Dhipi is near to Bamapukur Bazar. You can reach there by auto. Ballal dhipi is under Archaeological Survey of India. A Structural complex if Vikram Shila Bihar , maybe used for social learning and pilgrimage.


Monday, 28 May 2018

019 Weekend Tour Betla National Park

Betla National Park is situated at Latehar District of Jharkhand in India. Betla National Park is around 140 kilometre from Ranchi. Betla National Park is situated on the Chota Nagpur Plateau in Jharkhand.









Betla National Park is a national park, elephant, tiger, Leopard,  monkey, Samber, chital are natural inhabitant of the Jungle. Besides this animal, different kind of rare birds , different kind of  rare trees are found in Betla National Park . As you enter deep forest, you will see green all around jungles and hear creeping of birds the jungle. We found , small Board is attached with some trees, this boards gives information about the trees.








Betla National Park is 3 hours journey from Ranchi.The nearest Railway station of Betla National Park is Daltongung, which is around 25 km away.




 



For tourist , there are two option either elephant safari or by car. Elephant ride starts at 5 am in the morning. It is about  400 rupees per person. You can book Safari Jeep from the gate of Betla National Park or you can take your own car in the jungle, in both cases you have to hire guide. Guide charges 100 rupees per hour.





 



The most beautiful thing Betla National Park  is dear. You will see plenty of Deer in the jungle. Sambar, Mouse deer, monkey roaming around the jungle. In the Jungle you will find some ruin  of earlier  construction.




 



Some few number of private hotels is there , outside the Betla National Park. You can book van vihar  from OTDC. If you stay in the tree house, you will enjoy the dear. In the morning you will see that hundred of the dear  is roaming around your  room.


008 Node.js Zlib

The Node.js zlib used for compression implemented using Gzip and Deflate/Inflate.zlib module can be added as  

const obj = require('zlib');
 

Below is the code to compress file.

Example 1

const obj = require('zlib');
const gobj = obj.createGzip();
const fs = require('fs');
const inp = fs.createReadStream('myFile.txt');
const out = fs.createWriteStream('myFile.txt.gz');

inp.pipe(gobj).pipe(out);
 


Output :




Below is the code to de compress file.

Example 2
 
const obj = require('zlib');
const gobj = obj.createGzip();
const fs = require('fs');
const inp = fs.createReadStream('myFile.txt.gz');
const out = fs.createWriteStream('myFile.txt');

inp.pipe(gobj).pipe(out);
 

Output :







 




 

007 Node.js Errors

Node.js Applications generally experience 4 categories of errors:

Standard JavaScript errors :


 
System errors : Operating system constraints such as file does not exist, send data over a closed socket, etc;

User-specified errors:
User-specified errors triggered from application code.

AssertionErrors :
AssertionErrors are a special class of error that can be triggered whenever Node.js detects an exceptional logic violation that should never occur. 


Node.js errors inherit from the Error base class 

Error
   TypeError


JavaScript errors are handled as exceptions,below is the example.

Example 1

try {
  const a = 1;
  const c = a + b;
} catch (err) {
   console.log(err); 
}


Output :

ReferenceError: b is not defined

Below is a example of System errors ,We are going to open a file , that does not exists.


Example 2

const fs = require('fs');

function MyCallback(err, data) {
  if (err)
  {
    console.error('There was an error opeing the file', err);
    return;
  }
  console.log(data);
}
fs.readFile('C:/does-not-exist.txt', MyCallback);
Output :

There was an error opeing the file { Error: ENOENT: no such file or directory, open 'C:\does-not-exist.txt'
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'C:\\does-not-exist.txt' } 





006 Node.js OS Module

Node.js provides the basic information about the information of Operating system.

  • arch() : Returns a string identifying the  operating system CPU architecture.
  • constants : Returns an object containing the  commonly used operating system's constants for process signals.
  • cpus() : Returns an array of objects containing information about the computer CPU core.
  • endiannes() : Returns a string identifying the endianness of the CPU on which Node.js compiled.
  • EOL :  string constant defining  end-of-line marker for the current operating system.
  • freemem() : Returns the amount of free memory of the system.
  • hostname() : Returns the hostname of the operating system.
  • loadavg() : Returns an array containing the load averages, (1, 5, and 15 minutes).
  • networkInterfaces() : Returns the network interfaces that has a network address.
  • platform() : Returns information about the operating system's platform.
  • release() : Returns a string identifying information about the operating system's release.
  • tmpdir() : Returns the operating system's default directory for temporary files.
  • totalmem() : Returns the number of amount memory of the system.
  • type() : Returns a string identifying the operating system name.
  • uptime() : Returns the uptime of the operating system, in seconds.
  • userInfo() : Returns information about the current user.

Example 1
 const os=require('os');

console.log("os.os.arch(): \n",os.arch()); 

console.log("os.endianness(): \n",os.endianness()); 

console.log("os.freemem(): \n",os.freemem()); 

console.log("os.homedir(): \n",os.homedir()); 

console.log("os.hostname(): \n",os.hostname()); 

console.log("os.loadavg(): \n",os.loadavg());

console.log("os.platform(): \n",os.platform());

console.log("os.release(): \n",os.tmpdir());

console.log("os.platform(): \n",os.platform());

console.log("os.totalmem(): \n",os.totalmem());

console.log("os.type(): \n",os.type());

console.log("os.uptime(): \n",os.uptime());
 
Output :


os.os.arch():
 x64
os.endianness():
 LE
os.freemem():
 1696145408
os.homedir():
 C:\Users\dbhattacharjee
os.hostname():
 edmsws95
os.loadavg():
 [ 0, 0, 0 ]
os.platform():
 win32
os.release():
 C:\Users\DBHATT~1\AppData\Local\Temp
os.platform():
 win32
os.totalmem():
 4249927680
os.type():
 Windows_NT
os.uptime():
 461648 




Example 2

const os=require('os');
console.log("os.cpus(): \n",os.cpus());


Output :

os.cpus():
 [ { model: 'Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz',
    speed: 3093,
    times:
     { user: 53989468,
       nice: 0,
       sys: 17333000,
       idle: 390462515,
       irq: 379687 } },
  { model: 'Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz',
    speed: 3093,
    times:
     { user: 53434718,
       nice: 0,
       sys: 18220625,
       idle: 390129406,
       irq: 63562 } },
  { model: 'Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz',
    speed: 3093,
    times:
     { user: 46948515,
       nice: 0,
       sys: 17317781,
       idle: 397518453,
       irq: 54734 } },
  { model: 'Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz',
    speed: 3093,
    times:
     { user: 50369218,
       nice: 0,
       sys: 16611015,
       idle: 394804515,
       irq: 60406 } } ]











023 Weekend Tour Dhap Dhapi Dakshineswar

Dhap Dhapi Dakshineswar is a temple near Dhap Dhapi. Dhap Dhapi is a railway station under Sealdah south division,  you need to hire local pedal van to come at Dhap Dhapi Dakshineswar Temple from Dhap Dhapi. If you are coming through road , you have to fast come to Baruipur and then by road to Dhap Dhapi



Dhap Dhapi Dakshineswar is a very old temple of Hindu religious God, called "Dashina Roy". It is believed, the God once domain the entier Sundarban  area. The temple contain the idol of "Dashina Roy"  armed with armor. Around 11 a.m in the morning worship starts. 




Devotee from different area and far away come to attend Pooja and make offer to  the God. You will find small stall all around The temple, you can purchase  offering from them. Several festivals  happens  in this temples. Nil, ambubachi, Sanyas ect. Famous and the most  festival is "Jatal Usav", which is considered the birthday of the God "Dashina Roy" in  the month of January. This time a large fair  happen around the Temple. Devotee from far away come to celebrate the festival.

Dhapapdhapi  was a Panchayat area earlier, now it is municipality area . Dhapdhapi is well connected with Roadways and Railways also. You will find some small shop to get your tiffin. But you will not get any hotels to stay here or no good restaurant.


 

022 Weekend Tour Baba Barakachari

Baba Barakachari temples very near to Kolkata, it is just 14 km from Thakur pukur. Baba Barakachari is very popular Hindu religious place, thousands of  devotee come here to worship daily. 




Baba Barakachari idol is a fig tree ,locally name Aastha , beside this, idol of Shiva, Krishna, Bramha is there. People from different part of the area come here an offer Pooja to Baba Barakachari. In the temple area, there is a large pond, devotee take Bath there. In the temple area, there are a large number of small shops, selling elements for wordship. Devotee ask blessing from Baba Barakachari.

 




Baba Barakachari means "Grand Court"  in local Bengali lanfuage, however it is a temple of Lord Shiva. You can come here by two ways, home Thakurpukur Amtala  to Bakhrahat, then take a rickshaw auto to reach the  Temple. Or you can reach home Charial  to Bakrahat , then Rickshaw  auto to the temple. 



Baba Barakachari is very popular, during the month of "Baisakh"  in Bengali , devotee from far away, walk here to pour  water the Lord Shiva. They carry the water, to their own shoulder the  entire way, finally offer to the Lord Shiva. Baba Barakachari is a one day tour for religious people of Hindu.

021 Weekend Tour Shantipur

Shantipur is famous for Rash festival . It is very near to Kolkata. Santipur is a Municipal area under Ranaghat division of Nadia district West Bengal India. Shantipur celebrate several festival like dol festival ,Rash festival ect. But it is famous for Rash festival. Big big pandals, Grand procession, lighting, sound of different playing instrument change the ambience of Shantipur in those days. 



Rash festival last for 4 days, last day, people do Grand  procession with drums, Kirtan, 108 dhaki ,banjo and other different playing instrument  in the road . Hindu people in those days goes to very festival mode  with their festival, they visit pandals to pandals and visit the idols and the decoration. Idols are generally made of clay, different Portrait of a epics  with background decoration.





Goswami Bari, Modan Gopal Thakur Bari, Radha Bollova  are very well known for Rash festival. Another attraction of Santipur is  Santipur library, one of the interesting for ancient culture and heritage. 



Shantipur is very near to Kolkata, almost each hour, train from Sealdah to Santipur is available. Shantipur is well connected with Kolkata by road also, you can  go to Shantipur by SBSTC bus from Esplanade. To visit Shantipur Rash festival, We hired an Toto , it was around 2 hours to visit almost all pandals,  there are plenty of Toto  available  in the Shantipur. We hired   at Rs.200. Could not found any good restaurant in the Shantipur,we took our launch by at Fulia, the nearest railway station of Santipur.

Shantipur also famous for saree. Santipur  produce  the traditional Bengali tant sarees. You can purchase from the manufacturer all wholesaler also.


020 Weekend Tour Chandipur

Another weekend Getaway of Odisha  is Balasore, commonly known as Baleshwar . Balasore is  a district  of Odisha,India.
Chandipur : Chandipur is the main attraction of Balasore. Auto , Traker service available  to move go Balasore to Chandipur. Chandipur is a good beach spending time after  a hectic weekend. Chandipur sea  play Hide and Seek with the visitor, during the high tide, sea appear near you , during low tide the sea goes far away. We walked around 2 to 2.5 km during low tide to see the sea . During high tide , people bath on the beach with the Rolling waves . We noticed,small car are  moving around the beach during low tide. You will find a lot of red crabs  in the beach , if you walk through during the low tide time. There are several private and government hotels near Chandipur beach, you can visit OTDC website for booking purpose.










Devkund Waterfall : Devkund waterfall is very famous picnic spot and very attractive to the tourist, huge waterfall is falling around 50 fit with roaring sound within a deep forest. Devkund waterfall is situated in Simlipal forest of Odisha. Dense forest, creeping of birds,  roaring of water create a beautiful ambience here. Beside waterfall, you can ride around 100 staircase to visit Devi Ambika Mata Temple. You can worship here  and ask blessing from Devi Ambika Mata. You should keep in mind,  you have to travel around half kilometre by walk, card will be stop at a place near Devkund Falls, the rest you have to travel by walk.






Similipal : Similipal is a wildlife sanctuaries of Odisha. It is a tiger reserve. Leopard, elephant, dear, crocodile are found here. It is a dense forest and deep green all around the forest, most of them are sal trees. You can stay in the Jungle or night stay in the jungle, you can visit otdc for this purpose.











Panchalingeswar  : Panchulingeswar is another place to visit near Chandipur. Panchalingeswar is situated at the top of a hill , you have to  upstairs around 250  to reach panchalingeswar. Panchalingeswar is idol of Lord Shiva, you will not be able to see the idol of Lord Shiva, the ideal is immerse in a  small flow of water , you have to put your hand to touch the idol of Lord Shiva. You can wordship  Lord shiva and ask for blessing. The scenic beauty of this place is wonderful.

Who is well connected with Kolkata, we boarded at Falaknuma Express at around 7:30 a.M and reach Balasore around 11:30 A.M. Then book a auto to reach Balasore.

বাঙালির বেড়ানো সেরা চারটি ঠিকানা

  বাঙালি মানে ঘোড়া পাগল | দু একদিন ছুটি পেলো মানে বাঙালি চলল ঘুরতে | সে সমুদ্রই হোক , পাহাড়ি হোক বা নদী হোক। বাঙালির ...