Skip to content

Instantly share code, notes, and snippets.

View aziis98's full-sized avatar

Antonio De Lucreziis aziis98

View GitHub Profile
@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 }) => {
ALGEBRA 2
https://esami.unipi.it/programma.php?c=53646&aa=2022&docente=&insegnamento=ALGEBRA+2&sd=0
ALGEBRA SUPERIORE A - ALGEBRA SUPERIORE A/a
https://esami.unipi.it/programma.php?c=53903&aa=2022&docente=&insegnamento=ALGEBRA+SUPERIORE+A&sd=0
ALGEBRE E GRUPPI DI LIE - ALGEBRE E GRUPPI DI LIE/a
https://esami.unipi.it/programma.php?c=53928&aa=2022&docente=&insegnamento=ALGEBRE+E+GRUPPI+DI+LIE&sd=0
ALGORITMI E STRUTTURE DEI DATI - ALGORITMI E STRUTTURE DATI
@aziis98
aziis98 / webcmp.sh
Last active December 8, 2022 00:08
#!/usr/bin/env bash
STORAGE_FILE="webpage.sum"
init() {
while [[ "$1" == -* ]]; do
case "$1" in
-s|--storage)
STORAGE_FILE="$2"
shift 2
@aziis98
aziis98 / 001-next-bits-permutation.md
Last active September 21, 2022 22:11
Exploration of bit operations to compute the next permutation with constant number of ones

Next Permutation

... code to view each step of the "next permutation" bit manipulation algorithm ...

@aziis98
aziis98 / go-templates-cheatsheet.md
Created August 13, 2022 23:42
A small cheatsheat of Go Templates

Go Templates Cheat Sheet

Usage

Import text/template or html/template as needed.

tmpl, _ := template.New(“template_name”).Parse(“...”)
tmpl.Name() // => name of current template
tmpl.Execute(...) // =&gt; current template

Tema personalizzato per "www.dm.unipi.it"

Features

  • Il logo sta in una posizione più decente.
  • Le scatole al centro non hanno bordo #fff.

Installazione

  • Google Chrome / Chromium. Installare l'estensione Stylus per il browser, a quel punto andare su e premere sull'estensione e fare "Nuovo stile per" e selezionare tutto il sotto-dominio. A quel punto incollare il CSS di sopra e premere "Salva".
@aziis98
aziis98 / server.js
Created June 30, 2022 00:13
Simple ViteJS dev server with custom dynamic routes
import { dirname, resolve } from 'path'
import express from 'express'
import { createServer as createViteServer } from 'vite'
import { fileURLToPath } from 'url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const ROUTES = {
'/': './index.html',
'/buckets/:bucket': './[bucket].html',