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
@import url('https://fonts.googleapis.com/css?family=Raleway|Raleway+Dots|Roboto+Slab'); | |
:root { | |
--color-navy: #001F3F; | |
--color-blue: #0074D9; | |
--color-aqua: #7FDBFF; | |
--color-teal: #39CCCC; | |
--color-olive: #3D9970; | |
--color-green: #2ECC40; | |
--color-lime: #01FF70;--color-yellow: #FFDC00; |
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 script = document.createElement('script'); | |
const link = document.createElement('link'); | |
function appendThisScriptToTheBodyTag(src, callback, options) { | |
// Explicitly set the defaults for any optional parameters of the function | |
options = (options) ? options : new Object() | |
callback = (callback) ? callback : new Function() | |
const scriptClone = script.cloneNode(true); | |
// Reference: https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode |
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
(async () => { | |
const img = document.createElement('img') | |
img.src = "_assets/data/example.png" | |
img.onload = () => { | |
document.body.appendChild(img) | |
const canvas = document.createElement('canvas') | |
canvas.width = img.width; | |
canvas.height = img.height; | |
canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height); | |
document.body.removeChild(img) |
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
/** USAGE | |
import { speak, createSound } from './synth.js'; | |
(async () => { | |
document.querySelector('button[start-static]').addEventListener('click', () => { | |
const sound = createSound("a.mp3"); | |
sound.play() | |
}) |
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
export const getInput = () => new Promise((resolve, reject) => { | |
document.querySelector('form').addEventListener('submit', function listener(e) { | |
e.preventDefault() | |
const inputString = e.target.querySelector('input[type=text]').value | |
resolve(inputString) | |
e.target.removeEventListener('submit', listener) | |
}) | |
}) | |
/* USAGE |
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 data = [ | |
[1,2,3,4,5], | |
[6,7,8,9,10] | |
] | |
function* getNumbers() { | |
for(let idx in data) { | |
for(let subIdx in data[idx]) { | |
yield data[idx][subIdx] |
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() { | |
console.clear() | |
const response = {} | |
const values = [ ...document.querySelectorAll('.infobox td') ].slice(1).map(el => el.innerText) | |
;[ ...document.querySelectorAll('.infobox th') ].map(el => el.innerText).map(keyText => { | |
response[keyText.replace(/\s/g, '_').toLowerCase()] = values.shift() | |
}) | |
return { ...response} | |
})() |
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
// Works on https://en.wikipedia.org/wiki/Electron. | |
(function() { | |
console.clear() | |
const response = {} | |
const values = [ ...document.querySelectorAll('.infobox td') ].slice(1).map(el => el.innerText) | |
;[ ...document.querySelectorAll('.infobox th') ].map(el => el.innerText.replace(/ /g, '')).map(keyText => { | |
response[keyText] = values.shift() | |
}) | |
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 fibonacci = (n) => { | |
const a = Array(n).fill(0) | |
return a.map((_, i) => a[i] = (i < 2) ? 1 : a[i-1] + a[i-2]) | |
} | |
/** This would work if the third parameter of map was a pointer to the array and not a copy :( **/ | |
// const fibonacci = (n) => Array(n).fill(0).map((_, i, a) => a[i] = (i < 2) ? 1 : a[i-1] + a[i-2]) |
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
console.log('im here now') |