Skip to content

Instantly share code, notes, and snippets.

View aziis98's full-sized avatar

Antonio De Lucreziis aziis98

View GitHub Profile
@aziis98
aziis98 / pkgver_sorter.py
Last active January 19, 2026 11:53
This script parses version update lines from standard input, calculates a "distance" metric between old and new versions (prioritizing major version changes), and then prints the update lines sorted by this distance in descending order
#!/usr/bin/env python3
import re
import sys
def parse_version(version_str):
"""Parse version string, marking date/timestamp components"""
parts = []
for x in re.findall(r"\d+", version_str):
@aziis98
aziis98 / !pdf-notes-to-latex-markdown.md
Created November 21, 2025 16:52
Small helper script to convert a PDF into markdown by converting pages to images and running an LLM-based OCR prompt on each image.

llm-ocr: PDF → Markdown OCR pipeline

Small helper script to convert a PDF into markdown by converting pages to images and running an LLM-based OCR prompt on each image.

Requirements

  • pdftoppm (poppler-utils) — to convert PDF pages to PNG images
  • aichat CLI — to run the OCR prompt against each page image
@aziis98
aziis98 / !css-extract.md
Last active October 31, 2025 15:56
css-extract vite js plugin

css-extract

I really don't like TailwindCSS and recently I discovered that llms are good at writing ViteJS plugins and did some experiments that came out pretty well in opinion.

Note. I know about styled-components, EmotionCSS and vanilla-extract and others but I don't like to write CSS-as-JS and some of the libraries do not support ViteJS or are too much tied to the React ecosystem and can't be used with Preact.


I really like to write CSS by hand but I get that Tailwind gives the ability to write everything directly in the same files keeping related things together. In an ideal world I think I would just ditch HTML+CSS and have the separation at components+layout and colors+styles, or just have a single language like in SwiftUI or Jetpack Compose.

@aziis98
aziis98 / !rust-data-structure-api-techniques.md
Last active January 30, 2025 14:42
Rust example of how to organize code using a single trait for multiple implementations using various techniques: duplications, trait objects, generics

Our Trait

pub trait StackLike<T> {
    fn new() -> Self; // minor omission, see notes
    
    fn my_push(&mut self, value: T);
    fn my_pop(&mut self) -> Option<T>;
}
@aziis98
aziis98 / lexical-hooks.js
Last active August 14, 2024 13:06
Lexical "hooks" in JS using TemplateStringsArray to distinguish callsites (in contrast to react hooks that use a form of stack/dynamic scoping)
//
// Library
//
const newValueToUpdater = newValue => (typeof newValue === 'function' ? newValue : () => newValue)
const hooks = {
state: (hookContext, initialValue) => {
if (!hookContext.initialized) {
hookContext.initialized = true
@aziis98
aziis98 / parser.go
Created August 9, 2024 22:36
A small Golang parser with a backtracking helper
package lang
import (
"fmt"
"regexp"
"strings"
"unicode"
)
type parser struct {
@aziis98
aziis98 / !00-readme.md
Last active April 25, 2024 12:06
A small declarative DSL for CanvasRenderingContext2D

GDSL

Graphics DSL is a small library to help write canvas drawing code in a more declarative style.

The main function of this library is render2d(g, dsl)

  • The first argument is the CanvasRenderingContext2D to draw to.

  • The second one is a structure must be one of the following:

@aziis98
aziis98 / !proxy-props-to-rest.md
Last active December 5, 2023 14:43
Small js Proxy library to map props to rest calls

Example Proxy in JS (Props to REST mapper)

MDN has documentation about Proxy.

Example Usage

const api = createObjectMapper('https://example.org/base-path/')

await api.users['user-id-1'].get()
@aziis98
aziis98 / hash2addr.sh
Created September 14, 2023 20:54
A simple script to generate a seeded ip+port from any string (generally a route for a docker container, useful for plumbing)
#!/bin/bash
# Display help message
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
echo "usage: $(basename $0) <input_string>"
echo "Outputs a randomly generated IP address and port number based on the MD5 hash of the input string."
echo ""
exit 0
fi
@aziis98
aziis98 / InputTags.jsx
Created March 31, 2023 16:57
JSX Tags Input Widget
const normalizeTag = tag => {
return tag
.toLowerCase()
.replace(/\s+/g, ' ')
.replace(/ /g, '-')
.replace(/[^\p{L}0-9\/\-]/gu, '')
}
const InputTags = ({ tags, setTags, availableTags }) => {