Skip to content

Instantly share code, notes, and snippets.

@3v1n0
3v1n0 / .zshrc
Created Jun 6, 2020
ZSH zinit configuration with powerlevel10k instant mode
View .zshrc
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 / fattura-elettronica-imap-extractor.py
Last active Feb 23, 2021
Extract italian electronic invoices (fatture elettroniche) from a PEC provider IMAP server
View fattura-elettronica-imap-extractor.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2019 - 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 Feb 23, 2021
Kotlin Map<String, Any?> (andy Any type in general) (de)serialization tests with both Binary (CBOR) and JSON support
View map-string-any-kotlin-serialization-tests.kt
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 / pulse-audio-hdmi-switch.sh
Last active Feb 11, 2021
Script to automatically switch audio to HDMI using PulseAudio in Linux
View pulse-audio-hdmi-switch.sh
#!/bin/bash
USER_NAME=$(who | grep tty$(sudo fgconsole) | cut -f1 -d' ')
USER_ID=$(id -u "$USER_NAME")
HDMI_STATUS=$(</sys/class/drm/card0/*HDMI*/status)
HDMI_CARD="pci-0000_00_03.0"
HDMI_PROFILE="hdmi-stereo-extra1"
INTERNAL_CARD="pci-0000_00_1b.0"
@3v1n0
3v1n0 / canoninvoice.py
Last active Feb 5, 2021
Fattura Elettronica and Python playground
View canoninvoice.py
#!/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 / vscode-unused-workspace-storage-cleanup.sh
Last active Feb 5, 2021
VSCode unused workspaceStorage cleanup
View vscode-unused-workspace-storage-cleanup.sh
#!/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 / python.vapi
Created Oct 12, 2011
A simple test to use python code from Vala
View python.vapi
[CCode (lower_case_cprefix = "Py_", cheader_filename = "Python.h")]
namespace Python
{
public void Initialize ();
public void Finalize ();
[CCode (lower_case_cprefix = "PyRun_")]
namespace Run
{
public void SimpleString (string @string);
@3v1n0
3v1n0 / fitbit-svg-to-grayscale-magic-png.sh
Last active Jan 6, 2021
Simple script to convert SVG icons to fitbit Grayscale Magic compatible PNGs
View fitbit-svg-to-grayscale-magic-png.sh
#!/bin/bash
# Simple script to convert SVG icons to fitbit grayscale magic compatible PNGs
# Usage: convert-svg.sh [icons-path]
#
# Author: Marco Trevisan (Treviño) <mail@3v1n0.net>
# Licensed under GPLv3
PNG_SIZE=${PNG_SIZE:-80}
icons_path=${1:-$(dirname "$0")}
@3v1n0
3v1n0 / keybindings.json
Last active Dec 29, 2020
VSCode keybindings for alternative HJLK navigation, when using non-vim mode and support for quick panel navigation with Tab/Shift+Tab.
View keybindings.json
/* 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-keybindings-alt+hjkl-zation.py
Last active Dec 9, 2020
Make VSCode default key-bindings more HJLK friendly using Alt to alternate to them
View vscode-keybindings-alt+hjkl-zation.py
#/usr/bin/python3
import json
import sys
import os
import re
import copy
input = sys.argv[1]