Skip to content

Instantly share code, notes, and snippets.

@adamchester
adamchester / NoSpecPerf.fs
Created December 28, 2015 06:50
AutoFixture NoSpecimen Perf (Singleton vs. new Instance)
#r "./bin/NoSpecimenNewInst/lib/net40/Ploeh.AutoFixture.dll"
printfn "%A" typeof<Ploeh.AutoFixture.Fixture>.AssemblyQualifiedName
let createWithNoSpecNewInst<'T> =
let fixture = Ploeh.AutoFixture.Fixture()
fun () -> fixture.Create(typeof<'T>, Ploeh.AutoFixture.Kernel.SpecimenContext(fixture)) :?> 'T
#r "./bin/NoSpecimenSingleton/lib/net40/Ploeh.AutoFixture.dll"
printfn "%A" typeof<Ploeh.AutoFixture.Fixture>.AssemblyQualifiedName
let noSpecimenSingleton = typeof<Ploeh.AutoFixture.Kernel.NoSpecimen>
@adamchester
adamchester / blog_computer.setup.md
Last active October 8, 2015 23:28
My 2011/2012 computer setup

I do all my work on a laptop.

Hardware

  • Apple MacBook Pro 15" Early 2011, 8GB RAM, Core i7 2.3GHz (MacBookPro8,2)
  • Storage: 750GB hdd, plus 240GB OCZ Vertex 3 MI (note: removed optical media drive)
  • Apple magic mouse <- I hate this thing
  • External monitors/keyboards available depending on client site(s)
@adamchester
adamchester / blog_class_apply.coffeescript.md
Created July 25, 2012 03:27
How do you create a CoffeeScript class instance using 'apply'?

How do you create a CoffeeScript class instance using 'apply'?

The answer is, like this:

util = require('util')
assert = require('assert')

class MyClass
	constructor: (@splatArgs...) -&gt; @first = splatArgs[0]; @second = splatArgs[1]
@adamchester
adamchester / blog_test_assertion.testing.node.md
Created July 18, 2012 04:47
A simple test assertion DSL

Why?

I am not good at writing bug-free code in JavaScript or CoffeeScript. I am equally not good at writing bug-free tests. It would be nice to have a way to quickly build a basic 'safety net' for my code, and be able to describe the tests in a format less verbose than 'describe->it-should->etc'.

It should also be a good learning experience.

Goals

@adamchester
adamchester / blog_purpose.blog.md
Created June 17, 2012 13:26
This blog is purely a learning experience
@adamchester
adamchester / blog_welcome.blog.md
Created June 3, 2012 02:37
Welcome to my blog, it may be updated rarely
@adamchester
adamchester / keybase.md
Created May 27, 2015 04:41
keybase proof

Keybase proof

I hereby claim:

  • I am adamchester on github.
  • I am adamchester (https://keybase.io/adamchester) on keybase.
  • I have a public key whose fingerprint is 6573 51C0 41D2 58D2 9BE8 83F1 835B 3087 94D3 EC6F

To claim this, I am signing this object:

open System
type WeekOf<'T> = { Mo:'T; Tu:'T; We:'T; Th:'T; Fr:'T; Sa:'T; Su:'T }
with
static member FromDays (allDays: (DayOfWeek * 'T)[]) =
let dayFor theDay = snd (allDays |> Array.find (fun (day, data) -> day = theDay))
{ Mo = dayFor DayOfWeek.Monday
Tu = dayFor DayOfWeek.Tuesday
We = dayFor DayOfWeek.Wednesday
Th = dayFor DayOfWeek.Thursday
@adamchester
adamchester / twitter_clients_2014.fsx
Created January 3, 2015 03:31
F# Community Twitter Clients (2014)
#I @"packages/"
#r @"FSharp.Data/lib/net40/FSharp.Data.dll"
#load @"FSPlot\FsPlotBootstrap.fsx"
#r @"Deedle\lib\net40\Deedle.dll"
do fsi.AddPrinter(fun (printer:Deedle.Internal.IFsiFormattable) -> "\n" + (printer.Format()))
open FSharp.Data
type Tweets = CsvProvider<"fsharp_2013-2014.csv">
@adamchester
adamchester / gist:cdabfc76d76c3a641698
Last active August 29, 2015 14:02
Except (faster; set-based)
let except ex all = all |> Seq.filter (not << Set.ofSeq(ex).Contains)
let filtered = [| 1..1000000 |] |> except [| 20..29 |]