Skip to content

Instantly share code, notes, and snippets.

View fjod's full-sized avatar
🎯
Focusing

Michael fjod

🎯
Focusing
  • Lithuania
View GitHub Profile
@fjod
fjod / imageConverter.cs
Last active July 6, 2022 10:19
image from memoryStream to base64 with little allocations
using System.Buffers;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using ConverterTest;
namespace MyBenchmarks
{
public class Program
{
public static void Main(string[] args)
@fjod
fjod / Parser.cs
Created April 24, 2022 05:45 — forked from Petrusion/Parser.cs
Quickly thrown together Interpolated String Handler based Parser
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace ParserTest;
public static class Parser
{
[InterpolatedStringHandler]
[StructLayout(LayoutKind.Auto)]
@fjod
fjod / fizbuzz.fs
Created April 19, 2022 14:21
The Power of Composition - Scott Wlaschin - NDC Oslo 2020
open Microsoft.FSharp.Core
type FizzBuzzResult =
| Unhadnled of int
| Handled of string
let isDivisiblyBy n divisor =
n % divisor = 0
let handle divisor label n =
@fjod
fjod / funcs.fs
Last active October 11, 2021 05:12
module Server.BikeScreen
open System
open FSharp.Control.Tasks
open Shared
open BikeAPI
open Security
open Database
source https://nuget.org/api/v2
storage:none
nuget FSharp.Core redirects: force
nuget Saturn
nuget System.Net.NetworkInformation
nuget Thoth.Json.Net
nuget Thoth.Json.Giraffe
nuget Fable.Core
nuget Fable.Browser.Dom
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
namespace chapsasParallel
@fjod
fjod / rec.fs
Last active May 28, 2021 05:26
F# reverse tree using tail-call recursion (code can be shortened)
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Running
type Tree<'a when 'a : comparison> =
| Node of 'a * Tree<'a> * Tree<'a>
| Empty
let rec insert newValue (tree : Tree<'a>) =
@fjod
fjod / gist:efaa0c2c52f098deebb93e383737ff39
Last active March 24, 2021 10:14
attempt to generate protobuf-native schema using protobuf-net instead of google-protobuf generated class (protoc)
using System;
using System.IO;
using System.Runtime.Serialization;
using Google.Protobuf.Reflection;
using ProtoBuf;
using ProtoBuf.Reflection;
namespace nativeCheck
{
[DataContract]
@fjod
fjod / gist:bd1e18320a4123c17fdc467a7d7df0d3
Created November 9, 2020 12:29
F# CE from Skeet&Petrichek book
open System
type TheValue<'a> =
| Value of 'a
| None
let ReadInt() =
match Console.ReadLine() |> Int32.TryParse with
| true , v -> Value v
@fjod
fjod / mysql-docker.sh
Created August 19, 2020 06:08 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE