Skip to content

Instantly share code, notes, and snippets.

@Rychu-Pawel
Rychu-Pawel / axiosIdleTimeout.ts
Created May 22, 2025 10:01
Axios idle timeout with axios-retry and abort controller
/*
This is a snippet of how I added an idle timeout to the Axios.
My use case includes having an external abort signal that should abort the whole request. I also want to have axios-retry configured.
*/
/* This is the idle manager class that includes most of the logic. The usage example is below. */
export type AxiosIdleTimeout = { mergedSignal: AbortSignal; idleTimeoutSignal: AbortSignal; resetIdleTimeout: () => void; stopIdleTimeout: () => void; }
export default class AxiosIdleTimeoutManager {
@Rychu-Pawel
Rychu-Pawel / test.spec.mjs
Last active November 23, 2024 20:14
NodeJS AES-256-CTR IV counter increment functions test
/*
This is a comparison-test of multiple IV counter increment functions I found on the internet and created myself.
The goal here was to pick the most reliable one.
`incrementIVOriginal` comes from https://stackoverflow.com/questions/49954020/is-it-possible-to-decipher-at-random-position-with-nodejs-crypto
Run with:
> npx ava
Output:
$ npx ava --timeout=10m
@Rychu-Pawel
Rychu-Pawel / TimeSpanExtensions.cs
Created April 29, 2021 08:37
TimeSpan Readable Ago String
public static class TimeSpanExtensions
{
// Inspired by @Peter answear from https://stackoverflow.com/questions/842057/how-do-i-convert-a-timespan-to-a-formatted-string
public static string ToReadableAgoString(this TimeSpan span, double justNowSecondsThreshold)
{
if (span.TotalSeconds < justNowSecondsThreshold)
return "just now";
return span switch
{
@Rychu-Pawel
Rychu-Pawel / zfs_health_check.sh
Last active March 12, 2023 09:18
ZFS Health Check script for monit. For detailed description and usage go to http://pawelrychlicki.pl/Article/Details/58/zfs-health-check-script-for-monit-09
#! /bin/bash
#
## ZFS health check script for monit.
## v1.0.2
#
## Should be compatible with FreeBSD and Linux. Tested on Ubuntu.
## If you want to use it on FreeBSD then go to Scrub Expired section and Trim Expired section
## and comment two Ubuntu date lines and uncomment two FreeBSD lines in Scrub Expired section.
## In Trim Expired section adjust the date format directly in the for loop's awk parameter.
#