Skip to content

Instantly share code, notes, and snippets.

View JGrossholtz's full-sized avatar

Julien Grossholtz JGrossholtz

View GitHub Profile
# My basic i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
colors = true
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 / 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!
@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))
@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
# 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
#!/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
@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/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"
@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