Skip to content

Instantly share code, notes, and snippets.

@SLAVONchick
SLAVONchick / oh-my-posh-theme.json
Created November 20, 2023 13:54
Theme for oh-my-posh
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"background": "#2b3589",
"foreground": "#ffffff",
// "leading_diamond": "\ue0b6",
open System
open System.Collections.Generic
open System.IO
open System.Runtime.CompilerServices
open System.Threading
open System.Threading.Tasks
open FSharp.Control
module AsyncEnum =
type Hole() =
member _.Add(_, _) = ()
member _.Add _ = ()
type CollectionBuilder< ^Collection, 'b, ^Dictionary, 'c
when ^Collection : (member Add : 'b -> unit) and ^Collection : (new : unit -> ^Collection)
and ^Dictionary : (member Add : 'b * 'c -> unit) and ^Dictionary : (new : unit -> ^Dictionary)>() =
member inline _.Combine((x1, y1), (x2, y2)) =
// Learn more about F# at http://fsharp.org
open System
open TomlParser.Toml
open FParsec
[<EntryPoint>]
let main argv =
let res =
run toml
@SLAVONchick
SLAVONchick / JsonBuilder.fs
Created June 9, 2020 13:31
Write JSONs in F#!
open System.Collections.Generic
open Quotations.Patterns
let inline ( ==> ) a b = KeyValuePair(a, b)
let isCall = function Call _ -> true | _ -> false
let findQuotes q =
let rec findQuotes' q res = seq {
match q with
| Call (_, _, [Lambda (_, Call (_, _, [Call (_, _, [Call (_, _, l)]); next]))] ) ->
open System
open System.Net
open FSharp.Control.Tasks
open Pipelines.Sockets.Unofficial
use client = new TcpClient("127.0.0.1", 9851)
let pipe = StreamConnection.GetDuplex(client.GetStream())
let scan = Encoding.UTF8.GetBytes "*2\r\n$4\r\nSCAN\r\n$36\r\n85AB427D-316C-4BD4-A511-6631851D212E\r\n" |> ReadOnlyMemory
task {
let! _ = pipe.Output.WriteAsync(scan)
open System
open System.Text
open Utf8Json
[<JsonFormatter(typeof<PointFormatter>)>]
type Point =
{ Longitude: float
Latitude: float }
//type Feature =
@SLAVONchick
SLAVONchick / TryParse.fs
Last active March 4, 2020 14:57
tryParse srtp function
open System
let inline tryParse s =
let mutable tmp = Unchecked.defaultof<_>
if ( ^a : (static member TryParse : string * byref< ^a> -> bool ) (s, &tmp) )
then Some tmp
else None
let (|Int|_|) s : int option = tryParse s
let (|Int64|_|) s : int64 option = tryParse s