Skip to content

Instantly share code, notes, and snippets.

View NigelGreenway's full-sized avatar

Nigel Greenway NigelGreenway

View GitHub Profile
<?php
## Specification:
## A User needs to be able to manage tasks to help with their workflow and and self management.
## They will need the ability to add tasks, update a task and delete a task for themselves only.
## Concept:
## A user can have a collection of tasks attached to them.
## A task must consist of a `Title`, `Description` and a `User`
@NigelGreenway
NigelGreenway / RouteCollection.php
Last active August 29, 2015 14:15
Example code for Route/FastRoute config...
<?php
/**
* This is simplistic code to illustrate how routing config files could be implemented.
*/
public function addRoutesFromConfig(
array $routes = [],
$namedRoutes = false,
Strategy\StrategyInterface $strategy = null
@NigelGreenway
NigelGreenway / ajax.js
Created March 9, 2015 11:06
Trial of my own JS AJAX module
(function(window, document, undefined) {
/**
* @returns {XMLHttpRequest|ActiveXObject}
*/
function initialise () {
if (window.XMLHttpRequest) {
// [ IE7+, FireFox, Chrome, Opera, Safari ]
return new XMLHttpRequest();
} else {
@NigelGreenway
NigelGreenway / discussion.php
Last active August 29, 2015 14:21
Simple web to domain/application interface
<?php
final class EmployeeProfileAction
{
private $domain;
private $responseHandler;
public function __construct(
EmployeeService $domain,
ActiveEmployeeListingResponseHandler $responseHandler
<?php
$start = microtime(true);
/*
CREATE TABLE `employees` (
`sId` varchar(40) NOT NULL DEFAULT '',
`sUsername` varchar(255) NOT NULL DEFAULT '',
`sFirstname` varchar(255) NOT NULL DEFAULT '',
`sLastname` varchar(255) NOT NULL DEFAULT '',
@NigelGreenway
NigelGreenway / RouteFinder.php
Last active August 29, 2015 14:23
A quick mock up of generating routes from a Route config
<?php
namespace League\Route\RouteGenerator;
final class RouteGenerator
{
private $routes;
public function __construct(
array $routes = []
@NigelGreenway
NigelGreenway / analyse.php
Last active January 23, 2016 02:35
check for return type hints with interfaces
<?php
require __DIR__.'/test.file.php';
$class = new ReflectionClass(Some\TheThing::class);
////
// Better way to find if the class has strict_type enabled
////
$tokens = token_get_all(file_get_contents(__DIR__.'/test.file.php'));
@NigelGreenway
NigelGreenway / spl_subject.php
Created June 24, 2016 09:29
SplSubject playground
<?php
class Newspaper implements \SplSubject{
private $name;
private $observers = array();
private $content;
public function __construct($name) {
$this->name = $name;
}
## Pre-reqs
sudo apt-get install -y apt-transport-https ca-certificates
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
## Create docker sources list file
sudo touch /etc/apt/sources.list.d/docker.list
sudo echo "deb https://apt.dockerproject.org/repo debian-jessie main" >> /etc/apt/sources.list.d/docker.list
## Update sources
sudo apt-get update
## Install docker engine
sudo apt-cache policy docker-engine
@NigelGreenway
NigelGreenway / react.go
Last active June 1, 2017 13:03
File watcher for ReactPHP
# to run:
# ./react.go {path_to_server.php} ./dir_one ./dir_two ...
package main
import (
"log"
"os"
"os/exec"
"fmt"