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
const statsFinder = (array) => { | |
const total = array.reduce((nextitem, previtem) => (nextitem + previtem),0); | |
const mean = total / array.length; | |
const getMode = (array) => { | |
const modeObject = {}; | |
array.forEach(number => { | |
modeObject[number] = (!modeObject[number]) ? 1 : modeObject[number]+1; | |
}); | |
return +Object.keys(modeObject).reduce((a, b) => modeObject[a] > modeObject[b] ? a : b); | |
} |
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
// Copy to Clipboard | |
// Easily copy any text to clipboard using navigator.clipboard.writeText. | |
const copyToClipboard = (text) => navigator.clipboard.writeText(text); | |
copyToClipboard("Hello World"); | |
// Check if Date is Valid | |
// Use the following snippet to check if a given date is valid or not. | |
const isDateValid = (...val) => !Number.isNaN(new Date(...val).valueOf()); | |
isDateValid("December 17, 1995 03:24:00"); | |
// Result: true |
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
/** | |
* @param {number[]} nums | |
* @param {number} target | |
* @return {number[]} | |
*/ | |
const nums = [2, 7, 11, 15, 20], target = 9; | |
for (const [idx, testnum] of nums.entries()) { | |
console.log(`id:(${idx}): ${testnum}`); |
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
getMethods = (obj) => Object.getOwnPropertyNames(obj).filter(item => typeof obj[item] === 'function') |
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
const isThereAMaxMatch = (list) => { | |
let thereIsASum = false; | |
let sortedList = list.sort((a, b) => { return b - a }); // hi to low | |
const maxNumber = sortedList[0]; | |
let numCheck = (list) => { | |
let accumulatedSum = list[0]; | |
for (i = 1; i < list.length; i++) { |
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 trace = { | |
output : false, | |
queue : [], | |
push: function(data){ | |
trace.queue.push(data); | |
if(trace.output){ | |
trace.post(); | |
} | |
return |
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
AuthUserFile #Location of htpasswd file# | |
AuthType Basic | |
AuthName #<Site Name># | |
Require valid-user | |
Order deny,allow | |
Deny from all | |
# Update the fb and twitter crawler IP lists by running the following commands, then copy & replace the IPs below. | |
# | |
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
//Making jQuery Google API | |
function modify_jquery() { | |
if (!is_admin()) { | |
wp_deregister_script('jquery'); | |
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js', false, '1.6.4'); | |
wp_enqueue_script('jquery'); | |
} | |
} | |
add_action('init', 'modify_jquery'); |