Skip to content

Instantly share code, notes, and snippets.

View object's full-sized avatar

Vagif Abilov object

View GitHub Profile
@object
object / AdventOfCode2022.12.07.fsx
Created December 7, 2022 08:21
Advent of Code 2022, December 7
#time "on"
open System
open System.IO
open System.Collections.Generic
let input =
File.ReadAllLines(__SOURCE_DIRECTORY__ + "/../data/input07.txt")
|> Seq.toList
@object
object / AdventOfCode2022.12.06.fsx
Last active December 6, 2022 05:56
AdventOfCode2022 December 6
open System
open System.IO
let input =
File.ReadAllLines(__SOURCE_DIRECTORY__ + "input06.txt")
|> Seq.head
|> Seq.toArray
// First solution uses "windowed" function. It is not memory efficient because it allocates large number of arrays
// (the number of allocated arrays is approximately the count of characters in input string)
@object
object / Logger.cs
Last active October 16, 2022 08:42
Reproducing failure to log large messages using Serilog.Sinks.Grafana.Loki
using Serilog;
using Serilog.Sinks.Grafana.Loki;
namespace LokiMemoryTest
{
internal class Logger
{
public static ILogger Create()
{
return new LoggerConfiguration()
@object
object / gist:3c7d4d27481207394faceecaea780403
Created October 11, 2021 10:53
Gitversion could not determine which branch to treat as the development branch
[12:26:44][Step 2/21] Starting: C:\Windows\system32\cmd.exe /c dotnet gitversion /output buildserver /b refs/heads/use-gitversion
[12:26:44][Step 2/21] in directory: C:\BuildAgent\work\3f54bead41b5db4e
[12:26:44][Step 2/21] INFO [10/11/21 12:26:44:57] Working directory: C:\BuildAgent\work\3f54bead41b5db4e
[12:26:44][Step 2/21] INFO [10/11/21 12:26:44:59] Branch from build environment: 9c96c02dabd37958ecc9c267f6ed27d75decf286
[12:26:44][Step 2/21] INFO [10/11/21 12:26:44:59] Project root is: C:\BuildAgent\work\3f54bead41b5db4e\
[12:26:44][Step 2/21] INFO [10/11/21 12:26:44:59] DotGit directory is: C:\BuildAgent\work\3f54bead41b5db4e\.git
[12:26:44][Step 2/21] INFO [10/11/21 12:26:44:60] Begin: Normalizing git directory for branch '9c96c02dabd37958ecc9c267f6ed27d75decf286'
[12:26:44][Step 2/21] INFO [10/11/21 12:26:44:63] One remote found (origin -> 'https://github.com/nrkno/distribution-oddjob').
[12:26:44][Step 2/21] INFO [10/11/21 12:26:44:63] Skipping fetching, if GitVersion does not calculate your vers
@object
object / ProtobufSerializationTest.fs
Created May 24, 2021 19:13
Protobuf serialization in F#
module ProtobufSerializationTests
open System
open System.IO
open ProtoBuf
open Xunit
module ProtoBufUtils =
[<ProtoContract>]
@object
object / GuaranteedDeliveryActor.fs
Created May 10, 2021 16:11
Code used by Guaranteed delivery actor
let rec loop lastSavedSnapshotSequenceNr =
actor {
let! msg = mailbox.Receive()
let effect = deliverer.Receive (upcast mailbox) msg
if effect.WasHandled()
then
return effect
else
return
match msg with
@object
object / PhobosAppInsights.fs
Created May 4, 2021 05:52
Phobos AppInsights configuration
module PhobosBootstrapper =
module AppInsights =
let createMetrics (mb : IMetricsBuilder) =
let metrics = mb.Configuration.Configure (fun opts ->
opts.GlobalTags.Add("host", Dns.GetHostName())
opts.DefaultContextLabel <- "akka.net"
opts.Enabled <- true
opts.ReportingEnabled <- true)
let metrics =
@object
object / AdventOfCode2020.12.23.fsx
Created December 23, 2020 06:45
AdventOfCode 2020, December 23
module TwentyThree =
open System
let testInput = "389125467"
let input = "942387615"
let cups = (Seq.map ((fun x -> x.ToString()) >> Int32.Parse) input) |> Seq.toList
let rec findDestination (cups : int list) pickup destination =
if not (pickup |> List.contains destination) then
@object
object / AdventOfCode2020.12.21.fsx
Created December 21, 2020 09:36
AdventOfCode 2020, December 21
module TwentyOne =
open System
open System.IO
let parseFood (line : string) =
let splitter = " (contains "
let splitIndex = line.IndexOf splitter
let ingredients =
line.Substring(0, splitIndex).Split(' ') |> Set
@object
object / AdventOfCode2020.12.19.fsx
Created December 19, 2020 08:18
AdventOfCode 2020, December 19
module Nineteen =
open System
open System.IO
open System.Text.RegularExpressions
type RuleContent =
| Char of string
| Rules of int array array