Skip to content

Instantly share code, notes, and snippets.

View pjdietz's full-sized avatar

PJ Dietz pjdietz

View GitHub Profile
@pjdietz
pjdietz / resolution-fix.sh
Created August 30, 2016 18:44
Fix WoW Resolution on Macbook Pro Retina
# http://us.battle.net/forums/en/wow/topic/8873728013
defaults write com.blizzard.worldofwarcraft DesktopModeIsDefault 1
@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 / ContainsElements.java
Created July 22, 2015 15:24
ArgumentMatcher for checking if two collection contains the same elements.
class ContainsElements<T> extends ArgumentMatcher<Collection> {
private Collection<T> expected;
public ContainsEqualElements(Collection<T> expected) {
this.expected = expected;
}
public boolean matches(Object list) {
if (list instanceof Collection) {
Collection<T> actual = (Collection<T>) list;
return actual.size() == expected.size() && actual.containsAll(expected) && expected.containsAll(actual);
}
@pjdietz
pjdietz / rfc3339.js
Last active March 14, 2024 10:57
Format a local date as an RFC 3339 date with timezone
function rfc3339(d) {
function pad(n) {
return n < 10 ? "0" + n : n;
}
function timezoneOffset(offset) {
var sign;
if (offset === 0) {
return "Z";
@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 / 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 / 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 / cloudSettings
Last active June 18, 2020 22:29
Testing Protected Method of Abstract Class with PHPUnit
{"lastUpload":"2020-06-18T22:29:09.889Z","extensionVersion":"v3.4.3"}
@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 / refCount.php
Last active August 29, 2015 14:17
Return the number of references for a variable's zval
<?php
/**
* Return the number of references for a variable's zval
*
* @param mixed $var Variable to inspect
* @return int Number of references according to debug_zval_dump
*/
function refCount($var)
{