🐛 ✨ 📦 🚨 ✔️❌ ✅❎ ⚙️ 🔧 🚨 📚
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Globalization; | |
using Microsoft.Extensions.Logging; | |
using MQTTnet; | |
class ChargeOrchestrator | |
{ | |
const double PackSizeRemainingAtFull = 85000; // kWh | |
readonly ILogger<ChargeOrchestrator> logger; | |
readonly IMessagePublisher messagePublisher; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Globalization; | |
using System.Linq; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Microsoft.Extensions.Logging; | |
using MQTTnet; | |
class DsmrTeslaLoadBalancer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# originally based on https://www.huizebruin.nl/home-assistant/esphome/watermeter-uitlezen-in-home-assistant-met-esphome | |
# | |
# Differences: | |
# - Uses MQTT. | |
# - Uses internal_filter: 250ms to skip short pulses due to "floating pin" | |
# voltage. Measure your minimum pulse time by opening several taps in your | |
# home and count the number of pulse in 30 seconds and you can calculate the | |
# minimum pulse duration. If you set this value just under this you should be | |
# safe. | |
# - Blinks the blue LED (GPIO2) for every received pulse. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Preserves: | |
// | |
// - Whitespace (`LoadOptions.PreserveWhitespace`) | |
// - BOM (passing `UTF8Encoding(false)` ensures reader.Encoding will use this encoding, if BOM is present reader will swap to UTF8Encoding(true)) | |
// - Line endings (using StreamReader instead of passing filename preserves line endings in document) | |
// - XML declaration header | |
// | |
var path = ""; // Path to XML file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Based on https://stackoverflow.com/a/5641272/199551 | |
// | |
public class NaturalComparer : IComparer<string> | |
{ | |
public static readonly NaturalComparer Instance = new NaturalComparer(); | |
private NaturalComparer() { } | |
public int Compare(string x, string y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://github.com/LogosBible/Logos.Utility/blob/master/src/Logos.Utility/GuidUtility.cs | |
using System; | |
using System.Security.Cryptography; | |
using System.Text; | |
/// <summary> | |
/// Helper methods for working with <see cref="Guid"/>. | |
/// </summary> | |
static class GuidUtility | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Usage: | |
// | |
// var endpointConfiguration = new EndpointConfiguration("MyEndpoint") | |
// ... | |
// endpointConfiguration.Pipeline.Register(new CheckSizeBehavior(CheckSizeBehavior.StandardTierMaxSize), nameof(CheckSizeBehavior)); | |
// | |
using NServiceBus.Pipeline; | |
class CheckSizeBehavior : IBehavior<IOutgoingPhysicalMessageContext, IOutgoingPhysicalMessageContext> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var uptimeInSeconds = Stopwatch.GetTimestamp() / Stopwatch.Frequency; | |
var uptime = TimeSpan.FromSeconds(uptimeInSeconds); | |
Console.WriteLine(uptime); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage: | |
// | |
// var endpointConfiguration = new EndpointConfiguration("MyEndpoint") | |
// ... | |
// var connectionString = Environment.GetEnvironmentVariable("AzureServiceBus_ConnectionString"); | |
// var managementClient = new ManagementClient(connectionString); | |
// endpointConfiguration.Pipeline.Register(new ValidateDestinationExistsBehavior (managementClient), nameof(ValidateDestinationExistsBehavior)); | |
// | |
using Microsoft.Azure.ServiceBus.Management; | |
using NServiceBus.Pipeline; |