Skip to content

Instantly share code, notes, and snippets.

View elexisvenator's full-sized avatar

Ben Edwards elexisvenator

  • PageUp People
  • Melbourne, Australia
View GitHub Profile
@elexisvenator
elexisvenator / QuerySessionInProjections.cs
Created March 25, 2022 03:09
Testing IQuerySession in async projections
public class QuerySessionInProjections : OneOffConfigurationsContext
{
private readonly ITestOutputHelper _output;
public QuerySessionInProjections(ITestOutputHelper output)
{
_output = output;
}
[Fact]
@elexisvenator
elexisvenator / 1_readme.md
Last active March 24, 2022 22:28
Testing IQuerySession usage in projections

What is being tested?

This test is to determine how the querysession behaves when used as part of a create/apply method on a projection.

    public record Document([property: Identity] Guid DocumentId, string AuthorName, Guid AuthorId)
    {
        public static async Task<Document> Create(DocumentCreated @event, IQuerySession session)
        {
            var author = await session.Events.AggregateStreamAsync<User>(@event.AuthorId);
@elexisvenator
elexisvenator / I2CRemapper.cs
Created May 31, 2020 23:30
Helper class that wraps an `II2cBus` and allows for bus addresses to be remapped. Useful as a workaround for I2c drivers that expect a specific address range. Can be used by calling the `Remap` or `RemapAll` extension methods on any II2cBus (including itself!)
public class I2cRemapper : II2cBus
{
private readonly byte[] _addressMap = new byte[256]
{
0,
1,
2,
3,
4,
5,
@elexisvenator
elexisvenator / I2CRemapper.cs
Created May 31, 2020 23:29
Helper class that wraps an `II2cBus` and allows for bus addresses to be remapped. Useful as a workaround for I2c drivers that expect a specific address range.
public class I2cRemapper : II2cBus
{
private readonly byte[] _addressMap = new byte[256]
{
0,
1,
2,
3,
4,
5,
@elexisvenator
elexisvenator / SerialEventPoller.cs
Last active May 25, 2020 23:24
Example workaround for serial port DataReceived events until events work as intended
using System;
using System.Threading;
using System.Threading.Tasks;
using Meadow.Hardware;
namespace Meadow.Foundation.Serial.Helper
{
public class SerialEventPoller : IDisposable
{
private readonly int _pollingIntervalMs;
@elexisvenator
elexisvenator / Dockerfile
Created November 11, 2019 05:48
dbt trimmed dockerfile. 0.15.0rc1
FROM ubuntu:16.04
### <SNIP>
# python libraries
RUN add-apt-repository ppa:deadsnakes/ppa && apt-get update && apt-get install -y --no-install-recommends \
python3.7 \
python3.7-dev \
python3.7-venv && ln -sf /usr/bin/python3.7 /usr/local/bin/python3
RUN python3 --version
@elexisvenator
elexisvenator / DbtBaseModelGenerator.cs
Last active December 20, 2018 00:51
Basic parts for generating load models from a csv list of tables/columns
public class DbtBaseTransformGenerator : IGenerator
{
private const string SourceSchema = "load";
public string Generate(ConfigurationModel model)
{
var sb = new StringBuilder();
AppendGeneratedRow(sb, model, -1, "NULL");
sb.AppendLine("UNION ALL");
AppendGeneratedRow(sb, model, -2, "UNKNOWN");