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
// https://twitter.com/MylesBorins/status/929414418680643585?s=09 | |
const context = new window.AudioContext(); | |
for (let i = 0; i < 10; i++) { | |
let osc = context.createOscillator(); | |
osc.type = 'square'; | |
osc.frequency.value = 40 + i * 0.1111; | |
osc.connect(context.destination); | |
osc.start(); | |
} | |
// second part |
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
<!-- https://philipwalton.com/articles/deploying-es2015-code-in-production-today/ --> | |
<!-- Browsers with ES module support load this file. --> | |
<script type="module" src="main.js"></script> | |
<!-- Older browsers load this file (and module-supporting --> | |
<!-- browsers know *not* to load this file). --> | |
<script nomodule src="main-legacy.js"></script> | |
<!-- safari fix https://gist.github.com/samthor/64b114e4a4f539915a95b91ffd340acc --> |
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
/* https://medium.com/web-standards/a-theme-switcher-96174d95be75 */ | |
:root { | |
background-color: #fefefe; | |
filter: invert(100%); | |
} | |
* { | |
background-color: inherit; | |
} |
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
// finally -------------------------------------------- | |
const fetchAndDisplay = async ({url, element}) => { | |
showLoadingSpinner(); | |
try { | |
const response = await fetch(url); | |
const text = await response.text(); | |
element.textContent = text; | |
} catch (error) { | |
element.textContent = error.message; | |
} finally { |
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
# https://stackoverflow.com/questions/17667023/git-how-to-reset-origin-master-to-a-commit | |
git checkout master | |
git reset --hard e3f1e37 # put here the latest commit | |
git push --force origin master | |
# Then to prove it (it won't print any diff) | |
git diff master..origin/master |
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
// https://twitter.com/0x00A/status/904419238110261250 | |
// Unique array (of primitives) | |
const haystack = ['a', 'b', 'a'] | |
const unique = [...new Set(haystack)] | |
// -------------------------------------------------- | |
// https://twitter.com/rauschma/status/961020269446991872 | |
// Removing duplicate characters from a string: |
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
// DevTools: Quick debugging of your Node.js code straight from DevTools | |
node --inspect --debug-brk node-script.js |
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 costlyFunction = () => 'finished :)'; | |
performance.mark('costlyFunction Start'); | |
costlyFunction(); | |
performance.mark('costlyFunction End'); | |
performance.measure( | |
'costlyFunction', |
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
import makeStore from './src/store'; | |
import startServer from './src/server'; | |
export const store = makeStore(); | |
startServer(store); | |
store.dispatch({ | |
type:'SET_ENTRIES', | |
entries:require('./entries.json') | |
}); |
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
// https://www.webreflection.co.uk/blog/2015/10/22/how-to-add-dom-events-listeners | |
// arrow function for a click | |
let click = (evt)=>{evt.preventDefault(); alert('CLICK')} | |
// arrow function add or remove | |
node.addEventListener('click', click); | |
node.removeEventListener('click', click); | |
// anonymous bound (WeakMap between DOM nodes and objects) | |
node.addEventListener('click', { |