Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ramonsmits's full-sized avatar

Ramon Smits ramonsmits

View GitHub Profile
@ramonsmits
ramonsmits / solution.md
Last active January 22, 2024 11:47
1152: Error extracting to the temporary location

I had issue running the Yamaha USB driver installer part of um3141x64.zip. Running the setup.exe showed dialog with the message:

1152: Error extracting to the temporary location

I used Sysintermals Procmon to check what failed but that didn't reveal the problem. My current TEMP folder points to the folder S:\.tmp on a ReFS partition. After temporarily creating a c:\tmp, set TEMP and TMP environment variables to that value the setup.exe ran without any issues. That means the installer could:

  1. Required C: drive
  2. Didn't like the period character in the path
  3. Isn't working with ReFS partitions
@ramonsmits
ramonsmits / howto.md
Created December 30, 2023 22:15
Backup restore Postgres between major versions via docker
  1. Ensure that a shared folder exists between the containers. For example, I have the following volume mapping on both instances: - ./backups:/backups
  2. Create a backup via the command pg_dump. For example, the following docker container myapp_db_1:
  • docker exec myapp_db_1 bash -c "pg_dump --username=myuser --no-password --format=c mydatabase > /backups/1.dump"
    
  1. Restore via the command pg_restore on another (newer major) of postgres:
  • docker exec myapp_db_2 bash -c  "pg_restore --username=myuser --no-password --dbname=mydatabase --verbose /backups/1.dump"
    
@ramonsmits
ramonsmits / FileIsInUse.cs
Created November 30, 2023 12:19
Check if a file is in use by trying to open it exclusively
static class FileHelper
{
public static bool FileInUse(string path)
{
try
{
using var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.None);
return false;
}
catch (IOException)
// Placeholder
@ramonsmits
ramonsmits / SagaJsonPatcher.cs
Created November 16, 2023 10:25
NServiceBus.Persistence.Sql v7.0.3 JSON patch for saga tables
// <PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.2" />
// <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
using Microsoft.Data.SqlClient;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Data;
internal class Program
{
@ramonsmits
ramonsmits / TimeoutBehavior.cs
Last active September 27, 2023 15:59
NServiceBus TimeoutBehavior
class TimeoutBehavior : Behavior<IIncomingPhysicalMessageContext>
{
static readonly ILog Log = LogManager.GetLogger<TimeoutBehavior>();
static readonly TimeSpan TimeoutDuration = TimeSpan.FromSeconds(5);
static readonly TimeSpan CancellationThresholdDuration = TimeSpan.FromSeconds(5);
static readonly TimeSpan TerminationDetectionDuration = TimeoutDuration + CancellationThresholdDuration;
public override async Task Invoke(IIncomingPhysicalMessageContext context, Func<Task> next)
{
using var timeoutCTS = new CancellationTokenSource(TimeoutDuration);
@ramonsmits
ramonsmits / HOWTO.md
Last active April 11, 2024 23:01
Install .NET 8 on Raspberry pi
ILogger logger = null;// Get logger
var appDomain = AppDomain.CurrentDomain;
appDomain.UnhandledException += (sender, ea) => Log.Fatal((Exception)ea.ExceptionObject, "UnhandledException");
if (logger.IsEnabled(LogEventLevel.Debug))
{
appDomain.FirstChanceException += (sender, ea) =>
{
var ex = ea.Exception;
@ramonsmits
ramonsmits / ReportFailedDurationsBehavior.cs
Created July 25, 2023 16:27
NServiceBus - Report processing durations for failed messages
//
// endpointConfiguration.Pipeline.Register(new ReportFailedDurationsBehavior(), nameof(ReportFailedDurationsBehavior));
//
class ReportFailedDurationsBehavior : IBehavior<IIncomingLogicalMessageContext, IIncomingLogicalMessageContext>
{
static readonly ILog Log = LogManager.GetLogger(typeof(ReportFailedDurationsBehavior));
static readonly bool IsDebugEnabled = Log.IsDebugEnabled;
static readonly TimeSpan WarningThreshold = TimeSpan.FromSeconds(30);
@ramonsmits
ramonsmits / Fedora38-VM.ps1
Last active July 24, 2023 12:55 — forked from PatrickLang/Fedora34-VM.ps1
Hyper-V example setup for Fedora Workstation 38
# Echo the commands as they're run
Set-PSDebug -Trace 1
# Dump Windows version
Get-ComputerInfo | Format-Table WindowsVersion, OsVersion
# Create a UEFI VM, secure boot enabled, use the secure boot settings for the
$vm = New-VM -Generation 2 -Name "Fedora 38" -Path .
$vm | Set-VMFirmware -EnableSecureBoot On -SecureBootTemplate "MicrosoftUEFICertificateAuthority"