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
var myList = [0, 1, 2, true, false, null, undefined, '', [], {}]; | |
function identity(i) { | |
return i; | |
} | |
// Filtering with the identity function will filter out the non-truthy values | |
var truthies = myList.filter(identity); | |
console.log(truthies); |
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
// From https://stackoverflow.com/questions/20180046/attachevent-doesnt-work-in-ie-8-0 | |
// You can run some feature-checking code to check if the supported features exist: | |
if (window.addEventListener) { | |
// Check for addEventListener first, since IE9/10 have both, | |
// but you should use the standard over the deprecated IE-specific one | |
window.addEventListener('click', myFunc); | |
} else if (window.attachEvent) { | |
window.attachEvent('onclick', myFunc); |
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
// Sets up files for https://start.jcolemorrison.com/react-and-redux-sagas-authentication-app-tutorial/ | |
const fs = require('fs'); | |
const root = { | |
src: { | |
login: [ | |
'sagas.js', 'reducer.js', 'actions.js', 'constants.js', 'index.jsx' | |
], | |
signup: [ | |
'sagas.js', 'reducer.js', 'actions.js', 'constants.js', 'index.jsx' |
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
var place1 = ['lord', 'master', 'slimiest', 'swampiest', 'grand toad', 'swampy boy']; | |
var place2 = ['slimy', 'swamply', 'toadly', 'ribbeting', 'croaking', 'fly eating']; | |
var place3 = ['toads', 'pledges', 'toads', 'basement dwellers']; | |
function randomItemFromArray(array) { | |
return array[Math.floor(Math.random() * array.length)]; | |
} | |
function kurekTheSlimyToad() { | |
const place1Choice = randomItemFromArray(place1); |
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 kurekTheSlimyToad() { | |
function place1RandomChoice() { | |
let place1Random = Math.floor(Math.random() * 6); | |
switch (place1Random) { | |
case 0: | |
return 'lord'; | |
case 1: | |
return 'master'; | |
case 2: |
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
###hs-eu-cookie-confirmation |
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
// Regex to match an ethereum address or transaction: | |
0x[a-fA-F0-9]{40,64} | |
// I put this in a gist because medium uses character codes | |
// that iTerm2 doesn't recognize |