How to fix HP scanning errors in MacOS

If you made the mistake of buying an HP printer and encountered one of the following symptoms:

  • Scanner does not work. Both HP Easy Scan and the OSX Printers and Scanners utilities fail. Printing might still work.
  • In HP Easy Scan, you get a message that says Scanner reported an error: An error occurred while communicating with the scanner
  • In the OSX Printers and Scanners utility, you get a message that says An error occurred while communicating with the scanner. (-9923)

I had this problem with my HP M28w multifunction printer. The HP support forums were useless, but I managed to fix it.

The following things did not work:

One of these things fixed scanning for me:

  1. Disable IPv6 on the printer. You can do this by opening HP Utility. In Network > IPv6, deactivate IPv6 and save the settings. It did not seem to fix my issue, but it worked for many other users.
  2. Run HP Easy Start again and reinstall everything. When I did this, I got a message that said System Extension cannot be used: The system extension “/Library/Extensions/hp_fax_io.kext” was installed improperly and cannot be used. Please try reinstalling it, or contact the product’s vendor for an update. I simply deleted that file. The printer started working again.

HP scanner disable IPv6 HP System Extension cannot be used error

Why Chrome 72 broke your Chromecast app

Since Chrome 72 came out, the Chromecast button stopped working on my home server. Plex and Emby users report similar having issues. This change was not officially announced, but it happens on all platforms.

If your Chromecast sender application stopped working, it’s probably because Chrome only supports casting from HTTPS sources since Chrome 72 (released in early 2019). If you serve cast_sender.js from an HTTP source, casting will not work. The solution is to switch your website or Plex server to HTTPS.

Related pages:

How to clear Terminal output on Mac

If you want to delete all previous output in an OS X terminal window, just press Cmd + K. This will clear the output, but it won’t kill the currently running tasks. I often use this command to remove thousands of lines of logs, so that the new output is easier to search.

If you just want to add some blank space, press Ctrl + L twice. This inserts a blank page in the terminal, but you can still see the previous output if you scroll up.

Google Drive trash won’t empty? Here’s the fix

When you try to empty the Google Drive trash, it sometimes seems as if the files are not being deleted. When you reload the page, the files are still there, and the space isn’t freed.

The solution is really simple: just wait!

Google Drive takes a while to delete the files in the trash. If you check again in a few minutes, you will have more free space, and some or all of the files will be deleted. It can take up to a few hours to delete all the files.

How to change the default Google Assistant timer and clock

A few weeks ago, I bought a Samsung S9. The hardware is great, but the software is terrible. The first thing I did was uninstall the Samsung bloatware and install my favourite apps.

I replaced Samsung Clock with Google Clock. Google Clock allows you to set multiple timers, among other things. You might also want to use your own alarm clock app, such as the excellent Sleep As Android. After a lot of trial and error, I found out how to set the default app that Google Assistant will use to set alarms and timers.

Changing the default timer app

All you need to do is say “Okay Google, set a timer”. Do not specify the time. Google will ask you when you want to set the timer. Do not say anything.

There will be a bubble that lets you enter a timer duration. In the bottom left corner of the bubble, there should be a small clock icon. Click this icon to select which clock app to use. Select your favourite app, then set the timer and click confirm.

Google will now use that clock app by default.

Changing the default alarm app

The procedure for setting the default alarm is the same. Say “Okay Google, set an alarm”, then select the app to use on the time selection bubble.

How to flatten a directory on Linux and MacOS

If you want to flatten a directory with lots of deeply nested files (for example ./2012/06/09/images/previews/200x200/image1.jpg becomes ./image1.jpg), you can run this simple command:

find target/ -mindepth 2 -type f -exec mv -i '{}' target/ ';'

All the files in target‘s subdirectories will be moved directly under target. If multiple files have the same name (target/hello.txt, target/backup/hello.txt, target/hello/english/hello.txt), you will be asked to overwrite them:

overwrite ./hello.txt? (y/n [n])

The default option is “no”, so you can just hold the Enter key to say no to all overwrites.

Ubuntu: apt-get -f fails, “no space left on device”, apt-get autoremove doesn’t work.

After getting this issue on two different servers, I thought I’d write a tutorial for everyone else.

What’s the problem?

First, you try to install some packages, either with apt-get install or apt-get update. For some reason, it fails with an error like this one:

You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 linux-image-extra-4.4.0-112-generic : Depends: linux-image-4.4.0-112-generic but it is not going to be installed
 linux-image-extra-4.4.0-93-generic : Depends: linux-image-4.4.0-93-generic but it is not going to be installed
 linux-image-generic : Depends: linux-image-4.4.0-112-generic but it is not going to be installed
                       Recommends: thermald but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

So you type apt-get -f install, and that fails too, this time with an error like this one:

Unpacking linux-image-4.4.0-112-generic (4.4.0-112.135) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-4.4.0-112-generic_4.4.0-112.135_amd64.deb (--unpack):
 cannot copy extracted data for './boot/System.map-4.4.0-112-generic' to '/boot/System.map-4.4.0-112-generic.dpkg-new': failed to write (No space     left on device)
