Techie Stuff

Setting the default search path for Catfish File Search

The Problem

It was surprisingly difficult to find out how to set a default search path for Catfish. On the command line, you can simply do this to always make Catfish search from the root directory:

alias catfish='/usr/bin/catfish --path=\/'

But adding this line to your ~/.bashrc file will not affect the default search path for Catfish unless you launch it from the command line. What I wanted was to be able to click on the Catfish icon on the Unity launcher and have it launch in my root directory (so that it would search all my hard drives). Typically for a Linux program, Catfish’s settings do not offer a way to set this.

The Solution

The solution is to open up the file /usr/share/applications/catfish.desktop as root, for example by typing this on the command line:

gksudo gedit /usr/share/applications/catfish.desktop

Once the file opens up, change the Exec line near the bottom as follows, adding a --path=/some_path/ to the end of the line. Below, I’ve only put a forward slash as a path, meaning I want catfish to search everything, including all mounted hard drives.

Now, when I click the Catfish icon on the Unity launcher, the default search path is “File System”, which is how the program refers to the root directory.

When will the average flagship smartphone have a 5000 mAh battery? Probably around 2029

From 2007 to 2016, the iPhone’s battery grew from 1400 mAh in the first iPhone to 1960 mAh in the iPhone 7 (ignoring the new plus size iPhones). The energy density of lithium ion batteries grows at an exponential rate (5-8% a year), doubling every ten years, according to Tesla’s J.B. Straubel. The iPhone’s battery density growth is lagging this trend probably due to the continuous push for thinner phones.

Using Microsoft Excel’s exponential regression functionality, the following chart forecasts future iPhone battery sizes based on the available historical data, predicting that the small (non-plus) iPhone’s battery capacity will reach 5000 mAh around the year 2036:

Moving on to the more interesting new plus-sized iPhones, Excel cannot do an accurate automatic exponential regression due to the fact that there isn’t enough historical data available on the plus-sized iPhones. By examining the above chart and manually doing the regression using a second series, I found that Excel assumed an approximate rate of growth of 3.81%, and an approximate rate of growth of the rate of growth of 0.09%. Using these same rates on current iPhone Plus battery sizes, we get the following chart:

As it can be seen, around 2024 the iPhone Plus battery size reaches 4000 mAh, and around 2029 it reaches 5000 mAh. If the trend toward ever thinner phones slows, then the 5000 mAh smartphone battery might be achieved at an earlier date. I am hopeful that at least one large manufacturer is brave enough to bet on much larger batteries as a selling point, instead of following Apple’s lead in making things thinner and thinner.

When will smartphones have 1 terabyte of storage? Probably around 2021

While I’m no fan of Apple, the iPhone has so far been the leader in performance and storage. The internal storage of Apple’s latest and greatest iPhone provides a good benchmark for the current level of storage of the entire smartphone industry. When an iPhone with a new level of storage comes out, every manufacturer plays catch-up with Apple releases a flagship phone of similar storage.

Here is a chart that shows the trend in iPhone in internal storage. It extrapolates the trend into the future to predict when the iPhone will likely have one terabyte of internal storage (blue is historical storage levels, orange is predicted, and the dotted line is the trendline):

The chart assumes an exponential trend, since storage density and prices have followed an exponential increase and reduction trend.

I assumed that from 2018 through 2020, the iPhone will stay at 512 GB, similar to how it remained at 64 GB from 2011 through 2013. It is possible that instead of this, the iPhone will stay at 256 GB from 2017 through 2019. This will not significantly affect the historical trend.

Here is the same chart with the forecast extended to 2030. The trendline predicts an internal storage of 5 terabytes in 2027 and 10 terabytes in 2029.

I know that 10 terabytes in a smartphone may seem unnecessarily high. But historical trends show that every age can find good (and frivolous) uses for all the storage it can get.

Below is a table of every iPhone release date, device name, highest offered storage and battery capacity:

Release Date
Device Storage (GB)
Battery (mAh)
June 29, 2007 iPhone 1 16 1400
July 11, 2008 iPhone 3G 16 1150
June 19 2009 iPhone 3GS 32 1219
June 24, 2010 iPhone 4 32 1420
October 14, 2011 iPhone 4S 64 1432
September 21, 2012 iPhone 5 64 1440
September 20, 2013 iPhone 5S 64 1560
September 19, 2014 iPhone 6 128 1810
September 25, 2015 iPhone 6S 128 1715
September 16, 2016 iPhone 7 256 1960

