Command line

Only Windows makes this mess (OneDrive)

When taking a hard drive containing OneDrive folders out and mounting it as a secondary drive, some files in the OneDrive folders might be “online only” or to be “downloaded on demand”. On that disk, which is disconnected from the OneDrive account, all the files will be there (until disconnected) but not accessible.
The inaccessible files can be detected by the “dir” command, giving the file sizes in parentheses.
One option to clean out the mess made by disconnecting the OneDrive disk is to just delete the whole old OneDrive folder, if you are sure there’s nothing there you want to keep (you files should be stored online).
If you want to be safe, keeping all the files that are available offline in the folder, you need to get rid of the “placeholder” files in there.
This is how I did, it might or might not work for you (always be careful when deleting files).
First, I removed all files in my Pictures (automatic sync from camera) folder with a block size of zero:
stat -c "#rm%brm %n" * | sed 's/#rm0rm/rm/g' >rmscript
./rmscript

I decided it was too much work to use that method for doing all directories recursively inside the OneDrive folder, so for the rest of the online-only files I used another method.
For this, I used the “file” command which gave an error for the inaccessible files “(Invalid argument)”:
find . -type f -exec file {} >>filinfo \;
grep "(Invalid argument)" filinfo >offlinefiles
sed "s;\./;rm './;g" offlinefiles >offlinefiles2
sed "s;: ERROR: ;' #;g" offlinefiles2 >offlinefiles3

