Bash

SSH/SCP quick help

Written by  on October 17, 2019

Challenge was to reconfigure a device, which has a Linux running on a TQ-board. Some files had to be adjusted.

Connect to the device:

(Then enter password.)

List amount of free space:

Show target of symlink:

how to resume broken downloads

Written by  on April 24, 2019

aka: fix the weird firewalling settings ..
aka: How to download the latest stable Qt SDK source code?
curl -L -O -C - http://download.qt.io/official_releases/qt/5.12/5.12.3/single/qt-everywhere-src-5.12.3.zip

cmd replacement: cmder

Written by  on March 29, 2019

Sometimes you have to call some batch-files with spoecific windows-tools, so a bash is not helpful on Win.
A colleague recommended cmdr, which is quite nice and fine.
Suits my needs 🙂

advanced whitespace-correction

Written by  on February 26, 2019

(for CMake/C++-projects)

Find all fitting files and run the fixer-script in parallel over it.

After playing for a while with sed and awk and not being able to get a fitting solution, I decided to create my own as python-script. It squashes all consecutive double-whitespace-lines (and adds one to the end if missing).

Sources:
removeTrainling.sh
squashMultipleWhitespace.py
get GNU parallel (developed by Ole Tange):

Pick a random reviewer

Written by  on January 30, 2019

Most teams have a certain code-review-process. But most of the time there is no “round robin”-implementation who will be the reviewer, but the coder itself should select the reviewer. Because of domain-knowledge, etc. And then you her lots of times “I am currently busy. Not me!”

Solution: random and fair selection via bash.

Current version of the script can be found at: https://github.com/marcelpetrick/bashCollection/blob/master/randomReviewer.sh

Inspired by a stack-overflow answer.

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