Important Javascript Code snippets

To Generate UUID function generateUUID() { var d = new Date().getTime(); var uuid = ‘xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx’.replace(/[xy]/g, function(c) { var r = (d + Math.random() * 16) % 16 | 0; d = Math.floor(d / 16); return (c == ‘x’ ? r : (r & 0x3 | 0x8)).toString(16); }); return uuid; } Sample output : 48808c28-24e0-4081-be13-2c27948bfa27 Extract …

Scroll to Top Angular Directive

The below directive creates a scroll to top icon on the bottom right corner of the page. On click it will smoothly scroll you position back to top. Angular Directive: function ScrollToTop() { return { template: “<a ng-click=’click()’ class=’scroll-to-top-anchor’></a>”, replace: true, scope: true, controller: function($scope) { $scope.click = function() { var startY = currentYPosition(); var stopY …

How to install the latest nodejs version in ubuntu

As of writing this article the latest node version was 4.2.4, you can install this one using the distribution from NodeSource repository: sudo apt-get install curl curl –silent –location https://deb.nodesource.com/setup_4.x | sudo bash – sudo apt-get install nodejs You can find all the sources here, https://github.com/nodesource/distributions/tree/master/deb Then, you have the latest version of node.js installed.