TO THE NEW Blog PAGES

Technology

Capped Collections In Mongodb

We can create collections in mongoDb on which we can apply size limit. These special type of collections are called Capped Collections. These are a kind of circular queues, in which if allocated size limit is reached, it makes space for new documents by overwriting the oldest documents in the collection. How to create Capped […]

Sakshi Tyagi
Sakshi Tyagi
Read

Technology

Sandboxing In Node.JS Using VM Module

Two commonly known ways to execute a script in Node.JS are using eval () function or running it using VM module. Lets see this through an example: [js] var vm = require(‘vm’); this.name = "Sakshi"; var script = "this.name = ‘Tyagi’", withVM, withEVAL; withEVAL = eval(script); console.log("withEVAL :" + withEVAL + ", " + "local […]

Sakshi Tyagi
Sakshi Tyagi
Read

Technology

Digging Into Event Emitters In Node.JS

In extension to my previous blog on Event Emitters Event Emitters In Node.JS, here we will see some variations in implementing Event Emitters. We can bind more than one listeners to an event. For example: [js] var events = require(‘events’); var eventEmitter = new events.EventEmitter(); var printFruit = function printFruit() { console.log(‘I like Mango!!’); } […]

Sakshi Tyagi
Sakshi Tyagi
Read

Technology

Constants In JavaScript

We can create constants in JavaScript using ‘const’ keyword. [js] const name = ‘Sakshi’ console.log(name) [/js] This will print: Sakshi Now, if we try to change or re-initialize ‘name’ constant, the value will not change. [js] const name = ‘Hello’ console.log(name) [/js] This will again print: Sakshi Compatibility: ‘const’ is supported in Firefox & Chrome. […]

Sakshi Tyagi
Sakshi Tyagi
Read

AWS

Setup custom CloudWatch metrics on EC2 instance

AWS provides its user the Cloud Monitoring service which is used to keep a check on the resources being used. It can be a great tool for developers and system administrators for cases like: Monitoring data/graphs Setting up alarms Identify trends Take actions based on the state of cloud environment But AWS does not provide […]

Grails

Spock @ConfineMetaClassChanges annotation made writing grails unit test easier

Grails version 2.0 and above made unit testing much simpler with so many new annotations introduced. However if you wanted to mock a specific method of a class whose method is being tested or you wanted to create a stub of the class already annotated by @Mock, things would become difficult. So I always ended up […]

Amit Jain
Amit Jain
Read

Technology

Event Emitters In Node.JS

Event Emitters are used to create and manage our own events and trigger them accordingly. We can bind listeners and emit those events whenever required. Example : [js] var events = require(‘events’); var eventEmitter = new events.EventEmitter(); eventEmitter.on(‘Morning’, function welcomeMessage() { console.log(‘Good Morning!!’); }); eventEmitter.on(‘Evening’, function goodByeMessage() { console.log(‘Good Evening!!’); }); if(new Date().getHours() <= 12) […]

Services