Skip to content

Instantly share code, notes, and snippets.

View brianium's full-sized avatar
🕊️
Human

Brian Scaturro brianium

🕊️
Human
View GitHub Profile
@brianium
brianium / gist:2052652
Created March 16, 2012 20:59
simple ddd console app
using System;
using System.Collections.Generic;
using DMSSubscriberUpdate.Domain;
using DMSSubscriberUpdate.Infrastructure;
using DMSSubscriberUpdate.Domain.Services;
namespace DMSSubscriberUpdate
{
class Program
{
@brianium
brianium / IInputConfigRepositoryTest.php
Created March 14, 2012 17:40
mocking interfaces in php
<?php
namespace Test\Unit\Domain\Repositories;
use Domain\Repositories;
use Domain\Entities\InputConfig;
use Infrastructure\Reflection\Reflection;
class IInputConfigRepositoryTest extends \PHPUnit_Framework_TestCase
{
public function setUp() {
$this->mock = $this->getMockBuilder('Domain\Repositories\IInputConfigRepository')
->disableOriginalConstructor()
@brianium
brianium / gist:2029237
Created March 13, 2012 14:49
closure with bind
var obj = {
method: function(name){
this.name = name;
console.log(this.name);
var inner = function(msg) {
console.log(msg + " " + this.name);
}.bind(this,'hello');
inner();
}
};
@brianium
brianium / gist:2029233
Created March 13, 2012 14:49
bindless closure
var obj = {
method: function(name){
this.name = name;
console.log(this.name);
var self = this;
var inner = function(msg) {
console.log(msg + " " + self.name);
};
inner('hello');
}
@brianium
brianium / gist:2026243
Created March 13, 2012 02:39
ecmascript 3 bind
function bind(f,o) {
if(f.bind) return f.bind(o);
else return function() {
return f.apply(o, arguments);
};
}
@brianium
brianium / Autoloader.php
Created March 12, 2012 18:54
PHP 5 Autoloader with Namespace support
<?php
class Autoloader
{
protected $directory;
protected $methodQueue;
/**
* @param string $dir the directory to look from
*/