Grails

Mapping multiple Route53 record sets to a record set

Lets take an example where we need to point somedns.com, www.somedns.com to anotherdns.com using AWS’ Route53. Creating a record set to point www.somedns.com to anotherdns.com is easy, where www.somedns.com would be a CNAME type record with value “anotherdns.com”. But mapping somedns.com to anotherdns.com is not that trivial as R53 does not allow creation of a […]

Hitesh Bhatia
Hitesh Bhatia
Read

Node.js

Streams in node.js : Readable and Writable

Within Node.js development, streams are used to transfer data including requests to an HTTP server, opening a file, stdin, stdout, stderr etc. Streams can be readable, writable or both. We can connect the readable stream to a writable stream using the pipe method. All streams are instances of event emitters in node.js. We can get different […]

AWS

Mounting S3 bucket into an EC2 instance

One of our clients has hosted his application on AWS and it uses EC2 instances behind the load balancer. The application provides an interface where users are suppose to upload files. For saving the same on centralize location we use S3 bucket and mount the same on the EC2 instances. Following are the step which […]

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