Skip to content

Instantly share code, notes, and snippets.

View singhmohancs's full-sized avatar
👨‍💻
Building with JavaScript, React, Angular, NodeJs, MongoDb and AWS Serverless

Mohan Singh singhmohancs

👨‍💻
Building with JavaScript, React, Angular, NodeJs, MongoDb and AWS Serverless
View GitHub Profile
@singhmohancs
singhmohancs / states_hash.json
Created February 26, 2016 14:45 — forked from mshafrir/states_hash.json
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@singhmohancs
singhmohancs / ng.js
Created May 22, 2016 14:47 — forked from mizhdi/ng.js
angular
app.factory('EventBus', function() {
var EventMap = [];
var EventBus = {
on: function(eventType, handler) {
if (!EventMap[eventType]) {
EventMap[eventType] = [];
}
/**
* @ngDoc Directive
* @name app.Directive.onKeyEnter
* @module app
*
* @description
* this directive triggers callback function when enter key is pressed
*
* @author Mohan Singh <mslogicmaster@gmail.com>
*
@singhmohancs
singhmohancs / test.html
Last active June 2, 2016 09:03
Warn on route change if unsaved changes
<form name="anything" confirm-on-exit>......</form>
<form name="anything" confirm-on-exit="collection">......</form>
@singhmohancs
singhmohancs / timezones
Created August 17, 2016 16:07 — forked from ykessler/timezones
JSON list of time zones (Based on Olson tz database)
[
{"group":"US (Common)",
"zones":[
{"value":"America/Puerto_Rico","name":"Puerto Rico (Atlantic)"},
{"value":"America/New_York","name":"New York (Eastern)"},
{"value":"America/Chicago","name":"Chicago (Central)"},
{"value":"America/Denver","name":"Denver (Mountain)"},
{"value":"America/Phoenix","name":"Phoenix (MST)"},
{"value":"America/Los_Angeles","name":"Los Angeles (Pacific)"},
{"value":"America/Anchorage","name":"Anchorage (Alaska)"},
.config(function ($provide) {
$provide.decorator('$state', function ($delegate) {
// let's locally use 'state' name
var state = $delegate;
// let's extend this object with new function
// 'baseGo', which in fact, will keep the reference
// to the original 'go' function
state.baseGo = state.go;
@singhmohancs
singhmohancs / AngularJS-Cachebusting.js
Created November 30, 2016 19:25 — forked from ProLoser/AngularJS-Cachebusting.js
Elegant cache-busting for AngularJS HTML assets
anglar.module('myApp',['ui']).config(["$provide", function($provide) {
return $provide.decorator("$http", ["$delegate", function($delegate) {
var get = $delegate.get;
$delegate.get = function(url, config) {
// Check is to avoid breaking AngularUI ui-bootstrap-tpls.js: "template/accordion/accordion-group.html"
if (!~url.indexOf('template/')) {
// Append ?v=[cacheBustVersion] to url
url += (url.indexOf("?") === -1 ? "?" : "&");
url += "v=" + cacheBustVersion;
}
@singhmohancs
singhmohancs / default.value.directive.js
Created January 27, 2017 09:32
Toggle default value on focus and blur on text field
/**
* @ngdoc Directive
* @name defaultValue
* @restrict 'A'
* @element ANY
* @author Mohan Singh ( gmail::mslogicmaster@gmail.com, skype :: mohan.singh42 )
**/
(function () {
'use strict';
angular
@singhmohancs
singhmohancs / detectDevice.directive.js
Last active March 3, 2017 18:18
Determine device type from container width
/**
* @ngdoc Directive
* @name app.directive.detectViewPort
* @module app
*
* @description
* detectViewPort staring component with star
* @TODO
* onDetectViewPort callback
* @author Mohan Singh ( gmail::mslogicmaster@gmail.com, skype :: mohan.singh42 )
/* Checks if localStorage exists on the browser, if not, creates a JSONFallbackStorage object where all the data will be stored. Also creates the localStorage methods so you won't need to change anything on your script. Just remember to send the data on JSONFallbackStore to the server. */
(function(window, undefined){
if (typeof(localStorage) === undefined) {
JSONFallbackStore = {};
window.localStorage = {
getItem: function(key){
return JSONFallbackStore[key];
},
setItem: function(key, value){