Skip to content

Instantly share code, notes, and snippets.

View pgraham's full-sized avatar

Philip Graham pgraham

  • Ottawa
View GitHub Profile
@pgraham
pgraham / MyComponent-spec.js
Created November 17, 2016 04:50
babel, deamdify bug demo
var MyComponent = require("MyComponent");
var React = require("react");
describe("views/MyComponent", function () {
it("renders", function () {
var el = React.createElement(MyComponent, {
style: { color: "#000" }
});
@pgraham
pgraham / observable-test.js
Created December 6, 2012 18:53
Make any object observable with subtyped events
test( "test interface", function () {
var eventRegistry = window.eventRegistry();
ok(eventRegistry.hasOwnProperty('on'), "No `on` method found");
ok(eventRegistry.hasOwnProperty('trigger'), "No `trigger` method found");
});
test( "test binding", function () {
var eventRegistry = window.eventRegistry();
@pgraham
pgraham / gist:4127832
Created November 21, 2012 21:22
function to create a mock iterator over an array using PHPMock
/**
* Create a mock iterator over the given array.
*
* @param array $a
* @param string $class The class to use for the mock, should be/implement/extend Iterator
* @param boolean $complete Whether or not to build a complete iteration. This is
* used when an exception/break is expected in the middle of the iteration.
* @param integer $numElms The number of elements that should be iterated in the case of an
* incomplete iteration.
*/
@pgraham
pgraham / php-resource-pkg-compiler
Created August 11, 2012 00:10
Package structure for javascript files which allows them to be written modularly but easily compiled into large scripts for more efficient page loading.
<?php
/**
* Class which compiles web resources composed of multiple files into larger files for quicker
* page loading.
*
* The compilation happens based on a conventional package structure which is defined by the file system
* containing the source. The root of the file system containing the packages only contains directories.
* Each directory in the root is itself the root of a set of hierarchical packages.
*
* Packages are referred use a dot (.) notation similar to Java. Compilation will produce one file per