Skip to content

Instantly share code, notes, and snippets.

View elliotaplant's full-sized avatar
:atom:
hotkeys_4_lyfe

Elliot Plant elliotaplant

:atom:
hotkeys_4_lyfe
View GitHub Profile
// 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
###hs-eu-cookie-confirmation
function kurekTheSlimyToad() {
function place1RandomChoice() {
let place1Random = Math.floor(Math.random() * 6);
switch (place1Random) {
case 0:
return 'lord';
case 1:
return 'master';
case 2:
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);
// 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'
@elliotaplant
elliotaplant / Attach Event Listener for IE > v9
Created March 22, 2018 17:45
How to add event listeners in Internet Explorer 9+
// 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);
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);