Skip to content

Instantly share code, notes, and snippets.

🤔
Zen mode

Moritz Friedrich Radiergummi

🤔
Zen mode
Block or report user

Report or block Radiergummi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Radiergummi
Radiergummi / cloudflare_update_certificate.sh
Created Feb 28, 2020
Updates a custom certificate on Cloudflare from inside a Let's Encrypt renewal hook. Check the blog post at https://www.moritzfriedrich.com/posts/feature-branch-previews for more info..
View cloudflare_update_certificate.sh
#!/usr/bin/env php
<?php
// This should be the main domain your certificate is valid for. It's used for reverse
// matching the installed certificate and resolving the file path to your certificate
// files on the local file system.
$domain = 'your.domain.name.tld';
// This should be your Cloudflare zone ID. You can find it in the right sidebar on your
// Cloudflaare account dashboard.
@Radiergummi
Radiergummi / Cloudflare.js
Last active Nov 16, 2019
Cloudflare worker deployment
View Cloudflare.js
'use strict';
const axios = require('axios');
class Cloudflare {
constructor ( zone, emailAddress, apiKey ) {
this._zone = zone;
this._emailAddress = emailAddress;
this._apiKey = apiKey;
@Radiergummi
Radiergummi / OutputInterceptor.php
Created Nov 23, 2018
PHP class that allows to intercept output to a stream, like STDOUT. Very useful for testing CLI applications using `fwrite('', STDOUT);`.
View OutputInterceptor.php
<?php
/**
* Intercepts bytes written to an output stream and redirects them into a buffer instead
*/
class OutputInterceptor extends php_user_filter
{
/**
* Holds the PHP stream filter
*/
@Radiergummi
Radiergummi / TemplateEditor.vue
Last active Oct 11, 2018
Twig template editor Vue component
View TemplateEditor.vue
<template>
<article class="template-editor">
<header>
<h2 class="editor-heading">Twig Template editor</h2>
</header>
<section class="variable-editor">
<header>
<h3 class="variables-heading">
Variables
<span class="variable-count">{{ Object.keys(this.variables).length }}</span>
@Radiergummi
Radiergummi / http.js
Created Jul 26, 2018
Micro ajax wrapper in vanilla JS
View http.js
/**
* Micro-wrapper for HTTP requests
*
* @type {Object}
*/
window.http = {
/**
* Builds a valid URL. Unless a full URL (including a protocol) is given, the current origin will be used.
*
@Radiergummi
Radiergummi / TimeSpan.php
Last active Jul 12, 2018
TimeSpan class - a flexible PHP class to handle time calculations
View TimeSpan.php
<?php
/**
* TimeSpan class
* ==============
*
* Provides a convenience class to handle time amounts and time spans: Ever wondered how to easily figure out how many
* hours there are between 09:15:31 and 18:55:01? This class is for you. Going with the example, it's as easy as:
*
* `echo (new TimeSpan('18:55:01'))->sub('09:15:31')->format('h:m'); // '09:39'`
View Spreadsheet.js
'use strict';
import FileSaver from 'file-saver';
import JSZip from 'jszip';
class Spreadsheet {
/**
* Holds all replacement strings to escape
*
View Spreadsheet.js
'use strict';
import FileSaver from 'file-saver';
import JSZip from 'jszip';
class Spreadsheet {
/**
* Holds all replacement strings to escape
*
@Radiergummi
Radiergummi / Cryptor.php
Last active Jan 7, 2020
A PHP class to encrypt and decrypt strings using a static application secret. Input is converted to hex strings to enable easier handling
View Cryptor.php
<?php
namespace Vendor\Library;
use function bin2hex;
use function hex2bin;
use function openssl_decrypt;
use function openssl_encrypt;
use function random_bytes;
@Radiergummi
Radiergummi / OpentableWidget.vue
Created Dec 12, 2017
Wraps the Opentable widget into a Vue.js component
View OpentableWidget.vue
<template>
<div class="opentable-widget-container" v-html="content"></div>
</template>
<script>
'use strict';
/*
global window
*/
You can’t perform that action at this time.