Skip to content

Instantly share code, notes, and snippets.

View cboden's full-sized avatar
📉
Munging data

Chris Boden cboden

📉
Munging data
View GitHub Profile
@cboden
cboden / AccountedExceptions.php
Created May 10, 2014 13:51
Account for expected errors
<?php
namespace MyNamespace;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
class AccountedExceptions MessageComponentInterface {
protected $_app;
public function __construct($app) {
$this->_app = $app;
#!/bin/bash
SCRIPT=$(pwd)/$(dirname $0)/filter-repo.sh
$SCRIPT "event-loop" EventLoop
$SCRIPT stream Stream
$SCRIPT cache Cache
$SCRIPT dns Dns
$SCRIPT http Http
$SCRIPT "http-client" HttpClient
@cboden
cboden / factory.php
Last active August 29, 2015 14:21
Exceptions...
<?php
class ExceptionFactory implements ExceptionFactoryInterface {
public function __invoke($msg = '') {
return new \Exception($msg);
}
}
@cboden
cboden / gist:43bff1f920a4b2603f1a
Created June 18, 2015 14:17
LdnPHP Trivia June 17th, 2015
Language
- In the function strpos which comes first: the haystack or the needle?
haystack, needle
- What does the acronym "SPL" stand for?
Standard PHP Library
- Aside from inheriting these via genes, they're also good for horizontal code re-use
Traits
- Your only hope of implementing this interface is via Iterator or IteratorAggregate
Traversable
- SplStack and SplQueue both extend this common base class
@cboden
cboden / gist:0d21983e82ab0fb26c20
Created June 23, 2015 14:42
Operator Subject
var sub = new Rx.Subject();
var obs = sub.distinctUntilChanged(); // This is what I want
function module1(sub) {
sub.subscribe(console.log.bind(console));
sub.onNext('hello');
}
Rx.Observable.prototype.changes = function(deleteObs, keySelector) {
var source = this;
return new Rx.AnonymousObservable(function(observer) {
var store = new Map;
return new Rx.CompositeDisposable(
deleteObs.subscribe(function(key) {
var last = store.get(key);
store.delete(key);
@cboden
cboden / gist:1775473
Created February 8, 2012 23:39
Strange Failing Travis CI Test
<?php
/**
* The method that is being tested
*/
public function generateKeyNumber($key) {
// If there are no spaces, reject
if (0 === substr_count($key, ' ')) {
return '';
}
@cboden
cboden / gist:2044871
Created March 15, 2012 15:43
Truncate Foreign Key'd Tables
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `table1`;
TRUNCATE TABLE `table2`;
SET FOREIGN_KEY_CHECKS = 1;
@cboden
cboden / libevent-react.php
Created May 10, 2012 14:01
Libevent React
<?php
require __DIR__.'/vendor/autoload.php';
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
//$loop = new React\EventLoop\StreamSelectLoop();
$loop = new React\EventLoop\LibEventLoop();
$socket = new React\Socket\Server($loop);
@cboden
cboden / UvConnection.php
Created July 13, 2012 13:55
Ratchet w/ php-uv
<?php
namespace Ratchet\Server;
use Ratchet\ConnectionInterface;
class UvConnection implements ConnectionInterface {
private $client;
public function __construct($client) {
$this->client = $client;
}