Skip to content

Instantly share code, notes, and snippets.

@lukeramsden
lukeramsden / use-paginated-fetch.ts
Created January 18, 2025 20:30
usePaginatedFetch
import { useCallback, useMemo, useRef, useState } from "react"
import { produce } from "immer"
interface PaginatedFetchState {
pageSize: number
startingAfter: string | undefined
endingBefore: string | undefined
direction: 'forward' | 'backward'
isOnFirstPage: boolean
@fbraz3
fbraz3 / openwrt_add_guest.sh
Last active July 7, 2025 17:39
[OpenWRT] Shell Script to Create a Fully Isolated Guest Network with Bandwidth Control
#!/bin/sh
#
# FOR USE IN OPENWRT
# This script creates a guest network fully isolated from the main one.
# Tested on a Xiaomi AX3000T router; should work on any OpenWRT-powered router.
#
# - Ensure the Wi-Fi interfaces retain their default names (radio0 and radio1).
# - For enable download/upload limits, you MUST install the sqm-scripts package on your OpenWRT router.
# - For enable roaming (aka wifi mesh):
@gue-ni
gue-ni / [...nextauth].js
Last active April 22, 2024 17:13
NextAuth.js postgres adapter
import NextAuth from "next-auth";
import GoogleProvider from "next-auth/providers/google";
import PostgresAdapter from "../../../lib/adapter";
const pool = new Pool({
user: "postgres",
host: "localhost",
database: "postgres",
password: "postgres",
port: 5432,
@LinusCDE
LinusCDE / ffmpeg-wrapper.sh
Last active December 18, 2024 00:55
FFmpeg Wrapper script that forces jellyfin to use nvmpi hardware accelleration when device is a nvidia jetson and jetson-ffmpeg is added
#!/bin/bash
SHELLDIR=$(dirname "`realpath \"$0\"`")
FORCE_HW_DECODE=true
FORCE_HW_ENCODE=true
echo "WRAPPER OLD: " $0 "$@"
skipnext=false
@the-spyke
the-spyke / pipewire.md
Last active July 10, 2025 10:25
Enable PipeWire on Ubuntu 22.04

Enable PipeWire on Ubuntu 22.04

This guide is only for original Ubuntu out-of-the-box packages. If you have added a custom PPA like pipewire-debian, you might get into conflicts.

Ubuntu 22.04 has PipeWire partially installed and enabled as it's used by browsers (WebRTC) for recoding the screeen under Wayland. We can enable remaining parts and use PipeWire for audio and Bluetooth instead of PulseAudio.

Starting from WirePlumber version 0.4.8 automatic Bluetooth profile switching (e.g. switching from A2DP to HSP/HFP when an application needs microphone access) is supported. Jammy (22.04) repos provide exactly version 0.4.8. So, we're good.

Based on Debian Wiki, but simplified for Ubuntu 22.04.

@steveruizok
steveruizok / findSnapPoints.ts
Last active January 23, 2025 01:54
Find the snap points between a bounding box and several other bounding boxes.
interface TLBoundsWithCenter {
minX: number
midX: number
maxX: number
minY: number
midY: number
maxY: number
width: number
height: number
}
@plembo
plembo / you-need-spice-vdagent.md
Last active January 27, 2025 00:55
You need spice-vdagent

You need spice-vdagent

Debian or Kali Linux installed to as KVM (libvirtd) guests do not automatically have qemu-guest-agent or spice-vdagent installed. This will prevent seamless movement of the mouse cursor between the guest and host desktop in Virtual Machine Manager (requiring the use of a Ctrl-Alt to release the cursor from the guest window).

To cure this, install both qemu-guest-agent and spice-vdagent on each guest and reboot (the guests).

$ sudo apt install qemu-guest-agent
$ sudo apt install spice-vdagent
@fidelsoto
fidelsoto / Fraction.cs
Last active October 17, 2024 05:35
Fraction Class C#. Supports formatting, comparing and simplifying fractions. In this code we can see the usage of constructors, operator overriding and helper functions.
public class Fraction
{
public int numerator;
public int denominator;
public Fraction(int numerator, int denominator)
{
this.numerator = numerator;
this.denominator = denominator;
}
@Manouchehri
Manouchehri / rfc3161.txt
Last active July 19, 2025 17:15
List of free rfc3161 servers.
https://rfc3161.ai.moda
https://rfc3161.ai.moda/adobe
https://rfc3161.ai.moda/microsoft
https://rfc3161.ai.moda/apple
https://rfc3161.ai.moda/any
http://rfc3161.ai.moda
http://timestamp.digicert.com
http://timestamp.globalsign.com/tsa/r6advanced1
http://rfc3161timestamp.globalsign.com/advanced
http://timestamp.sectigo.com
@mikelehen
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/