Skip to content

Instantly share code, notes, and snippets.

@atsapura
atsapura / GuaranteedDeliveryActor.fs
Created September 9, 2020 16:40 — forked from object/GuaranteedDeliveryActor.fs
Guaranteed delivery actor in Akka.NET/F#
module GuaranteedDelivery =
open Akka.Actor
open Akka.Persistence
open Akkling
open Akkling.Persistence
type Payload = string
type DeliveryEnvelope = { Payload: Payload; DeliveryId: int64 }
@atsapura
atsapura / Floc.fs
Created September 20, 2020 15:50
Count fsharp lines of code in your project!
open System
open System.IO
type FSharpCodeLine =
| NamespaceDeclaration
| Open
| Comment
| Source
| Brace
[<RequireQualifiedAccess>]
module Array =
let private swap (arr: _[]) i j =
let buf = arr.[i]
arr.[i] <- arr.[j]
arr.[j] <- buf
let permutations arr =
match arr with

Programming for a non programmer

A while ago I was thinking about how to explain what it feels like to do programming to a non-programmer. So, this is what I came up with, and hopefully you’ll find it entertaining.


Essentially, programming is automating things using computer. The greatest power and the greatest weakness of computer is that it does exactly what you told it to, no more, no less. Which means, that on the one hand, it doesn’t get tired, doesn’t lose focus and doesn’t complain. On the other hand, you have to give it very detailed and specific instructions. Because of that even if the task in real life appears to be quite simple and strait forward, programming it can become a bit tricky. Consider an example: let’s say I ask you – a human – to buy groceries for spaghetti carbonara. Now, you probably don’t keep the recipe at the top of your head, so you ask me what products exactly do I need. Then you go to the grocery store and you find out that there’s no spaghetti left, but there’s some l

@atsapura
atsapura / CleanSolution.fs
Created October 1, 2021 09:36
proper clean of .net solution
open System.IO
let deleteBinAndObj (dirInfo: DirectoryInfo) =
let bin = dirInfo.GetDirectories("bin")
for dir in bin do
if dir.Name.ToLower() = "bin" then
dir.Delete(true)
let objDirs = dirInfo.GetDirectories("obj")
for dir in objDirs do
if dir.Name.ToLower() = "obj" then
dir.Delete(true)
@atsapura
atsapura / appEnv.fs
Created September 1, 2023 16:31
App Env example with test env
type IAppEnv =
abstract member Now: Instant
abstract member OrderDiffStorage: IOrderDiffStorage
abstract member DomainOrderStorage: IOrderStorage
abstract member OrderEventSender: IOrderEventSender
abstract member CatalogClient: ICatalogClient
abstract member ErpOrderListener: IErpOrderListener
abstract member Config: Config
type AppEnv(diffStorage: IOrderDiffStorage,