No apport report written because the error message indicates a disk full error
                                                                              dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
...
E: Sub-process /usr/bin/dpkg returned an error code (1)

You do a bit of research and find something about running out of inodes, so you type df -i, but you are using under 10% of the inodes on all devices. Another post suggests running apt-get autoremove, but that gives you the same error message as before:

You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 linux-image-extra-4.4.0-112-generic : Depends: linux-image-4.4.0-112-generic but it is not installed
 linux-image-extra-4.4.0-93-generic : Depends: linux-image-4.4.0-93-generic but it is not installed
 linux-image-generic : Depends: linux-image-4.4.0-112-generic but it is not installed
                       Recommends: thermald but it is not installed
E: Unmet dependencies. Try using -f.

So what’s the f***ing deal?!

How to solve that problem

Long story short, you don’t have enough space to fit the new Linux kernel, so you have to delete some of the old ones. You can delete those manually, but it’s a long, tricky manual process, and if you’re like me, you only understand half of what’s going on and you just want the damn thing to work.

You might have found this solution or a variant of it, but once more you’ll get one of the error messages above:

Unmet dependencies. Try 'apt-get -f install' with no packages

Well, you were almost there! All you need is to use dpkg instead of apt-get purge.

Before you try that, run this command to see which packages will be removed. This command has no side effects and will not delete anything:

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'

Make sure that your current kernel version is not in that list. You can see your kernel version by running uname -a.

Once you are sure that you want to delete these kernel files, run this command to run dpkg --remove on each of them:

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs dpkg --remove

After that, you can run apt-get -f install without problems, then do whatever you wanted to do in the first place. See, Linux isn’t that complicated!

Help! That didn’t work!

If you run into an error like this one:

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
...
Errors were encountered while processing:
 linux-image-extra-4.4.0-31-generic
 linux-image-extra-4.4.0-47-generic
 linux-image-extra-4.4.0-75-generic
 linux-image-extra-4.4.0-79-generic
 linux-image-extra-4.4.0-81-generic
 linux-image-extra-4.4.0-83-generic
 linux-image-extra-4.4.0-87-generic
 linux-image-extra-4.4.0-89-generic

…don’t panic! Some of the kernels will likely removed, so you can run apt-get -f autoremove to clear up some space, and then you can run the long command above again.

tl;dr

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs dpkg --remove
apt-get -f install

How to fix “READ ERROR” on Fujifilm cameras

You might get a grey screen that says “READ ERROR” when you try to view your photos on a Fujifilm camera. I had this issue on my X-T10 camera, but this issue happens with all Fujifilm X-series cameras.

The issue is caused by hidden files and folders created on the memory card when you read them on your computer. For instance, the .DS_Store files on OS X. Unfortunately, the bright minds at Fujifilm did not account for that when designing their cameras, and the problem remained unfixed for years.

The easiest solution is to lock your SD card before you read in on your computer. The other solution is to use software that disables the creation of hidden metadata files on external devices. This problem was documented here and here.

If you already get a “READ ERROR” message, the only solution is to format your memory card. The long term solution is to stop buying Fujifilm cameras.

How to fix ImportMismatchError in Python

If you get an ImportMismatchError when running a Python app, it’s likely that you have some Python bytecode files (*.pyc) from a different runtime. For example, this happens when I run my Python unit tests inside a Docker container, then try to run them again in PyCharm.

Here is an example error message:

/.../env/bin/python2.7 "/Applications/PyCharm CE.app/Contents/helpers/pycharm/_jb_pytest_runner.py" --target app_test.py::TestAppThing
Testing started at 10:51 AM ...
Launching py.test with arguments app_test.py::TestGroundTruthGet in /Users/xxxxxxx/Projects/.../app
Traceback (most recent call last):
  File "/.../env/lib/python2.7/site-packages/_pytest/config.py", line 362, in _importconftest
    mod = conftestpath.pyimport()
  File "/.../env/lib/python2.7/site-packages/py/_path/local.py", line 680, in pyimport
    raise self.ImportMismatchError(modname, modfile, self)
ImportMismatchError: ('module.name.here', '/app/filename.py', local('/Users/xxxxxxx/.../filename.py'))
ERROR: could not load /Users/xxxxxxx/.../filename.py

Process finished with exit code 0
Empty test suite.

The solution to this error is simple: delete all *.pyc files in your project. You can do this with a simple command:

find . -name \*.pyc -delete

Your Python code should now run properly.

How to prevent Chrome from changing text color when printing

Chrome has a feature that turns light text to black before printing. For instance, if you have a light gray paragraph on the page, it will print as black text.

While this feature might ensure that unoptimized pages are readable when printed, you might want to disable it so colors come out the way you intended.

To ensure that background images, background colors and text colors remain the same while printing, use the following CSS rule:

-webkit-print-color-adjust: exact