Linux
Fix whitespace
Sometimes there is too much whitespace and tabs in my last commit.
In former times I used a VisualStudio-plugin, but this is not helpful there. So I wrote a small script (see on my github) which:
β’ replaces all tabs with four spaces
β’ removes all trailing whitespace
β’ converts line-endings to CRLF
I invoke it on the list of all changes files in my last commit in the git-repo with:
1 |
$ git diff --name-only HEAD~1 HEAD | xargs -L1 ../removeTrailing.sh |
(first part gives you a list of changed files and then feeds it to the script for execution)
keep the catcam up to date
Logging in to the raspberry(ies) to update them on a regular basis takes time and effort. Both are currently dear.
Also: while the catcam is taking pictures, you can’t update the rpi-binaries.
So I made this nice script, which first suspends the catcam-operation while renaming the script from the cronjob, then does all updates, reverts the renaming and then reboots the MCU.
1 2 3 4 5 6 7 8 9 10 11 |
#!/usr/bin/env bash # author: Marcel Petrick (mail@marcelpetrick.it) mv /home/pi/Desktop/webcam/regulargif.sh /home/pi/Desktop/webcam/regulargif.sh1 sudo rpi-update sudo apt-fast update && sudo apt-fast dist-upgrade -y sudo apt-get autoclean sudo apt-get autoremove mv /home/pi/Desktop/webcam/regulargif.sh1 /home/pi/Desktop/webcam/regulargif.sh sudo reboot |
Make it executeable via ‘sudo chmod +X updateCatcam.sh’ and also add it as cronjob (once a day).
rsync: get all files from the camera’s sd-card .. without interruption
1 |
rsync -avzr --progress /media/tanteedith/4C26-6BEF/DCIM/ /home/tanteedith/digikamArchive/ |
Of course, you need the same source- and target-directory π
Using this, because Nautilus (or how that horrible explorer is called) is prone to auto-unmounting the card while transfer due to heavy load ..
backup often, backup early: Duplicati
I wanted an open source-solution which allows to backup locally and remote certain directories (or whole PC). I found some month ago duplicati and used it for good at work, where it currently backups the content of the whole SSD-partitions to some interal hard disk (not the most secure backup, I know. But given to the constraints still better than no backup at all.)
At home the content of the two home-directories (Linux) is transferred to a shared folder on the Synology-NAS.
duplicati on wikipedia // code under GNU LGPL
I can just repeat: working without a backup is the best path to failure.
In my history as “computer technician” I have ruined several drives and especially when you just want to do a default, simple operation (*cough* move a partion on a hard drive *cough*), everything fails and there is no way to revert back to the original state. Never again π
Cullendula
Small program to pick out the best shots of the vast amount of taken pictures per session (excursion). The name itself is a wordplay of the plant Calendula and the activity “to cull” (slang for sorting the photos).
url for the repository: https://github.com/marcelpetrick/Cullendula/
development time for fully usable version 0.1: one day
used technologies: C++ and Qt – my favorite ones <3
netdata for monitoring several (headless) Raspberries
I had netdata already recommended once two years ago, but .. it was quite helpful to track down the issue with the camera on the catcam-raspberry. Yes, of course I could login via SSH or VNC and then manually check if it is still running, or just call “catcam:19999” in the browser.
Install on Raspbian Jessy via:
1 |
bash <(curl -Ss https://my-netdata.io/kickstart.sh) |
Catcam upgraded!
Finally! The old catcam-setup of a RPi 3 with a NoIR v2.1-camera was working for almost one and ahalf years without any issues. I’ve had improved the PiCamGifForTumblr-script several times, also changed location – never any issues. More than 40.000 GIF were uploaded.
But then I decided to buy a new, fancy case in black (of course) which should add some camera-support. And then two weeks afterwards it stopped working. Sporadically frozen. Sometimes 10 min after start, sometimes during the night. I checked the casing, if all power connectors were tightly fit, I installed netdata on it, I did longterm temperature-measurements (never over 54 Β°C even with closed case), I ran with minimal setup or with cam attached.
Then it became clearer: the camera was working for singleshot-mode, but for the 30 pictures every ten minutes, it broke. So, it was time to order a new camera, 1080p (5 MPixel) were enough, but for four more Euro I could get two IR-illuminators … so, why not? The focal distance of the objective is adjustable, it looks like it works (long time-test needed). But I am happy. And we can watch cats (and family) in darkness :3
tracking bugs in complex systems ..
Some weeks ago I’ve replaced the case of the ‘catcam’. A Raspberry Pi 3 which was running for 1.5 years without interruption with the nice script & python-upload triggered by a cronjob. And now the device freezes. Still running, but neither accessible via SSH nor VNC (of course, if SSH is not working ..).
I left the case open; removed the camera; upgraded kernel and Raspbian: nothing helped.
My last guess is that the camera stopped working. But to be sure I want to let the RPi3 long-time with temperature-logging. So … we need a simple program:
1 2 3 4 5 6 7 8 9 10 |
import os import time def measure_temp(): temp = os.popen("vcgencmd measure_temp").readline() return (temp.replace("temp=","")) while True: print(time.ctime() + " ## " + measure_temp()) time.sleep(1) |
executed like this, because else the output is buffered up to 4 or 8 kByte:
1 |
$ stdbuf -oL python temperature.py > worstLoggingEver.txt |
and the content of the textfile is something like:
1 2 |
Tue Mar 6 22:52:59 2018 ## 51.5'C Tue Mar 6 22:53:00 2018 ## 52.1'C |
backup your Raspberry Pi-sd card
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
tanteedith@miniPC ~/ $ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdb 8:16 1 29G 0 disk ββsdb2 8:18 1 1K 0 part ββsdb7 8:23 1 27,3G 0 part /media/tanteedith/root ββsdb5 8:21 1 32M 0 part /media/tanteedith/SETTINGS ββsdb1 8:17 1 1,1G 0 part ββsdb8 8:24 1 512M 0 part /media/tanteedith/data ββsdb6 8:22 1 66M 0 part /media/tanteedith/boot sda 8:0 0 119,2G 0 disk ββsda2 8:2 0 7,7G 0 part [SWAP] ββsda3 8:3 0 81,1G 0 part /home ββsda1 8:1 0 30,5G 0 part / tanteedith@miniPC ~/ $ sudo dd bs=4M if=/dev/sdb of=catcam.img 7416+0 records in 7416+0 records out 31104958464 bytes (31 GB) copied, 2794,33 s, 11,1 MB/s tanteedith@miniPC ~/ $ |
Newer versions (8.24+) of coreutils dd have also a progress-option, but not the one bundled with the current distribution ..
add param: “status=progress”
banner generator: figlet (online)
Ok, most of the times your classes and functions shall be commented.
So, let us decorate a bit: your wish shall be my command π
I had just remembered the good old toolkit to generate banners!
url: http://patorjk.com/software/taag/
1 2 3 4 5 6 7 8 9 10 11 |
// // 88888888ba 88 // 88 "8b ,d ,d 88 // 88 ,8P 88 88 88 // 88aaaaaa8P' ,adPPYba, ,adPPYba, MM88MMM ,adPPYba, ,adPPYba, 88,dPYba,,adPYba, 88,dPYba,,adPYba, ,adPPYba, 8b,dPPYba, MM88MMM ,adPPYba, 8b d8 ,adPPYba, 8b,dPPYba, 88 // 88""""""8b, a8P_____88 I8[ "" 88 a8" "" a8" "8a 88P' "88" "8a 88P' "88" "8a a8P_____88 88P' `"8a 88 a8P_____88 `8b d8' a8P_____88 88P' "Y8 88 // 88 `8b 8PP""""""" `"Y8ba, 88 8b 8b d8 88 88 88 88 88 88 8PP""""""" 88 88 88 8PP""""""" `8b d8' 8PP""""""" 88 "" // 88 a8P "8b, ,aa aa ]8I 88, "8a, ,aa "8a, ,a8" 88 88 88 88 88 88 "8b, ,aa 88 88 88, "8b, ,aa `8b,d8' "8b, ,aa 88 aa // 88888888P" `"Ybbd8"' `"YbbdP"' "Y888 `"Ybbd8"' `"YbbdP"' 88 88 88 88 88 88 `"Ybbd8"' 88 88 "Y888 `"Ybbd8"' "8" `"Ybbd8"' 88 88 // // |