How to search a document on Linux while ignoring diacritics (harakat/accents)

The Problem

Most applications are not smart enough to ignore accents when searching through the text of a document. Here is a screenshot of LibreOffice 5.2 failing at finding the word Arabic word “bsm” because I didn’t type in every single diacritic:

This is an especially serious problem when searching through Arabic text because the usage of diacritics is totally inconsistent as they are not strictly necessary. Different levels of diacritics are added according to the level of user-friendliness that is desired by the document creator.

Firefox is equally miserable at searching Arabic text:

The Solution

The solution is to open the document in a WebKit-based web browser, which has sensible handling of diacritics. Below is a screenshot of the open source Midori browser succeeding at finding and highlighting the Arabic word I was searching for even though I didn’t type in the diacritics:

Other WebKit browsers include Chromium and Chrome, both by Google. I would rather use a non-Google browser personally, so Midori is my preferred option.

If your document is not in the HTML format (the format that browsers use), you can use LibreOffice or Microsoft Word (etc.) to save it as HTML.

Fixing washed out colors in Ubuntu 16.10

How I improved the colors and brightness/contrast and the appearance of fonts on my Ubuntu 16.10 PC monitor

After moving to Ubuntu from Windows, one thing that has been constantly annoying me was the washed out/stark colors on my monitor and ugly-looking fonts in Firefox. I have spent hours fiddling with my monitor’s settings, color profiles on the Color tool, and various random font-related hacks using the terminal to no benefit.

Today I finally found the solution. It was to connect my monitor to my PC using a DVI cable instead of HDMI. Apparently there is an issue with communication between the Linux Kernel and most (if not all) monitors when they use HDMI and DisplayPort, at least this is what I understood from this discussion on Kernel.org.

One other possible solution is using this command (replace HDMI1 with the name of your display as given by the command /usr/bin/xrandr -q --prop | grep ' connected'):

xrandr --output HDMI1 --set "Broadcast RGB" "Full"

When trying the above, I kept getting this error:

BadName (named color or font does not exist)

Not wanting to spend the rest of my day troubleshooting this error, I took the brute-force approach of using a DVI cable that I fortunately had lying around in a closet.

How I solved “jQuery Ajax Uncaught TypeError: Cannot read property ‘type’ of undefined”

A solution for an error occurring during a jQuery $.ajax request.

