Skip to content

Instantly share code, notes, and snippets.

View emmettnicholas's full-sized avatar

Emmett Nicholas emmettnicholas

View GitHub Profile
@emmettnicholas
emmettnicholas / code_fellows_dev_bootcamp_application_question.js
Last active October 5, 2015 23:30
Code Fellows dev bootcamp application question
// QUESTION
// What does the following JavaScript code do?
var
obj1 = {value: 1},
obj2 = {value: 2},
obj3 = {value: 3};
var ValueCollect = function() {
var values = [];
@emmettnicholas
emmettnicholas / regex.js
Created May 11, 2015 02:51
Web URL regex for JavaScript
// Started with https://gist.github.com/dperini/729294
// which performed best in a series of tests: https://mathiasbynens.be/demo/url-regex
/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?$/i
// Next I added '?' after the protocol to make it optional, since I want it to match "foo.com" and not just "http://foo.com"
/^(?:(?:https?|ftp):\/\/)?(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]