Skip to content

Instantly share code, notes, and snippets.

View mrcgrtz's full-sized avatar
:octocat:
I may be slow to respond.

Marc Görtz mrcgrtz

:octocat:
I may be slow to respond.
View GitHub Profile
@mrcgrtz
mrcgrtz / csp-reporter.php
Last active September 3, 2023 21:42
A PHP-based CSP reporter sending mails when a violation occurs.
<?php
declare(strict_types=1);
// Configuration: Set mail from/to.
$from = $_SERVER['SERVER_ADMIN'];
$to = $_SERVER['SERVER_ADMIN'];
// Get the raw POST data.
$data = file_get_contents('php://input');
@mrcgrtz
mrcgrtz / ping-example.html
Last active November 19, 2021 12:07
Simple PHP script for mailing an HTML5 "ping"
<!doctype html>
<meta charset="utf-8">
<title>Ping Test</title>
<p>Click this <a href="https://example.com" ping="/ping.php">test link</a>.
@mrcgrtz
mrcgrtz / greeting.php
Last active June 6, 2021 15:42
User greeting in a random languages, using RUBY-based markup if needed.
<?php
function greeting(string $userName, string $tagName = 'span'): ?string
{
if (!isset($userName)) {
return null;
}
$greetings = [
[
'lang' => 'de',
@mrcgrtz
mrcgrtz / swarm-coin.svg
Last active December 7, 2022 19:27
I recreated the Swarm coin as SVG for my blog.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mrcgrtz
mrcgrtz / WKWebViewExtension.swift
Last active August 11, 2019 14:29
Swift 3 Extension for opening target="_blank" and mailto:/tel: links in native iOS apps
import UIKit
import WebKit
class ViewController: UIViewController {
var webView: WKWebView = WKWebView() {
didSet {
webView.navigationDelegate = self
webView.uiDelegate = self
}
@mrcgrtz
mrcgrtz / html-inspector.js
Last active August 29, 2015 14:05 — forked from hirayama-evolni/min.js
HTML Inspector as a bookmarklet.
(function(w) {
if (typeof w.HTMLInspector !== "undefined") {
w.HTMLInspector.inspect();
} else {
var el = document.createElement('script');
el.setAttribute('src', 'https://rawgit.com/philipwalton/html-inspector/master/html-inspector.js');
el.addEventListener('load', function() {
w.HTMLInspector.inspect();
});
document.head.appendChild(el);
@mrcgrtz
mrcgrtz / template.php
Created October 10, 2012 12:03
Remove unneeded meta tags and links from Drupal 7
<?php
/**
* Override or insert variables into the HTML head.
*
* @param $head_elements
* An array of variables to pass to the HTML head.
*/
function MYTHEME_html_head_alter(&$head_elements) {
// remove unneeded metatags
$remove = array(
@mrcgrtz
mrcgrtz / gist:2693196
Created May 14, 2012 10:36
Remove whitespace between DIV tags
/* Remove whitespace between DIV tags:
* <div class="foo">
* <div class="bar">
*/
$str2 = preg_replace('/(<\/{0,1}div[^>]*>)(\s+)(<\/{0,1}div[^>]*>)/im', '\\1\\3', $str);
@mrcgrtz
mrcgrtz / order.css
Created April 18, 2011 10:25
My preferred CSS property order.
selector {
/* display and flow */
display: value;
visibility: value;
float: value;
clear: value;
/* positioning */
position: value;
top: value;
right: value;
@mrcgrtz
mrcgrtz / button-png.txt
Created August 27, 2010 08:19
Scalable CSS3 soap buttons, fallback to gradient button in IE8 or lower
data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00(%00%00%00(%08%06%00%00%00%8C%FE%B8m%00%00%00%04sBIT%08%08%08%08%7C%08d%88%00%00%00%09pHYs%00%00%0B%12%00%00%0B%12%01%D2%DD~%FC%00%00%00%1CtEXtSoftware%00Adobe%20Fireworks%20CS4%06%B2%D3%A0%00%00%11%9CIDATX%85U%98%E9W%DBV%FA%C7%3F%B2%BCK%5E0%06%0C%C6%C4%04%08Y%C8%09%09K%09%25C%934%93%A5%9Dv%FE%DA%CE%E9%9BN%CF%9C%244i%D2%09K%D8%C1%FB%8AW%D9%B2-%D9%92%7F%2Fr%A23%BF%FBRG%E7J%F7%B9%CFw%7BD%60%DC%E9tJ%86aH%80%B4%BA%BA*%C9%B2%2C%DD%B9sGJ%A5R%92%DDn%97L%D3%94VVV%A4Z%AD%26%0D%87C%E9%E7%9F%7F%96%06%83%81%D4%E9t%A4%C1%60%20%01R4%1A%954M%93%0C%C3%90dY%96~%FA%E9'%E9%F2%F2RZ%5E%5E%96dY%96%A6%A7%A7%A5r%B9%2C%3Dz%F4H%AA%D7%EB%92%AE%EBR0%18%94n%DE%BC)%15%8BE%E9%E5%CB%97%D2%E5%E5%A5%14%8B%C5%24%40%D24M%FA%E6%9Bo%241%12%89%C8~%BF_P%14Ep8%1CB%3C%1E%17%0E%0F%0F%85%CB%CBKazzZh4%1A%82%CF%E7%13%B2%D9%AC%D0%EF%F7%85%EB%D7%AF%0B%3B%3B%3B%C2%600%10%26%26%26%84z%BD.D%22%11%A1%DDn%0Bv%BB%5D%F0%FB%FD%C2%D7%95%C9d%84b%B1(t%3A%1DaeeE%18%19%19%11%DA%ED%B6%D0h4%84P(%24T*%15%A1V%AB%09%