Post

1 July 2024

Introducing TypeSpec: A New Language for API-Centric Development

A new API definition language.
TypeSpec is a language for describing cloud service APIs and generating other API description languages, client and service code, documentation, and other assets.

Microsoft overhaul treats security as ‘top priority’ after a series of failures

Do security.

Why Your Wi-Fi Router Doubles as an Apple AirTag

Interesting article about how Apple and Google each maintain a database of the geo-location of Wi-Fi access points. I don’t think that was ever a secret, but this article is specifically about how Apple’s API is public and verbose, enabling anyone to track the location of any Wi-Fi access point. The report gives an example of tracking StarLink devices and military personnel in Ukraine.

Choosing the Best Immutable Dictionary for Your C# Projects

Performance comparison of ReadOnlyDictionary, ImmutableDictionary, and FrozenDictionary, and a bit about the differences between non-modifiability and immutability.

Why you should batch message processing and how to do it with .NET AsyncEnumerable

Cool idea to combine AsyncEnumerable and System.Threading.Channels to do:

Either try to gather batch of size X or wait Y milliseconds to process it. Whetever happens first.

1
2
3
4
5
6
7
8
9
10
11
public static IAsyncEnumerable<List<T>> Batch<T>(
        this IAsyncEnumerable<T> enumerable,
        int batchSize,
        TimeSpan deadline,
        CancellationToken ct
    ) =>
        enumerable
            .ToChannel(cancellationToken: ct)
            .Batch(batchSize)
            .WithTimeout(deadline)
            .AsAsyncEnumerable(cancellationToken: ct);
1
2
3
4
5
6
7
8
var subscription = eventStoreClient
    .SubscribeToAll(FromAll.Start, cancellationToken: ct)
    .Batch(100, TimeSpan.FromMilliseconds(150), ct);

await foreach (var events in subscription)
{
    await HandleBatch(events, ct);
}

Add Non-Production Endpoints in ASP.NET Application

Interesting idea: add endpoints to your APIs that can be used for doing things that you need for testing, but only enabling them in a dev environment by using an attribute. The article describes using IHostEnvironment.IsProduction(), but you could do it differently.

the Gilbert–Johnson–Keerthi algorithm explained as simply as possible

“as simply as possible”, not “simply”!

The GJK algorithm is a weird way to do a simple thing:
We have shape A and shape B, and we’d like to determine if they overlap.

This post is licensed under CC BY 4.0 by the author.