Skip to content

Instantly share code, notes, and snippets.

View danielecr's full-sized avatar
🐢
stay quite

Daniele Cruciani danielecr

🐢
stay quite
View GitHub Profile
@danielecr
danielecr / edit_uefi.md
Created August 18, 2026 09:58
uefi: edit da OS Linux

Sì, per la procedura standard tramite BIOS serve un monitor e una tastiera. Tuttavia, se sul tuo Mini PC è installato Linux, puoi modificare questa impostazione direttamente dal sistema operativo senza riavviare, sfruttando i tool nativi del kernel. Nei PC moderni, i parametri del BIOS non sono memorizzati in una vecchia EPROM, ma in una memoria NVRAM accessibile tramite l'interfaccia UEFI. Linux espone queste variabili nel filesystem, permettendoti di leggerle e modificarle. Ecco i passaggi per farlo da terminale Linux.

1. Installare lo strumento per le variabili UEFI

Devi installare efibootmgr, uno strumento standard che permette di interagire con le variabili del firmware UEFI.

  • Su Ubuntu / Debian / Linux Mint:

sudo apt update && sudo apt install efibootmgr

@danielecr
danielecr / Logger.php
Last active June 25, 2026 13:28
Logger.php
<?php
// Logger class
// see https://medium.com/@WC_/the-ultimate-guide-to-building-a-robust-logging-system-in-php-from-concept-to-deployment-05d46ac5800e
class Logger
{
const INFO = 1;
const WARNING = 2;
const ERROR = 3;
private static $logFilePath;
@danielecr
danielecr / wait-prompt.js
Created May 11, 2022 08:07
await for the prompt question
const readline = require('readline');
const waitPrompt = (line) => new Promise((resolve,reject) => {
const handle = (msg) => (err) => {
//console.log(msg, err);
reject(err);
}
const d = require('domain').create();
d.on('error', handle("ERROR"));
@danielecr
danielecr / get-all-paths.js
Created May 10, 2022 16:20
find all path in a digraph
// find list of all paths in a digraph defined by a set of edges
// create a list of candidates.
// repeat until is not stable:
// for each edge: try to extends the candidate: at the end, at the begin
// after first turn, also split paths if necessary
// if a whole edge turn is stable, break the loop.
// Complexity: enough
let edges = [];
@danielecr
danielecr / src_data.txt
Created December 11, 2019 16:55
Some code to show events in stream
example text data to copy from
execute
> node stream-to-target.spec.js
to read:
"""
read stream end
write stream finish ./tgt_data.txt
read stream close
@danielecr
danielecr / problem1.txt.md
Created August 29, 2019 19:55
eventloop based async programming patterns

There are patterns for solving async tasks. Not just promise vs callback. Real problems and real patterns

Problem example 1.

Send messages to a service that give reply async, store data into an array of promises, solve all promises at the end. Additional constraint: the number of message that could be sent to the service is limited, and the only way to test if the limit is reached is to catch an exception on failed sent.

i.e.

@danielecr
danielecr / testTimer-wrong.php
Created August 29, 2019 13:33
tricky timer in reactphp
<?php
require_once 'vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$context = new React\ZMQ\Context($loop);
$timer = $loop->addPeriodicTimer(20, function() use($timer) {
global $loop;
echo "is executed\n";
@danielecr
danielecr / zmq-client.js
Created July 31, 2019 19:31
Compare node with reactphp
const zmq = require('zeromq-stable');
const messageToJson = (request) => {
try {
return JSON.parse(request.toString());
} catch (err) {
return { error: {msg: 'error while parsing', detail: err.toString}}
}
}