Skip to content

Instantly share code, notes, and snippets.

@3v1n0
3v1n0 / .zshrc
Created June 6, 2020 14:35
ZSH zinit configuration with powerlevel10k instant mode
typeset -g MY_ZSH_CONFIG_PATH=${ZDOTDIR:-$HOME/.config/zsh}
typeset -g MY_ZINIT_PATH=${ZDOTDIR:-$HOME/.local/share}/zinit
HISTFILE=$MY_ZSH_CONFIG_PATH/zsh_history
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
if [ ! -f $MY_ZINIT_PATH/bin/zinit.zsh ] && ((${+commands[git]})); then
@3v1n0
3v1n0 / .zshrc
Last active June 6, 2020 14:35
Broken zsh syntax highlighting when using async zinit (turbo mode) + powerlevel10k and zsh-autosuggestions
typeset -g MY_ZSH_CONFIG_PATH=${ZDOTDIR:-$HOME/.config/zsh}
typeset -g MY_ZINIT_PATH=${ZDOTDIR:-$HOME/.local/share}/zinit
HISTFILE=$MY_ZSH_CONFIG_PATH/zsh_history
if [ ! -f $MY_ZINIT_PATH/bin/zinit.zsh ] && ((${+commands[git]})); then
__zinit_just_installed=1
mkdir -p $MY_ZINIT_PATH && chmod g-rwX "$MY_ZINIT_PATH" && \
git clone --depth=1 https://github.com/zdharma/zinit.git $MY_ZINIT_PATH/bin
fi
@3v1n0
3v1n0 / fish-shell-bash-complete-function.sh
Last active April 3, 2025 16:37
Use bash completions in Fish Shell
#!/usr/bin/fish
# You can add this to your ~/.config/fish/config.fish
function __fish_complete_bash
set cmd (commandline -cp)
bash -c "source get-bash-completions.sh; get_completions '$cmd'"
end
# Set the tool to use bash completions
@3v1n0
3v1n0 / io_uring-ops-checker.c
Last active April 27, 2020 14:34
Dynamically check for io_uring operations availability
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <liburing.h>
typedef enum {
TEST_URING_OP_NONE = 0,
@3v1n0
3v1n0 / argbToRgbaConversionTests.js
Last active March 12, 2020 13:58
ARGB to RGBA conversion tests in Javascript
function argbToRgba(src, inline=false) {
let dest = inline ? src : new Uint8Array(src.length);
let srcView = new DataView(src.buffer);
let destView = new DataView(dest.buffer);
for (let i = 0; i < src.length; i += 4) {
let argb = srcView.getUint32(i);
let rgba = (argb & 0x00FFFFFF) << 8 |
(argb & 0xFF000000) >>> 24;
destView.setUint32(i, rgba);
@3v1n0
3v1n0 / vscode-unused-workspace-storage-cleanup.sh
Last active January 29, 2025 18:43
VSCode unused workspaceStorage cleanup
#!/bin/bash
CONFIG_PATH=~/.config/Code
for i in $CONFIG_PATH/User/workspaceStorage/*; do
if [ -f $i/workspace.json ]; then
folder="$(python3 -c "import sys, json; print(json.load(open(sys.argv[1], 'r'))['folder'])" $i/workspace.json 2>/dev/null | sed 's#^file://##;s/+/ /g;s/%\(..\)/\\x\1/g;')"
if [ -n "$folder" ] && [ ! -d "$folder" ]; then
echo "Removing workspace $(basename $i) for deleted folder $folder of size $(du -sh $i|cut -f1)"
@3v1n0
3v1n0 / vscode-keybindings-alt+hjkl-zation.py
Last active December 9, 2020 09:22
Make VSCode default key-bindings more HJLK friendly using Alt to alternate to them
#/usr/bin/python3
import json
import sys
import os
import re
import copy
input = sys.argv[1]
@3v1n0
3v1n0 / fattura-elettronica.xml
Created October 21, 2019 13:41
Freedesktop MIME info for Italian Electronic Invoice (Fattura Elettronica) XML files
<!--
To associate the Italian Electronic Invoices (Fattura Elettronica) to a given
program, copy this to
~/.local/share/mime/packages/fattura-elettronica.xml
And run
update-mime-database ~/.local/share/mime
Then those .xml files may have a different behavior than standard .xml files
-->
@3v1n0
3v1n0 / fattura-elettronica-xml-lint.sh
Last active November 30, 2021 16:33
Linter script for the Italian electronic invoice (Fattura Elettronica)
#!/bin/bash
SCHEMA_URI="https://www.fatturapa.gov.it/export/documenti/fatturapa/v1.2.1/Schema_del_file_xml_FatturaPA_versione_1.2.1.xsd"
IMPORTED_SCHEMAS=(xmldsig-core-schema.xsd)
IMPORTED_SCHEMAS_BASE_URI="https://raw.githubusercontent.com/italia/fatturapa-testsdi/master/core/schemas/"
tmp_dir=$(mktemp -d -t fe-xml-lint-XXXXXXXXXX)
schemas=("$SCHEMA_URI")
@3v1n0
3v1n0 / fattura-elettronica-imap-extractor.py
Last active November 14, 2023 20:58
Extract italian electronic invoices (fatture elettroniche) from a PEC provider IMAP server
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2019-2022 - Marco Trevisan
#
# A Tool to export your invoices in the Italian electronic Fattura Elettronica
# format from any IMAP PEC provider (defaulting to Aruba PEC) to your computer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by