Node.js

High performance find query using lean() in mongoose

Lets start with a basic find query in mongoose and observe its execution time. [js] Event.find({'schedule.closing': {'$gte': +new Date()}}, {}, {limit:20, skip:0} ).exec(function (err, events){ ........ ........ } ); [/js] In my last project on Nodejs, I have used the above query to fetch the events...

by Sakshi Tyagi
Tag: javascript
13-Feb-2015

Node.js

‘resolve’ property in angular

Now a days , angular ui-router is being used actively for maintaining routes in angular applications. In my current project, I came across a use case in which I had to perform certain checks before executing certain route mapping. For example lets consider the most basic situation in which we want to directly show dashboard route in case...

by Rubi Saini
Tag: javascript
22-Jan-2015

Technology

How to get name initials as an image?

While making an application, showing user's image is a very common use case. Gone were the days when we used to show anonymous image in case a person's profile image or display image is not present. We can easily show a person's name initials as an image to identify the person. Like : Lets consider this html, where we use an...

by Sakshi Tyagi
Tag: javascript
07-Dec-2014

Android

Debugging Javascript on Android using Chrome

Nowadays almost all applications that we develop are made mobile friendly and a lot of times, everything works perfectly on desktop browsers but not on mobile. Even if we know it is some javascript that is not working as expected, it becomes quite difficult to narrow down on what is causing problem. As we cannot check console there, I...

by Vivek Sachdeva
Tag: javascript
30-Nov-2014

Technology

Variable Hoisting In JavaScript

Javascript handles function and variable declartions quite differently and you must have got stuck in one of the awkard scenarios due to it. First of all, you should be familiar with Scoping in JavaScript. If you are, then you would know already that JavaScript only has function scopes and no block scopes. [js] var a = 'hello'; ...

by Sakshi Tyagi
Tag: javascript
12-Oct-2014

Technology

Explicitly providing ng-model to DOM elements

In AngularJS, we can easily write our own custom directives to achieve required functionality. There are certain attributes which we provide in directive definition like restrict , scope , template, link, transclude etc. There is one more attribute named : require , which gives us the liberty to include another directive and inject...

by Sakshi Tyagi
Tag: javascript
28-Jul-2014

Grails

Uploading a file using only Ajax

We often need to upload a file without refreshing page or even before user submits the complete form. We have been using flash uploaders or i-frames to achieve that. However now it is possible to upload a file using only ajax and javascript. The first thing we need is a HTML form that will allow the user to select the file that they...

by Mansi Arora
Tag: javascript
04-Jul-2014

Node.js

Generate PDF in NodeJS using “node-phantom” module

PhantomJS is used to emulate browsers through command line, for generating PDFs, web page manipulation, headless testing and much more interesting stuff. Npm provides us a module called "node-phantom" which helps us to use PhantomJS in our NodeJS application in a non-fussy way. A prerequisite for using this module is, you must have...

by Sakshi Tyagi
Tag: javascript
27-Jun-2014

Node.js

Defining custom errors – NodeJS

Any well written piece of code should be defensive by nature with defensive error handling understanding that things could go wrong. Things would be great if we can define our own custom error classes which we can pass or throw in order to distinguish various errors. Custom error constructors helps in: ⇒   Identifying...

by Kushal Likhi
Tag: javascript
23-Jun-2014

Grails

FusionCharts Part – 2

Using Fusion charts you can create different variety of charts two of them are single series chart and multiple series chart . As the name implies in case of single series chart you can only display single chart and in case of multiple series chart you can display multiple charts. Now lets take an example to have better understanding of...

by pulkit
Tag: javascript
08-May-2014

Grails, Node.js

FusionCharts Part – 1

Stunning fusion charts will wow your audience . You can download javascript files for free trail of fusion chart from here . Following Javascript files are required to create fusion charts : [js] <script src="../js/jquery.min.js"></script> <script...

by pulkit
Tag: javascript
05-Apr-2014

Grails

jQuery dataTables plugin for pagination of HTML tables

In my project on Angular.js I came across a use case where I needed to paginate the HTML tables . DataTable jQuery plugin is a perfect choice in order to accomplish this task. Let us take a simple example to illustrate the use of dataTable plugin: [js] <html> <head> <style> <link rel="stylesheet"...

by pulkit
Tag: javascript
25-Mar-2014