Skip to content

Instantly share code, notes, and snippets.

Avatar
🏃‍♂️
Funemployed

Chris Boden cboden

🏃‍♂️
Funemployed
View GitHub Profile
@cboden
cboden / proxy.php
Created Apr 3, 2017
Connect to a WS server forward msgs to self WS server
View proxy.php
<?php
use Ratchet\ConnectionInterface;
require __DIR__ . '/vendor/autoload.php';
class Proxy implements \Ratchet\MessageComponentInterface {
private $clients;
public function __construct() {
$this->clients = new \SplObjectStorage;
View autobahn.js
/** @license MIT License (c) 2011,2012 Copyright Tavendo GmbH. */
/**
* AutobahnJS - http://autobahn.ws
*
* A lightweight implementation of
*
* WAMP (The WebSocket Application Messaging Protocol) - http://wamp.ws
*
* Provides asynchronous RPC/PubSub over WebSocket.
View multiple
curl http://localhost:5984/mydb/aSpecificDocId
// Take properties from aSpecificDocId which are keys for the following query
curl http://localhost:5984/mydb/_all_docs?keys=["docIdA","docIdB","docIdC","docIdD","docIdE"]
@cboden
cboden / couch.sh
Created Mar 30, 2016
Bash CouchDB shortcut function
View couch.sh
couch() {
curl -s "${@:2}" http://127.0.0.1:5984/$1 | json_pp
}
View Disposable.php
<?php
interface Disposable {
public function dispose();
}
View Rx.changes.js
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);
View gist:0d21983e82ab0fb26c20
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');
}
@cboden
cboden / gist:43bff1f920a4b2603f1a
Created Jun 18, 2015
LdnPHP Trivia June 17th, 2015
View gist:43bff1f920a4b2603f1a
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 / factory.php
Last active Aug 29, 2015
Exceptions...
View factory.php
<?php
class ExceptionFactory implements ExceptionFactoryInterface {
public function __invoke($msg = '') {
return new \Exception($msg);
}
}
View do-filters.sh
#!/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
You can’t perform that action at this time.