Skip to content

Instantly share code, notes, and snippets.

View giuseppe998e's full-sized avatar

Giuseppe Eletto giuseppe998e

View GitHub Profile
@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:(avvisi@unito.it) {(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 / 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 / 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 / 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 / dead-simple-js-calculator.html
Last active June 25, 2022 10:08
A dead simple calculator written in HTML, CSS and pure JS.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dead simple JS Calculator</title>
<style>
body {
background-color: whitesmoke;
margin: 0;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<title>base64 + lzma + iframe</title>
<style>iframe{position:absolute;top:0;left:0;height:100vh;width:100%;border:none}</style>
</head>
<body>
<iframe sandbox="allow-same-origin allow-downloads allow-scripts allow-forms allow-top-navigation allow-popups allow-modals allow-popups-to-escape-sandbox"></iframe>
@giuseppe998e
giuseppe998e / twitchchatreader.js
Last active August 4, 2022 07:34
An IRC WebSocket client that reads Twitch channel chat without the need to authenticate
/**
* MIT License
*
* Copyright (c) 2022 Giuseppe Eletto <giuseppe@eletto.me>
*
* 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 / media_rename.py
Created July 16, 2022 14:03
A Python3 script that asynchronously renames files (media) in a directory
#!/usr/bin/env python3
# Copyright 2022 Giuseppe Eletto <giuseppe@eletto.me>
#
# 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
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@giuseppe998e
giuseppe998e / trait_test.php
Created October 26, 2022 23:12
Test of PHP traits behavior using "self" and "static" keywords
<?php declare(strict_types = 1);
// Tried on PHP 8.0.25
// Trait
trait TestTrait {
public static function spawnSelf(): self {
return new self();
}
public static function spawnStatic(): static {
@giuseppe998e
giuseppe998e / nge.rs
Last active December 14, 2022 19:29
"Next Greater Element" and "Previous Greater Element" arrays using stack in Rust - Complexity O(n)
fn next_greater_elems<T: Copy + PartialOrd>(array: &[T]) -> Box<[Option<T>]> {
let array_len = array.len();
let mut stack = Vec::<usize>::with_capacity(array_len);
let mut result = Vec::<Option<T>>::with_capacity(array_len);
stack.push(0);
result.push(None);
for (index, element) in array.iter().enumerate().skip(1) {
result.push(None);