Bash

find the fattest files of certain type

Written by  on January 30, 2019

creates something like

Fix whitespace

Written by  on January 24, 2019

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:

(first part gives you a list of changed files and then feeds it to the script for execution)

Overview of author-activities for the git-repo

Written by  on January 16, 2019

If some ‘sophisiticated’ tool like git-stats is too cumbersome to configure, just do some git-log and shell-magic:

Ok, just noticed that git has something built-in:

from: https://coderwall.com/p/pek-yg/git-statistics-for-repo-per-author – Thanks Marcin Olichwirowicz!

keep the catcam up to date

Written by  on July 10, 2018

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.

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

Written by  on July 6, 2018

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 ..

Catcam upgraded!

Written by  on March 13, 2018


Terminator is watching you!

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 ..

Written by  on March 6, 2018

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:

executed like this, because else the output is buffered up to 4 or 8 kByte:

and the content of the textfile is something like:

backup your Raspberry Pi-sd card

Written by  on February 28, 2018

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”

Need to fake some incoming packets?

Written by  on October 26, 2017

Try Packet Sender (available for all major OS: I used the portable version for Windows as well as the AppImage for Linux (I love that AppImage-idea. Already the third OSS which was packaged like this instead of a *.deb or as pure source ..)) to emulate the sending of some UDP-datagrams to test one of my programs. And it works really neatly.
You’ve got a tidy window with some textfields for receiver, type and content, a “fire away”-button, some repeat-ability. Nice!
On the receiving end we all know Wireshark. But the emulation was (at least to me) before some big black hole.

Yes, I know, there would be as well sendip. But at work I barely could make a Cygwin work. Not to speak about some dynamic “oh, I load more packages on the fly from the internet”-possibility, meh.
But for those interested: short tutorial for sendip.

clean my code: reloaded!

Written by  on June 21, 2017

As always: some projects need a first (working) implementation and then over time you can improve them.
During lunch I was talking with a colleague about this tool. Then the idea to just use those actually changed files from the current implementation (means: the current branch in Git) shall be used as input. Et voila: consider it done!
Also added some fine-tuning to the call-parameter of the script itself, so it can be run as well with some custom string beside “todoM” (which is my marker).

Cleaning an implementation of properly tagged lines takes now a second – not minutes (like before!
Enjoy and have fun 🙂

Code can be found as always at https://github.com/marcelpetrick/cleanMyCode/blob/master/remove_todoM.sh