Skip to content

Instantly share code, notes, and snippets.

View giuseppe998e's full-sized avatar

Giuseppe Eletto giuseppe998e

View GitHub Profile
@giuseppe998e
giuseppe998e / kvm-image.xml
Last active May 13, 2022 12:45
KVM - User mode network port forwarding
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<!-- ... -->
<devices>
<!-- ... -->
<interface type="user">
<!-- ... -->
<model type="e1000e"/>
<!-- ... -->
</interface>
<!-- ... -->
@giuseppe998e
giuseppe998e / Serializer.java
Created April 28, 2022 11:03
Utility class that writes and reads serializable classes using Java.NIO
// package ...
import java.io.*;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
@giuseppe998e
giuseppe998e / gdm-fractional_scaling.md
Last active September 8, 2024 07:11
GDM - Setup display fractional scaling
  1. Check if you are running X11 or Wayland:
    • echo $XDG_SESSION_TYPE
  2. Copy your monitors.xml config file into GDM home directory:
    • sudo cp ~/.config/monitors.xml ~gdm/.config/monitors.xml
    • sudo chown gdm:gdm ~gdm/.config/monitors.xml
  3. Access GDM's shell:
    • sudo machinectl shell gdm@ /bin/bash
  4. Enable scale-monitor-framebuffer experimental feature:
    • On Wayland: gsettings set org.gnome.mutter experimental-features "['scale-monitor-framebuffer']"
  • On X11: gsettings set org.gnome.mutter experimental-features "['x11-randr-fractional-scaling']"
@giuseppe998e
giuseppe998e / filtro-spam-unito.md
Last active May 13, 2022 14:47
Filtro Gmail che elimina automaticamente le email di spam inviate dall'Università degli studi di Torino
  1. Aprire l'inbox della mail universitaria dal browser PC
  2. Cliccare l'ingranaggio in alto a destra
  3. Cliccare su Visualizza tutte le impostazioni
  4. Selezionare Filtri e indirizzi bloccati tra le sezioni in alto
  5. Cliccare su Crea un nuovo filtro al centro della pagina
  6. Inserire il seguente codice in Contiene le parole: from:([email protected]) {(seduta {consiglio senato}) forum questionari questionario indagini indagine maratone maratona opinioni opinione elezioni elezione convegni convegno candidature candidatura scopri}
  7. Cliccare su Crea filtro
  8. Selezionare:
  • Segna come già letto (opz.)
@giuseppe998e
giuseppe998e / nixos-btrfs-tmpfs.md
Last active February 26, 2025 10:06
Install NixOS with BTRFS and IN-RAM root

Install NixOS with BTRFS and IN-RAM root

1. Format and partition the hard drive

  1. Create the GPT partition table
    • $ parted /dev/sdX mklabel gpt
  2. Create the UEFI FAT32 partition (which will be /dev/sdXY)
    • $ parted /dev/sdX mkpart esp fat32 1MiB 512MiB
    • $ parted /dev/sdX set 1 esp on
    • $ parted /dev/sdX set 1 boot on
  • $ mkfs.fat -F 32 -n UEFI /dev/sdXY
@giuseppe998e
giuseppe998e / ethwallet-generator.js
Last active December 17, 2021 20:11
Javascript function that generates an Ethereum wallet (address, pubKey and privKey) using a random private key
/**
* MIT License
*
* Copyright (c) 2021 Giuseppe Eletto <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@giuseppe998e
giuseppe998e / text-compression-test.py
Created August 9, 2021 13:18
A simple compression test of a book in TXT UTF-8 format
#!/bin/python3
import lzma
import gzip
import deflate #pip install deflate
import brotli #pip install brotlipy
# From https://www.gutenberg.org/files/1342/1342-0.txt
BOOK_NAME = "pride_and_prejudice-jane_austen.txt"
@giuseppe998e
giuseppe998e / calc_voto_triennale.py
Created June 9, 2021 18:28
Script per calcolare il voto di partenza per la laurea triennale presso il Dip.Inf. @ UniTo
#!/usr/bin/env python3
# Calcolatore della media di laurea triennale
# presso l'università degli studi di Torino
# dipartimento di informatica
#
# Questo script segue la direttiva qui di seguito:
# http://laurea.educ.di.unito.it/packages/offerta_formativa/single_pages/accreditamento/consultazione/ScaricaDocumento.php?documento=846
#
# Author: Giuseppe Eletto
# License: MIT
@giuseppe998e
giuseppe998e / xentrace_event_id.c
Last active March 26, 2021 17:08
Example of bit subdivision of an id of a XenTrace event
#include <stdio.h>
int main() {
// TRC_TRACE_CPU_CHANGE
unsigned cpu_change = 0x0001f003;
struct {
unsigned minor:12,
sub:4,
main:12,
@giuseppe998e
giuseppe998e / bitwise_32to2x16_and_viceversa.c
Last active April 30, 2021 10:10
Example of "32bit -> 2 * 16bit" and viceversa
#include <stdio.h>
/* 32bit -> 2 * 16bit */
void from32to2x16() {
int z = 0x77771010,
x = z >> 16,
y = z & 0x0000ffff;
printf(">> 32bit -> 2 * 16bit <<\n");
printf("Result 1: 0x%08x\n", x);