Skip to content

Instantly share code, notes, and snippets.

View tobiasroeder's full-sized avatar
:octocat:
I <3 </>

Tobias Röder tobiasroeder

:octocat:
I <3 </>
View GitHub Profile
@tobiasroeder
tobiasroeder / better-comments-nordtheme.json
Created February 3, 2022 11:01
Better Comments Nord Theme
{
"better-comments.tags": [
{
"tag": "!",
"color": "#bf616a"
},
{
"tag": "?",
"color": "#81a1c1"
},
@tobiasroeder
tobiasroeder / getTomorrow.js
Created March 1, 2022 12:39
Simple and reliable way to get date from tomorrow in JavaScript.
// 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 ) {
@tobiasroeder
tobiasroeder / coming-soon.html
Created April 16, 2022 19:07
Locking/unlocking a website, e.g. for a landing page that is currently in a beta phase.
<h1>Coming Soon</h1>
@tobiasroeder
tobiasroeder / wpcf7-spam-filter.php
Last active July 22, 2022 09:41
WordPress Contact Form 7 Spam Filter
<?php
/**
* Contact Form 7 Spam Filter
*/
add_filter( 'wpcf7_spam', function( $spam ) {
if ( $spam )
return $spam;
$spam_key_words = [
@tobiasroeder
tobiasroeder / advent.js
Created November 29, 2022 13:46
Get the date for all four advent.
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;
@tobiasroeder
tobiasroeder / .htaccess
Last active January 15, 2023 08:49
Very simple PHP Router
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@tobiasroeder
tobiasroeder / dateFormat.js
Created February 2, 2023 09:46
Custom date format prototype.
/**
* 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);
@tobiasroeder
tobiasroeder / better-comments-malibuheme.jsonc
Created April 25, 2023 08:55
Better Comments Malibu Theme
// Default Tags
{
"color": "#c8342a",
"tag": "!"
},
{
"color": "#3c63a6",
"tag": "?"
},
{
@tobiasroeder
tobiasroeder / PseudoCrypt.php
Created May 11, 2023 14:54
A tiny lib to generate obfuscated hashes from integers.
<?php
/**
* PseudoCrypt by KevBurns (http://blog.kevburnsjr.com/php-unique-hash)
* Reference/source: https://stackoverflow.com/a/1464155/933782
*
* @author KevBurns
* @link https://web.archive.org/web/20130727034425/http://blog.kevburnsjr.com/php-unique-hash
*/
@tobiasroeder
tobiasroeder / to2digits.js
Last active May 15, 2023 13:01
Turn a one digit number into a two digit number string.
/**
* 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.