Skip to content

Instantly share code, notes, and snippets.

View cspray's full-sized avatar

Charles Sprayberry cspray

View GitHub Profile
PHPUnit 6.5.14 by Sebastian Bergmann and contributors.
E.F 3 / 3 (100%)
Time: 132 ms, Memory: 4.00MB
There was 1 error:
1) Amp\PHPUnit\Test\AsyncTestCaseTest::testThatMethodRunsInLoopContext
Error: Loop exceptionally stopped without resolving the promise
@cspray
cspray / aysnc-test-example.php
Created February 9, 2019 15:52
AsyncTestCase example with amphp
<?php
// We assume that your PHPUnit bootstrap will include the appropriate class loader and setup your environment
use Amp\Delayed;
use Amp\Promise;
use Amp\PHPUnit\AsyncTestCase;
use function Amp\call;
@cspray
cspray / php-ds-stubs.php
Created June 26, 2016 01:23
A gist to create a PHP class for stubbing from a classname
<?php
declare(strict_types = 1);
/**
* @license See LICENSE file in project root
*/
require_once '/spraybot-app/vendor/autoload.php';
<?php
abstract class AsyncTestCase extends \PHPUnit\Framework\TestCase {
public function runTest() {
Loop::run(function() {
$watcherId = Loop::delay(1500, function() {
Loop::stop();
$this->fail('The asynchronous test was expected to finish before the 1500 millisecond time limit');
});
@cspray
cspray / cv-ring-description.md
Created January 27, 2012 15:55
A brief description of cv-ring and cv-pls

What is 'cv-ring', 'cv-pls' and 'delv-pls'

In the Stack Overflow PHP chat you may notice the regulars using tags like cv-pls, cv-ring and delv-pls. These tags are used only in the chat room to communicate with other users that a question or answer may need more votes to be closed or deleted. The PHP tag has a lot of inferior quality and duplicative information on Stack Overflow. We feel that inferior quality questions bring down the site and make it harder to find good information, particularly about PHP. By closing and merging these questions as appropriate you'll find the information you need quicker.

  • cv-ring is just a 'funny name' we give to the group of regulars who use the tags
  • cv-pls is an in-chat tag that communicates "Hey, this question may be of inferior quality. Check it out and, if you feel appropriate, cast a close vote."
  • delv-pls is an in-chat tag that communicates "Hey, this question has alr
@cspray
cspray / insert-into-to-array.php
Last active December 28, 2015 03:09
A very rough implementation to convert an INSERT INTO SQL statement to an appropriate array structure for inserted values. There are caveats to the use of this function and full error handling has not yet been implemented.
<?php
function convertInsertIntoToArray($sql) {
$text = \explode(\PHP_EOL, $sql);
$data = array();
if (!empty($text)) {
$firstLine = \preg_replace('/\s+$/', '', $text[0]);
if ($firstLine === 'INSERT INTO') {
if (\preg_match('/\(.+\)/', $text[1], $cols)) {
$cols = \explode(',', \preg_replace('/\(|\)|\s|\`/', '', $cols[0]));
@cspray
cspray / my-alabama-football-story.md
Last active October 13, 2015 11:37
My story of Alabama football

My story of Alabama football

I was born to the parents of SEC fans and, although I didn't move to the state of Alabama until 1992, Alabama football had been ingrained in me. From pictures of a baby me in a Bama bib or all the stories of Alabama football and the Bear, I was saying 'Roll Tide Roll' way before I actually lived in the state. SEC fans might notice that 1992 was a year that Alabama won an SEC and National Championship. Unfortunately it appears as if I was a harbinger of doom for Alabama football.

The 1993 year of Alabama football was the beginning of the end for the program. Once I entered the state Alabama football's program spiraled, truly hitting rock bottom. Auburn's current state of affairs is just the beginning of what the Alabama program endured. NCAA sanctions soon started rolling in and the slip down had begun. After a few reasonably successful seasons after the '92 Championship Mike DuBose came on board. Only more sanctions came against the program and we suffered one of the

<!--
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░▄▄▄▄▀▀▀▀▀▀▀▀▄▄▄▄▄▄░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░█░░░░▒▒▒▒▒▒▒▒▒▒▒▒░░▀▀▄░░░░░░░░░░░░░░░░░░░░░░░░
░░░░█░░░▒▒▒▒▒▒░░░░░░░░▒▒▒░░█░░░░░░░░░░░░░░░░░░░░░░░
░░░█░░░░░░▄██▀▄▄░░░░░▄▄▄░░░░█░░░░░░░░░░░░░░░░░░░░░░
░▄▀▒▄▄▄▒░█▀▀▀▀▄▄█░░░██▄▄█░░░░█░░░░░░░░░░░░░░░░░░░░░
█░▒█▒▄░▀▄▄▄▀░░░░░░░░█░░░▒▒▒▒▒░█░░░░░░░░░░░░░░░░░░░░
█░▒█░█▀▄▄░░░░░█▀░░░░▀▄░░▄▀▀▀▄▒█░░░░░░░░░░░░░░░░░░░░
░█░▀▄░█▄░█▀▄▄░▀░▀▀░▄▄▀░░░░█░░█░░░░░░░░░░░░░░░░░░░░░
@cspray
cspray / windows-8-tablet-flawed.md
Created July 30, 2012 22:35
Microsoft's Windows 8 Strategy is Flawed

Windows 8 Tablet Strategy is Flawed

This is why I think Microsoft's tablet strategy with Windows 8, one OS to handle both mouse based and finger based input, is flawed and that Microsoft doesn't really "get" touch.

In case you've been kept out of the loop, Microsoft introduced a new keyboard and mouse that are designed to work well with tablets. Arguably the keyboard is a useful addition. Typing on a touch screen simply is not as efficient as the traditional physical keyboard. But the very need to create and market a mouse for a device designed to accept finger touch input is a sign of a flawed strategy.

You see, if you could perform your most basic tasks completely using touch then this isn't nearly that big a deal. But, [when Windows 8 dumps you into a desktop interface for various routine tasks](http://arstechnica.com/information-technology/2012/07/does-windows-8-succeed-as-a-true-tablet-operat

@cspray
cspray / else_if.md
Created July 27, 2012 22:37
Opcodes for else if versus elseif
<?php
if (false === true)
{}
else if (true === false)
{}
else
{}
?>