Skip to content

Instantly share code, notes, and snippets.

View Szer's full-sized avatar

Ayrat Hudaygulov Szer

  • Thrive Global
  • Dublin, Ireland
  • X @omgszer
View GitHub Profile
let genericMapReduce toOutput folder src =
src
|> Seq.map toOutput
|> Seq.reduce folder
let inline mapReduceAdd toOutput src =
src |> genericMapReduce toOutput (+)
type Person =
{ Name : string
@Szer
Szer / list.fsx
Created August 18, 2017 07:34
example of immutable list in F#
let a = new obj();
let b = new obj();
let c = new obj();
a.Equals(b) // <- false
b.Equals(c) // <- false
c.Equals(a) // <- false
let aList = [a] // <- [System.Object]
let bList = [b] // <- [System.Object]
@Szer
Szer / Test.fs
Last active August 21, 2017 10:09
module Test
open System
open System.Threading.Tasks
open System.Diagnostics
open BenchmarkDotNet
open BenchmarkDotNet.Running
open BenchmarkDotNet.Attributes
let f input =
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Threading.Tasks.Schedulers;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
namespace Test
{
public class Worker
@Szer
Szer / wordCount.cs
Last active January 31, 2018 20:09
Word count
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
namespace ConsoleApp9
{
@Szer
Szer / Pool.fs
Last active February 27, 2018 10:33
WorkerPoolHopac
#I @"C:\Users\___\.nuget\packages\hopac\0.3.23\lib\netstandard1.6"
#r "Hopac.dll"
#r "Hopac.Core.dll"
#r "Hopac.Platform.dll"
open System
open Hopac
open Hopac.Infixes
open Hopac.Stream
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" />
</ItemGroup>
@Szer
Szer / stream_ex.fsx
Created April 2, 2018 22:38
Example of Hopac streams
#r @"./packages/Hopac/lib/net45/Hopac.Core.dll"
#r @"./packages/Hopac/lib/net45/Hopac.dll"
open Hopac
open Hopac.Stream
open System
let requestDetailAsync url=
async {
Console.WriteLine ("Simulating request " + url)
@Szer
Szer / async_work.fsx
Last active April 3, 2018 12:52
async work
open System.Threading
open System
let random = Random(int DateTime.UtcNow.Ticks)
let asyncMockup s = async {
let sleepFor = int (random.NextDouble() * 3000.)
do! Async.Sleep sleepFor
return sprintf "resulted %s" s
}
open System
let random = Random(int DateTime.UtcNow.Ticks)
let asyncMockup s = async {
let sleepFor = int (random.NextDouble() * 3000.)
//let sleepFor = 2000
do! Async.Sleep sleepFor
printfn "resulted %s" s
return sprintf "resulted %s" s