Skip to content

Instantly share code, notes, and snippets.

@codenamegary
codenamegary / gist:7015030
Last active December 25, 2015 17:39 — forked from s3gfau1t/gist:7014684
ERMAHGERD IF/ELSE! $raceWriter('Message to console or file.');
<?php
$velocities = array("turtle", "donkey", "rabbit");
$mode = isset($argv[1]) ? $argv[1] : 'console';
$file = isset($argv[2]) ? $argv[2] : '';
$fp = null;
$raceWriters = array(
'file' => function($output)use($file, $fp){
if(!$fp) $fp = fopen($file, 'a+');
@codenamegary
codenamegary / gist:7495415
Created November 16, 2013 03:04
#laravel IRC pong
$players = array();
<?php
use Validator;
use RuleSet;
use Filters;
use Rule;
use Constraints;
class ValidationBuilder {
@codenamegary
codenamegary / php-scalars.php
Last active January 4, 2016 09:48
Scalar Type Hinting in PHP
<?php
// See: http://nikic.github.io/2012/03/06/Scalar-type-hinting-is-harder-than-you-think.html
// And RFC: https://wiki.php.net/rfc/scalar_type_hinting_with_cast
//
// Basically the same implementation as outlined in the RFC but with a concept for scalar
// magic to be added to objects at some point in the future.
class MyObjectWithScalarMagic {
@codenamegary
codenamegary / data-contain-play.php
Created February 18, 2014 22:01
Example of how to use DataContain to make entities.
<?php
include __DIR__.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
class Entity extends DataContain\Container {
/**
* @var DataContain\DefinitionContainer
*/
protected $attributes;
@codenamegary
codenamegary / datacontain-validator.php
Created February 19, 2014 22:01
Just a random example of how a ContainerBuilder for DataContain might be implemented, needs work
<?php
class Entity extends DataContain\Container {
/**
* @var DataContain\DefinitionContainer
*/
protected $attributes;
public function __construct(array $data = array(), DataContain\DefinitionContainer $attributes = null)
<?php
namespace Vent;
trait VentTrait {
/**
* Handle a write request
* @param $name
* @param $value
@codenamegary
codenamegary / Person.php
Last active August 29, 2015 13:59 — forked from amcsi/Person.php
<?php
namespace MyProject;
class Person
{
private $data;
/**
*
@codenamegary
codenamegary / dev-ops-resource-needed.md
Created September 8, 2014 19:19
Dev-ops Resource Needed

#SKILLED DEV-OPS RESOURCE NEEDED FOR TEMPORARY / PART-TIME CONTRACT

##BACKGROUND

We are a small development team focused on mostly LAMP (or LEMP) based application development. We have traditionally deployed to hosting solutions using a PaaS like PagodaBox or FortRabbit. Some of our internal and client projects are beginning to grow and we need to focus on moving our hosting out to a more robust solution using Amazon, SoftLayer, BlueMix (CloudFoundry) or some other provider of your choosing.

Applications are entirely custom and built on either Laravel or Symfony, there is no Wordpress or Joomla or any other CMS involved in any of the existing projects.

Currently, we are a small team of sales and developers. We are familiar with all of the technologies involved in deploying to Amazon through Elastic Beanstalk and other facilities but do not have the will nor manpower to automate and assemble the process as much as we'd like. We are looking to augment and fill the dev-ops gap in our skills with a person who

@codenamegary
codenamegary / fizzbuzz.php
Last active August 29, 2015 14:07
Functional FizzBuzz
<?php
$zork = function($result, $mod) {
return function($num)use($result, $mod) {
return $num % $mod ? '' : $result;
};
};
$fizz = $zork('Fizz', 3);