Skip to content

Instantly share code, notes, and snippets.

View IvanRainbolt's full-sized avatar

Ivan Rainbolt IvanRainbolt

View GitHub Profile
@vhogemann
vhogemann / RandomPort.fs
Last active November 15, 2023 12:03
Quick and dirty example of how to get a random open TCP/UDP port using F#
namespace Test
module RandomPort =
open System
open System.Net.NetworkInformation
let isFree port =
let props =
IPGlobalProperties.GetIPGlobalProperties()
let tcpListeners =
props.GetActiveTcpListeners()
@ianrussellsoftwarepark
ianrussellsoftwarepark / ExampleUsage.fs
Last active October 28, 2020 00:11
Functional wrapper for HttpClient
let getResponse body (cookie: string option) (client:HttpClient) =
task {
return!
Http.createPostRequest Url
|> withBody (RequestBody.Xml body)
|> fun req ->
match cookie with
| Some c -> withCookie c req
| _ -> req
|> Http.execute client
@jhewlett
jhewlett / HttpClient.FSharp.fs
Last active May 14, 2023 15:42
Functional wrapper around System.Net.Http.HttpClient. Inspired in part by Http.fs (https://github.com/haf/Http.fs) and FSharp.Data (https://fsharp.github.io/FSharp.Data/library/Http.html)
namespace HttpClient.FSharp
open System
open System.Net.Http
type HttpMethod =
| Post
| Put
| Delete
| Get
@swlaschin
swlaschin / 1-checkers-scratch-design.fsx
Last active March 17, 2022 16:06
Example of Domain Driven Design for the game of checkers. There are two files: a scratch file with a series of designs, and a final version.
(*
Example of domain-driven design for Checkers
Rules from here: https://www.itsyourturn.com/t_helptopic2030.html
A SERIES OF SCRATCH DESIGNS
*)
// As we go through the rules, and learn things, we create a series of designs
module Version1 =
@swlaschin
swlaschin / type-dependency-graph.fsx
Last active March 4, 2021 19:24
This script analyzes the dependencies between top level types in a .NET Assembly. It is then used to compare the dependency relationships in some F# projects with those in some C# projects.
(*
This script analyzes the dependencies between top level types in a .NET Assembly.
It is then used to compare the dependency relationships in some F# projects with those in some C# projects.
Note that no attempt has been made to optimize the code yet!
REQUIRES:
* Mono.Cecil for code analysis
From http://www.mono-project.com/Cecil#Download
@jrusbatch
jrusbatch / AvailablePorts.cs
Created December 5, 2012 02:17
Find an Available Port with C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.NetworkInformation;
using System.Net;
namespace AvailablePort
{
class Program