Skip to content

Instantly share code, notes, and snippets.

View Porges's full-sized avatar
🏠
Working from home

George Pollard Porges

🏠
Working from home
View GitHub Profile
@Porges
Porges / 0-Person.cs
Last active May 30, 2016 21:09
Comparisons
using System;
using Comparisons;
namespace Types
{
class Person : Comparable<Person>
{
private static readonly Comparer<Person> _comparer =
Comparer<Person>
@Porges
Porges / 0-Implicit.fs
Created June 2, 2016 23:41
Using reader monad in F# to pass around dependencies
module Implicit
type Implicitly<'i, 't> = private Implicitly of ('i -> 't)
let implicitly = Implicitly
let runImplicit impl (Implicitly f) = f impl
type ImplicitBuilder<'i> () =
member __.ReturnFrom x = x
@Porges
Porges / 0-before.cs
Created June 14, 2016 08:32
Banishing Booleans
class Example
{
}
@Porges
Porges / 0-producer.cs
Last active January 17, 2017 04:05
Examples for the "Ignore Null Strategies" post: https://porg.es/ignore-null-strategies/
interface IProducer
{
Result Produce();
}
class ProducerExample
{
readonly IProducer _producer;
// constructor elided...
@Porges
Porges / 0-situation.cs
Last active January 17, 2017 08:25
Code for the post "Managing Multiplicity": https://porg.es/managing-multiplicity-monoidally/
interface IStrategy
{
Result DoTheThing(Input input);
}
class Consumer
{
readonly ICollection<IStrategy> _strategies;
public void PerformDuties()
@Porges
Porges / hardlink.cpp
Created November 10, 2016 00:27
hardlink a directory recursively
using System;
namespace Result
{
class Program
{
static void Main(string[] args)
{
var r = new Random();
for (int i = 0; i < 10; ++i)

Keybase proof

I hereby claim:

  • I am porges on github.
  • I am porges (https://keybase.io/porges) on keybase.
  • I have a public key whose fingerprint is 15E4 4626 39AF 06CF 5F0A AA58 0FE3 4FF5 2469 705F

To claim this, I am signing this object:

#include <iostream>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
// We want to put all registered types into a map:
std::unordered_map<std::type_index, std::string> registered_types;
template<class T>
@Porges
Porges / provenance.cs
Last active January 15, 2017 07:08
Tracking value provenance
using System;
using System.Runtime.CompilerServices;
namespace Provenance
{
public struct Provenance
{
public Provenance(string callerFileName, int callerLineNumber)
{
CallerFileName = callerFileName;