This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FsTests.PartialApplication | |
let tupleAdd(a, b) = | |
//printf "test" | |
a + b | |
let curriedAdd a b = | |
a + b | |
let addOne = curriedAdd 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FsTests.PartialApplication | |
let tupleAdd(a, b) = | |
a + b | |
let curriedAdd a b = | |
a + b | |
let addOne = curriedAdd 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var partitionNumber = CalculatePartition(key, data); | |
Producer.ProduceAsync(topicName, key, data, partitionNumber) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var config = new ProducerConfig | |
{ | |
Partitioner = Partitioner.Consistent | |
}; | |
public enum Partitioner | |
{ | |
Random, //random distribution | |
//CRC32 hash of key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Event | |
{ | |
public string Id { get; set; } | |
public string Type { get; set; } | |
public string EventName { get; set; } | |
public long TotalBets { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let consumeWithKafkaBackPressure(consumer: Consumer<byte[],byte[]>, lowPriorityPartitions, token: CancellationToken) = | |
let execOptions = ExecutionDataflowBlockOptions(MaxDegreeOfParallelism = 2, | |
BoundedCapacity = 100) | |
let flow = TransformBlock<_,_>(deserialize, execOptions) | |
let buffer = BufferBlock<string*Event>() | |
flow.LinkTo(buffer) |> ignore | |
while token.IsCancellationRequested do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let consumeWithBackPressure(consumer: Consumer<byte[],byte[]>, token: CancellationToken) = | |
let execOptions = ExecutionDataflowBlockOptions(MaxDegreeOfParallelism = 2, | |
BoundedCapacity = 100) | |
let flow = TransformBlock<_,_>(deserialize, execOptions) | |
let buffer = BufferBlock<string*Event>() | |
flow.LinkTo(buffer) |> ignore | |
while token.IsCancellationRequested do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://fsprojects.github.io/FSharp.Collections.ParallelSeq/ | |
#r "FSharp.Collections.ParallelSeq.dll" | |
open FSharp.Collections.ParallelSeq | |
open System.IO | |
let linesOfCode path = | |
DirectoryInfo(System.IO.Path.GetDirectoryName path) | |
.GetFiles(Path.GetFileName path, SearchOption.AllDirectories) | |
|> PSeq.map (fun f -> File.ReadAllLines(f.FullName).Length) | |
|> PSeq.reduce (+) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Probably not the best ever solution but a) easy to understand b) do not create/mutate array(s) | |
type Direction = | |
| LeftRight | |
| TopBottom | |
| RightLeft | |
| BottomTop | |
let snakePrint (array: int[,]) = | |
let len = array |> Array2D.length1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
status : Status -> Html a | |
status st = | |
let ( color, txt ) = | |
case st of | |
Right s -> ( "green", "Right. " ++ s ) | |
Wrong s -> ( "red", "Wrong! " ++ s ) | |
None -> ( "", "" ) | |
in | |
div [ style [ ( "color", color ) ] ] [ text txt ] |
NewerOlder