Skip to content

Instantly share code, notes, and snippets.

@stephenwf
stephenwf / Example.php
Last active August 29, 2015 14:15
Drupal OOP Hooks using reflection
<?php
/**
* Assumtions:
* IoC Container setup under $container
* EntityManager interface with 2 classes:
* - Traditional Storage
* - MongoDB
* 2 Services in IoC
* - services.user injects the Traditional Storage
@stephenwf
stephenwf / Server.php
Last active August 29, 2015 14:19
Multi-process PHP Webserver
<?php
interface ServerInterface {
/**
* This is called at the end of every request, to determine wether to continue
* with the event loop. Returns true to conitune, false to stop.
*
* @return bool
*/
@stephenwf
stephenwf / fix.sh
Created October 5, 2015 13:13
iTerm true fullscreen
defaults write /Applications/iTerm.app/Contents/Info LSUIElement true
@stephenwf
stephenwf / wat1.php
Last active August 5, 2016 13:24
Wat.php
<?php
$fn1 = function() {
yield 'foo';
yield 'bar';
yield 'bar';
};
$fn2 = function() use ($fn1) {
yield 'baz';
yield from $fn1();
<?php
function changeMe($o) {
$o->name = "changed";
}
$object_1 = new StdClass();
$object_1->name = "original";
changeMe($object_1);
@stephenwf
stephenwf / Express.php
Last active August 30, 2016 14:55
Express.php
<?php
/** Requires classes from previous gist **/
/**
* Express lightweight wrapper around Server
*/
class Express extends Server implements ServerInterface {
/**
* Routing default registry
@stephenwf
stephenwf / BEM.js
Last active October 12, 2016 10:44
BEM JavaScript Helper
const BEM = {
block: (b) => {
const modifier = function (m, c) {
if (m.toString() === '[object Object]') return this.ms(m);
if (!c && c !== undefined) {
return this;
}
return `${this} ${this}--${m}`;
};
const modifiers = function (m) {
@stephenwf
stephenwf / getClassNames.js
Created August 25, 2016 10:52
Class Name list
function *traverse(item) {
for ( var child of item.children ) {
if (child.className) {
yield* child.classList;
}
if (child.childElementCount !== 0) {
yield* traverse(child);
}
}
}

Keybase proof

I hereby claim:

  • I am stephenwf on github.
  • I am stephenwf (https://keybase.io/stephenwf) on keybase.
  • I have a public key ASB4TEHYRhc11RCXXjmjIQdtlQcwz_x2uBu37jkseKRa8go

To claim this, I am signing this object: