Skip to content

Instantly share code, notes, and snippets.

View DaveRandom's full-sized avatar

Chris Wright DaveRandom

View GitHub Profile
<?php
namespace Seedstream;
use React\EventLoop\LoopInterface,
React\Socket\ConnectionInterface;
class HandlerManager
{
private $loop;
@DaveRandom
DaveRandom / Pusher.php
Last active December 24, 2015 15:49 — forked from J7mbo/gist:6823472
<?php
namespace Seedstream;
use React\EventLoop\LoopInterface,
React\Socket\ConnectionInterface;
class Pusher
{
private $loop;
@DaveRandom
DaveRandom / QueryLevel.php
Last active December 22, 2015 23:49
URI/query string classes
<?php
class QueryLevel implements \ArrayAccess, \Iterator, \Countable
{
private $elements = [];
private $iterationValid;
private function encodeElement($name, $value, $nameFormat = '%s')
{
<?php
// Because PHP_URL_* constants are sequential :-(
const URL_SCHEME = 0x01;
const URL_USER = 0x02;
const URL_PASS = 0x04;
const URL_HOST = 0x08;
const URL_PORT = 0x10;
const URL_PATH = 0x20;
const URL_QUERY = 0x40;
@DaveRandom
DaveRandom / config.php
Last active July 26, 2018 00:50
Push notification daemon example for @PeeHaa
<?php
$pidFile = __DIR__ . '/push-notify.pid';
$localSockAddr = __DIR__ . '/push-notify.sock'; // used for sending updates
$publicSockAddr = 'tcp://0.0.0.0:1337'; // bind address for push clients
$remoteSockAddr = 'tcp://127.0.0.1:1337'; // push client remote address for testing
@DaveRandom
DaveRandom / any-min.js
Last active December 21, 2015 01:49
I'm not gay, I just really like rainbows.
(function(){"use strict";var e="http://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/ICA_flag.svg/220px-ICA_flag.svg.png",t="http://freegeoip.net/json/?callback=window.____PeskyRuskies____.jsonpCallback",n="RU",r=false,i=null;window.____PeskyRuskies____={init:function(){var e=this,t=function(){e.initJsonpRequest()},n=function(){if(!r){try{document.documentElement.doScroll("left")}catch(t){setTimeout(n,1);return}e.initJsonpRequest()}};if(document.readyState==="complete"){this.initJsonpRequest()}else if(document.addEventListener){document.addEventListener("DOMContentLoaded",t,false);document.addEventListener("load",t,false)}else if(document.attachEvent){document.attachEvent("onreadystatechange",t);document.attachEvent("onload",t);try{if(document.documentElement.doScroll&&window.frameElement===null){n()}}catch(i){}}},initJsonpRequest:function(){if(!r){i=document.createElement("script");i.type="text/javascript";i.src=t;document.body.appendChild(i);r=true}},jsonpCallback:function(t){if(i){if(t.country_code!==u
@DaveRandom
DaveRandom / ContentType.php
Last active December 20, 2015 06:59
PHP Content-Type negotiation
<?php
/**
* Represents a MIME content type
*
* @author Chris Wright <github@daverandom.com>
*/
class ContentType
{
/**
@DaveRandom
DaveRandom / build_url.php
Last active December 20, 2015 05:28
PHP build_url()
<?php
function build_url($parts)
{
$result = '';
if (isset($parts['scheme'])) {
$result .= $parts['scheme'] . ':';
}
@DaveRandom
DaveRandom / Module.vbs
Created July 5, 2013 15:38
Module for repositioning windows in Access using Window API calls
Option Compare Database
Option Explicit
Private Type Point
x As Long
y As Long
End Type
Private Type Position
left As Long
@DaveRandom
DaveRandom / ImageRandomizer.js
Created July 1, 2013 09:20
Prototype for object which randomly displays a list of images with fading transitions
/*jslint browser: true, plusplus: true, regexp: true, white: true */
/**
* Prototype for object which randomly displays a list of images with fading transitions
*
* @package ImageRandomizer <https://gist.github.com/DaveRandom/5899497>
* @author Chris Wright <https://github.com/DaveRandom>
* @copyright Copyright (c) Chris Wright <https://github.com/DaveRandom>
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 1.0.127