What this does is creating a list of all the files starting from the current directory. The next command filters out the lines with the error “(Invalid argument)”. As the names in the list begins with “./”, this is then replaced with “rm ./”, creating commands to remove all the files which was filtered out in the previous command.
I then replace ” ERROR” with a hashtag to tell shell to ignore the rest of the line (“#” starts a comment, if you didn’t know).
Double check the “offlinefiles3” before executing it.

UNIX

The most of the commands below are also valid for Windows 10, since Microsoft invented Ubuntu and bash in 2016.

Mounting CD images on Linux

mount /path/to/cdimage.iso /mnt/cdmount -o loop,ro

Mounting .bin / .cue files on Linux
Is not possible, but the .bin and .cue can be converted to .iso as follows using ‘bchunk’ (Binchunker):

sudo apt-get install bchunk
bchunk cdimage.bin cdimage.cue output

Compare the Contents of Two Folders with the Diff Command
https://lifehacker.com/compare-the-contents-of-two-folders-with-the-diff-comma-598872057

rsync
Can I make rsync output only the summary?
summary only in output

awk
Print Column – Change Field Separator – Linux Bash
https://www.shellhacks.com/awk-print-column-change-field-separator-linux-bash/
Remove line break
https://serverfault.com/questions/391360/remove-line-break-using-awk

grep getting confused by filenames with dashes
https://unix.stackexchange.com/questions/364922/grep-getting-confused-by-filenames-with-dashes

HEX dump a file
http://www.theunixschool.com/2011/06/3-different-ways-of-dumping-hex.html

Exclude directory using tar
https://www.linuxquestions.org/questions/linux-software-2/tar-exclude=directory-455908/

Moving and renaming files

Rename files, replace spaces with underscore
https://unix.stackexchange.com/questions/405085/rename-files-to-change-spaces-to-underscore

for file in *.doc *.mp3 *.wav *.txt
do
  mv -- "$file" "${file// /_}"
done

More mass-renaming of files
If you, for example use some program to split a PDF document into single-page files, and that program does not name the files as you want, as in resultig files named as: p_Part_1.pdf, p_Part_2.pdf … p_Part_10.pdf, p_Part_11.pdf … p_Part_100.pdf, p_Part_101.pdf …
The PDFill PDF Editor (tools) does stupid naming like this (you have to supply at least one letter for the file names, and “_Part_” is appended).
Correct naming could be possible by using ‘convert’ from the imagemagick package, but when I tried, the PDFs got large and/or in low quality (converted to images and then back to PDF).

for file in *.pdf; do mv -- "$file" "${file//p_Part_/}"; done
for file in ?.pdf; do mv -- $file 00$file; done
for file in ??.pdf; do mv -- $file 0$file; done

The following search and replace is related to above, but can be used for other purposes:

Search and replace filenames in a text
Add leading zeroes to short numerical filenames (1.pdf = 001.pdf, 10.pdf = 010.pdf)

sed -E 's%/([0-9][0-9]).pdf%/0\1.pdf%' source.1  >source.2
sed -E 's%/([0-9]).pdf%/00\1.pdf%' source.2  >source.1

Another multi-step renaming I did
This time, I renamed the output files from Wondershare Video Converter, in this specific case the DVDs from “The Amiga Years”.
The converted files were in this case named lika:
THE_AMIGA_YEARS_D1_Title_01_02.mp4
THE_AMIGA_YEARS_D1_Title_02_01.mp4
THE_AMIGA_YEARS_D1_Title_03_01.mp4
..
THE_AMIGA_YEARS_D1_Title_03_10.mp4

and
THE_AMIGA_YEARS_D2_Title_02_01.mp4
..
THE_AMIGA_YEARS_D2_Title_02_16.mp4

I also made converted files with the subtitles, and these were named as usual with windows, appending ” (2)” at the end of the filename:
THE_AMIGA_YEARS_D1_Title_03_10 (2).mp4

First step: decide on how you want the files named
I want my file names short, keeping the disc, track and chapter numbers, later appending (manually) the title of the track, so in case for DVD1:
D1.03.02.mp4
D1.03_02 (sub).mp4

When manually adding titles, I will append ” – title”:
D1.03.02 – David Pleasance – Releasing The Amiga CD32 (sub).mp4*
D1.03.02 – David Pleasance – Releasing The Amiga CD32.mp4*

The renaming process:
Be careful when working on your files. Always use a simple echoing command first to determine what will be done.
The common part of the file names for DVD1 is “THE_AMIGA_YEARS_D1_Title_”, and according to my naming goals, that part should be replaced by “D1.”:

for file in THE_AMIGA_YEARS_D1_Title_*.mp4; do echo -- "$file" "${file//THE_AMIGA_YEARS_D1_Title_/D1.}"; done

This will shorten the file names to:
D1.03_10.mp4
D1.03_10 (2).mp4

This next renaming step will replace “(2)” with “(sub)”:

for file in D1.*\(2\).mp4; do mv -- "$file" "${file//(2)/(sub)}"; done

The last step will replace the underscore ‘_’ with ‘.’:

for file in D1.03_*.mp4; do mv -- "$file" "${file//_/.}"; done

Move finished downloads out of the downloads folder
Automatically move finished downloads of specific size (larger than) or any other criteria out to a mounted network drive with more space:

(windows steps)
Mount the share as usual and take note of the drive letter (in the example “S”)

(windows-Ubuntu shell steps)

mkdir /mnt/s
mount -t drvfs S: /mnt/s

The script (edit as suitable) to move the files out of downloads (my script is in the downloads drawer, which is also the cwd):

cd /mnt/c/Users/user-name/Downloads

Find any zip-files, larger than about 20MB, not altered in 30 minutes

#!/bin/sh
find . -type f -mmin +30 -name "*\.zip" -size +20000000c -exec mv {} /mnt/s/downloads/ \;

Run this whenever you want to move files, or automate it as follows:

while true; do date;./move-downloads.sh; sleep 300; done

(Scan for new files to move every 5 minutes)

Finding files

Find directories containing matching files

find . -iname "*.pdf" -exec dirname {} \; | sort | uniq

Find the latest modified file(s) in a directory
https://unix.stackexchange.com/questions/240418/find-latest-files

To print the last 3 accessed files (sorted from the last accessed file to the third last accessed file):

find . -type f -exec stat -c '%X %n' {} \; | sort -nr | awk 'NR==1,NR==3 {print $2}'

To print the last 3 modified files (sorted from the last modified file to the third last modified file):

find . -type f -exec stat -c '%Y %n' {} \; | sort -nr | awk 'NR==1,NR==3 {print $2}'

Find files NOT matching search pattern
Simple.. use -not with the ‘find’ command:

find . -type f -not -name *html

Remove Apache-generated indexes after wget -m

find . -type f -name "index.html\?C=?;O=?" -exec rm {} \;

Finding IN files

Use ‘grep’
Finding files which does not match search pattern (use ‘grep -L’, as inverse for ‘grep -l’)

FreeBSD

Periodic – using it to run shell scripts
http://www.freebsddiary.org/periodic.php

4.5. Using the Ports Collection
https://www.freebsd.org/doc/handbook/ports-using.html

Internet radio with Linux

Internet Radio Players for Linux
http://www.webupd8.org/2017/02/5-cool-internet-radio-players-for-linux.html

MOC – Music on Console
http://moc.daper.net/

Raspberry Pi Headless Internet Radio and Audio Player (updated)
https://www.raspberrypi.org/forums/viewtopic.php?t=43108

Raspberry Pi Internet Radio Tutorial (MPD + 20×4 LCD)

Curseradio
https://github.com/chronitis/curseradio

HTML & CSS

Everything You Need to Know About HTML’s ‘pre’ Element

CSS selector last row from main table
https://stackoverflow.com/questions/16010791/css-selector-last-row-from-main-table

Google search – “html5 canvas layers transparency”
https://www.google.se/search?q=html5+canvas+layers+transparency

Tutorial: How To Style the HTML 5 Audio Player
https://serversideup.net/style-the-html-5-audio-element/

Play local video file with HTML5
https://jsfiddle.net/dsbonev/cCCZ2/

Use Fetch as Google for websites
https://support.google.com/webmasters/answer/6066468?hl=en

hreview-examples
http://microformats.org/wiki/hreview-examples

PDF from every page of website
https://mpdf.github.io/real-life-examples/pdf-from-every-page-of-website.html

Google: php add protection to existing pdf
https://www.google.se/search?q=php+add+protection+to+existing+pdf

Custom colored Bootstrap button
https://codepen.io/anon/pen/RdBqbY
http://blog.koalite.com/bbg/

Styling checkboxes
https://stackoverflow.com/questions/49355676/trying-to-change-color-of-custom-checkbox-label-when-checked-css-only

Text
Background
Border (darken background 10%)
Active (darken background 7.5%)

dd-wrt for Linksys wrt3200acm

Check here if your router is supported (wrt3200acm is)
https://www.dd-wrt.com/site/support/router-database

Installing and upgrading
https://www.dd-wrt.com/wiki/index.php/Installation
https://www.dd-wrt.com/phpBB2/viewtopic.php?t=310943&sid=5cfc85d3b1f6b9470ceffdb4d713bd1a
https://www.dd-wrt.com/phpBB2/viewtopic.php?p=1086369&sid=bcebf05e8b74e0e1a6b43d84b27501cf
https://www.dd-wrt.com/phpBB2/viewtopic.php?t=305228&postdays=0&postorder=asc&start=45

Firmware FAQ
https://www.dd-wrt.com/wiki/index.php/Firmware_FAQ
Download locations:

  • https://download1.dd-wrt.com/dd-wrtv2/downloads/betas/2018/
  • ftp://ftp.dd-wrt.com/betas/2018/
  • ftp://ftp.dd-wrt.com/betas/2018/

IVS Grandslam / Trumpcard Professional

Overview, collection of articles, and since December 2018 the manual
http://www.stone-oakvalley-studios.com/0009_21_dashboard_index.php

IVP TrumpCard 2000 (Not PRO), driver disk needed
http://eab.abime.net/showthread.php?t=35685

A2000 question, IVS Grandslam / Trumpcard Pro
http://www.amiga.org/forums/archive/index.php/t-64315.html

A500 + Grandslam won’t autoboot
http://www.amiga.org/forums/archive/index.php/t-22640.html

Trumpcard 500 not working
http://www.amiga.org/forums/archive/index.php/t-70432.html

SCSI accessories (adapters, cables, terminators)
https://www.ramelectronics.net/SCSI.aspx