Skip to content

Instantly share code, notes, and snippets.

Meredith Palmer Memorial Celebrity Rabies Awareness ProAm FunRun Race 4 The Cure

Sammy Kaye Powers SammyK

Meredith Palmer Memorial Celebrity Rabies Awareness ProAm FunRun Race 4 The Cure
View GitHub Profile
SammyK / invert-binary-tree.php
Created Sep 6, 2018
Invert A Binary Tree in PHP (Array Implementation)
View invert-binary-tree.php
// Similar, but not quite the same as LeetCode problem #226
// @see
function invertTree(array $nodes): array
$height = (int) floor(log(count($nodes), 2));
$level = 1;
while ($level <= $height) {
$start = 2 ** $level - 1;
SammyK /
Last active Aug 1, 2018 — forked from nikic/varVar.php
Script for finding variable-variable usages potentially affected by uniform variable syntax

Find Bugs Related To Uniform Variable Syntax

When upgrading to PHP 7, you might run into really hard-to-debug error messages which might be a result of the uniform variable syntax RFC.

This script (forked from Nikita Popov's gist) will scan a PHP 5 codebase and call out the file and line number of an indirect expression with an offset. The evaluation of these expressions has changed in PHP 7.


To run this script against a PHP 5 codebase, make sure you have PHP and Composer installed. Then create a directory somewhere and install nikic/php-parser with Composer.

SammyK / Color.php
Created Oct 5, 2017
Color RGB matcher
View Color.php
class Color
private $hex;
private $r;
private $g;
private $b;
public function __construct(string $hex) {
SammyK /
Created Aug 11, 2017
Northeast PHP Hack-a-thon notes

Northeast PHP Hack-a-thon (php-src) 2017

  • Set up GitHub account + add your SSH keys
  • Fork php-src repo to your GitHub account
  • Clone source (or use USB stick) & cd into directory
  • Update origin remote URL with your fork
$ git remote set-url origin {your-fork-URL}
SammyK / Dockerfile
Last active Apr 10, 2019
Writing tests for php-src: Docker setup
View Dockerfile
FROM ubuntu:16.04
MAINTAINER Sammy Kaye Powers
RUN apt-get update \
&& apt-get install sudo vim git -y \
&& apt-get install build-essential autoconf valgrind -y \
&& apt-get install re2c bison -y \
&& apt-get install libxml2-dev locales lcov -y
SammyK /
Last active May 25, 2017
Proposed `retry` keyword in PHP 7.NEXT

Proposed retry keyword in PHP

This is a pivot of the original syntax proposal thanks to feedback from twitter.

The retry keyword adds to the try\catch\finally block to optionally execute an arbitrary statement before jumping to the top of the try block n times.

TL;DR The retry keyword offers a cleaner, more readable & more efficient solution to a common problem.

A simple example

SammyK /
Last active Apr 3, 2018
Possible syntax for adding the `retry` keyword to PHP

Without retry keyword

try {
	$attempts = 0;
	throw new Exception('Oops!');
} catch (Exception $e) {
	if ($attempts < 4) {
SammyK / MyQueueServiceProvider.php
Last active Sep 23, 2015
AWS SQS Push Queues for Laravel 4.1
View MyQueueServiceProvider.php
<?php namespace App\LaravelExtensions;
use Illuminate\Queue\QueueServiceProvider;
class MyQueueServiceProvider extends QueueServiceProvider {
* Register the connectors on the queue manager.
* @param \Illuminate\Queue\QueueManager $manager
SammyK / errors_null.phpt
Created Apr 14, 2015
The test we wrote for Chicago PHP. The file was located at `ext/json/tests/errors_null.phpt`
View errors_null.phpt
Checks for return types on error
if (!extension_loaded('json')) die('skip: json extension not available');