Skip to content

Instantly share code, notes, and snippets.

@3v1n0
3v1n0 / fish-shell-bash-complete-function.sh
Last active March 11, 2024 13:46
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 / web-snapshts-saver.py
Last active March 6, 2024 16:07
Simple Browser snapshots saver with webkit and python-gtk3
#!/usr/bin/env python3
import gi
import datetime
import os
os.environ['GDK_BACKEND'] = 'x11'
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
@3v1n0
3v1n0 / keybindings.json
Last active January 23, 2024 05:53
VSCode keybindings for alternative HJLK navigation, when using non-vim mode and support for quick panel navigation with Tab/Shift+Tab.
/* VSCode keybindings for alternative HJLK navigation, when using non-vim mode
* and support for quick panel navigation with Tab/Shift+Tab.
*
* So basically I just tried to use everywhere in the editor these aliases:
* Alt+j = down
* Alt+k = up
* Alt+l = right
* Alt+h = left
* Alt+b = previous-word
* Alt+w = next-word
@3v1n0
3v1n0 / vscode-unused-workspace-storage-cleanup.sh
Last active January 4, 2024 23:40
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 / .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 / parse-gov-certs.py
Last active November 14, 2023 21:28
ParseGovCerts
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) Marco Trevisan
#
# Authors:
# Marco Trevisan <marco@trevisan.xyz>
#
# Revision for new URL:
# Andrea Costantino <costan@amg.it>
#
@3v1n0
3v1n0 / canoninvoice.py
Last active November 14, 2023 21:26
Fattura Elettronica and Python playground
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# 2019-2021 - Marco Trevisan
#
# Fattura Elettronica and python Playground
#
# 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
# the Free Software Foundation, either version 3 of the License, or
@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
@3v1n0
3v1n0 / map-string-any-kotlin-serialization-tests.kt
Last active September 25, 2023 18:15
Kotlin Map<String, Any?> (andy Any type in general) (de)serialization tests with both Binary (CBOR) and JSON support
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.CompositeDecoder
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.*
import kotlin.reflect.KType
import kotlin.reflect.full.isSubtypeOf
import kotlin.reflect.full.starProjectedType
@3v1n0
3v1n0 / sssd-smart-card-pam-auth-configs-tester.sh
Last active September 14, 2023 10:27
A simple interactive tester for sssd PAM configurations
#!/usr/bin/env bash
# Copyright 2023 - Marco Trevisan
# Released under the GPLv3 terms
#
# A simple tool to simulate PAM authentication using SSSD smartcard settings.
#
# To be used with softhsm2 smart cards generators from
# https://gist.github.com/3v1n0/287d02ca8e03936f1c7bba992173d47a
#
# Origin: https://gist.github.com/3v1n0/d7bc0f10cf44a11288648ae9d228430d