Skip to content

Instantly share code, notes, and snippets.

View forki's full-sized avatar

Steffen Forkmann forki

View GitHub Profile
let name = Something.Data.Methods
|> Seq.filter (fun x-> x.C > 0UL)
|> Seq.sortBy (fun x-> 999999999999UL - x.C)
|> Seq.take 50
|> Seq.iter dump_minfo
@shishkin
shishkin / semver.fs
Created August 30, 2014 09:18
Making incorrect version specifications impossible with F# typesystem
type VersionNumber =
| Major of major: int
| Minor of major: int * minor: int
| Patch of major: int * minor: int * patch: int
type Version =
| Release of VersionNumber
| PreRelease of VersionNumber * string
static member create (x) = Release (Major x)
@shishkin
shishkin / FunctionalErrorHandling.cs
Created December 16, 2013 09:31
Functional error handling
using System;
using System.Collections.Generic;
using System.Linq;
using FSharpx;
using Microsoft.FSharp.Core;
using NUnit.Framework;
namespace FunctionalErrorHandling
{
public static class Extensions
@forki
forki / gist:7813579
Last active December 30, 2015 10:09
Trying the Gettysburg example from RInRuby - see https://sites.google.com/a/ddahl.org/rinruby-users/example-gettysburg-address
#I "../packages/FSharp.Charting.0.90.5"
#I "../packages/Deedle.0.9.12"
#I "../packages/RProvider.1.0.5/"
#load "FSharp.Charting.fsx"
#load "Deedle.fsx"
#load "RProvider.fsx"
open System
open System.IO
open Deedle
type FileSetBuilder() =
member x.Delay f = f
member x.Run f = f() |> Scan
member x.Yield (()) = { Include "" with Includes = [] }
[<CustomOperation ("take", MaintainsVariableSpace = true)>]
member x.Take (fs, pattern: string) = fs ++ pattern
[<CustomOperation ("notTake", MaintainsVariableSpace = true)>]
member x.NotTake (fs: FileIncludes, pattern: string) = fs -- pattern
@haacked
haacked / code-review-checklist.md
Last active March 9, 2020 19:28
Code Review Checklist

General

  1. Unit tests: Review unit tests first. Unit tests are a fantastic way to grasp how code is meant to be used by others and to learn what the expected behavior is. Are there any test gaps that should be there?
  2. Method arguments" Make sure arguments to methods make sense and are validated. Mentally test boundary conditions and edge cases.
  3. Null References" (Yah yah, we know. Use F# and this goes away. We get it already.) Null references are a bitch and it’s worth looking out for them specifically.
  4. Conventions Consistency" Make sure naming, formatting, etc. follow our conventions and are consistent. I like a codebase that’s fairly consistent so you know what to expect.
  5. Disposables: Make sure disposable things are disposed. Look for usages of resources that should be disposed but are not.
  6. Security: There is a whole threat and mitigation review process that falls under this bucket. In simple terms, ask yourself how this code could be exploited. The [STRIDE Threat Mo