Skip to content

Instantly share code, notes, and snippets.

View emaballarin's full-sized avatar
🦾
Ingegno c'era nell'allenare congegni!

Emanuele Ballarin emaballarin

🦾
Ingegno c'era nell'allenare congegni!
View GitHub Profile
@emaballarin
emaballarin / xml_validate.py
Created January 26, 2026 16:41
Validate an XML document against an XSD schema, handling browser artifacts and remote imports
#!/usr/bin/env python3
"""Validate an XML document against an XSD schema, handling browser artifacts and remote imports."""
import argparse
import re
import shutil
import sys
import tempfile
from pathlib import Path, PurePosixPath
from urllib.parse import urlparse
@emaballarin
emaballarin / ccglm.fish
Last active January 21, 2026 22:24
Adapt Claude Code to work on-demand with Z.ai GML 4.7, MiniMax M2.1, and Ollama-provided models
#!/usr/bin/env fish
function ccglm --description "Claude Code with GLM 4.7 (Z.AI)"
if test -f ~/.secrets/zai.fish
source ~/.secrets/zai.fish
else
echo "Error: ~/.secrets/zai.fish not found" >&2
echo "Create it with: set -gx Z_AI_API_KEY 'your-key'" >&2
return 1
end
@emaballarin
emaballarin / aireview.sh
Last active August 4, 2025 00:01
Tool for AI-powered code review, wrapping around git diff
#!/usr/bin/env bash
# An original project of Bill Mill (https://billmill.org/):
# See: https://notes.billmill.org/blog/2025/07/An_AI_tool_I_find_useful.html
# https://github.com/llimllib/personal_code/blob/master/homedir/.local/bin/review
# LICENSE: unlicense. This is free and unencumbered software released into the public domain.
# see unlicense.org for full license
set -euo pipefail
# Configuration
diff --git i/bin/scripts/name_parser/FontnameTools.py w/bin/scripts/name_parser/FontnameTools.py
index c15afdd..0088216 100644
--- i/bin/scripts/name_parser/FontnameTools.py
+++ w/bin/scripts/name_parser/FontnameTools.py
@@ -32,6 +32,8 @@ class FontnameTools:
'ProFontWindows',
'ProFont',
'ProggyClean',
+ 'BerkeleyMono',
+ 'XBerkMono',
@emaballarin
emaballarin / seqtranslib.m
Created February 12, 2025 01:25
Transformations of Integer Sequences (Mathematica Version)
(* seqtranslib.m -- version batch 0.10 -- 10 Jan 1998 *)
(* Integer Sequences Transformations Mathematica Library *)
(* by Olivier Gerard from original Maple code and ideas by N. J. A. Sloane *)
(* Batch code *)
(* List of meaningful transformed sequences prefixed with indice of transform and without signs *)
SuperTrans[seq_List] := Abs[Cases[MapIndexed[ {First[#2],#1[seq]} & , EISTransTable ],{_Integer,{__Integer}}]]
@emaballarin
emaballarin / jbppatch.sh
Created October 20, 2024 17:14
Easily make incompatible JetBrains plugins "magically" compatible again!
#!/usr/bin/bash -li
PNAME="$1"
PVER="$2"
JARNAME="${3-$PNAME}"
mkdir -p ./EXT01/
cd ./EXT01/ || exit
unzip ../"${PNAME}"-"${PVER}".zip
rm -f ../"${PNAME}"-"${PVER}".zip
mv ./"${PNAME}"/lib/"${JARNAME}"-"${PVER}".jar ./"${JARNAME}"-"${PVER}".zip
mkdir -p ./EXT02/
@emaballarin
emaballarin / xicor.py
Last active August 9, 2024 02:42
Implementation of the Xi correlation coefficient in pure PyTorch. After: S. Chatterjee, "A New Coefficient of Correlation", 2020.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ──────────────────────────────────────────────────────────────────────────────
from math import sqrt
from typing import List
from typing import Optional
from typing import Tuple
import torch
from safe_assert import safe_assert as sassert
@emaballarin
emaballarin / tmux_install.sh
Created July 18, 2024 00:06
Script for installing tmux on systems where you don't have root access. Courtesy of Alfredo Canziani (https://github.com/Atcold/Unix-dot-files/blob/master/Tmux/local_install.sh).
#!/usr/bin/bash -li
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/.local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# Exit on error
set -eo pipefail
TMUX_VERSION="3.4"
@emaballarin
emaballarin / telegram_bot_echo.py
Created July 17, 2024 22:35
Modern Python implementation of a Telegram bot that only delivers messages
from os import environ
from typing import Dict
from typing import Optional
from typing import Tuple
from httpx import Client
from safe_assert import safe_assert as sassert
def _isnn(c):
@emaballarin
emaballarin / pristall.sh
Last active September 26, 2023 21:38
Installing the very latest Prism (https://github.com/prismplp/prism) should not be *that* convoluted...
#!/usr/bin/env bash
#
# PRISM
git clone --recursive --recurse-submodules --single-branch --depth=1 --shallow-submodules --branch master https://github.com/prismplp/prism.git
cd prism/src/c
USE_NPY=1 make -f Makefile.gmake
USE_NPY=1 make -f Makefile.gmake install
cd ../prolog
make install
cd ../../tools/