Ever wondered why programming in Bash is so difficult? Bash employs the same constructs as traditional programming languages; however, under the hood, the logic is rather different.
I knew that day that the Shortcuts app has paved the way for automation in iPhone, but I didn’t realize that it can also be used to keep a track on the proliferating police abuse.
Source: This Siri Shortcut Automatically Triggers Camera Every Time Cops Pull You Over (Fossbytes)
Every so often something really useful appears on Reddit, and this is such a case. You may encounter a situation where you want to execute the contents of a bash script, but not more frequently than every few seconds. A Reddit user wanted to know How to check if a command in .bashrc has been executed within last 10 seconds if yes don’t execute the command again. The response by Reddit user mdaffin is brilliant in its simplicity, and can be used in any bash script where you don’t want the contents executed too often:
Write a time stamp to some file, check said file before you run the command if now – timestamp > 10s run the command and update the timestamp.
EDIT: Like this (with modification times instead):
if [[ ! -f "$TS_FILE" ]] || [[ "$(expr "$(date +%s)" - "$(stat -c %Y "$TS_FILE")")" -gt 10 ]]; then
You’d replace the
echo "running" line with the part of the bash script you want to run only if it’s been 10 seconds since the last time the script was run, or whatever number of seconds you specify after the
-gt. If the bash script actually outputs a file as part of its normal operation then you could specify that file in the
TS_FILE= line; there would be no need to create a separate timestamp file (unless some other process could also modify that same file).
This doesn’t actually stop the bash script from running; it just prevents it from executing the part of the script that you don’t want executed too frequently. This could be very useful in a situation where without such protection, the too-frequent execution of the script might cause something undesirable to happen (such as getting locked out of an online site for hammering it with requests). Depending on the situation there may be other, perhaps even better ways to avoid this possibility, but in other cases this may indeed be the best approach.
Grepping is awesome, as long as you don’t glob it up! This article covers some grep and regex basics.
SSH-key-based authentication provides a more secure alternative to password-based authentication. In this tutorial we’ll learn how to set up SSH key-based authentication on a Debian 9 installation.
Some websites don’t allow copying and pasting into input fields. Use this add-on to enable copying and pasting at sites that don’t allow it.
I almost always setup a samba share on every Raspberry Pi I install, it allows me to easily share files and work on my projects – so I thought I had better write down how I do it.
Source: Setup Raspberry Pi Samba share (Stuff about code)
If you’re trying to remove a Time Machine backup from a drive and find that it’s stuck in the Mac Trash with a specific error message stating the trash can’t be emptied because “Some items in the Trash cannot be deleted because of System Integrity Protection”, then read on to learn how to resolve this particular Time Machine backup removal problem.
We originally set out to do this because we were having problems getting an older model laser printer, specifically a Konica Minolta PP1350W, to work with MacOS High Sierra (10.13). With previous versions of MacOS we’d been able to connect the printer directly to the computer, and with some fiddling with drivers and other software, get it to work. But newer versions of MacOS seem to be far less tolerant of this, and we had a spare Raspberry Pi, so the idea came to us to use the Raspberry Pi as a bridge between the printer and any computers on the local network from which we wanted to be able to print. The bonus is that the printer is no longer tethered to a single machine, but instead can potentially be used by any computer on the local network.
You do not need to have a Raspberry Pi to make this work – any computer that can run Linux will do. And of course the Raspberry Pi or other Linux computer can be used for other purposes besides this. We do not guarantee that this technique will work for every older printer out there, but this will work with a surprising number of them.
Source: Convert an older model USB printer to a networked printer using a Raspberry Pi or other Linux-based computer — also works well for making an older printer compatible with a newer version of MacOS – Two “Sort Of” Tech Guys
MacBuntu (Macbuntu Mojave/High Sierra/El Capitan/Yosemite) transformation pack is ready for Ubuntu 18.04 Bionic Beaver, we were constantly asked for this pack to be available on our site, so here it is for you guys. In this transformation pack we are featuring many themes for almost every desktop, so you don’t have to worry about the desktop you are using whether it is Gnome Shell, Mate, Xfce, Cinnamon or any other desktop. You can simply install it in Ubuntu/Linux Mint or any other Ubuntu based distribution and make your desktop look like Mac OS X. The Unity desktop is still supported in case you are using unofficial version of Unity desktop. In this pack you will find plenty of light variants as well as dark versions, which is managed by different creators and I would like to thank all of them for contributing these themes (McOS-themes, macOS High Sierra, macOS 11, macOS High Sierra – ELBULLAZUL). There are two themes for cursors, for dock we recommend you to install Plank dock and we are providing themes for it as well (credits: KenHarkey and erikdubois. Also we are including themes for Gnome Shell, for Cinnamon, and three icon packs in this transformation pack.