This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getValidationRules = (el) => { | |
const rules = []; | |
const required = el.hasAttribute('required') | |
const min = el.getAttribute('min') | |
const max = el.getAttribute('max') | |
const maxlength = el.getAttribute('maxlength') | |
const minlength = el.getAttribute('minlength') | |
const pattern = el.getAttribute('pattern') | |
if (required) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Responsive rem hack | |
* --- | |
* Makes the `rem` unit behave like a dynamic value based on the viewport, with a max width. | |
* This makes it easy to apply dynamic values to margin and paddings. | |
* warning, `rem` becomes useless for font-sizes. | |
* | |
* Usage: | |
* | |
* .vertical-spacing { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Class representing an events interface similar to EventEmitter/Backbone.Events | |
* @author Jeroen Ransijn [@Jeroen_Ransijn] | |
* @example | |
* const events = new Events(); | |
* | |
* events.on('change', (...args) => { console.log(args); }); | |
* events.trigger('change', 'firstArg', 'secondArg'); | |
* // Returns ['firstArg', 'secondArg'] | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Author: Jeroen Ransijn | |
* Date: August 5 2014 | |
* Pass functions as arguments | |
*/ | |
function mix () { | |
var args = Array.prototype.slice.call(arguments), argsLength = args.length; | |
return { | |
in: function (fn) { | |
for (var i = 0; i < argsLength; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function typed (types, cb) { | |
if (Object.prototype.toString.call(types) === '[object Array]' && typeof cb === "function") { | |
return function () { | |
var i = arguments.length, areTypesCorrect = true; | |
while (i--) { | |
// need to check for some literals: string/number/boolean | |
var type = typeof arguments[i], arg; | |
if (type === 'string') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add() { | |
// Start from zero | |
var total = 0; | |
// Floating-points, bah! | |
// 1e12 = 1000000000000. | |
var factor = 1e12; | |
// Undefined, set in the loop | |
var value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<h1>Website title</h1> | |
<h2>Slogan</h2> | |
<div id="content"> | |
<article class="blog-post"> | |
<h1>Blog title</h1> | |
<section class="abstract"> | |
Lorem ipsum |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cache.coffee | |
# ------------------------------------------------------------ | |
# Hard dependency: underscore.js | |
class Cache | |
# @description if a string is given it will be the namespace | |
# @param {string|object} options | |
constructor: (options) -> | |
settings = { | |
# will be used for the localStorage | |
namespace: 'global' |