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 / 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 / MyApp1.php
Created June 19, 2012 12:43
TempRouter
<?php
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
class MyApp1 implements MessageComponentInterface {
public function onOpen(ConnectionInterface $conn) {
}
public function onMessage(ConnectionInterface $from, $msg) {
}
@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;
}
@cboden
cboden / example.php
Last active February 11, 2024 14:38
Ratchet Routing
<?php
$collection = new RouteCollection;
$collection->add('chatRoom', new Route('/demo', array(
'_controller' => new ChatRoom
, 'allowedOrigins' => 'socketo.me'
)));
$collection->add('echo', new Route('/echo', array(
@cboden
cboden / certificate.pem
Created August 19, 2012 16:03
No Async SSL w/ PHP
-----BEGIN CERTIFICATE-----
MIIEFzCCAv+gAwIBAgIBADANBgkqhkiG9w0BAQQFADBqMQswCQYDVQQGEwJkZTEP
MA0GA1UECBMGSGVzc2VuMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBM
dGQxEzARBgNVBAcTCkRpbGxlbmJ1cmcxEjAQBgNVBAMTCTEyNy4wLjAuMTAeFw0x
MjA2MTYyMDE2MDhaFw0yMjA2MTQyMDE2MDhaMGoxCzAJBgNVBAYTAmRlMQ8wDQYD
VQQIEwZIZXNzZW4xITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDET
MBEGA1UEBxMKRGlsbGVuYnVyZzESMBAGA1UEAxMJMTI3LjAuMC4xMIIBIjANBgkq
hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAofA7J9eN5Q8pTrbHOBQC63gB4m6NPNjx
NZ302U5VK5SIkT8lYNk/uwY88C93jAgEBjgSk9IcLdzCRIay5UJmf92fSwZS+x+7
V8nQyuMtQ+9uipX5nhFVAj1iGbO92McsuBb9ck1jQuNt5YZW1WsnGivh88vMiKBa
@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);
}
}