Skip to content

Instantly share code, notes, and snippets.

View marcus-at-localhost's full-sized avatar
💭

Marcus marcus-at-localhost

💭
View GitHub Profile
@marcus-at-localhost
marcus-at-localhost / content.html
Last active April 13, 2022 13:40
Encrypted PDF with DOMPDF and FPDI/FPDF
<html>
<head>
<style>
@page { margin: 27pt }
@font-face {
font-family: 'Open Sans Regular';
src: url('/assets/fonts/opensans-regular-webfont.ttf') format('truetype');
font-weight: normal;
@marcus-at-localhost
marcus-at-localhost / codemirror-sisyphus.html
Last active September 12, 2016 11:33
Codemirror and Sisyphus.js Example
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>CodePen - Codemirror and Sisyphus.js</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.18.2/codemirror.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.18.2/addon/edit/continuelist.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.18.2/addon/mode/overlay.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.18.2/mode/xml/xml.min.js"></script>
@marcus-at-localhost
marcus-at-localhost / move-inline-scripts.php
Last active November 12, 2020 06:26
[Move inline scripts in HTML DOM to the bottom of the document] Sandbox: http://ideone.com/pDCedR
<?php
// test code
// http://ideone.com/pDCedR
$html = <<<HTML
<html>
<head>
</head>
<body>
<script class="keep">
@marcus-at-localhost
marcus-at-localhost / jQ - Filter an array of objects for a certain key: value.js
Last active October 11, 2016 06:53
jQ - Filter an array of objects for a certain key: value
var arr = [
{"name": "post_id", "value": "0"},
{"name": "post_date", "value": "2016-10-10 11:11:11"},
{"name": "post_title", "value": "User Input"}
];
// retrive the index
var post_id_idx = arr.map(function(obj) { return obj.name; }).indexOf("post_id");
// access the right entry
console.log(arr[post_id_idx].value);
@marcus-at-localhost
marcus-at-localhost / github-markdown.css
Created October 11, 2016 14:01
github-markdown.css for pandoc
/* https://github.com/sindresorhus/github-markdown-css */
@font-face {
font-family: octicons-link;
src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAZwABAAAAAACFQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEU0lHAAAGaAAAAAgAAAAIAAAAAUdTVUIAAAZcAAAACgAAAAoAAQAAT1MvMgAAAyQAAABJAAAAYFYEU3RjbWFwAAADcAAAAEUAAACAAJThvmN2dCAAAATkAAAABAAAAAQAAAAAZnBnbQAAA7gAAACyAAABCUM+8IhnYXNwAAAGTAAAABAAAAAQABoAI2dseWYAAAFsAAABPAAAAZwcEq9taGVhZAAAAsgAAAA0AAAANgh4a91oaGVhAAADCAAAABoAAAAkCA8DRGhtdHgAAAL8AAAADAAAAAwGAACfbG9jYQAAAsAAAAAIAAAACABiATBtYXhwAAACqAAAABgAAAAgAA8ASm5hbWUAAAToAAABQgAAAlXu73sOcG9zdAAABiwAAAAeAAAAME3QpOBwcmVwAAAEbAAAAHYAAAB/aFGpk3jaTY6xa8JAGMW/O62BDi0tJLYQincXEypYIiGJjSgHniQ6umTsUEyLm5BV6NDBP8Tpts6F0v+k/0an2i+itHDw3v2+9+DBKTzsJNnWJNTgHEy4BgG3EMI9DCEDOGEXzDADU5hBKMIgNPZqoD3SilVaXZCER3/I7AtxEJLtzzuZfI+VVkprxTlXShWKb3TBecG11rwoNlmmn1P2WYcJczl32etSpKnziC7lQyWe1smVPy/Lt7Kc+0vWY/gAgIIEqAN9we0pwKXreiMasxvabDQMM4riO+qxM2ogwDGOZTXxwxDiycQIcoYFBLj5K3EIaSctAq2kTYiw+ymhce7vwM9jSqO8JyVd5RH9gyTt2+J/yUmYlIR0s04n6+7Vm1ozezUeLEa
@marcus-at-localhost
marcus-at-localhost / baseTagRelativeLinkFixer.js
Created November 14, 2016 22:39 — forked from EdwardCoyle/baseTagRelativeLinkFixer.js
Fixes references to inline SVG elements when the <base> tag is in use.
/**
* SVG Fixer
*
* Fixes references to inline SVG elements when the <base> tag is in use.
* Firefox won't display SVG icons referenced with
* `<svg><use xlink:href="#id-of-icon-def"></use></svg>` when the <base> tag is on the page.
*
* More info:
* - http://stackoverflow.com/a/18265336/796152
* - http://www.w3.org/TR/SVG/linking.html
@marcus-at-localhost
marcus-at-localhost / date-interval.php
Last active August 4, 2018 09:18
A few date DateTime Class snippets. Date comparison, formatting etc
<?php
$begin = new DateTime( '2012-01-01' );
$end = new DateTime( 'today' );
//$end = $end->modify( '+1 day' );
$interval = new DateInterval('P1M'); // in month steps
$daterange = new DatePeriod($begin, $interval ,$end);
foreach($daterange as $date){
@marcus-at-localhost
marcus-at-localhost / usort-SplFileInfo.php
Last active May 27, 2017 12:34
Sort by a date field in multidimensional array
<?php
// read all files
$allFiles = array_filter(iterator_to_array($this->directoryIterator), function($file) {
return $file->isFile();
});
usort($allFiles, function($a,$b){
return ($a->getMTime() < $b->getMTime()) ? 1 : -1;
});
@marcus-at-localhost
marcus-at-localhost / multisort.php
Created December 22, 2016 10:04
General solution to sort multidimensional array. http://stackoverflow.com/a/16788610/814031
<?php
// http://stackoverflow.com/a/16788610/814031
$data = array(
array('zz', 'name' => 'Jack', 'number' => 22, 'birthday' => '12/03/1980'),
array('xx', 'name' => 'Adam', 'number' => 16, 'birthday' => '01/12/1979'),
array('aa', 'name' => 'Paul', 'number' => 16, 'birthday' => '03/11/1987'),
array('cc', 'name' => 'Helen', 'number' => 44, 'birthday' => '24/06/1967'),
);
matchMedia("screen and (min-width:40em)").addListener(function(mql) {
if(mql.matches) {
// do something when matching
}
else {
// do soemthing when no match
}
});