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
//jquery-dosomething-ES6.js | |
//after modification | |
//assumes jQuery is avail as global or via NPM etc | |
import jQuery from 'jquery' | |
export default function() { | |
+function($) { | |
var $this = $(this); | |
var newText = $this.data('text'); |
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 reggie = { | |
email: /^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i, | |
password: /^[a-z0-9]{4,25}$/i | |
}, | |
valid = { | |
email: false, | |
password: false | |
}, | |
data = {}; |
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
#npm | |
node_modules/ | |
bower_components/ | |
#jetbrains | |
.idea/ | |
#OS junk files | |
[Tt]humbs.db | |
*.DS_Store |
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 isMobile = () =>{ | |
return ( navigator.userAgent.match(/Android/i) || | |
navigator.userAgent.match(/BlackBerry/i) || | |
navigator.userAgent.match(/iPhone/i) || | |
navigator.userAgent.match(/iPad/i) || | |
navigator.userAgent.match(/iPod/i) || | |
navigator.userAgent.match(/iPhone|iPad|iPod/i) || | |
navigator.userAgent.match(/IEMobile/i) ) | |
} |
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
// Element.matches() | |
if (!Element.prototype.matches) | |
Element.prototype.matches = | |
Element.prototype.msMatchesSelector || | |
Element.prototype.webkitMatchesSelector | |
// NodeList.forEach() | |
if (window.NodeList && !NodeList.prototype.forEach) { | |
NodeList.prototype.forEach = function (callback, thisArg) { |
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
{ | |
"parserOptions": { | |
"ecmaVersion": 2017, | |
"sourceType": "module", | |
"ecmaFeatures": { | |
"experimentalObjectRestSpread": true | |
} | |
}, | |
"rules": { | |
"func-names": [ |
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
//*********server.js********* | |
const express = require('express') | |
const path = require('path') | |
const app = express() | |
const port = process.env.PORT || 3000 |
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 trimAnything = (str, trimChar, opts = { start: false, end: true }) => { | |
if (str.length > 1 || opts.allowEmpty) { | |
let pattern; | |
if (opts.start && !opts.end) { | |
pattern = `^\\${trimChar}+`; | |
} else if (!opts.start && opts.end) { | |
pattern = `\\${trimChar}+$`; | |
} else { | |
pattern = `^\\${trimChar}+|\\${trimChar}+$`; | |
} |
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
<script> | |
const els = document.querySelectorAll('li') | |
const iterables = new Map([ | |
['myObject', { | |
appetizer: 'Soup', | |
entree: 'Mahi Mahi', | |
dessert: 'Pie!' | |
}], | |
['myArray', [ |
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 isTruthy = (expression) => { | |
if (typeOf expression === 'number') return true // 0 returns true | |
if (Array.isArray(expression) && expression.length < 1) return false // empty array returns false | |
if typeOf expression === 'Object' && Object.keys(expression).length < 1) return false // empty object returns false | |
return !!expression | |
} |
OlderNewer