Skip to content

Instantly share code, notes, and snippets.

View Radiergummi's full-sized avatar
💻
Yes of course I can implement that 🥲

Moritz Friedrich Radiergummi

💻
Yes of course I can implement that 🥲
View GitHub Profile
@Radiergummi
Radiergummi / TimeSpan.php
Last active July 12, 2018 16:49
TimeSpan class - a flexible PHP class to handle time calculations
<?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'`
@Radiergummi
Radiergummi / http.js
Created July 26, 2018 21:31
Micro ajax wrapper in vanilla 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 / TemplateEditor.vue
Last active October 11, 2018 11:44
Twig template editor Vue component
<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 / OutputInterceptor.php
Created November 23, 2018 09:48
PHP class that allows to intercept output to a stream, like STDOUT. Very useful for testing CLI applications using `fwrite('', STDOUT);`.
<?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 / Cloudflare.js
Last active November 16, 2019 12:43
Cloudflare worker deployment
'use strict';
const axios = require('axios');
class Cloudflare {
constructor ( zone, emailAddress, apiKey ) {
this._zone = zone;
this._emailAddress = emailAddress;
this._apiKey = apiKey;
@Radiergummi
Radiergummi / cloudflare_update_certificate.sh
Created February 28, 2020 15:45
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..
#!/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.
[www]
user = www-data
group = www-data
listen = 127.0.0.1:9000
listen.backlog = 511
;listen.allowed_clients = 127.0.0.1
; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user or group is differrent than the master process user.
@Radiergummi
Radiergummi / App.vue
Last active May 2, 2023 09:51
A Vue directive to react to something being dragged on the browser window. Port of this Stack Overflow answer: https://stackoverflow.com/a/55392885/2532203
<template>
<div v-dragging="{ enter, leave }">
</div>
</template>
<script>
import './dragging.ts';
export default {
methods: {
/**
* Validates a value that isn't falsy.
*
* @param field
* @param message
*/
export function required(
field?: string,
message?: string | Message<string>,
): Validator {
This file has been truncated, but you can view the full file.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"Stripe.Account": {
"description": "The Account object.",
"properties": {
"business_profile": {
"$ref": "#/definitions/Stripe.Account.BusinessProfile",
"description": "Business information about the account."
},