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
// Building-blocks to use for composition | |
const double = x => x + x; | |
const triple = x => 3 * x; | |
const quadruple = x => 4 * x; | |
// Function composition enabling pipe functionality | |
const pipe = (...fns) => input => [...fns].reduce((acc, fn) => fn(acc), input); | |
// Composed functions for multiplication of specific values | |
const multiply6 = pipe(double, triple); |
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 scream = str => str.toUpperCase() | |
const exclaim = str => `${str}!` | |
const repeat = str => `${str} ${str}` | |
const string = 'Egghead.io is awesome' | |
// Nested | |
const result2 = repeat(exclaim(scream(string))) | |
// EGGHEAD.IO IS AWESOME! EGGHEAD.IO IS AWESOME! |
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 RemoveAccents(strAccents) { | |
var strAccents = strAccents.split(''); | |
var strAccentsOut = new Array(); | |
var strAccentsLen = strAccents.length; | |
var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž'; | |
var accentsOut = "AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz"; | |
for (var y = 0; y < strAccentsLen; y++) { | |
if (accents.indexOf(strAccents[y]) != -1) { | |
strAccentsOut[y] = accentsOut.substr(accents.indexOf(strAccents[y]), 1); | |
} else |
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
# Safety First | |
git branch | grep ‘your_string_here’ | |
# Delete'em | |
git branch | grep 'your_string_here' | xargs git branch -D | |
# Delete Remote too | |
git branch | grep ‘your_string_here’ | xargs git push origin — delete |
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 React, { Component, PropTypes } from 'react'; | |
import popperJS from 'popper.js'; | |
export default class Popper extends Component { | |
constructor(props) { | |
super(props); | |
this.state = {}; | |
this.update = this.update.bind(this); | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>React Template</title> | |
<style> | |
body { | |
font-family: sans-serif; | |
font-weight: 100; | |
} |
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 getSafe(fn) { | |
try { | |
return fn(); | |
} catch (e) { | |
return undefined; | |
} | |
} | |
getSafe(() => obj.a.lot.of.properties); |
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
var ageInput = document.getElementById("age") | |
ageInput.addEventListener("keydown", function(e) { | |
// prevent: "e", "=", ",", "-", "." | |
if ([69, 187, 188, 189, 190].includes(e.keyCode)) { | |
e.preventDefault(); | |
} | |
}) |
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
// HTML5 Pattern | |
// http://html5pattern.com/ | |
const alphaNumeric = /[a-zA-Z0-9]+/; | |
const userNameWith20Chars = /^[a-zA-Z][a-zA-Z0-9-_\.]{1,20}$/; | |
const twitterHandle = /^[A-Za-z0-9_]{1,15}$/; | |
const password = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$/; // Uppercase, lowercase, and number | |
const password2 = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$/; // Password (UpperCase, LowerCase, Number/SpecialChar and min 8 Chars) |