Skip to content

Instantly share code, notes, and snippets.

View giuseppe998e's full-sized avatar

Giuseppe Eletto giuseppe998e

View GitHub Profile

Keybase proof

I hereby claim:

  • I am giuseppe998e on github.
  • I am peppe (https://keybase.io/peppe) on keybase.
  • I have a public key ASBBNqjBQjelWJ8BP99gS3SnE6uyypUsh6QtLciG1XPU5Ao

To claim this, I am signing this object:

@giuseppe998e
giuseppe998e / Dockerfile
Last active September 26, 2021 23:16
Docker Alpine MurMur (Mumble Server) with persistence | Works on RPI (3B tested)
FROM alpine
LABEL maintainer="Giuseppe Eletto <[email protected]>"
# Setup environment
RUN adduser -DHs /sbin/nologin murmur \
&& apk update \
&& apk upgrade \
&& apk add murmur \
&& rm -rf /var/cache/apk/*
@giuseppe998e
giuseppe998e / fliter.js
Last active March 23, 2021 21:33
5 Lines Iterator JS
// Five Lines Iterator [ fliter (╥﹏╥) ]
const fliter = (a, p = 0) => ({
hasNext: () => p < a.length,
next: () => a[p++],
remove: () => a.splice(--p, 1)
})
/* Minified
* const fliter=(a,p=0)=>({hasNext:()=>p<a.length,next:()=>a[p++],remove:()=>a.splice(--p,1)})
*/
@giuseppe998e
giuseppe998e / aay.js
Last active September 15, 2021 07:53
Academic Year generator in JS (Start from October)
const academicYear = (firstMonth = 8) => {
const date = new Date(),
year = date.getFullYear(),
start = date.getMonth() > firstMonth
return `${year - !start}/${year + start}`
}
/* const academicYear=(firstMonth=8)=>{const d=new Date(),y=d.getFullYear(),s=d.getMonth()>firstMonth;return `${y-!s}/${y+s}`} */
console.log(`Academic Year: ${academicYear()}`);
@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);
@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 / 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 / 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 / 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 / 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