Skip to content

Instantly share code, notes, and snippets.

View davlgd's full-sized avatar

David Legrand davlgd

View GitHub Profile
@davlgd
davlgd / index.js
Created March 7, 2024 22:07
Node.js 21.7.0 features demo
// This is a quick Node.js 21.7.0 new features demo
// Update Node.js to 21.7.0 to run this code
// You can use nvm or Volta to sideload it
// Run this file with: node index.js
const { styleText } = require('node:util');
const { parseEnv } = require('node:util');
const { loadEnvFile } = require('node:process');
const crypto = require('node:crypto');
const fs = require('node:fs');
@davlgd
davlgd / main.v
Created November 3, 2023 22:32
V recursive struct demo app
module main
struct Directory {
name string
subs []Directory
files []string
}
// Prints the directory structure recursively
fn print_directory(dir Directory, level int) {
@davlgd
davlgd / bench-sdx.sh
Last active February 27, 2024 23:36
Benchmark HDD in batch using ioping
#!/bin/bash
if ! command -v ioping &> /dev/null; then
echo "Error: ioping is not installed."
exit 1
fi
root_disk=$(df / | grep '/' | awk '{print $1}' | sed 's/[0-9]*//g')
disks=$(ls /dev/sd* | grep -E "/dev/sd[a-z]$" | grep -v "$root_disk")
@davlgd
davlgd / spinner.sh
Created August 20, 2023 22:20
Spinner for Shell commands
#!/bin/bash
spinner() {
local pid=$1
local delay=0.1
local spinstr="⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"
local i=0
local len=${#spinstr}
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
i=$(( (i+1) % len ))
@davlgd
davlgd / dmisysinfo.sh
Created August 14, 2023 08:35
This script retrieves and displays information about the system's CPU, motherboard, and memory through DMI Decode
#!/bin/bash
display_help() {
echo "Usage: $0 [option]"
echo
echo "This script retrieves and displays information about the system's CPU, motherboard, and memory through DMI Decode."
echo
echo "Options:"
echo " --help Display this help message and exit."
echo
@davlgd
davlgd / gist:9d88dbc95d2626495310d3ff6adec963
Created January 25, 2023 13:15
Remove .DS_Store files globally from git in macOS
echo .DS_Store >> ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
@davlgd
davlgd / openssl.sh
Created November 19, 2021 20:37
OpenSSL Benchmark
openssl speed rsa4096 2>/dev/null | grep 'rsa 4096 bits' | awk '{print "1T : "$6" s/s | "$7" v/s"}' && openssl speed --multi $(nproc) rsa4096 2>/dev/null | grep 'rsa 4096 bits' | awk '{print "nT : "$6" s/s | "$7" v/s"}'
@davlgd
davlgd / fio.sh
Last active January 3, 2023 09:28
fio benchmark script
#!/bin/bash
IO_ENGINE=$1
TESTS=$2
TARGET=$3
SIZE=$4
launch () {
sudo fio --name=test --group_reporting --ioengine=$1 --disable_clat=1 --disable_slat=1 --percentile_list=0 --norandommap=1 --randrepeat=0 --direct=1 --rw=$2 --bs=$3 --size=$4 --iodepth=$5 --numjobs=$6 --filename=$7 | grep avg=
}
@davlgd
davlgd / rb.sh
Last active November 14, 2021 08:40
Redis benchmark script
#!/bin/bash
REQUEST=5000000
SIZE=3
if [ $1 == "--help" ]
then
echo "Usage : ./rb.sh [requests] [block]"
echo
echo " requests : how many to use during performance testing (default : 5000000) "
@davlgd
davlgd / nvmeTarget.sh
Last active November 2, 2021 17:04
NVMe/TCP Target Creator
#!/bin/bash
# On affiche les informations sur les modules NVMe
clear
echo
echo "Module NVME_TARGET de votre noyau :"
echo "==================================="
echo
cat /boot/config-`uname -r` | grep NVME_TARGET