Skip to content

Instantly share code, notes, and snippets.

View JGrossholtz's full-sized avatar

Julien Grossholtz JGrossholtz

View GitHub Profile
#!/bin/sh
#
# Play an mp3 file at start with the wifiberry-miniamp.
# Loads all necessary modules and uses ffplay (ffmpeg) to
# play the file.
#
start() {
echo "loading modules"
/*
* This file is an MPU6050 demonstration.
* https://openest.io/en/2020/01/21/mpu6050-accelerometer-on-raspberry-pi/
* Copyright (c) 2020 Julien Grossholtz - https://openest.io.
*
* 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, version 3.
*
* This program is distributed in the hope that it will be useful, but
@JGrossholtz
JGrossholtz / analyse_cpu_usage.txt
Last active September 3, 2019 16:53
Quick CPU/process consumption analysis using mpstat&top
# run mpstat and top for 5 minutes, at then end, get a loadaverage value
export DURATION=300 # run for 5 minutes
rm -rf /tmp/analysis; mkdir -p /tmp/analysis; $(timeout -t $DURATION -s2 sh -c './mpstat 1 >/tmp/analysis/mpstat.txt') & $(timeout -t $DURATION -s2 sh -c 'top -b -d1 >/tmp/analysis/top.txt') & sleep $DURATION; cat /proc/loadavg >/tmp/analysis/loadavg.txt
# Filter top output (necessary as the top binary on my embedded system lack many options)
export PROCESS_NAME=communication
cat /tmp/analysis/top.txt | grep $PROCESS_NAME | awk '{ print $7 }' | sed 's/%//g' > /tmp/analysis/top_filtered.txt
awk '{ total += $1 } END { print total/NR }' /tmp/analysis/top_filtered.txt > /tmp/analysis/top_avg.txt
cat /tmp/analysis/top_filtered.txt | sort -nr | uniq -c > /btmp/analysis/top_weighted_categories.txt
#!/bin/bash
# This script converts all the files in a given folder to a list a VAW files readable by the Horbert kid radio
var=0
for file in *.mp3 ; do
ffmpeg -i "$file" -acodec pcm_s16le -ac 1 -ar 32000 $var.WAV
var=$((var+1))
done
# Convert mp3 file to Hoerbert kid radio, copy files directly under the corresponding folders
ffmpeg -i InputFile.mp3 -acodec pcm_s16le -ac 1 -ar 32000 0.WAV
@JGrossholtz
JGrossholtz / Execute a command on filechange
Created November 19, 2018 13:44
basic example of inotify-wait usage to recompile code when any file is changed
# Install the inotifywait package, on Fedora:
$ sudo dnf install inotify-tool
# Run inotify-wait on a loop
while true; do inotifywait -e modify -r <folder to watch>; < curstom ; commands> ; done
# eg: recompile a progam when a file is changed:
while true; do inotifywait -e modify -r sources/; make clean; make;done
@JGrossholtz
JGrossholtz / t460_battery.sh
Created October 22, 2017 04:41
Script that calculates average battery percentage for a laptop with 2 batteries
#!/bin/sh
# This script can be used to determine the average load of 2 batteries
# It requires the acpi command.
battA=$(acpi | grep "Battery \0" | cut -d" " -f 4 | sed "s/[^0-9]//g")
battB=$(acpi | grep "Battery 1" | cut -d" " -f 4 | sed "s/[^0-9]//g")
avg=$((($battA+$battB)/2))
I had this issue with Qt Creator 4.1 on Fedora 25:
SSH connection failure: Botan library exception: No object identifier found for secp521r1
It seems to be realted with an internal QtCreator library. The easyest solution seems to remove the QtCreator package and to install it
with QtCreator installer:
http://download.qt.io/official_releases/qtcreator
@JGrossholtz
JGrossholtz / modbus_rs232_master_client.c
Last active November 29, 2023 02:55
A sample libmodbus client / server (master/slave) using RS232 to request data from a modbus client (tested with libmodbus3.0.6)
#include <stdio.h>
#include <unistd.h>
#include <modbus.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/serial.h>
#include <asm/ioctls.h>
#define NB_REGS 2
@JGrossholtz
JGrossholtz / i3config
Last active September 26, 2017 19:25
My .i3/config
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout somewhen, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!