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(strFakeNative) { | |
Function.prototype.toString = function() { | |
return strFakeNative.replace('atob', this.name || ''); | |
}; | |
})(atob + ''); |
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 (RGX_PLUS, RGX_SLASH, RGX_PARAM, decodeURIComponent, undefined) { | |
/** | |
* @license Copyright 2014 - Chris West - MIT Licensed | |
* | |
* Parses a given URL breaking it out into its parts. | |
* @param {string} opt_url | |
* Optional. The URL to be parsed and broken out into its individual | |
* parts. Defaults to the URL of the current page if not given. | |
* @return {!Object} | |
* Object containing the `href`, `protocol`, `host`, `hostname`, `port`, |
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
/** | |
* @license Copyright 2019 - Chris West - MIT Licensed | |
* | |
* Converts a number into an integer. | |
* @param {*} num | |
* The value to convert into an integer. | |
* @param {boolean|null} opt_infinityBiased | |
* Optional. If a true-ish value is specified the number will be rounded | |
* towards `Infinity` if positive or `-Infinity` if negative. If not given, | |
* or if `null` or `undefined` is specified the number will be rounded. If |
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 parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
console.log(parser.protocol); // => "http:" | |
console.log(parser.hostname); // => "example.com" | |
console.log(parser.port); // => "3000" | |
console.log(parser.pathname); // => "/pathname/" | |
console.log(parser.search); // => "?search=test" | |
console.log(parser.hash); // => "#hash" | |
console.log(parser.host); // => "example.com:3000" |
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 scramble(input) { | |
return input.replace(/\b(\w)(\w{2,})(\w)\b/g, function(all, a, b, c) { | |
return a | |
+ b.split('').sort(function(){return Math.random()-.5}).join('') | |
+ c; | |
}); | |
} | |
input = prompt("Enter the message you want scrambled:"); | |
console.log(scramble(input)); |
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
// Initial setup of variables. | |
var lowerLimit = 1; | |
var upperLimit = 25; | |
var tries = 5; | |
var answer = Math.floor(Math.random() * (upperLimit - lowerLimit + 1)) + lowerLimit; | |
var guess = ''; | |
var message = 'Guess a number between ' + lowerLimit + ' and ' + upperLimit + ':'; | |
// Keep prompting the user for a guess until the game ends. | |
while (tries > 0) { |
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 popProps(obj, keys) { | |
var ret = {}; | |
keys = ret.toString.call(keys) == '[object Array]' | |
? keys | |
: [].slice.call(arguments, 1); | |
for (var key, i = keys.length; i--;) { | |
key = keys[i]; | |
ret[key] = obj[key]; | |
delete obj[key]; | |
} |
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 getProps(obj, keys) { | |
var ret = {}; | |
keys = ret.toString.call(keys) == '[object Array]' | |
? keys | |
: [].slice.call(arguments, 1); | |
for (var key, i = keys.length; i--;) { | |
key = keys[i]; | |
ret[key] = obj[key]; | |
} | |
return ret; |
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(RGX_COMMENT, RGX_TRIM) { | |
getComments = function (fn, opt_trim) { | |
var comments = []; | |
(fn + '').replace(RGX_COMMENT, function(m, a, b, c) { | |
if (!c) { | |
m = a == undefined ? b : a; | |
comments.push(opt_trim ? m.replace(RGX_TRIM, '') : m); | |
} | |
}); | |
return comments; |
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
/** | |
* @license Copyright 2015 - Chris West - MIT Licensed | |
* Gets the substring before the specified target. | |
* @param {string|RegExp} target | |
* Specifies the substring to key off in order to pull the substring that | |
* precedes it. | |
* @param {number=} opt_occurrence | |
* Optional. The number of the occurrence to key off of. Defaults to 1. | |
* @return {string=} | |
* If the target is found, the substring that precedes will be returned. |
OlderNewer