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
/** | |
* DEMO: https://jsfiddle.net/gd6b71Ln/38/ | |
* | |
* CAUTION: You will need to edit `el.style.transform = 'rotate('+ deg +'deg)'`, | |
* in case the element has already existing transform styles (just append them) | |
* | |
* COMPATIBILITY: https://caniuse.com/#feat=getboundingclientrect | |
* https://caniuse.com/#feat=transforms2d | |
* | |
* Makes the element rotate based on the mouse position |
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
// Simple if condition that stops Observable from continuing passed condition function returns false. | |
// There's also an option to run else callback if needed. | |
/* | |
* USAGE | |
* | |
* of(events).pipe( | |
* ifCondition(event => event.name.endsWith('anything'), () => console.log('Not the anything event')) | |
* ) | |
*/ |
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 AVATAR_SIZE = 140; | |
function onFileChange(input: HTMLInputElement): Promise<string> { | |
const fileReader = new FileReader(); | |
fileReader.readAsDataURL(input.files.item(0)); | |
return new Promise((resolve) => { | |
fileReader.onload = (event) => { | |
const image = new Image(); | |
image.src = event.target.result as string; | |
image.onload = () => { |
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
function* getAllPossibleCombinations(arr, outputLength = arr.length) { | |
if (outputLength > arr.length) { | |
throw 'Not enough items in array'; | |
} | |
for (let i = 0; i < arr.length; i++) { | |
if (outputLength === 1) yield arr[i]; | |
for (let j = 0; j < arr.length; j++) { | |
if (i === j) continue; |
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
#!/usr/local/bin/node | |
const fs = require('fs'); | |
const path = require('path'); | |
const arguments = process.argv.slice(2); | |
const folder = arguments[0]; | |
const filePrefix = arguments[1]; | |
const map = { |