Skip to content

Instantly share code, notes, and snippets.

View mgldev's full-sized avatar

Michael Leach mgldev

View GitHub Profile
<?php
class NameValuePair
{
/** @var string */
private $name;
/** @var mixed */
private $value;
[URL]
Protocol=unreal
ProtocolDescription=Unreal Protocol
Name=Player
Map=Index.unr
LocalMap=CityIntro.unr
Host=
Portal=
MapExt=unr
SaveExt=usa
<script type="text/jsx">
var Modal = ReactBootstrap.Modal;
var ModalTrigger = ReactBootstrap.ModalTrigger;
var OverlayMixin = ReactBootstrap.OverlayMixin;
var Button = ReactBootstrap.Button;
var RefinableContent = React.createClass({
render: function () {
<?php
namespace App;
class CsvFile {
protected $closure;
protected $filename;
protected $skipHeadings = false;
@mgldev
mgldev / gist:7499736
Created November 16, 2013 12:42
So I was told about the Lizard and Spock extension to Rock, Paper Scissors and I wanted to see how the current OOP approach would extend to the introduction of the new winning methods and roles.
<?php
class DrawException extends DomainException {}
abstract class Hand {
public function beats(Hand $hand) {
$this->rejectDraw($hand);
return $this->assess($hand);
@mgldev
mgldev / gist:6764556
Last active December 24, 2015 07:29
<?php
class SentenceCorector {
protected $originalSentence = null;
protected $correctedSentance = null;
protected $corrections = 0;
public function corect($sentence) {
@mgldev
mgldev / gist:6461151
Last active December 22, 2015 10:48
Rock paper scissors OOP approach
<?php
class DrawException extends DomainException {}
abstract class Hand {
public function beats(Hand $hand) {
$this->rejectDraw($hand);
$this->assess($hand);
@mgldev
mgldev / gist:6437221
Last active December 22, 2015 07:19
A colleague set a task of creating a Rock, Paper, Scissors game for our junior developers to tackle, and I thought I'd give it a shot.
<?php
$pieces = ['r' => 'Rock', 'p' => 'Paper', 's' => 'Scissors'];
$stack = [[['p','r'],'p'],[['r','s'],'r'],[['s','p'],'s']];
$takes = 5;
function request_player_piece() {
global $pieces;
echo "\nChoose piece: ";
$playerPiece = strtolower(trim(fgets(STDIN)));