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
/** | |
* Original class | |
*/ | |
class Todo { | |
constructor(name) { | |
this.name = name || 'Untitled'; | |
this.done = false; | |
} | |
do() { | |
this.done = true; |
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
// (c) copyright unscriptable.com / John Hann | |
// License MIT | |
// For more robust promises, see https://github.com/briancavalier/when.js. | |
function Promise () { | |
this._thens = []; | |
} | |
Promise.prototype = { |
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 strict' | |
const { isNull, isStr, isRegExp } = require('./types') | |
module.exports = matchAll | |
/** | |
* RegExp: Get all matches and capturing groups | |
* @param {RegExp} re | |
* @param {String} str |
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
/** | |
* getFormElementValue() | |
* Returns the value of a form element, given it's name and type | |
* | |
* @param {String} name - An element's `name=""` attribute | |
* @param {String} type - An element type string, e.g. 'text', 'radio', 'select' | |
* @returns {String|Boolean} | |
*/ | |
const getFormElementValue = (function(){ | |
const getElement = name => document.querySelector('[name="' + name + '"]'); |
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
/** | |
* Invoker | |
* Repeatedly invokes a function until it returns a truthy value | |
* | |
* @see https://gist.github.com/branneman/53b820be519b54bfc30a | |
* @param {Number} limit - The amount of total calls before we timeout | |
* @param {Number} interval - The amount of milliseconds between calls | |
* @param {Function} fn - The function to execute, must return a truthy value to indicate it's finished | |
* @param {Function} cb - The callback for when we're finished. Recieves 2 arguments: `error` and `result` | |
*/ |
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
/** | |
* @param {HTMLElement} element - The element's coordinates to calulate | |
* @param {HTMLElement} relativeElement - An optional relative element, defaults to `document.body` | |
* @returns {{ offsetY: Number, offsetX: Number }} | |
*/ | |
const getElementCoordinates = function(element, relativeElement = document.body) { | |
const relativeRect = relativeElement.getBoundingClientRect(); | |
const elementRect = element.getBoundingClientRect(); | |
const offsetY = elementRect.top - relativeRect.top; | |
const offsetX = elementRect.left - relativeRect.left; |
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 strict'; | |
const fs = require('fs'); | |
const glob = require('glob').sync; | |
const mkdirp = require('mkdirp').sync; | |
const sass = require('node-sass'); | |
const path = require('path'); | |
const streams = require('stream'); | |
const runner = {}; |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Asynchronously load fonts and cache them into localStorage</title> | |
<script> | |
(function(d, w){ |
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
main(); | |
function main(){ | |
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, ''); | |
var Ext = decodeURI(app.activeDocument.name).replace(/^.*\./,''); | |
if(Ext.toLowerCase() != 'psd') return; | |
var Path = app.activeDocument.path; | |
var saveFile = File(Path + "/" + Name +".png"); | |
if(saveFile.exists) saveFile.remove(); | |
SavePNG(saveFile); |
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
// :: (String, String) => String | |
const spawn = require('child_process').spawnSync; | |
// :: String => [String] | |
const getRules = raw => raw | |
.split('\n') | |
.map(line => line.trim()) | |
.filter(line => !!line) | |
.filter(line => line[0] !== '/' && line[0] !== '✖') | |
.map(line => line.match(/[a-z-]+$/)[0]); |