Skip to content

Instantly share code, notes, and snippets.

Rasmus Schultz mindplay-dk

Block or report user

Report or block mindplay-dk

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
mindplay-dk / image-url.ts
Last active Jan 9, 2020
Rotate image preview to compensate for EXIF orientation (Javascript / Typescript)
View image-url.ts
// Based on:
* Create a Base64 Image URL, with rotation applied to compensate for EXIF orientation, if needed.
* Optionally resize to a smaller maximum width - to improve performance for larger image thumbnails.
export async function getImageUrl(file: File, maxWidth: number|undefined) {
return readOrientation(file).then(orientation => applyRotation(file, orientation || 1, maxWidth || 999999));
mindplay-dk /
Created Aug 17, 2017
Environment abstractions for PHP

Draft for a simple PSR providing a trivial abstraction of the local system environment.

Why? So we can stop using hacks to work around dependencies on system state - so that these dependencies can be made visible as (constructor) dependencies, and so we can mock the implementations under test.

mindplay-dk /
Last active Oct 25, 2019
Ubuntu on Windows


⚠️ I am no longer actively maintaining this. ⚠️

With the Windows 10 Creators Update comes an awesome new opportunity to run a lighweight Ubuntu Linux environment as a subsystem of Windows. This is officially known as Windows Subsystem for Linux (WSL) or Bash on Windows.

This is great news for PHP developers using Windows - we can now get access to native Linux builds of PHP, PECL extensions, ImageMagick, NGINX and other server components and tools, without having to migrate to a Linux desktop environment!

In this guide, we'll get you set up with WSL itself, a working PHP 7.2 environment with OpCache, XDebug and task/terminal integration with Php Storm, and working NGINX configuration - as well as various tools, including PEAR/PECL, Composer and Node.JS.

mindplay-dk /
Last active Nov 19, 2019
Linear collection workflow

You can have a linear workflow with the array functions.

The following is unreadable:

$output = array_reduce(
    function($n) { return $n ** 2; }
    array_filter($input, function($n) { return $n % 2 == 0; })
mindplay-dk / middleware-host.php
Created Aug 16, 2016
An ultra-naiive universal middleware host
View middleware-host.php
// an ultra-simple middleware host that works for middleware callables with any signature.
// the last argument is always the `$next` function, which delegates to the next middleware.
class Host
* @var callable[]
View MiddlewareDelegateInterface.php
namespace Psr\Middleware;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
* This interface defines the formal method common to HTTP Middleware components.
View scribe-plugin-smart-lists.js
* Automatically create ordered/unordered lists when detecting content like "* " or "1. "
define(function () {
"use strict";
return function () {
return function (scribe) {
mindplay-dk / shared-toolbar.js
Last active Mar 21, 2016
Shared toolbars plugin for Guardian's Scribe editor
View shared-toolbar.js
define(function () {
"use strict";
var active_scribe = null;
function create_handler_for(button) {
return function (event) {
if (!active_scribe) {
mindplay-dk / anonymous.php
Created Mar 10, 2016
class or object???
View anonymous.php
// anonymous classes are both instances and types. huh? what?
$type = new class {
public function foo() {
echo "YAY";
View dafuq.php
function kthxbai() {
$result = "hey";
try {
return $result;
} finally {
$result = "dafuq";
You can’t perform that action at this time.