Skip to content

Instantly share code, notes, and snippets.

View ashalkhakov's full-sized avatar

Artyom Shalkhakov ashalkhakov

View GitHub Profile
@ashalkhakov
ashalkhakov / HybridLogicalClock.cs
Created December 26, 2023 15:17
Hybrid Logical Clock in C#
namespace HLC;
/// <summary>
/// The Hybrid Logical Clock. Contains both Physical Time and Logical Clock inside.
/// Grows monotonically, can be used to obtain unique timestamps even if called more often than
/// allowed by the physical clock precision.
///
/// <see cref="https://cse.buffalo.edu/tech-reports/2014-04.pdf"/>
/// </summary>
/// <remarks>Single-threaded use only!</remarks>
@ashalkhakov
ashalkhakov / memory-management.md
Last active August 28, 2023 08:34
Objective-C basics

if type T is an NSObject descendant, then it will support these messages:

+ (T *)alloc;
- (T *)init:(T *)self;
- (void)release;
- (T *)retain;

Objects (technically, variables of type T * where T is class type) can be either owned or not.

@ashalkhakov
ashalkhakov / main.dats
Last active August 7, 2019 13:50
IO monad in ATS
(*
HX-2019-03-26-2:
The original code is available at
https://gist.github.com/ashalkhakov/c3577e97b20020fde31f84447fd1e056
I turned runCommand into a polymorphic function and
also made Command a linear datatype (i.e., dataviewtype)
AS-2019-03-26:
@ashalkhakov
ashalkhakov / flats.dats
Created January 31, 2019 10:18
Outputting HTML table in ATS
#include
"share/atspre_staload.hats"
#define N 9
#define M 14
implement main0 () = let
fun loop1
{i:nat | i <= N}
(i: int i): void =
@ashalkhakov
ashalkhakov / pitch.md
Last active April 2, 2018 05:35
ATS sales pitch

Time well spent when programming

Audience: C/C++ programmers.

Improving correctness means less maintenance and more fun!

  • everybody want more features
  • but more features usually mean more bugs and failures
  • stuck fixing bugs? not a good use of your time!
  • yet software devs spend most of their time hunting for and fixing bugs
@ashalkhakov
ashalkhakov / .gitlab-ci.yml
Last active August 16, 2022 17:24
Running .NET 3.5 CF builds under Docker for Windows
# this is the GitLab-CI file for building the image
variables:
CURRENT_IMAGE_TAG: rfid-applied/netcf35_build_environment:dev
stages:
- dockerize
dockerize:
stage: dockerize
script:
@ashalkhakov
ashalkhakov / fc-phantom-types.dats
Created December 22, 2017 09:02
First-class phantom types in ATS
(*
** Hello, world!
** run it here: http://www.ats-lang.org/SERVER/MYCODE/Patsoptaas_serve.php?mycode_fil=hello
*)
(* ****** ****** *)
//
#define
LIBATSCC2JS_targetloc
"$PATSHOME\
@ashalkhakov
ashalkhakov / gist:85902ec8992acef7eef3fbf0a1c41ddb
Created October 5, 2017 05:14
Simple linear object in ATSCC2JS
(*
** Hello, world!
*)
(* ****** ****** *)
//
#define
LIBATSCC2JS_targetloc
"$PATSHOME\
/contrib/libatscc2js/ATS2-0.3.2"
(*
** Hello, monadic world!
**
** Author: Artyom Shalkhakov
** artyom DOT shalkhakov AT gmail DOT com
**
** Can be run using:
** http://www.ats-lang.org/SERVER/MYCODE/Patsoptaas_serve.php
*)
@ashalkhakov
ashalkhakov / ats-syntax-hilighting-monaco
Created June 27, 2016 15:54
ATS/Postiats syntax hilighting support for the Monaco editor.
// see: https://microsoft.github.io/monaco-editor/monarch.html
// ATS/Postiats lexical syntax definition
// Written by Artyom Shalkhakov over the week of 20th - 27th of June, 2016.
// License: BSD v3 (but probably GPL, since ATS/Postiats lexer is GPL? not a lawyer!)
// TODO: staload and dynload are followed by a special kind of string literals
// with {$IDENTIFER} variables, and it also may make sense to highlight
// the punctuation (. and / and \) differently.