Raspberry Pi (rpi) – disable WiFi and/or Bluetooth

Open /boot/config.txt and add to the end of the file:

# disable wifi

# disable bt


Alternatively you can blacklist kernel modules for wifi and/or bluetooth

Create /etc/modprobe.d/raspi-blacklist.conf and copy this:

## wifi
blacklist brcmfmac
blacklist brcmutil

## bt
blacklist btbcm
blacklist hci_uart


Mail Tracking

It seems there is growing trend of tracking emails one sends. As an example, using a browser add-on – take a look at MAILTAG

They track you and your recipients and they share the collected information with you. That’s it!

What you usually get

You’ll know when your recipients will open your email and, optionally, if they clicked any link in that email you sent.

First when I heard about it, promoted by a Youtube channel that teaches web programming, it just sounded gross to me.

So I decided to write about it. I will try to describe the technique so you’ll understand what you are doing when you use such service.

How it generally works

The technique used is by inserting tracking code into sent emails. For example they would insert a transparent one pixel image with and ID parameter representing the email you are sending. This invisible image loads from their servers and they can tell when the mail was open and how many times. They’ll share that information with you.

To track links they would need to alter all of them in your sent email to point somewhere else where they can count clicks and later redirect to the original link.

They’ll know all the links from all email you sent and when your recipients clicked on them. The latter info they’ll share with you. The former you know already.

How to prevent being tracked

  • disable loading external images in all your email clients
  • don’t click on links unless you checked where they point
  • (most probably) ad blockers like uBlock Origin will block such links. This is not effective for standalone email clients
  • block mail client outgoing connections, but to the mail server
  • use mutt or alpine

Next available IP/Network with PostgreSQL

Get next available networks/IPs.
You’ll need to have a table with used networks/IPs defined similar to the one bellow.

    remote_addr CIDR NOT NULL CONSTRAINT ip_remote_addr UNIQUE

How it works

  • generates series of networks of length new_ip_mask_len inside the given ip_address/mask network and checks if they are available. This means there are no other (sub)network of the generated ones inside the ip table AND there is not a network with the same prefix (even a bigger one) @see last where clause
  • hardcoded vars are as example, use ? bind variables from your ORM instead
  • for a single IP set the mask new_ip_mask_len to 32, duh

The SQL code

