Skip to content

Instantly share code, notes, and snippets.

View Mezzle's full-sized avatar

Martin Meredith Mezzle

View GitHub Profile
@Mezzle
Mezzle / poolsample.php
Created February 16, 2012 23:51
Pool Sampling
<?php
class PoolSample
{
private $_pool = array()
/**
* Constructor
*
* @param Array The Pool to Sample - Zero Indexed Array
@Mezzle
Mezzle / FizzBuzz.php
Created April 18, 2012 09:54
Enterprise FizzBuzz
<?php
interface INumber
{
public function go();
public function setNumber($i);
}
class FBNumber implements INumber
{
@Mezzle
Mezzle / spellchecker.py
Created May 21, 2012 09:35
Spell Checker
import re
from random import choice
class Words:
list = {}
loaded = False
def load(self):
f = open('/usr/share/dict/words', 'r')
for line in f:
@Mezzle
Mezzle / spellchecker-test.py
Created May 22, 2012 16:55
SpellChecker Test
import random, re
from string import join
class SpellCheckerTest:
vowels = ['a','e','i','o','u']
def pick_words(self):
sample = []
f = open('/usr/share/dict/words')
@Mezzle
Mezzle / fix-commit
Last active October 11, 2015 09:38
Modified Version of ZF2 pre-commit hook
#!/bin/bash
for f in `git diff --cached --name-status --diff-filter=ACM | grep -Ev "^D" | awk '{print $2}' | grep -E "ph(p|tml)" | grep -v "misc/migrations"`;
do
php-cs-fixer --fixers=-psr0,-phpdoc_params fix $f
done
@Mezzle
Mezzle / EventManagerAwareTrait.php
Created October 18, 2012 14:33
ServiceLocator/EventManager Traits
<?php
namespace Protec\Stdlib;
use \Zend\EventManager\EventManagerInterface;
use \Zend\ServiceManager\ServiceLocatorAwareInterface;
trait EventManagerAwareTrait
{
protected $event_manager;
@Mezzle
Mezzle / gist:4944982
Created February 13, 2013 14:31
UTF-8 Safe slugifier (PHP)
<?php
function slugify($text)
{
// Swap out Non "Letters" with a -
$text = preg_replace('/[^\\pL\d]+/u', '-', $text);
// Trim out extra -'s
$text = trim($text, '-');
name "web-server"
description "Web Server"
run_list "recipe[apt]",
"recipe[nginx]",
"recipe[php]",
"recipe[php-fpm]",
"recipe[php::module_mysql]",
"recipe[php::module_apc]",
"recipe[php::module_intl]",
"recipe[php::module_curl]",
@Mezzle
Mezzle / acceptnewgas.js
Created July 24, 2013 23:15
Useful Tampermonkey / Greasmonkey scripts for ESL
// ==UserScript==
// @name Auto-Accept New GA Changes
// @namespace http://esl.eu/
// @version 0.1
// @description enter something useful
// @match http://www.esl.eu/*/admin_ga_changes/view/*
// @copyright 2013+, Martin Meredith
// ==/UserScript==
if (jQuery(jQuery(jQuery('#main_content table')[1]).find('tr')[3]).find('td')[1].innerHTML == '<em>none</em>') {
<?php
namespace ProtecTest\Employment;
use \ProtecInnovations\Recruiter;
use \PHPUnit_Framework_TestCase as TestCase;
class RecruiterTest extends TestCase
{
protected $object = null;