Skip to content

Instantly share code, notes, and snippets.

@rspieker
rspieker / request.php
Last active December 21, 2015 15:29
Request data in Konsolidate's Breed tier
<?php
// (we assume a working Konsolidate instance to be in $K)
// there are a couple of ways to work with Breed's Request object
// Given the GET request: http://example.com/request.php?foo=bar
// The implicit approach, just asking Request itself, which will determine
// the appropriate request type (GET in this case) and look up the variable
@rspieker
rspieker / example.php
Created November 19, 2014 22:50
Factory example, including loading from prefixed 'libraries'
<?php
include('konstruct.php');
$konstruct = Konstruct::fabricate([
'cc' => 'path/to/library/cc',
'bb' => 'path/to/library/bb',
'aa' => 'path/to/library/aa'
]);
@rspieker
rspieker / color-definitions-hex.css
Created August 5, 2015 09:21
HEX color definitions for use with CSS4 / Myth CSS preprocessor
root: {
/* red tones */
--hex-white: #ffffff;
--hex-snow: #fffafa;
--hex-seashell: #fff5ee;
--hex-white-smoke: #f5f5f5;
--hex-rose-white: #fbeee8;
--hex-hint-of-red: #f5efeb;
--hex-chablis: #fde9e0;
@rspieker
rspieker / color-definitions-rgb.css
Created August 5, 2015 09:22
RGB color definitions for use with CSS4 / Myth CSS preprocessor
root: {
/* red tones */
--rgb-white: rgb(255, 255, 255);
--rgb-snow: rgb(255, 250, 250);
--rgb-seashell: rgb(255, 245, 238);
--rgb-white-smoke: rgb(245, 245, 245);
--rgb-rose-white: rgb(251, 238, 232);
--rgb-hint-of-red: rgb(245, 239, 235);
--rgb-chablis: rgb(253, 233, 224);
@rspieker
rspieker / color-definitions-hsl.css
Created August 5, 2015 09:22
HSL color definitions for use with CSS4 / Myth CSS preprocessor
root: {
/* red tones */
--hsl-white: hsl(0, 0, 100);
--hsl-snow: hsl(0, 100, 99);
--hsl-seashell: hsl(25, 100, 97);
--hsl-white-smoke: hsl(0, 0, 96);
--hsl-rose-white: hsl(19, 70, 95);
--hsl-hint-of-red: hsl(24, 33, 94);
--hsl-chablis: hsl(19, 88, 94);
@rspieker
rspieker / color-definitions-hsv.css
Created August 5, 2015 09:23
HSV color definitions for use with CSS4 / Myth CSS preprocessor
root: {
/* red tones */
--hsv-white: hsv(0, 0, 100);
--hsv-snow: hsv(0, 2, 100);
--hsv-seashell: hsv(25, 7, 100);
--hsv-white-smoke: hsv(0, 0, 96);
--hsv-rose-white: hsv(19, 8, 98);
--hsv-hint-of-red: hsv(24, 4, 96);
--hsv-chablis: hsv(19, 11, 99);
@rspieker
rspieker / color-definitions.css
Created August 5, 2015 09:24
HEX/RGB/HSL/HSV color definitions for use with CSS4 / Myth CSS preprocessor
root: {
/* red tones */
/* White */
--hex-white: #ffffff;
--rgb-white: rgb(255, 255, 255);
--hsl-white: hsl(0, 0, 100);
--hsv-white: hsv(0, 0, 100);
@rspieker
rspieker / example.js
Created August 24, 2015 08:20
Hapi - allow for the CSP 2.0 'application/csp-report' content-type
'use strict';
var Hapi = require('hapi'),
server = new Hapi.Server();
server.connection({ port: 80 });
// Example #1, simply override the content-type header and trust the input
server.route({
path: '/csp/report/1',
@rspieker
rspieker / convert-glue-plugin-manifest-es2015.js
Last active January 20, 2016 12:11
Convert glue < 3 manifest to 3+ syntax
// compensate for old Glue configuration syntax
function convertGluePluginManifest(manifest) {
if ('plugins' in manifest) {
if (!manifest.connections || manifest.connections.length !== 1) {
throw new Error('it is probably a Bad Idea™ to bluntly convert the old Glue "plugins" to reside on all connections');
}
if (!('registrations' in manifest)) {
manifest.registrations = [];
}
@rspieker
rspieker / dimension.js
Last active March 19, 2016 20:36
Obtain screen/window/document dimensions
/**
* Obtain screen/window/document(.documentElement)/element dimensions
* @param object target
* @param mixed prefix [optional, default false-ish - no prefix, use best for target]
* @note best:
* - window >> outer
* - document >> client|offset|scroll
* - element >> client|offset|scroll
*/
function dimension(target, prefix) {