Skip to content

Instantly share code, notes, and snippets.

View paoloricciuti's full-sized avatar

Paolo Ricciuti paoloricciuti

View GitHub Profile
@paoloricciuti
paoloricciuti / create-sections-from-small-llm.ts
Created October 10, 2025 08:18
Creates a structured and separated sections from the `llms-small.txt` file
function split_docs(txt: string, level = '##') {
return [...txt.matchAll(new RegExp(`^${level}\\s(.+)$`, 'gm'))].map((match, i, arr) => {
const title = match[1]!;
const text = match.input.substring(match.index, arr[i + 1]?.index).trim();
return [title, { title, content: text, slug: slugify(title).toLowerCase() }] as const;
});
}
function clean(markdown: string) {
return markdown
@paoloricciuti
paoloricciuti / patch-file-changed.ts
Last active September 26, 2025 08:09
snippet to find the changed files from a git patch
const files = [...patch.matchAll(/^diff --git\sa\/(?<file>.+?)\sb\/\1\n(?:(?<action>deleted|new)\sfile mode)?/gm)].map(res => res.groups);
@paoloricciuti
paoloricciuti / hide-tab-bar.css
Created May 30, 2025 20:32
CSS to autohide the vertical tab bar in Vivaldi
/* Auto hide vertical tab bar */
#browser:not(.fullscreen) .inner > .tabbar-wrapper:not(:hover),
#browser:not(.fullscreen) .inner > .tabbar-wrapper:not(:hover) * {
pointer-events: none;
}
#browser:not(.fullscreen):has(
.ToolbarButtonPopup-DefaultStyles:not([aria-label='Accounts']):hover
)
@paoloricciuti
paoloricciuti / index.html
Created May 7, 2025 14:10
Signals from Scratch
<button id="btn">0</button>
<input id="input" /><input type="checkbox" id="check" />
@paoloricciuti
paoloricciuti / README.md
Created March 27, 2025 20:10
Gemini explains svelte reactivity

Signal-Based Reactivity System

This document provides an overview of the signal-based reactivity system implemented in this project. This system allows for efficient and fine-grained updates in response to data changes. It is inspired by reactive programming paradigms and utilizes key concepts like signals, derived values, and effects.

Core Concepts

The reactivity system revolves around three main concepts:

  1. Signals (Sources): These are the fundamental building blocks of the system. A signal holds a value that can change over time. When a signal's value is updated, it notifies all the parts of the system that depend on it.
@paoloricciuti
paoloricciuti / applyAction.ts
Created December 19, 2023 15:18
Apply Action action
/* eslint-disable @typescript-eslint/no-explicit-any */
export type Action = {
id: string;
action: (
node: HTMLElement,
props?: any
) => { update?: (newProps: any) => void; destroy?: () => void };
props?: any;
};
@paoloricciuti
paoloricciuti / [A] README.md
Last active June 15, 2023 08:50
Svelte Backgrounds

Svelte Backgrounds

I'm a svelte lover and whenever i love soemthing i like to have it around here and there.

That's why i created a bunch of svelte backgrounds for your laptop or your phone. Enjoy!

@paoloricciuti
paoloricciuti / gist:b9f82f2def4940e1499cdcfe9647c5b0
Created October 27, 2022 07:16
Docker command to run a project in linux if it has problems with Windows
docker run -it --rm -p 3000:3000 -v [project folder]:/app node:17-alpine /bin/ash
@paoloricciuti
paoloricciuti / useBroadcast.ts
Last active October 3, 2022 14:56
useBroadcast.ts
import {
Dispatch,
SetStateAction,
useCallback,
useEffect,
useRef,
useState,
} from 'react';
/**
@paoloricciuti
paoloricciuti / useCallbackState.ts
Created January 21, 2022 08:46
useCallbackState.ts
import { useEffect, useRef, useState } from "react";
type CallBackType<T> = (updatedValue: T) => void;
type SetStateType<T> = T | ((prev: T) => T);
type RetType = <T>(
initialValue: T | (() => T)
) => [T, (newValue: SetStateType<T>, callback?: CallBackType<T>) => void];