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

Office 2011 activation server unavailable? Here’s the fix

After almost a year after freshly installing MacOS, the time finally came for me to need the festering pile of ██ that is Microsoft Office 2011. Naturally, something was broken.

The activation screen refused to accept the license key I had used 5 minutes earlier to download the installer, stating that the activation server was temporarily unavailable.

The solution was to look for updates to Office 2011. After the latest update was installed, the key was accepted and my installation was activated. If that doesn’t work, you can always activate it by phone.

Fixing the “protocol error: bad pack header” error in git

When trying to push in git, you might get the following error message:

fatal: internal server error
remote: internal server error
fatal: protocol error: bad pack header

In my case, it was because I pulled a corrupted remote Gerrit repository, and tried to push the corrupted data back to the fixed remote. Everyone who had pulled the corrupted repository also ran into the same error.

Fortunately, the fix is really easy. All you have to do is run those four commands:

cp .git/config .git/config.backup
git remote remove origin
mv .git/config.backup .git/config
git fetch

This fix comes from Jordan Klassen.

Automatically tagging people for code review in Gerrit

If your gerrit workflow requires you to automatically tag people, or if you always end up tagging the same people, there is a way to tag people by default for all your commits.

To do so, edit .git/config to include the following lines and substitute the email with your colleague’s email:

[remote "origin"]
    ...
    receivepack = git receive-pack --reviewer "other.reviewer@company.com"

Fixing Jasmine “encountered a declaration exception”

If you ever come upon a Jasmine unit test that ends with “encountered a declaration exception”, it’s likely because you have committed a simple, subtle mistake. Every few weeks, I would get that error, and forgetting how I fixed it the previous time, spend another 30 minutes to fix it.

Here’s a screenshot of the Karma output:

enter image description here

Here’s the code that caused it:

describe('should be hidden when the scope is destroyed', () => {
  this.scope.$broadcast('$destroy');
  expect(this.scope.helpTooltip.hide).toHaveBeenCalledWith();
});

Can you spot the problem? It’s simple: I used describe instead of it. Let’s fix this…

it('should be hidden when the scope is destroyed', () => {
  this.scope.$broadcast('$destroy');
  expect(this.scope.helpTooltip.hide).toHaveBeenCalledWith();
});

Voilà! No more error! Sometimes, the solution is that simple.

How to improve Angular performance by disabling debugging

Angular JS

Angular gives elements classes such as ng-scope and ng-isolate-scope to help tools such as Batarang and Protractor retrieve debugging information. In production, these are unnecessary, and can be disabled to speed up your client-side application.

This is how you disable debugging information in Angular:

myApp.config(['$compileProvider', function ($compileProvider) {
  $compileProvider.debugInfoEnabled(false);
}]);

How to create static class constants in ES6

ES6 brings classes to JavaScript, but some things are not immediately obvious or entirely supported. For instance, there is no obvious way to create static class constants.

Here is the simplest way I have found to create constants:

class CurrentLocation {
  static get GEOLOCATION_ERROR() { return 'GEOLOCATION_ERROR'; }
  static get GEOLOCATION_REFUSED() { return 'GEOLOCATION_REFUSED'; }
  static get GEOLOCATION_ACQUIRED() { return 'GEOLOCATION_ACQUIRED'; }
  static get GEOLOCATION_PENDING() { return 'GEOLOCATION_PENDING'; }

  ...

  function isValid(){
    return this.status === CurrentLocationItem.GEOLOCATION_ACQUIRED
  }
}

In the example below, you can use CurrentLocation.GEOLOCATION_ERROR anywhere, but myGeolocationItem.GEOLOCATION_ERROR will not exist, as static members are not visible to class instances. Moreover, children of the CurrentLocation class will not inherit these attributes.