The gist version has been deprecated. Moved to https://github.com/graficos-net/html-cleanser and fixed some security issues! Please see instalation section for updates!
This file contains 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
// In TS, interfaces are "open" and can be extended | |
interface Date { | |
/** | |
* Give a more precise return type to the method `toISOString()`: | |
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString | |
*/ | |
toISOString(): TDateISO; | |
} | |
type TYear = `${number}${number}${number}${number}`; |
Cheks if a given URL for an image is available over the net. It uses a simple DOM trick to test it. Be careful as <img src>
can be an XSS attack vector: https://owasp.org/www-community/xss-filter-evasion-cheatsheet
npm i -S gist:b2efa76be5314a332cfcfd1d025f4601
This file contains 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
if ('NodeList' in window && !NodeList.prototype.forEach) { | |
console.info('polyfill for IE11'); | |
NodeList.prototype.forEach = function (callback, thisArg) { | |
thisArg = thisArg || window; | |
for (var i = 0; i < this.length; i++) { | |
callback.call(thisArg, this[i], i, this); | |
} | |
}; | |
} |
This file contains 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 puppeteer = require('puppeteer'); | |
(async () => { | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
// Adjustments particular to this page to ensure we hit desktop breakpoint. | |
page.setViewport({width: 1000, height: 600, deviceScaleFactor: 1}); | |
await page.goto('https://www.chromestatus.com/samples', {waitUntil: 'networkidle'}); |
This file contains 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
// Usage: @include transition(width, height 0.3s ease-in-out); | |
// Output: -webkit-transition(width 0.2s, height 0.3s ease-in-out); | |
// transition(width 0.2s, height 0.3s ease-in-out); | |
// | |
// Pass in any number of transitions | |
@mixin transition($transitions...) { | |
$unfoldedTransitions: (); | |
@each $transition in $transitions { | |
$unfoldedTransitions: append($unfoldedTransitions, unfoldTransition($transition), comma); | |
} |