Skip to content

Instantly share code, notes, and snippets.

@singhmohancs
singhmohancs / gist:e430068ac9642156fe962ad7bd888b5e
Created August 31, 2017 12:44 — forked from josephdburdick/gist:49a4bb299a614d8f3f77
Gulpfile - precompress and sprite generation
'use strict';
// generated on 2014-06-24 using generator-gulp-webapp 0.1.0
var src_dir = 'app',
dest_dir = 'dist';
var gulp = require('gulp');
// load plugins
@singhmohancs
singhmohancs / Setting up subdomain with Drupal installation on Linode
Created August 27, 2017 22:30 — forked from klan/Setting up subdomain with Drupal installation on Linode
How to set up a subdomain on a Linode server with a Drupal installation and a repository
• SSH to your server to start creating a subdomain (https://library.linode.com/hosting-website#sph_configuring-name-based-virtual-hosts)
• Go to ~/public/
› mkdir -p sub.example.com/{public,log,backup}
› cd sub.example.com/public/
› nano index.html | nano index.php
• Write 'Hello world' or whatever, we just need a html|php file to test with
@singhmohancs
singhmohancs / _baseline.scss
Created August 10, 2017 18:57 — forked from razwan/_baseline.scss
Aligning type to baseline the right way with SASS
$base-font-size: 16px;
$base-line-height: 1.5;
// this value may vary for each font
// unitless value relative to 1em
$cap-height: 0.68;
@mixin baseline($font-size, $scale: 2) {
/**
* Calculates numbers to the mathmatical power (exponent)
*
* @since 1.0.0
*
* @param int $number The number to increase
* @param int $exponent The power to increase the number by
*
* @return int The new number
*/
@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.
@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 / 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 / confirm-unsaved-changes.directive.js
Created May 22, 2017 05:39
Detect Unsaved changes and show confirm modal + angularjs
/**
* @ngdoc Directive
* @name app.confirmOnExit
*
* @description
* Prompts user while he navigating away from the current route (or, as long as this directive
* is not destroyed) if any unsaved form changes present.
*
* @element Attribute
* @scope
@singhmohancs
singhmohancs / dateFormat.js
Created May 19, 2017 07:56
Date format + Javascript
/**
* Format datetime
* Usage:
* new Date().format('yyyy/MM/dd'), new Date().format('hh:mm:ss')
* @param {String} format
* @return {String}
*/
Date.prototype.format = function(format) {
var self = this;
@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) -->