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
/** | |
* convert string (hash) to object | |
* @param {string} hash | |
* @returns {object} | |
*/ | |
function hashToObject(hash) { | |
let obj = {}; | |
hash = hash.slice(1); | |
let params = hash.split(','); | |
params.forEach(param => { |
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
<?php | |
/** | |
* @param string $date - [YYYY-MM-DD] | |
* @return int | |
*/ | |
function getWeekday( string $date ):int { | |
// 'w' 0 (for Sunday) through 6 (for Saturday) | |
$result = (int) date('w', strtotime($date)); |
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
{ | |
"better-comments.tags": [ | |
{ | |
"tag": "!", | |
"color": "#bf616a" | |
}, | |
{ | |
"tag": "?", | |
"color": "#81a1c1" | |
}, |
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
// main idea from https://www.youtube.com/watch?v=PNjNFatebgY&lc=UgzPj8mKHXk4akXfLcR4AaABAg | |
function getTomorrow( date = Date.now() ) { | |
let today = new Date(date); | |
let tomorrow = today.setDate(today.getDate() + 1); | |
return tomorrow; | |
} | |
function formatDate( date ) { |
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
<h1>Coming Soon</h1> |
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
<?php | |
/** | |
* Contact Form 7 Spam Filter | |
*/ | |
add_filter( 'wpcf7_spam', function( $spam ) { | |
if ( $spam ) | |
return $spam; | |
$spam_key_words = [ |
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
class Advent { | |
#oneDayMs = 86400000; | |
constructor(year = new Date().getFullYear()) { | |
this.christmasEve = `${year}-12-24`; | |
this.christmasEveDate = new Date(this.christmasEve); | |
} | |
#getDiff(days) { | |
return this.christmasEveDate.getDay() + days; |
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
/** | |
* Turn a one digit number into a two digit number string. | |
* | |
* If you can not garantee that the number n is a number, simply wrap it with Number(n) to turn the string into a number. | |
* | |
* The following three functions are doing the same thing. You can choose which one fits the best purpose for you. The last one has the most legacy support. | |
*/ | |
/** | |
* Turn a one digit number into a two digit number string by using the padStart method. |
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
/** | |
* Custom date format prototype. | |
* | |
* @param {string} format Format character inspired by PHP. @link https://www.php.net/manual/en/datetime.format.php | |
* | |
* @returns {string|Date} | |
*/ | |
Date.prototype.format = function (format) { | |
const to2digits = n => (n < 10 ? '0' + n : n); |
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
Show hidden characters
// Default Tags | |
{ | |
"color": "#c8342a", | |
"tag": "!" | |
}, | |
{ | |
"color": "#3c63a6", | |
"tag": "?" | |
}, | |
{ |