Skip to content

Instantly share code, notes, and snippets.

View mattsah's full-sized avatar

Matthew J. Sahagian mattsah

View GitHub Profile
@mattsah
mattsah / gist:5561492
Created May 11, 2013 21:31
prettify var_export for php 5.4
$config = preg_replace('#=>\s*array \(#', '=> [', $config);
$config = preg_replace('#\),#', '],', $config);
$config = preg_replace('#,(\s*)\]#', '$1]', $config);
$config = preg_replace('#\d+ => #', '', $config);
$config = preg_replace('#\[\s+\]#', '[]', $config);
$config = str_replace(' ', "\t", $config);
'/test/[!:name]' => function($this) {
if ($this['request']->checkMethod('get')) {
return strtoupper($this['request']->get('name'));
}
}
<% namespace Dotink\Inkwell\View {
/**
*
* @author Matthew J. Sahagian [mjs] <msahagian@dotink.org>
* @param $users The array of users
* @param
*/
if ($this['wtf'] == 'test'):
@mattsah
mattsah / Mime.php
Last active December 10, 2015 22:29
<?php namespace Dotink\Jest {
class Mime extends Jest
{
/**
*
*/
static private $parents = array();
<?php namespace Dotink\Jest {
include 'Mime.php';
Mime::define('App\Test')->implementing('IFake')
-> extending('App\TestBase')->implementing('IFakeBase');
$test = Mime::create('App\Test')
-> onNew('factory', function($mime) {
$mime -> onCall('speak') -> give(function(){
@mattsah
mattsah / gist:3260631
Created August 4, 2012 23:43
A better underscorize method?
<?php
$tests = [
'FavoriteURL',
'URLHelper',
'FavoriteURLs',
'AmazingURLsFromSpace',
'FavoriteURLHelper',
'FBIManBob',
'removeXMLTags',
@mattsah
mattsah / gist:3231836
Created August 2, 2012 00:16
Namespacing Concepts
\Dotink\Flourish\
# Loaded from /includes/lib/flourish via:
#
# 'autoloaders' => array(
# '\Dotink\Flourish\*' => 'COMPAT:includes/lib/flourish'
# )
ORM
ActiveRecord
@mattsah
mattsah / gist:3210863
Created July 30, 2012 22:10
Agile Development and REST?
REST is software design on the scale of decades: every detail is intended to promote software longevity and independent evolution. Many of the constraints are directly opposed to short-term efficiency. Unfortunately, people are fairly good at short-term design, and usually awful at long-term design. Most don’t think they need to design past the current release. There are more than a few software methodologies that portray any long-term thinking as wrong-headed, ivory tower design (which it can be if it isn’t motivated by real requirements).
@mattsah
mattsah / gist:3104455
Created July 13, 2012 11:39
A non-recursive version of PHP's array_replace_recursive()
<?php
/**
* Many examples of pre 5.3 versions of this function use recursion
* this one avoids it for people who, like me, are only going to rely
* on this logic in a single place. In short, you can fully remove the
* function definition and implications and the actual code will still
* work. That is, the function does not need to call itself.
*/
function array_replace_recursive($base, $replacements)
@mattsah
mattsah / gist:1872454
Created February 21, 2012 00:07
inKWell iw class constructor
<?php
/**
* Constructing an iw object is not allowed, this is purely for
* namespacing and static controls.
*
* @final
* @access private
* @param void
* @return void