Skip to content

Instantly share code, notes, and snippets.

View pjdietz's full-sized avatar

PJ Dietz pjdietz

View GitHub Profile
@pjdietz
pjdietz / Container.php
Last active August 29, 2015 14:18
DI Container with configuration
<?php
namespace MyNamespace;
/**
* Dependency injection container
*/
class Container extends \Pimple\Container
{
/**
@pjdietz
pjdietz / sed-slash-n-to-newline.sh
Created May 1, 2015 19:10
Convert literal \n to newline with sed
sed -E 's/\\n/\n/g'
@pjdietz
pjdietz / getControlPointsForPerspectiveDistortion.php
Created May 6, 2015 15:00
Imagick::distrortImage control points array function
/**
* Returns an array of control points for use with Imagick::distortImage
*
* Offset floats describe the proportions between 0.0 and 1.0 to move the
* given anchor point toward the opposite corner of the image. For example,
* an image of size 100x100. $topLeftOffsetX = .2, $topLeftOffsetY = .5
* will move the top left corner down and right from (0,0) to (20,50).
* $bottomRightOffsetX = .2, $bottomRightOffsetY will move the bottom right
* corner up and left from (100,100) to (80,50).
*
@pjdietz
pjdietz / Responder.php
Last active August 29, 2015 14:21
Class for making responses on legacy servers slightly less painful
<?php
class Responder
{
/**
* @param int $statusCode
* @param array $headers
* @param string|callable $body
*/
public function respond($statusCode, $headers = null, $body = "")
@pjdietz
pjdietz / switch-set.wow.macro
Created August 9, 2015 16:49
Switch spec and armor set
/equipset Mistweaver
/run SetActiveSpecGroup(2);
/run ShowHelm(1);
@pjdietz
pjdietz / AutomaticProperties.php
Last active December 11, 2015 15:39
Simple implementation of magic accessor methods (__get, __set, __isset, __unset) for PHP classes.
<?php
/*
* Use these methods to create automatic properties. When a property would be accessed,
* PHP will look for a function prefixed with get, set, isset, or unset followed by
* the property name with the first name capitalized. For example, the $this->name
* would be accessed as getName(), setName(), issetName(), and unsetName().
*/
/**
@pjdietz
pjdietz / stringFromTemplate.php
Last active December 11, 2015 23:08
Merge an associative array into a string template.
<?php
/**
* Merge an associative array into a string template.
*
* @param string $template
* @param array $mergeFields
* @return string
*/
function stringFromTemplate($template, $mergeFields)
@pjdietz
pjdietz / clean-table.css
Last active December 12, 2015 05:48
Styles for tables with minimal furniture.
table.clean {
margin-top: 20px;
border-collapse: collapse;
}
table.clean caption {
font-weight: bold;
font-size: 14px;
line-height: 18px;
margin-bottom: 10px;
@pjdietz
pjdietz / empty.html
Created March 31, 2013 17:40
HTML5 empty template
<!DOCTYPE html>
<html>
<head>
<title>Hello, World!</title>
<meta charset="utf-8" />
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
@pjdietz
pjdietz / RequestHeaders.php
Last active December 15, 2015 20:29
Static class to facilitate looking up request headers. The class allows you to look up request headers case insensitively.
<?php
/**
* Class RequestHeaders
*
* Static class to facilitate looking up request headers.
*/
class RequestHeaders
{
/**