Skip to content

Instantly share code, notes, and snippets.

View altbodhi's full-sized avatar
🏠
Working from home

altbodhi

🏠
Working from home
View GitHub Profile
@altbodhi
altbodhi / CSharpMailBoxProcessor.cs
Created March 12, 2021 06:43
CSharp MailBoxProcessor inspired F#
using System;
using static System.Console;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
using System.Threading;
using System.Collections.Generic;
namespace CSharpMailBoxProcessor
{
public class Reply
@altbodhi
altbodhi / rollup.config.js
Created February 15, 2021 09:02
svelte rolling config for multi pages (for example for mixin to asp.net core webapp)
const page = "syncSystems";
// "index";
export default {
input: `src/${page}.ts`,
output: {
sourcemap: true,
exports : 'named',
format: 'iife',
@altbodhi
altbodhi / simple-macros.lisp
Created January 11, 2021 06:51
macro for generete same writeln as in pascal
(defmacro writeln (&rest args)
`(progn
(loop for e in '(,@args)
do
(format t "~A" e))
(format t "~%")))
(defstruct person name)
(defgeneric hello (obj)
public sealed class ValidateResult : Result<bool, string>
{
}
public abstract class Result<TValue, TError>
{
public bool IsOk => this is Ok;
public sealed class Ok : Result<TValue, TError>
{
public TValue Value { get; }
@altbodhi
altbodhi / diskStatusChecker.fsx
Created September 3, 2020 02:58
Прототип новой функциональности на F# глазами C#-программиста
open System
open System.Threading
let rnd = Random(Environment.TickCount)
let disks = [ 1; 2; 3; 4 ]
type Status =
| Fail of int
| Normal of int
// This sample will guide you through elements of the F# language.
//
// *******************************************************************************************************
// To execute the code in F# Interactive, highlight a section of code and press Alt-Enter in Windows or
// Ctrl-Enter Mac, or right-click and select "Send Selection to F# Interactive".
// You can open the F# Interactive Window from the "View" menu.
// *******************************************************************************************************
//
// For more about F#, see:
// http://fsharp.org
module TickTocks exposing(..)
import Browser
import Html exposing (..)
import Html.Attributes exposing (style)
import Task
import Time
main =
Browser.element
{ init = init
, view = view
let now () = System.DateTime.Now.ToString("s")
type CacheCommand<'id, 'result> =
| Get of 'id * AsyncReplyChannel<Result<'result, string>>
| Clear
type Cache(getter) =
let mailbox =
MailboxProcessor.Start(fun inbox ->
@altbodhi
altbodhi / nemerle-sample.pas
Created July 1, 2020 13:15
Nemerle Sample
using System.Console;
using System.Threading;
using System.Threading.Tasks;
using Nemerle;
using Nemerle.Async;
enum Tone {
| REST = 0
| GbelowC = 196
| A = 220
@altbodhi
altbodhi / nemerle-web.pas
Created July 1, 2020 13:12
nemerle http server
using System;
using System.Console;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Nemerle;
using Nemerle.Async;