I hereby claim:
- I am aroesler-privat on github.
- I am a_roesler (https://keybase.io/a_roesler) on keybase.
- I have a public key ASDoSN6jyZVn3jEFbbkgw1dpfLHVRi3W_0efXfAV4PHn_Ao
To claim this, I am signing this object:
/* ---[ fetch the favicon of a given $site ]---------------------------- | |
Tries several ways to fetch the URL of the favicon of $site. Returns | |
<img>-tag on success. | |
--------------------------------------------------------------------- */ | |
function get_favicon($site, $class = 'favicon') | |
{ | |
$site = empty($parsed = parse_url($site, PHP_URL_HOST)) ? $site : 'https://' . $parsed; | |
$site = preg_match('/^http/', $site) ? $site : 'https://' . $site; | |
$class = empty($class) ? '' : ' class="' . $class . '"'; | |
<?php | |
/* ---[ set default template for new posts ]-------------------------------- | |
helper function using all kinds of hints, tipps and some hackish timeout | |
to let the old editor and Gutenberg startup with a defined template for | |
dedicated post_type's (default: page, post) | |
------------------------------------------------------------------------- */ | |
function setDefaultTemplate($template, $post_type = array('page', 'post')) | |
{ | |
if (!is_array($post_type) && is_string($post_type)) $post_type = array($post_type); | |
if (!is_array($post_type)) return false; |
/* ----------------------------------------------------------------- | |
create canvas & take care on the pixel ratio, especially to prevent | |
blurry canvas-images on mobile devices when using | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
----------------------------------------------------------------- */ | |
function getCanvas(width, height) | |
{ | |
let canvas = document.createElement('canvas'); | |
let dpr = window.devicePixelRatio; |
/* ------------------------------------------------------------------------- | |
https://stackoverflow.com/a/19354869 | |
------------------------------------------------------------------------- */ | |
function estimateObjectSize(obj) | |
{ | |
let buffer = JSON.stringify(obj).replace(/[\[\]\,\"]/g,''); | |
return buffer.length; | |
} |
/* inspired by https://codepen.io/osublake/pen/OMRdKq */ | |
function loadSvgIntoDiv(theDIV, pathToSvg, prefix = 'myPrefix-', fillColor = null, fillColorID = null) | |
{ | |
if ( theDIV == null || typeof theDIV.appendChild != 'function' ) return null; | |
fetch(pathToSvg).then( (res) => { | |
// check the status | |
/* *********************************************************************** | |
* random = new Random(seed); | |
* | |
* Just a little class to create random numbers between 0 and 1 (including | |
* 0 and excluding 1 just as Math.random() is doing it). To reproduce | |
* results a seed can be retrieved and used. | |
* | |
* Algorithm: https://en.wikipedia.org/wiki/Lehmer_random_number_generator | |
* *********************************************************************** */ |
I hereby claim:
To claim this, I am signing this object: