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
| (?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]) |
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 unique(iterable) { | |
| return new Set(iterable).size; | |
| } |
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 isPalindrome(str) { | |
| var len = Math.floor(str.length / 2); | |
| for (var i = 0; i < len; i++) | |
| if (str[i] !== str[str.length - i - 1]) | |
| return false; | |
| return true; | |
| } |
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
| // I'm writing out my whole thought process for this. Lots of console.logs and comments | |
| // Let's make some data | |
| let objA = { something: '1 does a thing' }; | |
| let objB = { something: '2 does a thing' }; | |
| let objC = objA; | |
| let objD = { something: objC }; | |
| let arrA = ['test', objB, 'testing thing', objA, '3 doing things']; | |
| let data = [objA, objB, objC, objD, arrA]; |
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 getAbsoluteUrl = function(url, path) { | |
| if(url.substr(-1) == '/') { | |
| url = url.substr(0, url.length-1); | |
| } | |
| var path = path; | |
| if(path !== null) { | |
| if(url.substr(-1) == "/") { | |
| url = url.substr(0, url.length-1); |
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
| /* | |
| ** intersect.js | |
| ** intersect multiple arrays | |
| ** Usage: | |
| var arr1 = ['hey', 'you', 'guys', 'test', 'there']; | |
| var arr2 = ['there', 'you']; | |
| var arr3 = ['some', 'there', 'you', 'thrice', 'hey', 'huzzah']; | |
| intersect(arr1, arr2, arr3); | |
| */ | |
| function intersect() { |
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
| if(!Array.prototype.shift) { // if this method does not exist.. | |
| Array.prototype.shift = function(){ | |
| firstElement = this[0]; | |
| this.reverse(); | |
| this.length = Math.max(this.length-1,0); | |
| this.reverse(); | |
| return firstElement; | |
| } | |
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
| if(!Array.prototype.unshift) { // if this method does not exist.. | |
| Array.prototype.unshift = function(){ | |
| this.reverse(); | |
| for(var i=arguments.length-1;i>=0;i--){ | |
| this[this.length]=arguments[i] | |
| } | |
| this.reverse(); |
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 removeEmptySubFolders($path) { | |
| $empty = true; | |
| foreach (glob($path.DIRECTORY_SEPARATOR."*") as $file) { | |
| $empty &= is_dir($file) && RemoveEmptySubFolders($file); | |
| } | |
| return $empty && rmdir($path); | |
| } |
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 in_array_exclusive($needles, $haystack) { | |
| $keys = count($haystack); | |
| if(is_array($needles)) { | |
| foreach($needles as $needle) { | |
| if(!in_array($needle, $haystack)) { | |
| return false; | |
| } else { | |
| $keys = $keys - 1; | |
| } | |
| } |
NewerOlder