Skip to content

Instantly share code, notes, and snippets.

<UserSettings><ApplicationIdentity version="12.0"/><ToolsOptions><ToolsOptionsCategory name="Environment" RegisteredName="Environment"/></ToolsOptions><Category name="Environment_Group" RegisteredName="Environment_Group"><Category name="Environment_FontsAndColors" Category="{1EDA5DD4-927A-43a7-810E-7FD247D0DA1D}" Package="{DA9FB551-C724-11d0-AE1F-00A0C90FFFC3}" RegisteredName="Environment_FontsAndColors" PackageName="Visual Studio Environment Package"><PropertyValue name="Version">2</PropertyValue><FontsAndColors Version="2.0"><Theme Id="{DE3DBBCD-F642-433C-8353-8F1DF4370ABA}"/><Categories><Category GUID="{58E96763-1D3B-4E05-B6BA-FF7115FD0B7B}" FontIsDefault="Yes"><Items><Item Name="Plain Text" Foreground="0x00444342" Background="0x00D9D9D9" BoldFont="No"/></Items></Category><Category GUID="{B36B0228-DBAD-4DB0-B9C7-2AD3E572010F}" FontName="Segoe UI" FontSize="9" CharSet="1" FontIsDefault="No"><Items><Item Name="Different content" Foreground="0x000014E5" Background="0x00FFFFFF" BoldFont="No"/><Item Name="Ident
class Showable a where
shw :: a -> String
data A = A String
data B = B Int
instance Showable A where
shw (A s) = s
instance Showable B where
* A brief history of time
* Black Swan
* Godel Escher Bach
* How not to be wrong
* Men of mathematics
@liammclennan
liammclennan / gist:56466b18014aeb2e530a
Last active August 29, 2015 14:06
Typescript game of life
// start of a port of Ristretto/Coffeescript game of life to typescript
// http://withouttheloop.com/articles/2013-08-11-coffeescript-gameoflife-ristretto/
class Cell {
constructor(public x: number, public y:number) {}
}
function isNeighbour(c:Cell, x:number, y:number): boolean {
return Math.abs(x-c.x) < 2
&& Math.abs(y-c.y) < 2
module Library1
open NUnit.Framework
open FsUnit
type IHaveAnAge =
abstract age: int
type Person =
{ name: string; age: int }
interface IHaveAnAge with
@liammclennan
liammclennan / gist:1014fffd40371cb8286f
Created June 1, 2014 09:14
React with design with Routing
euclid.start([{
title: 'Dashboard',
route: '/dashboard/:date'
entry: function (date) {
return [pageComponent, initialProps];
},
exit: function () {},
actions: {
showDetail: function (itemId) {
return updatedProps;
@liammclennan
liammclennan / gist:11100906
Last active August 29, 2015 14:00
F# postgresql document database WIP
type Person =
{ _id: System.Guid; age: int; name: string }
interface IDocument with
member x.tableName() = "People"
member x.id() = x._id
[<Fact>]
let ``insert, read, update, delete a document`` () =
// insert
let id = System.Guid.NewGuid()
@liammclennan
liammclennan / gist:10521441
Last active August 29, 2015 13:59
Reverse Polish notation
let solveRPN expression =
let foldingFunction stack item =
match (stack,item) with
| (x::y::xs,"*") -> x * y :: xs
| (x::y::xs,"+") -> x + y :: xs
| (x::y::xs,"-") -> y - x :: xs
| (s,o) -> int o :: s
let words (i:string) = i.Split(' ') |> List.ofArray
words expression
|> List.fold foldingFunction []
@liammclennan
liammclennan / gist:9925787
Created April 2, 2014 00:24
Problem using F# match
// this works
let makeImage bytes =
match Array.length bytes with
| 784 -> Image bytes |> Some
| _ -> None
// but this does not. The none branch is never used.
void Main()
{
var environment = new Environment(30);
var composed = DoSomeStuff();
var extracted = composed.RunReader(environment);
Console.WriteLine(extracted);
}
public class Environment {
public int Count {get; private set;}