I was using this common jQuery Ajax pattern on a page I am working:

    $(function () {
        $(document).on('click', '.create-domain .submit', function (e) {
            e.preventDefault();

            var data = {
                domain_description: $('.create-domain .domain-description-textarea')
        }

            $.ajax({
                type: 'post',
                url: '/process/something.php',
                data: data,
                error: function (data) {
                    console.debug(data);
                },
                success: function (response) {
                   //stuff
                }
            });
        });

But on clicking the submit element, I kept getting this cryptic error:

Uncaught TypeError: Cannot read property 'type' of undefined
    at r.handle (jquery-2.2.4.min.js:3)
    at e (jquery-2.2.4.min.js:4)
    at Gb (jquery-2.2.4.min.js:4)
    at Gb (jquery-2.2.4.min.js:4)
    at Gb (jquery-2.2.4.min.js:4)
    at Gb (jquery-2.2.4.min.js:4)
    at Function.n.param (jquery-2.2.4.min.js:4)
    at Function.ajax (jquery-2.2.4.min.js:4)
    at HTMLButtonElement. (something.php:575)
    at HTMLDocument.dispatch (jquery-2.2.4.min.js:3)
    at HTMLDocument.r.handle (jquery-2.2.4.min.js:3)

The problem was that in the data variable, I was including an HTML element (a textarea) inside the data variable, instead of including the textarea‘s content. Thus the corrected code is (notice the .val() at the end):

            var data = {
                domain_description: $('.create-domain .domain-description-textarea').val(),
        }

Hopefully this will help a few people, helping making the world economy more efficient by 1*10-12% (saving the world economy $107 USD over the next year).

Fixing the kworker CPU usage / ACPI errors issue on a Skylake motherboard (ASRock Z170 Pro4)

In which ASRock bricks my motherboard and a random $10 Chinese device comes to the rescue, with the help of a German gentleman

Since I no longer trust the spyware that is Windows 10, I have wanted to move my main PC (6700K CPU, R9 290 graphic card, ASRock Z170 Pro4 motherboard) to Linux for months now and finally did it yesterday. Everything worked as expected until, while working inside Ubuntu, I started getting messages that the computer was low on disk space even though I had allocated 25 gigabytes to the root partition.

Using ncdu in the terminal, I found that the log folder was taking up all the space, and found that /var/log/kern.log and /var/log/syslog were being written to at what seemed to be a rate of 1 MB/second, with endless repetitions of:

ACPI Error: Method parse/execution failed [\_GPE._L6F] (Node …), AE_NOT_FOUND (…)

Another issue was that the kworker process was using constantly 100% of one of the eight CPU cores.

Forums suggested this was a motherboard firmware issue. So I decided to do a firmware update. My firmware was a pretty early one, something like version 1.5, while the latest available firmware is 7.3. I went to the UEFI interface and tried using the “Internet Flash” utility provided by ASRock. It successfully retrieved the fact that there was a 7.5 version update available to the firmware, but when clicking on update, it would conveniently fail to connect to the internet. Somehow the geniuses at ASRock had created software that could connect to the internet to ask if an update was available, but on downloading the update it would fail to connect to the internet. Still, I am glad that we are light years ahead of the pain, anguish and days of wasted labor that we used to suffer in the 90’s to fix a simple hardware issue.

I downloaded the BIOS binary file from the ASRock website, put it on a USB flash drive, and went to UEFI interface again, this time using the “Instant Flash” utility. The first time I tried it, the computer instantly crashed and rebooted, and nothing else happened. I tried a second time. This time it seemed to work, until the firmware update got stuck at 10%. I waited for hours to see if it would finish, but it didn’t. I left my computer on overnight, thinking that there might still be a tiny chance it would eventually finish. In the morning it hadn’t. So I hard rebooted my PC, and then nothing. It would turn on, but it wouldn’t give any output, not even the ASRock logo that shows at the beginning.

Knowing that the BIOS chip had probably become corrupted from the update and that I had probably upgraded my motherboard from an ASRock to an ASBrick, I looked to see what could be done. After yanking on the BIOS chip on the motherboard for a while, I found that it was designed to come off, so I took it out. I then learned about devices that can reflash a corrupted BIOS chip. I found out about the the Chinese device CH341A  that sells for about $10. I ordered one made by a company called SMAKN on Amazon with overnight delivery. This morning it arrived.

At first I was dismayed to see that there were three unattached pieces, I thought they might need soldiering:

But after watching this video by UltraNSC, I found that I wouldn’t be needing those pieces. I installed the software provided in the description of the video on an old but working Windows 7 laptop that I have, inserted the device, tried installing all the drivers in the file, and still the software (CH341A.exe) wouldn’t detect the device. I unplugged the device and moved to another USB port, and this time the software detected it.

The software detected that the BIOS chip had a size of 16 megabytes, similar to the binary file provided by ASRock. This was a good sign. I erased the BIOS chip with the software, then tried to open the binary file with the software but it wouldn’t detect it because the file provided by ASRock doesn’t have a filetype extension. I renamed the file to have a .bin extension, and now the software could see it. I loaded the file and clicked “Program” to write it to the chip. Everything worked without a problem. I clicked “Verify” to make absolutely sure the data was copied without error and that came out positive.

I put the BIOS chip back into the motherboard and turned the computer on. A message by American Megatrends came up, and clicking F12, it took me to the UEFI interface. I rebooted and was immediately taken into Windows as the UEFI had forgotten my preferred boot device order. Windows tried to do some sort of automatic repair then restarted the computer, at which point I went into the UEFI interface and told it to use my main SSD as the boot device. Restarting, I was taken into grub, and from there went into Ubuntu. Logging in, I saw that kworker wasn’t acting up anymore, and that the logs weren’t being flooded.

Now it is time to install Windows 7 in a networking-disabled virtual machine inside Ubuntu so that I can continue using OneNote and Photoshop without sending all my data to Microsoft. I have also kept my Windows 10 installation on another partition just in case I ever need it, for example to play Battlefield 1, though it seems I’ve become enough of an adult that video games barely interest me anymore, though I still enjoy watching Stodeh on Twitch.