Skip to content

Instantly share code, notes, and snippets.

View navjinder's full-sized avatar

Navjinder Kainthrai navjinder

View GitHub Profile
@navjinder
navjinder / uniqid.js
Created April 12, 2017 19:08
Create unique ids for html elements
function uniqid(){
return String.fromCharCode(65 + Math.floor(Math.random() * 26)); + Date.now();
}
@navjinder
navjinder / readTextFile.js
Created April 11, 2017 18:25
A javascript function to read text file like json.
function readTextFile(file, callback) {
var rawFile = new XMLHttpRequest();
rawFile.overrideMimeType('application/json');
rawFile.open('GET', file, true);
rawFile.onreadystatechange = function() {
if (rawFile.readyState === 4 && rawFile.status == '200') {
callback(rawFile.responseText , rawFile.status);
}
else{
callback('',rawFile.status);
@navjinder
navjinder / gist:21288fd48e286f62885c
Created June 2, 2015 18:44
NPM Dependencies update
```
npm install -g bower-update npm-check-updates
```
then under your project root run
```
npm-check-updates -g // run npm install -g packagename for stuff outdated
npm-check-updates -u
npm update
@navjinder
navjinder / List.md
Last active August 29, 2015 14:22
AngularJs Speed imporvements

Full Post

Let's fix that by changing a single line of code:

ng-repeat="(key, db) in databases"

to:

ng-repeat="(key, db) in databases track by key"