BSODs Notebook

Linux admin stuff and other shenanigans

Some Random Snippets

This area contains just some short snippets / one-liners or configuration tricks I wrote down for later...

Git Tricks

disable Proxy for single repository

When everything needs to go over a proxy server except that one internal repository

git config http.proxy ""

ten minutes ago this was still working

git checkout master@{"10 minutes ago"}

One Line Python Webserver

Python 2.x:

python -m SimpleHTTPServer $PORT

Python 3.x:

python -m http.server $PORT

RAW File Cleanup Scripts

This is a Bash Script to remove JPEG Files when the corresponding RAW is present. Useful when shooting RAW+JPEG and needing the Space afterwards.

#!/bin/bash
read -p "please enter file suffix for raw format (e.g ORF, NEF, CR2): " suffix

find . -type f -iname "*.${suffix}" | \
while read line
do
  lowercase=$(echo "$line" | sed "s/${suffix}/jpg/gi")
  uppercase=$(echo "$line" | sed "s/${suffix}/JPG/gi")

  if [ -f "${lowercase}" ]
  then
    rm -v "${lowercase}"
  elif [ -f "${uppercase}" ]
  then
    rm -v "${uppercase}"
  else
    echo "${line}: no jpg present"
  fi
done

Transcode FLAC Files

A small script I wrote to transcode my flac files to mp3 or ogg files for my portable audio player.

Don’t do this to your primary FLAC archive because it removes the FLAC files after conversion and you will probably not like that.

cpu_cores=4
find . -iname "*.flac" -print0 | xargs -0 -P ${cpu_cores} -I % sh -c 'oggenc -q 5 "%" && rm -vf "%"'

or with ffmpeg:

cpu_cores=4
find . -iname "*.flac" -print0 | xargs -0 -P ${cpu_cores} -I % sh -c 'ffmpeg -i "%" -c:a libmp3lame -q:a 2 "%.mp3" && rm -v "%"'