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
| #r "nuget: FSharp.Data" | |
| open FSharp.Data | |
| open System | |
| type AccountTransaction = | |
| { Date: DateTime | |
| Category: string | |
| Amount: decimal | |
| Description: string } |
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
| // продолжения на F# | |
| type Cont<'a, 'r> = ('a -> 'r) -> 'r | |
| module Cont = | |
| // Создание continuation из значения | |
| let ret (x: 'a) : Cont<'a, 'r> = | |
| fun k -> k x | |
| // Связывание continuation | |
| let bind (m: Cont<'a, 'r>) (f: 'a -> Cont<'b, 'r>) : Cont<'b, 'r> = |
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
| namespace Company.AdPlaceSearchEngine; | |
| public record Location(string Name); | |
| public record AdPlace(string Name); | |
| public abstract record SearchResult(Location Location) | |
| { | |
| public record NotFound(Location Location) : SearchResult(Location); | |
| public record Success(Location Location, List<AdPlace> AdPlaces) : SearchResult(Location); | |
| } |
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 Text = | |
| /// поиск индекс первого вхождения образца в строке | |
| let findFirst (s: string) (p: string) = | |
| // предикат проверяющий совпадение части строки с образцом | |
| let eqSample i (s: string) (p: string) = | |
| let rec loop j = | |
| if j < p.Length && p.[j] = s.[i + j] then | |
| loop (j + 1) | |
| else |
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 TelegramWebApp = | |
| open System.Security.Cryptography | |
| open System.Text | |
| open System.Web | |
| let validateInitData botToken (initData: string) = | |
| let items = | |
| initData.Split "&" |> Array.map (fun x -> let p = x.Split("=") in (p[0], p[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
| // controller | |
| [HttpGet("tgCheckWebAppAuth")] | |
| public async Task<IActionResult> CheckWebAppAuth([FromQuery] Dictionary<string, string> userData) | |
| { | |
| var user = telegramLoginUrl.CheckWebAppTelegramAuthorization(userData); | |
| if (await Invalid(user)) return Unauthorized(); | |
| await SignIn(user, [new Claim("Source", "TelegramWebApp")]); |
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
| @page "/" | |
| @rendermode InteractiveServer | |
| <input value="@query" @oninput="OnInput" /> | |
| @if (isGetItems) | |
| { | |
| <div style="font-style: italic;">поиск...</div> | |
| } | |
| else |
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
| open System | |
| type Message<'a> = | |
| | Get of AsyncReplyChannel<'a> | |
| | Update of AsyncReplyChannel<'a> * ('a -> 'a) | |
| type Atom<'a>(o: 'a) = | |
| let agent = | |
| MailboxProcessor.Start(fun b -> | |
| let rec loop (acc) = |
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
| <MudButton ButtonType="ButtonType.Button" OnClick="BeepIfIncomingMessage">OK</MudButton> | |
| @code { | |
| async Task BeepIfIncomingMessage() | |
| { | |
| if (jsSoundUtils == null) | |
| jsSoundUtils = await JS.InvokeAsync<IJSObjectReference>("import", "./js/SoundUtils.js"); | |
| var res = await jsSoundUtils.InvokeAsync<object>("soundBeep"); | |
| } |
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 ZenUtil | |
| #r "nuget: NAudio" | |
| #r "nuget: System.Speech" | |
| open NAudio.Wave | |
| open System | |
| module WindowsSpeech = |
NewerOlder