🐛 ✨ 📦 🚨 ✔️❌ ✅❎ ⚙️ 🔧 🚨 📚
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
DECLARE @DispatchedBefore datetime = GETUTCDATE()-1 -- Removes entries older then 24 hours | |
DECLARE @BatchSize INT = 4000 -- Avoid batch sizes over 4.000 to prevent lock escalation | |
WHILE 1 = 1 | |
BEGIN | |
DELETE TOP (@BatchSize) FROM [dbo].[EndpointNameOutboxData] WITH (ROWLOCK) | |
WHERE Dispatched = 'true' AND DispatchedAt < @DispatchedBefore; | |
IF @@ROWCOUNT < @BatchSize -- Important that @@ROWCOUNT is read immediately after the DELETE | |
BREAK | |
END |
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
// If all handlers are compute bound or IO isn't happening early it can result in less concurrent processing as depending on the | |
// transport and it being full async and no IO is happening message processing could be sequential. This behavior will immediately | |
// do a Task.Run | |
// | |
// Usage: | |
// endpointConfiguration.Pipeline.Register(new TaskRunBehavior(), nameof(TaskRunBehavior)); | |
// | |
class TaskRunBehavior : IBehavior<IIncomingPhysicalMessageContext, IIncomingPhysicalMessageContext> | |
{ | |
public Task Invoke(IIncomingPhysicalMessageContext context, Func<IIncomingPhysicalMessageContext, Task> next) |
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.IO; | |
using System.Linq; | |
static class PathWalker | |
{ | |
public static string Find(string filename, string path) | |
{ | |
if (filename == null) throw new ArgumentNullException(nameof(filename)); | |
if (path == null) throw new ArgumentNullException(nameof(path)); |
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.IO; | |
using System.Reflection; | |
using System.Runtime.InteropServices; | |
using System.Runtime.Loader; | |
/// <summary> | |
/// Based on: | |
/// | |
/// - https://learn.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support |
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
SELECT 'DROP TABLE ' + '[' + TABLE_SCHEMA + '].[' + TABLE_NAME + ']' | |
FROM INFORMATION_SCHEMA.TABLES | |
ORDER BY TABLE_SCHEMA, TABLE_NAME |
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
netsh advfirewall firewall add rule name="ServicePulse - TCP 9090" dir=in action=allow protocol=TCP localport=9090 | |
netsh advfirewall firewall add rule name="ServiceControl - TCP 33333" dir=in action=allow protocol=TCP localport=33333 | |
netsh advfirewall firewall add rule name="ServiceControl.Monitoring - TCP 33633" dir=in action=allow protocol=TCP localport=33633 | |
netsh advfirewall firewall add rule name="ServiceControl.Audit - TCP 44444" dir=in action=allow protocol=TCP localport=44444 |
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
# 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 |