Skip to content

Instantly share code, notes, and snippets.

View SammyK's full-sized avatar
🐶
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
SammyK / Dockerfile
Last active April 10, 2019 03:02
Writing tests for php-src: Docker setup
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
SammyK / invert-binary-tree.php
Created September 6, 2018 21:54
Invert A Binary Tree in PHP (Array Implementation)
<?php
// Similar, but not quite the same as LeetCode problem #226
// @see https://leetcode.com/problems/invert-binary-tree/description/
function invertTree(array $nodes): array
{
$height = (int) floor(log(count($nodes), 2));
$level = 1;
while ($level <= $height) {
$start = 2 ** $level - 1;
@SammyK
SammyK / README.md
Last active August 1, 2018 16:54 — 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.

Installation

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
SammyK / php-retry-keyword.md
Last active April 3, 2018 05:47
Possible syntax for adding the `retry` keyword to PHP 7.next

Without retry keyword

try {
	$attempts = 0;
	retry:
	throw new Exception('Oops!');
} catch (Exception $e) {
	if ($attempts < 4) {
		$attempts++;
@SammyK
SammyK / Color.php
Created October 5, 2017 21:48
Color RGB matcher
<?php
class Color
{
private $hex;
private $r;
private $g;
private $b;
public function __construct(string $hex) {
@SammyK
SammyK / readme.md
Created August 11, 2017 14:48
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}
This works and takes args!
@SammyK
SammyK / php-retry-keyword-2.0.md
Last active May 25, 2017 13:11
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
SammyK / the-modern-php-developer.md
Last active April 7, 2017 03:19
Gone is the age of procedural WordPressy web apps in PHP. The modern PHP developer grabs best practices by the horns to be a coding badass.

The Modern PHP Developer

If you want to be a respectable PHP programmer in this age, make sure you know about a few important things!

PHP Framework Interoperability Group (FIG) Standards

Familiarize yourself with PSR standards. The most important one is PSR-0 as it changed the way PHP is coded in version 5.3.

@SammyK
SammyK / MyQueueServiceProvider.php
Last active September 23, 2015 12:01
AWS SQS Push Queues for Laravel 4.1
<?php namespace App\LaravelExtensions;
use Illuminate\Queue\QueueServiceProvider;
class MyQueueServiceProvider extends QueueServiceProvider {
/**
* Register the connectors on the queue manager.
*
* @param \Illuminate\Queue\QueueManager $manager