Various Tips and Tricks in Linux Bash

Find wireless device names:

nic=$(cat /proc/net/wireless | awk -F: '/^w/ {print $1}')

Check for internet connectivity:

nc -z 1.1.1.1 53 >/dev/null 2>&1 && echo "online" || echo "offline"

Explanation of the above command:
nc – netcat – Read and write data across networks – arbitrary TCP and UDP connections and listens.
-z Just scan for listening daemons, without sending any data to them.
1.1.1.1 – is a free Domain Name System (DNS) service by the American company Cloudflare in partnership with APNIC.
53 – is the port number associated with Domain Name System
> all standard and error output is directed to the null device
a zero response indicates success “online”, a non-zero response indicates “failure”

Stop/Start Cron Processing in Raspbian (Raspberry Pi OS)

sudo systemctl stop cron.service

sudo systemctl start cron.service

Mounting a VirtualBox Hard Drive image in Linux

I was looking for a way to access files on a Virtual Box hard drive. As usual StackExchange came to the rescue. Here is how I mounted a FreeDos virtual hard drive and gained access to the files that were on it:

sudo modprobe nbd
sudo qemu-nbd -r -c /dev/nbd1 /home/peter/VirtualBox\ VMs/Knoppix/FreeDos/NewVirtualDisk1.vmdk
sudo mount /dev/nbd1p1 /media/peter/vmdk/

Now the hard drive files are available on /media/peter/vmdk/

When done:
sudo umount /media/peter/vmdk

Live Edit of MariaDB generated table using Jquery and Bootstrap

My latest research involved the generation of a web table from a MySql/MariaDB database, with live CRUD capability (Create, Read, Update, Delete).
Key Learnings: JQuery is your friend. Bootstrap is also your friend. W3Schools is your friend. StackOverflow is your friend. Github is your friend.

With the help of all the above mentioned resources I was able to take a database of information, list it in a web page and then have options to delete records, update records, and add records. The biggest headache came with the question of how to signal a change to existing information in the listed table. An example I found on Github used the .on(blur…) functionality of JQuery but it had a bug(?) associated with it when the blur event fired multiple (an infinite number?) times. I solved the problem unsatisfactorily by changing .on(‘blur’,…) to .on(‘dblclick’…). I wanted to try avoiding mouse operations, but for now this has fixed the issue.

Update: April 1, 2023 (and this is not an April Fool)

The latest version of JQuery appears to have fixed this issue. The ‘dblclick’ references were changed to ‘blur’ references and the page appears to be working as intended.

This example on Github was particularly helpful:

https://github.com/rahmat058/Live-Table-Add-Edit-Delete-using-Ajax-Jquery-in-PHP-Mysql

Starting A Cold/Old Snowmobile

I saw this solution on Youtube and because it was simple and appeared to work, I decided to try it.

Remove the spark plug in each cylinder of a two stroke snowmobile motor. Using a turkey baster or other similar device, take a small amount of snowmobile oil and introduce it into the cylinder. Replace the spark plugs. Turn on the key, set the choke, lift the kill switch and pull. Hopefully the motor will start! It did for me in February 2016.

Now I can say that I’ve used it a few times and it works quite well.

2016 Results: Polaris – two pulls; Arctic Cat – three pulls.

2018 Results: Both machines only required a few pulls after sitting for more than a year unused.