Skip to content

Instantly share code, notes, and snippets.

@mindplay-dk
mindplay-dk / cookie.js
Created March 19, 2015 20:02
Simple client-side cookie reader/writer module in Typescript
@mindplay-dk
mindplay-dk / jquery.console.js
Created March 19, 2015 09:36
jquery.console.js
/**
* jQuery wrapper/plugin for console functions in FF/IE/Chrome.
*
* These functions execute silently when no console is available, so
* you can safely leave diagnotics calls in place during development
* and beta-testing.
*
* Examples:
*
* $.log('Hello, World.',1,2,3);
@mindplay-dk
mindplay-dk / ConduitFilterAdapter.php
Last active August 29, 2015 14:15
Draft filter interface for standardization of message exchange
<?php
// Sample implementation of a FilterInterface apadater for Conduit (UNTESTED)
use Phly\Conduit\MiddlewareInterface;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\FilterInterface as Filter;
class ConduitFilterAdapter implements MiddlewareInterface
@mindplay-dk
mindplay-dk / run.php
Last active August 29, 2015 14:15
Example middleware using Walkway as a router with Conduit
<?php
use mindplay\walkway\Route;
use Phly\Conduit\MiddlewareInterface;
use Phly\Conduit\MiddlewarePipe;
use Phly\Http\Server;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
require __DIR__ . '/vendor/autoload.php';
@mindplay-dk
mindplay-dk / modeling.md
Created February 11, 2015 17:00
Approaches to modeling

Approaches to modeling

In this short write-up, I will briefly summarize the types of modeling I have seen and attempted over the years, highlighting some of the advantages and drawbacks of each, ending with a conclusion explaining which one I prefer and why.

1. Bare Models

@mindplay-dk
mindplay-dk / README.md
Last active August 29, 2015 14:14
Semantic grid mix-ins for LESS

Example LESS file:

.layout {
    .row();    
    background: #ddd;
}

.nav {
 .col(4);
@mindplay-dk
mindplay-dk / README.md
Last active August 29, 2015 14:14
Replace a checkbox with a custom div for styling

jQuery plugin to replace checkboxes with <div> elements for styling.

This plugin makes no assumptions about class-names or the contents of the <div> element, it only implements the behavior - it returns the generated <div> elements for further operations with jQuery functions, so you can do for example:

$('input[type=checkbox]')
    .checkbox()            // returns set of <div> elements
    .addClass('checkbox')  // adds class="checkbox" to every <div> element

.html('✔') // inserts a unicode checkmark into every element

@mindplay-dk
mindplay-dk / hook.php
Created November 12, 2014 08:30
GitHub service hook example in PHP
<?php
// basic GitHub service hook example
$payload = file_get_contents("php://input");
$secret_key = 'secret';
$computed_signature = 'sha1=' . hash_hmac('sha1', $payload, $secret_key, false);
@mindplay-dk
mindplay-dk / error-relay.php
Last active August 29, 2015 14:08
Relay php errors to exceptions
<?php
/**
* Map php errors to the built-in ErrorException class.
*
* Respects the error_reporting() setting and the error-suppression operator.
*
* @see ErrorException
*/
@mindplay-dk
mindplay-dk / Cache.php
Last active May 6, 2017 18:20
Simplied cache interface
<?php
namespace Psr\Cache;
/**
* Cache defines a common driver interface for interacting with a cache back-end.
*/
interface Driver
{
/**