Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View t0yv0's full-sized avatar

Anton Tayanovskyy t0yv0

View GitHub Profile
@t0yv0
t0yv0 / AsyncSockets.fs
Last active September 7, 2023 11:45
Asynchronous socket programming with F# async.
open System.Net.Sockets
type A = System.Net.Sockets.SocketAsyncEventArgs
type B = System.ArraySegment<byte>
exception SocketIssue of SocketError with
override this.ToString() =
string this.Data0
/// Wraps the Socket.xxxAsync logic into F# async logic.
@t0yv0
t0yv0 / Binary.fs
Created July 14, 2011 15:00
Binary encoder/decoder for F# types.
module Serialization.Binary
exception EncodingError
exception NoEncoding of System.Type with
override this.ToString() =
sprintf "Failed to derive a binary encoding for type: %O" this.Data0
type E = (string -> int) -> System.IO.BinaryWriter -> obj -> unit
type D = (int -> string) -> System.IO.BinaryReader -> obj
/*
Add an option to ProgramTest framework to allow testing a Pulumi program against mock providers that
replay conversations from a previous run. Think of this as a useful way to test that P->P' program updates behave
identically in a quick-and-easy way.
- Unlike vanilla ProgramTest, on a warm cache the test does not touch the cloud.
- Unlike testing with mocks, there is no need to write mocks. Just record a successful run of the program.
@t0yv0
t0yv0 / .gitignore
Last active October 27, 2022 15:41
Pulumi Command CopyFile replacements
*.pyc
venv/
rsa
rsa.pub
@t0yv0
t0yv0 / .gitignore
Last active October 27, 2022 14:38
precompiled
@t0yv0
t0yv0 / pulum_10890.log
Created September 30, 2022 20:43
pulumi_10890.log
I0930 16:39:26.624970 6791 backend.go:461] found username for access token
I0930 16:39:27.051280 6791 util.go:557] errors detecting git metadata: 1 error occurred:
* detecting Git remote URL: could not read origin information: remote not found
I0930 16:39:27.052175 6791 backend.go:461] found username for access token
I0930 16:39:27.163292 6791 ignore.go:44] Explicitly ignoring and discarding error: could not read origin information: remote not found
I0930 16:39:27.274070 6791 backend.go:461] found username for access token
I0930 16:39:27.273620 6791 backend.go:1018] Stack dev being updated to version 103
I0930 16:39:27.491770 6791 update.go:190] *** Starting Update(preview=true) ***
I0930 16:39:27.491985 6791 plugins.go:120] gatherPluginsFromProgram(): gathering plugins from language host
@t0yv0
t0yv0 / MyStack.cs
Created November 24, 2021 23:21
Reproduce NPE in Pulumi .NET SDK
/*
To reliably hit the race NullPointerException with Pulumi, modify Pulumi.Core Resource.cs constructor to introduce a delay:
+ System.Threading.Thread.Sleep(100);
+ System.Console.WriteLine($"Delaying resource: {name}");
Deployment.InternalInstance.ReadOrRegisterResource(this, remote, urn => new DependencyResource(urn), args, options);
*/
@t0yv0
t0yv0 / Opt.v
Created March 23, 2013 15:35
A simple example of how to use Coq as a programming language - how to compute more efficient programs out of declarative programs, and then extract the efficient programs to ML. This facility is very obvious to serious users of Coq, but it took me a while as a beginner to realize this is practical and how can it be done. Compilers like Haskell d…
Require Import String.
Definition Parser (a : Type) :=
string -> option (a * string).
Definition Return {a} (x: a) : Parser a :=
fun s => Some (x, s).
Definition Bind {a b} (x: Parser a) (f: a -> Parser b) : Parser b :=
fun s =>
@t0yv0
t0yv0 / main.go
Created March 18, 2021 15:42
Cost of embedding Go structs with methods
TBD
@t0yv0
t0yv0 / subtyping.v
Last active February 28, 2021 01:47
Demonstrating TypeScript 0.8 type system to be unsound. The subtyping relationship is defined in a way that admits the following code that results in TypeError exception being thrown.
Require Import Utf8.
Inductive subtype (a b : Set) : Set :=
| ST : (a -> b) -> subtype a b.
Infix ":>" := subtype (at level 50).
Definition st {x y} f := ST x y f.
Definition unpack {a b : Set} (st : a :> b) :=