Skip to content

Instantly share code, notes, and snippets.

View dtryon's full-sized avatar

Davin Tryon dtryon

View GitHub Profile
var Game = (function () {
var _grid;
var init = function (size) {
_grid = [];
for (var x = size - 1; x >= 0; x--) {
var row = [];
for (var y = size - 1; y >= 0; y--) {
row.push(0);
var Game = (function () {
return function() {
return {};
};
})();
describe('Game of Life', function () {
var game;
beforeEach(function () {
game = Game(30);
});
it('should create a new 30 x 30 grid', function () {
expect(game.grid().length).toBe(30);
expect(game.grid()[0].length).toBe(30);
});
public class OrderingService
{
private ISendEmail sendEmail;
public OrderingService(ISendEmail sendEmail)
{
this.sendEmail = sendEmail;
}
// snip
public class Order
{
private Customer customer;
public Order(Customer customer)
{
this.customer = customer;
}
// snip
public class Order
{
private Customer customer;
public Order(Customer customer)
{
this.customer = customer;
}
// snip
public class Order
{
private Customer customer;
private ISendEmail sendEmail;
public Order(Customer customer, ISendEmail sendEmal)
{
this.customer = customer;
this.sendEmail = sendEmail;
}
public class Order
{
private Customer customer;
public Order(Customer customer)
{
this.customer = customer;
}
// snip
@dtryon
dtryon / gist:2467312
Created April 22, 2012 22:24
Func as selector
using System;
public class Program
{
public static void Main()
{
Brush brush = new Brush();
brush.ChooseColor(c => c);
Console.WriteLine("Choose Default: {0}", brush.Color);
@dtryon
dtryon / gist:2350988
Created April 10, 2012 12:17
Simple Bus implementation
public class Bus : IBus
{
// this is our dependency that will publish the message to a queue (or somewhere else)
private IMessageDispatcher messageDispatcher;
public void Publish<T>(Action<T> action) where T : IMessage
{
var newInstance = CreateInstance<T>();
// pass the new instance to the action (by reference)