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] = [];
}
@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 / 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 )
@singhmohancs
singhmohancs / template.html
Last active September 28, 2017 09:16
AngularJS - UTC to Local + Filter
<span>Local date & time converted from UTC: {{vm.myUtcDate | utcToLocal:'dd.MM.yy - hh.mm a'}}</span>
<!-- Where vm.myUtcLocal = '2016-03-31T00:11:31' (utc) -->
@singhmohancs
singhmohancs / countries.json
Last active September 28, 2017 09:16 — forked from keeguon/countries.json
A list of countries in JSON
[
{ "name": "Afghanistan", "code": "AF" },
{ "name": "Åland Islands", "code": "AX" },
{ "name": "Albania", "code": "AL" },
{ "name": "Algeria", "code": "DZ" },
{ "name": "American Samoa", "code": "AS" },
{ "name": "Andorra", "code": "AD" },
{ "name": "Angola", "code": "AO" },
{ "name": "Anguilla", "code": "AI" },
{ "name": "Antarctica", "code": "AQ" },
@singhmohancs
singhmohancs / utc-to-local.js
Created July 22, 2017 21:03 — forked from fntneves/utc.js
Moment.JS - Convert UTC to Local Time
$.fn.format = function() {
return this.each(function() {
var $this = $(this);
var time = $this.attr("datetime");
var localTime = moment.utc(time).local().format();
$this.attr("datetime", localTime).timeago();
return this;
});
@singhmohancs
singhmohancs / viewport-units-ios.scss
Created August 10, 2017 16:22 — forked from BenMorel/viewport-units-ios.scss
SCSS mixin to support vh and vw units on all iOS Safari versions. Based on an idea by Patrick Burtchaell's: https://gist.github.com/pburtchaell/e702f441ba9b3f76f587
/**
* Fix for vw, vh, vmin, vmax on iOS 7.
* http://caniuse.com/#feat=viewport-units
*
* This fix works by replacing viewport units with px values on known screen sizes.
*
* iPhone 6 and 6 Plus cannot run iOS 7, so are not targeted by this fix.
* Target devices running iOS 8+ will incidentally execute the media query,
* but this will still produce the expected result; so this is not a problem.