SELECT new.addr FROM ( 
    WITH vars AS (
            ''::varchar ip_address, 
            '24'::integer mask, 
            '29'::integer new_ip_mask_len
    ),   vals AS (
            ( host(network((vars.ip_address || '/' || vars.mask)::inet)) || '/' || vars.mask )::cidr AS subnet,
            ( 2 ^ ( 32 - mask ) )::integer - 2  AS max,
            ( 2 ^ ( 32 - new_ip_mask_len ) )::integer AS step
        FROM vars
    SELECT set_masklen(
        (generate_series(0, max, step) + subnet)::inet,
    ) AS addr FROM vals
) AS new
    SELECT ip.id FROM ip ip 
    WHERE new.addr >>= ip.remote_addr OR host(new.addr) = host(ip.remote_addr)

AC Power Wiring colors

According to International Electrical Commission standard IEC60445:2017, for AC power the following color codes should be used.

Check if the country where you are adheres to the standard!

See also outdated IEC60446.

  • Grounding symbol = protective conductor = green/yellow
  • N = Neutral conductor = blue
  • L = AC Phase conductors
    • L1 = brown (or just L for single AC phase)
    • L2 = black
    • L3 = grey

Clean URLs with Apache httpd

a la Caddy

Caddy server let’s you easily define implicit extensions for your server URLs. Check ext directive in it’s documentation.

Get the same result in apache httpd using rewrite rules

Configuration snippet
RewriteEngine On
# Auto ext, clean URLs
# -----
# .html
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !.*\.html$
RewriteRule ^(.*)$ $1.html [NC,L]
# .php
RewriteRule ^(.*)$ $1.php [NC,L]

The story: If (1) the URI does not already end with the extension and (2) if it is not a folder with the same name and (3) if the file with the added extension actually exists, then it adds the extension

Later edit:  If the folder exists the rewriting is not done and therefore the index.html or index.php in the folder is served. If you want the file plus the added extention to have precedence over folder, comment out out the 2nd condition.

flag L|last stop processing rules after match. If you have other rules you need applied, remove it!

flag NC|nocase case-insensitive matching

Use the config snippet per VirtualHost. Or add it to your server global rewrite rules. Usually it’s the /etc/apache2/mods-enabled/rewrite.conf file. Don’t forget about RewriteOptions Inherit in your VirtualHost if you use the global configuration.

— tried and works with Apache 2.4

Byobu Tmux Screen


Function keys work by default only in byobu.

Create a new window

c-a a or F2

Move to the previous window

c-a p or F3

Move to the next window

c-a n or F4

Detach from the session and logout

c-a d or F6

Enter scrollback/search mode

c-a [  or F7

Rename the current window

c-a A or F8

Tell byobu to not set the terminal window title

You can set the title of your terminal window by running
echo -ne "\033]0;${HOSTNAME%%.*}\007"

This will set your terminal title to the hostname your are on (without domain part). Add this to your $PROMPT_COMMAND to set it automatically with every command you run.

Organize your Photos by Date Using Exiftool

Find all photos without date information

$ exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

Set last created and modified to a specific date

$ find . -name "*.jpg" | while read filename;
exiftool "-AllDates=1986:11:05 12:00:00" "$filename";

Copy of the originals will be created. Remove *.jpg_original if everything went fine or add -overwrite_original parameter.


by one year

$ exiftool "-AllDates+=1:0:0 00:00:00" .

Rename your files to contain the date and time

they will be suffixed with -N if they have the same date and time

$ exiftool '-FileName<DateTimeOriginal' -d "%Y%m%d_%H%M%S%%-c.%%e" *.jpg
$ exiftool '-FileName<DateTimeOriginal' -d "%Y-%m-%d %H.%M.%S%%-c.%%e" *.jpg

Copy your photos in a folder structure organised by datetime

exiftool '-Directory<CreateDate' -d ~/Dropbox/Photos/%Y/%y%m -r .

Git Sheet

Release (aka get the last version without the .git folder)

git archive --remote gogs@rdd.ro:liv/dotFiles.git HEAD | tar xvf -
git archive --remote gogs@rdd.ro:liv/dotFiles.git HEAD sub-folder | tar xvf

Add remote origin and set upstream to and existing git repository

git remote add origin gogs@rdd.ro:liv/dotFiles.git
git push -u origin master # set the upstream branch to master

Change remote origin

Remove the current origin and add a new one as above

git remote remove origin

Delete remote tag

git push origin --delete refs/tags/TAG_NAME

Delete remote branch

git push origin --delete refs/heads/BRANCH_NAME

See commit log and changes before merging into working copy

git fetch origin
Check the log and/or the changes
git log -p master..origin/master
git log origin/master
git merge origin/master

Log Graph

$ git log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short

My .gitconfig

name = liv
email = liv@rdd.ro
 autocrlf = input
 safecrlf = true
 whitespace = trailing-space,space-before-tab
 co = checkout
 ci = commit
 st = status --short --branch
 br = branch
 hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
 type = cat-file -t
 dump = cat-file -p
 info = remote show origin
 please = push --force-with-lease
 default = simple
 statusHints = false


ReplayGain your music using mp3gain

ReplayGain is the name of a technique invented to achieve the same perceived playback loudness of audio files. Read more on Hydrogenaudio.

Set all files to 92db – this is the most used loudness now-a-days (it’s recommended also in Serato DJ software and most streaming platforms seems to use same value). You might want to use 89db if you are listening on a Hi-Fi system – in this case just ignore the -d 3 option.

The suggested loudness is ~89, so we add 3.

mp3gain -d 3 -c -p -r *.mp3


mp3gain -s r -d 3 -c -p -r *.mp3

-s r this will ignore the replaygain information already stored in the file

-c will ignore clipping warning, use -k to lower the gain to not clip

-p preserve original timestamp of files

-r gain per track (as opposed to per album), it’s good for collections, best of, etc.

recursively apply gain to all your mp3 files

  • it works also for file names with spaces
find . -iname '*.mp3' -print0 | xargs -0 mp3gain -d 3 -c -p -r


Plain Text Messages in Apple Mail

I am a fan of plain text, so I prefer using plain text mails whenever possible. Here is how you do it for Apple Mail ( OS X El Capitan, but probably works on most versions).

Change the (default) format  for all messages:

  • go to Mail > Preferences, click Composing, then choose Plain Text as Message Format.

Change format of the current message:

  • go to Format > Make Rich Text > Make Plain Text

Reply to messages in the same format you received them:

  • go to Mail > Preferences, click Composing, then select Use the same message format as the original message

Most probably you will also want to use fixed-width font for plain text messages. So, go to Mail > Preferences > Fonts & Colors and choose Use fixed-width font for plain text messages