Skip to content

Instantly share code, notes, and snippets.


Ugo Varetto ugovaretto

View GitHub Profile
ugovaretto /
Created June 1, 2023 08:53
Wez term dependencies on Linux
sudo apt install libx11-xcb-dev libxcb-util libxcb-util-dev libxcb-image0-dev libxcb1-dev libxkbcommon-dev libxkbcommon-x11-dev
ugovaretto / config.kdl
Created May 28, 2023 12:25
zellij configuration
View config.kdl
// If you'd like to override the default keybindings completely, be sure to change "keybinds" to "keybinds clear-defaults=true"
keybinds {
normal {
// uncomment this and adjust key if using copy_on_select=false
// bind "Alt c" { Copy; }
locked {
bind "Ctrl g" { SwitchToMode "Normal"; }
resize {
ugovaretto / config.toml
Last active May 28, 2023 13:34
helix configuration
View config.toml
theme = "tokyonight"
line-number = "relative"
mouse = false
bufferline = "multiple"
rulers = [80]
right = ["diagnostics", "selections", "position", "position-percentage", "file-encoding", "file-line-ending", "file-type"]
View .tmux.conf
# Set prefix (Ctrl+a)
set-option -g prefix C-a
unbind-key C-a
bind-key C-a send-prefix
# Use Alt-arrow keys to switch panes (Alt+left/right/up/down)
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
ugovaretto / result-example.cpp
Last active May 8, 2023 03:28
Rust-style C++ Result implementation, supporting references
View result-example.cpp
// Implementation of Result<Result,Error> type a la Rust.
// author: Ugo Varetto
// License: Zero-clause BSD
// SPDX identifier: 0BSD
#include "result.h"
Result<int, std::string> Foo(int i) {
if (i == 0) {
return Err(std::string("Error"));
} else {
ugovaretto / sha256.c
Last active April 26, 2023 13:56
SHA256 implementation
View sha256.c
// sha256.c - SHA256 reference implementation
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
View par-heic2jpeg.cabal
cabal-version: 3.4
-- The cabal-version field refers to the version of the .cabal specification,
-- and can be different from the cabal-install (the tool) version and the
-- Cabal (the library) version you are using. As such, the Cabal (the library)
-- version used must be equal or greater than the version stated in this field.
-- Starting from the specification version 2.2, the cabal-version field must be
-- the first thing in the cabal file.
-- Initial package description 'y' generated by
-- 'cabal init'. For further documentation, see:
ugovaretto / heic2jpeg.hs
Created April 16, 2023 14:52
Convert HEIC to JPEG (Haskell version)
View heic2jpeg.hs
import System.Directory
import System.FilePath
import Control.Monad
import System.Process
import Data.Char
main = do
c <- listDirectory "."
f <- filterM (\x -> return (map toLower (snd(splitExtension x)) == ".heic")) c
mapM (\x -> callProcess "convert" [x, (dropExtension x) ++ ".jpg"]) f
ugovaretto /
Created February 11, 2023 11:44
Enable wake-on-lan magic packet before hibernating
#!/usr/bin/env bash
# run with sudo
ethtool -s enp8s0 wol g
systemctl hibernate
ugovaretto /
Created February 11, 2023 11:42
Make Wake-on-line on magic packet persistent