Skip to content

Instantly share code, notes, and snippets.

@ToJans
ToJans / example.ex
Last active Aug 29, 2015
Statistics usable for data series
View example.ex
Stream.repeatedly(&:random.uniform/0)
|> Enum.take(10000)
|> Stats.all
|> IO.inspect
@ToJans
ToJans / csharp.cs
Last active Aug 29, 2015
Trying to convert a simple C# app to eloquent F#; failing so far; to verbose IMO
View csharp.cs
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
namespace TDDCoverage
{
public class Order
{
@ToJans
ToJans / FullCoverage.cs
Last active Aug 29, 2015
100 Percent test coverage means nothing
View FullCoverage.cs
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace TDDCoverage
{
public enum Gender { Unknown, Male, Female }
public class Customer
{
public Gender Gender = Gender.Unknown;
@ToJans
ToJans / threes.exs
Last active Aug 29, 2015
An implementation in Elixir for Threes (http://asherv.com/threes/). Started out of curiosity after seeing a tweet by GraemeF(https://twitter.com/GraemeF/status/442580143140134912)
View threes.exs
defmodule Threes do
def right(board) do
board
|> Enum.map(&pack/1)
end
def left(board) do
board
|> Enum.map(&reverse_pack/1)
@ToJans
ToJans / error.txt
Last active Aug 29, 2015
Odd error: pilar is a Mesh, and I want to change some fields, so I use the with-syntax. On the last line I get this error:
View error.txt
Error 1 This expression was expected to have type
unit
but here has type
Mesh C:\dev\.Net\arealities\Arealities.Models\Veranda.fs 17 11 Arealities.Models
@ToJans
ToJans / Models.fs
Last active Aug 29, 2015
Try describing this in C#
View Models.fs
namespace Arealities.Models
type Size = Size of decimal * decimal * decimal
type Position = Position of decimal * decimal * decimal
type Rotation = Rotation of decimal * decimal * decimal
type Direction = Direction of decimal * decimal * decimal
type LightIntensity = float
type Material = Ground | Floor | ShinyStuff | Wall
type Geometry = CubeGeometry of Size
@ToJans
ToJans / types.fs
Last active Aug 29, 2015
I am probably overdoing it regarding types ATM
View types.fs
namespace Arealities.Models
type [<Measure>] mm; // milimeter
type [<Measure>] degrees; // degrees
type [<Measure>] intensity; // unit = 1
type Vector3D<'a> = {x: 'a; y: 'a; z: 'a}
type Placement = Placement of position: decimal<mm> Vector3D *
rotation: decimal<degrees> Vector3D
@ToJans
ToJans / povify.fs
Created Mar 30, 2014
What is the best way to do this in F#?
View povify.fs
let povify model =
match model with
| (v:Vector3D<decimal>) -> sprintf "<%M,%M,%M>" (v.x/1M) (v.y/1M) (v.z/1M)
| CubeGeometry c ->
let half = c.size/2M
sprintf "box {%s %s} " (povify half) (povify vec3D0-half)
@ToJans
ToJans / ranges.fs
Created Apr 1, 2014
This should do it for ranges
View ranges.fs
type Range(min: decimal,max: decimal) =
member this.min = min
member this.max = max
static member (*) (r: Range, d: decimal) = Range(r.min * d,r.max * d)
static member (*) (d: decimal, r: Range) = r*d
static member (/) (r: Range, d: decimal) = Range(r.min / d,r.max / d)
static member (/) (d: decimal, r: Range) = r/d
static member (+) (r: Range, d: decimal) = Range(r.min + d,r.max + d)
static member (+) (d: decimal, r: Range) = r+d
static member (-) (r: Range, d: decimal) = Range(r.min - d,r.max - d)
View Tojans.md

Link to picture

Tom Janssens solves business problems by building software and helps organisations to get better at building software. He is also one of the founders of Domain Driven Design Belgium.

He explores and cross-contaminates ideas from different languages and platforms; over the years he has been using languages like C#, F#, JavaScript, Erlang, Elixir and Haskell, and he is currently studying Idris. Other aspects include start-ups, BDD, DDD, CQRS and tackling legacy software.

When Tom is not working for his start-up, he is consulting clients and occasionally dumping random opinionated blurbs on his blog.