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.

Islam, the Good Parts: Guaranteed Basic Income for Women

One thing that is rarely mentioned when speaking about Islam, even among Muslims, is that Muslim women don’t have to work. They can work if they want to, but they don’t have to if they don’t want to.

Islam makes it the duty of a woman’s male relatives to take care of her financially. Men have to provide for their sisters, mothers, wives and daughters. This is not merely an act of charity that men are encouraged to do. It is their legal duty. In a devout Muslim society, no woman can ever be homeless as long as she has a self-respecting male relative.

This provides a tremendous sense of freedom for women, including single women, who want to do creative work. They can focus on doing what they like, for example growing a small business or a writing career, while enjoying freedom from the stress of having to earn a living. Instead of having to work for potentially abusive employers or customers, they will have the option of only choosing jobs they like and leaving whenever they want.

In a country like the United States where two incomes are often necessary for a small family to maintain a dignified existence, it may seem unrealistic (and potentially unfair to men) for such a system to be implemented. How can a few men provide for so many people? The answer is Islam’s mechanisms for wealth-preservation and the encouragement of productive investment that ensure the super-wealthy can never get too financially powerful and collude to lower wages as has happened in the United States, and also ensures that a single stream of income is generally enough to feed a large family. These mechanisms, such as the ban on interest and the speculation tax, will  be discussed later on.

There is one flip side to the system that needs to be mentioned. When inheritance is distributed, women receive half as much as men. Since Islam puts all financial duties on men, it rewards them by giving them a larger share of inheritance, as men’s wealth is, after all, also partially women’s, as a man is obliged to take care of all of his close female relatives. Islam, however, doesn’t run away with the idea of a male-provider society by giving all inheritance to men, since not all men can be relied upon to be good and fair care-takers of women. It also doesn’t run away blindly with the idea of equality by giving men and women equal shares of inheritance when it has burdened men with heavier financial duties. It chooses a middle ground between the two extremes. It gives men more duties and a larger inheritance, while also providing a fall-back in case of unfair and undutiful male relatives by giving women a half-share of inheritance.

The virtues and evils of such a system can be debated. Why not give men and women equality in all things? Islam’s view is that men and women are not identical when it comes to all things. It assigns different rights and duties to each sex depending on their particular strengths and weaknesses.

The main issue at question here is this: Is a system that takes the differences between the sexes into account more likely or less likely to be fair, compared to a system that assumes men and women are exactly the same? Is it unimaginable that differentiating between the sexes can lead to a fairer system of rights and duties compared to turning a blind eye to all differences?

Feelings run high when this matter is discussed. The only way to resolve the matter is to undertake large-scale scientific studies to find out whether sex-aware systems lead to better societal outcomes compared to sex-blind systems.

Does it improve the mental health and happiness of women for them to know they will never have to work, and for them to know that there isn’t one chance in a million for them to ever be homeless (given the potentially dozens of male relatives eager and willing to take care of them if they lose their homes or jobs)?

Does it increase or decrease a woman’s chance of career advancement for her not to have to worry about making a living while she focuses on her studies or work? Or is it better to put her in debt and compel her to work as a waitress or bartender so that she can make ends meet while she studies or grows her small business as it is done in the United States?

If we cherry-pick facts and anecdotes, we can make either system look good or bad, but rigorous and empirical comparisons can be done. We can fully resolve the debate through decades of unbiased social research  that compares the outcomes of an Islamic system to competing systems.

Any comparison’s of an Islamic system compared to others will have to take account of IQ, as IQ is the most important factor in determining a population’s prosperity. India is much poorer than China, for example, not largely because of Hinduism versus Communism or Buddhism, but because India’s average IQ is in the mid-80’s, while China’s IQ is above 100. Populations of equal IQ tend to converge toward having the same level of prosperity. China is in the same league as South Korea and Japan when it comes to IQ, so it is practically certain that it will reach the same level of prosperity as these two countries within a decade or two. India, however, is in the same league as the Dominican Republic and Paraguay when it comes to IQ, so as it develops, it will converge toward the same level of prosperity as these two countries. Of course, different population sizes and natural resources will affect things, but not to a great degree, and the larger the populations of the countries that we are comparing, the smaller will the effect of natural resources become. To study this topic further, I recommend the book IQ and the Wealth of Nations by professors Richard Lynn and Tatu Vanhanen.

To have a fair comparison of an Islamic system compared to others, we can compare ethnic Japanese Muslims to ethnic Japanese non-Muslims in Japan (similar IQ, same country) and see how Islam’s system of rights and duties affects the Muslim population compared to the non-Muslim one. Are ethnic Japanese Muslim women happier, more productive, more mentally healthy compared ethnic Japanese non-Muslims, or not?

Unlike Communism, whose adherents can claim that it wasn’t properly implemented when it fails, the Islamic system can be scientifically tested. The requirement is to account for IQ and devoutness (a Muslim who uses credit cards, mortgages and for-profit insurance is not following Islam properly and should not be counted toward the Muslim side). Examples of devout Muslim populations that can be studied are the conservative Muslim middle classes of Egypt and Malaysia. Egypt’s conservative Muslim middle class can be compared to the middle classes of non-Muslim countries of similar IQ (low-80’s), such as Honduras, Nicaragua and the Dominican Republic. And as for Malaysia (IQ 92), we can compare the conservative Muslim middle class there with the middle classes of Greece, Ireland, Bulgaria and Lithuania.

Solve the invisible spaces problem in Word 2013

An annoying issue in Word 2013 is that sometimes the space key seems to stop working, until you press a non-space character, at which point Word deigns to show you both the space and non-space characters.

To solve the problem, press enter to create a new line, then go back to your line. The problem is caused by a bug in Word where having a page break or section break right after the line you are on prevents spaces from showing. Make sure there is a line (empty or not) below the line you are typing on, and the problem disappears.

How to export the entire sequence by default in Adobe Premiere Pro CS6

  1. Move the yellow playback marker far to the right, until it goes into the blank area and the preview window becomes black. If you are doing batch work, move the marker farther than any of your clips are going to be. For example, if you are exporting 1 minute videos, move the marker to the 2 minute mark.
  2. On the bar below the playback marker’s bar, find the right end of the selection bar and move it to the far left, so that there are 0 seconds selected. The left end of the selection marker should also be to the far left, obviously.
  3. That’s all. Now when exporting, Premiere will automatically select the entire sequence for export.

AWS Storage Historical Pricing and Future Projections

Some blogs are calling the recent price wars between cloud providers “a race to zero”. But this is the wrong way to think about it. As technology progresses, we simply need to start thinking in terms of larger units.

Here is a table of historical Amazon S3 prices:

Date $/GB/Month $/TB/Month
14-Mar-06 0.15 150
1-Nov-08 0.15 150
1-Nov-10 0.14 140
1-Feb-12 0.125 125
1-Dec-12 0.095 95
1-Feb-14 0.085 85
1-Apr-14 0.03 30

In terms of gigabytes the prices seem to be approaching zero. But in terms of terabytes, the prices are just barely starting to become reasonable. The linear projection below suggests that we will be using terabytes as our unit of choice when speaking of cloud storage until 2020 and later, when prices will start going below $1 per terabyte per month.

Some time after 2020, perhaps around 2025, we will start speaking in terms of petabytes per month.

Fire Phone folder where screenshots are stored

Using my Windows 7 computer to browse the Fire Phone’s files, I found the screenshots in the following folder:

Computer\Fire\Internal storage\Pictures\Screenshots

To take screenshots, you need to hold down the volume down and power buttons together. You will hear a sound and see an animation informing you that the screenshot was successfully taken.

Horoscopes and Islam

A Muslim should believe or read horoscopes or not? Because I saw a post that says the person who believes in horoscopes is a disbeliever.

Horoscopes go under the category of superstition, since there is no basis in science or religion for them. Therefore a well educated and intelligent Muslim should take them for what they are: Fancy-sounding nonsense that impress the gullible.

However, we should not be judgmental toward those who believe in horoscopes. Even though this is an obvious flaw in their faith, we ourselves may have greater flaws that are not so apparent. Those who take pleasure in attacking the obvious flaws of others almost certainly have similar or greater flaws themselves.

We shouldn’t be quick to say who is a believer and who is a disbeliever. We can say a person who is not thankful toward God is a disbeliever; but we all show unthankfulness toward God every now and then; therefore are we to say that we are all disbelievers? We should not pass final judgment on people, that is God’s job, not ours. A person who has a part of disbelief in him or her may also have many parts of belief and goodness that outweigh the disbelief.

List of 20,000 right-angled triangles with whole-number sides

Some mathematical investigations can benefit from having a handy list of right-angled triangles with whole number sides. We know of the common [a = 3,b = 4, c = 5] triangle often used to illustrate the Pythagorean theorem (5^2 = sqrt(3^2 + 4^2)), but sometimes we need more of these. For this reason I made the following lists, placed inside handy text files. They start from the smallest possible triangle (the [3,4,5] one) and iterate up.

List of 20,000 right-angled triangles with whole-number sides sorted by the smallest side (i.e. side a).

List of 20,000 right-angled triangles with whole-number sides sorted by the largest side (i.e. the hypotenuse or side c).

Mashing two regular expressions together in JavaScript on the fly

var pattern1 = /Aug/;
var pattern2 = /ust/;
var fullpattern = (new RegExp( (pattern1+'').replace(/^\/(.*)\/$/,'$1') + (pattern2+'').replace(/^\/(.*)\/$/,'$1') ));

Explanation:

  • pattern1+'' turns (“casts”) the regular expression object into a string.
  • .replace(/^\/(.*)\/$/,'$1') removes the beginning and ending slashes from the pattern
  • new RegExp() turns the resultant string into a regular expression object. There is no need to add back a regular expression delimiter (i.e. slashes usually) since the RegExp() function (“constructor”) adds the delimiter if it is lacking.
  • If you want the resultant expression to have a flag, for example i, you add it so: new RegExp(string,'i');
  • This code is quite unreadable and you might be doing yourself and others a kindness if you use a less clever method. To make it more readable, the technique can be wrapped in a function:
var rmash = function(reg1,reg2) {
var fullpattern = (new RegExp( (reg1+'').replace(/^\/(.*)\/$/,'$1') + (reg2+'').replace(/^\/(.*)\/$/,'$1') ));
return fullpattern;
};

var my_new_pattern = rmash(pattern1,pattern2);

Generalizing the mash function to handle an arbitrary number of regular expressions and flags is left as an exercise.

How to do long-running computations in JavaScript while avoiding the “maximum call stack size exceeded” error

The following program calculates the value of the series of the Basel Problem. The result is a number that starts with 1.644934. Like π, this sequence can go on forever, which means the program never exits. Without proper design, such a program runs into the maximum call stack size exceeded error, which is designed to prevent a program from using too much memory.

var cr = 1;
var total = 0;
var x = function() {

    total = total + (1/(cr*cr));

    
    if(! (cr % 20000)) {
        $('#t1').val(total);
        $('#t2').val(cr);
        setTimeout(x,0);
    }
    else {
        x();
    }
    cr++;

};
x(); //initial call to x().

The solution is to add a setTimeout call somewhere in the program before things get too close to exceeding the call stack. In the above program, cr is a counter variable that starts with 1 and increases by 1 for every iteration of the x function. Using the conditional if(! (cr % 20000)) allows the program to catch its breath every 20,000 iterations and empties the call stack. It checks whether cr is divisible by 20,000 without a remainder. If it is not, we do nothing and let the program run its course. But if is divisible without a remainer, it means we have reached the end of a 20,000 iteration run. When this happens, we output the value of the total and the cr variables to two textboxes, t1 and t2.

Next, instead of calling x() the normal way, we call it via setTimeout(x,0);. As you know, setTimeout is genearlly used to run a function after a certain amount of time has passed, which is why usually the second argument is non-zero. But in this case, we do not need any wait time. The fact that we are calling x() via setTimeout is what matters, as this breaks the flow of the program, allowing proper screen output of the variables and the infinite continuation of the program.

The program is extremely fast, doing 1 million iterations about every 2.4 seconds on my computer. The result (the value of total) is not perfectly accurate due to the limitations of JavaScript numbers. More accuracy can be had using an extended numbers library.

You may wonder why we cannot put all calls to x() inside a setTimeout(). The reason is that doing so prevents the JavaScript interpreter from optimizing the program, causing it to run extremely slowly (about 1000 iterations per second on my computer). Using the method above, we run the program in optimized blocks of 20,000 iterations (the first block is actually 19,999 iterations since cr starts from 1, but for simplicity I have said 20,000 throughout the article).

Using an object anonymously in JavaScript

var month = 'Jan'; //or another three-letter abbreviation

//After the following operation, proper_month will contain the string "January".
var proper_month = {'Jan':'January',
                              'Feb': 'February',
                              'Mar' : 'March',
                              'Apr' : 'April',
                              'May'   : 'May',
                              'Jun'  : 'June',
                              'Jul'  : 'July',
                              'Aug'   : 'August',
                              'Sep'  : 'September',
                              'Oct'   : 'October',
                              'Nov'   : 'November',
                              'Dec'   : 'December'
                             
                             }[month];

How to: Become wise

If you want to become wise, read 100 books that interest you. The books you choose to read can be about any topic and they can be of any quality, good or bad. The important thing is that you should find them interesting, because the fact that you find a book interesting means it contains information that is new1 to you (and thus it increases wisdom), because “interesting” simply means “something that provides new information to the brain”.

No book is going to solve all of your problems. Each book may make you a 1% wiser person. Thus if you want to become double as wise as you are now, you would have to read about 70 books. 100 books would be a safer number.

Some of the books you read will contain false information, because almost any book will contain some claims and assumptions that are false. But if you don’t give up and continue reading books one after another, as your knowledge increases, so will your awareness of what is true and what is false. Wisdom is simply a map of reality (accurate information about how things really are), and each book you read (even a simple story) tries to give you a small piece of the map. Some books will give you false pieces that do not describe anything that actually exists on the map. But as you read more books, your knowledge increases about the other pieces that surround the false piece, and thus you start to have an intuitive sense of what the false piece should actually look like, and thus you recognize the false piece for what it is: false. Recognition of the falsehood in itself increases your knowledge, for your brain can abstract the patterns of falsehood, and it can actually build a map of what falsehood itself looks like, and thus it will become increasingly hard for falsehoods to mislead you.

If you start to read a book that at first seems interesting, but eventually lose interest in it and start to find it boring and tiring, you should feel no qualms about abandoning the book and starting another. When this happens, it can be due to one of two things:

  1. The book does not contain anything that’s new to you, and thus your brain recognizes it as a repetition of things that you already know very well, and therefore you brain is asking you to stop wasting your time with the book.
  2. The book contains information that has too many prerequisites, and thus your brain is not equipped to handle the information. You should abandon the book now and return to it after reading many other books.

Spend a year doing this and at the end of it you may laugh at how unwise and biased you used to be a year ago. During your journey you would have picked up some new biases, therefore it is unwise to stop your journey. Continue reading books and these biases will be cleared up. You will never stop picking up biases, but their frequency will decrease as your wisdom increases, for biases have patterns of their own and the wise mind can learn to avoid many of them. This is why you find the wisest people to be those who are least ready to make final judgments on any topic–they are “open-minded”, knowing when they do not have enough information.

In most cases, when it comes to most topics, humans rarely have perfect knowledge, therefore the wisest often refuse to give final answers on anything or to give counsel freely to those who ask for it. They will speak about what they know, and refuse to delve into what they do not know.

Import and play your own audiobooks on the Amazon Fire Phone

[Update: I now recommend using these steps to install the Google Play Store (which does not “root” the device and does not cause any permanent changes), then buying the highly rated Listen Audiobook Player (which has up to 3x playback speed with pitch correction and a slider that shows your place in the book and how much is left–while taking playback speed into account) in the Play Store for $0.99. The entire process takes about 15 minutes.]

Amazon makes it impossible to import audiobooks into the Audible app, probably wanting you to buy all your stuff from them and under their control. I’d actually be more willing to use Audible if it let me import the many audiobooks I already own from other sources. Most Fire Phone audio apps are useless for audiobooks since they do not let you browse the audiobook’s files, instead treating the audiobook as a song album and and making a complete mess out of the order of the tracks. Another issue with music players is playback speed. I usually like to listen to audiobooks at double speed (and usually more if I am able to fully give the book my attention), but most music players I’ve tried on the Fire Phone do not have a playback speed feature.

I was almost losing hope that I would be able to get a proper audiobook experience out of the Fire Phone, until I happened on the Rocket Player App, which has almost all the required features for an audiobook player:

  1. It allows you to browse the files on the phone and keep the proper order of the tracks (while others players mess up the track order). If the track order is still messed up in Rocket Player, use a free and open-source Windows program called Mp3BookHelper (Project Page | Download Link) to rename the tracks (both file names and the Title ID3 tag) sequentially.
  2. It has a playback speed setting (after buying the $4 premium version of the app) with pitch correction. The playback speed can only go up to double speed, which is pretty good but I wish it could go up to four.
  3. It remembers your place in the book, even after closing the app (provided that you do not use the app to listen to other things, which is quite doable since there are many other apps optimized for music listening).

Steps for importing your own audiobooks on the Fire Phone and playing them using Rocket Player

  1. Install the free Rocket Player App, then upgrade it to the $4 premium version.
  2. Move your audiobook into a folder on your phone. You can use the USB cable or, if your laptop supports bluetooth, you can use that too, though USB is much faster.
  3. If you used the USB cable, unplug it, otherwise the audio player may not be able to see the new files.
  4. Tap the “Folders” tab in Rocket Player. Browse to the audiobook folder (but don’t go inside the folder). Tap the folder and hold, until a menu comes up. Press “Add to playlist” and create a new playlist. Now you can go to the “Playlists” tab to find the audiobook and play it.
  5. In the Rocket Player settings, you can find the “Playback speed” setting and change it to what you like.

Is reading the Quran better than listening to it?

The majority of scholars (such as Qatar’s Islamic Affairs Ministry, Ibn Baaz, and the UAE Islamic Affairs Ministry) do think that reading is better than listening, but they have no evidence for this except their own personal opinions and unauthentic sayings of the Prophet. To me reading a book or listening to it are the same thing. I listened to the Harry Potter and Lord of the Rings books (instead of reading them with my eyes), does this mean that I somehow understood or “benefited” less from the books than if I had read them?

I suffer from dry eyes and late at night when I read Quran, if my eyes start to feel bad, I switch to listening. Does this mean that God automatically drops my rewards because I decided to receive God’s word through my ears instead of my eyes?

To me, Islam is a religion based on logic, not magic. No good deed is magically better than another, and whether I decide to receive the Quran through my eyes or ears my reward depends on my effort and sacrifice (how much attention I give to the meaning and how much time I dedicate to it), not on some random eyes-are-better-than-ears prejudice.

Growth of CPU GFLOPS by year, with future projections

In Q1 2006, the fastest, most expensive CPU could do 12.421 GFLOPS on the Whetstone test. In Q4 2014, the fastest consumer CPU (Intel Core i7-5960X) can do 169.79 GFLOPS.

I added two trend lines to the chart. The green one is a linear trend line, showing that in January 2018 we will have a 200 GFLOPS CPU, which doesn’t sound like much, while the red exponential trend line promises 500 GFLOPS during the same period. The truth will likely be somewhere in between.

The latest CPU’s gains come from its 8 cores, therefore a better performance chart would only show single-thread improvements, since single-thread shows the true performance improvement per core and is a big bottleneck for many games and applications.

A quick single-thread comparison can be done between the Intel Core 2 Extreme X7900 (Q3 2007), which received a single-thread score of 968 on the PassMark test, and the Intel Core i7-2600K (Q1 2011), which received almost exactly double the single-threaded performance at 1943. It took Intel less than 4 years to double the performance of its highest-end consumer CPU. But three years later, the fastest CPU in single-threaded tests is the Intel Core i7-4790K with a score of 2532, meaning that in about four years Intel has only managed to gain a 30% performance improvement in single-threaded applications.

This is a big deal and shows the performance stagnation that gamers and professionals have been complaining about in recent years. If the next four years end up like the past four, in 2018 the fastest consumer CPU will only be 30% faster if no additional cores are added. The interpretation of Moore’s Law that promised a doubling of performance every 18 months has long been inaccurate.

Below is the data that I based the chart on the top on, taken from CPU reviews that featured the SiSoft Sandra Whetstone test.

 Quarter        GFLOPS
 10-Jan-06	12.421  
 10-Apr-06	15.703   
 10-Oct-06	33.797   
 10-Apr-07	37.693   
 10-Jul-07	26.7     
 10-Oct-07	44.4     
 10-Jan-08	44.2     
 10-Oct-08	62.879   
 10-Jan-09	66.5     
 10-Oct-09	55.9     
 10-Oct-10	67       
 10-Apr-11	83       
 10-Jul-11	91       
 10-Oct-11	121      
 10-Jan-12	136      
 10-Apr-12	93.2     
 10-Jul-12	126      
 10-Apr-13	93       
 10-Jul-13	135.4    
 10-Oct-14	169.79

Using one category page to show multiple categories in WordPress

[Update: There is probably never a good reason to do this. Instead, create a new category to hold the posts.]

Trying to show multiple categories in one loop is easily the hardest thing I’ve done in WordPress.

  1. First, create a container category where you want your multiple categories to be shown. Let’s call it the MultiCat category and give it the multicat slug. No posts are required to belong to this category, and if they do, it will have no benefit.
  2. Next, add this bit of code to functions.php of your theme. This is where we create a query variable which enables us to identify the multi-category page properly. Update the category slugs below to match the slugs of the categories you want to show together.
    function multi_cat_handler( $query ) {
        if ( $query->is_main_query() && $query->query["category_name"] == 'cat1-slug,cat2-slug,cat3-slug,cat4-slug' ) {
         $query->set("allish",'yes');
        }
    }
    add_action( 'pre_get_posts', 'multi_cat_handler' );
  3. Next, add this code to functions.php. Update multicat to the slug of your multiple categories category. Also update the other slugs as in the previous step.
    function alter_the_query_for_me( $request ) {
        $dummy_query = new WP_Query(); 
        $dummy_query->parse_query( $request );
    	  if($dummy_query->query['category_name'] == 'multicat') {
    		$request['category_name'] = 'cat1-slug,cat2-slug,cat3-slug,cat4-slug';
    	  }
        return $request;
    }
    add_filter( 'request', 'alter_the_query_for_me' );
  4. To display the h1 tag of the MultiCat category page properly, we use the following code:
    if(get_query_var('allish') == 'yes') {
    echo 'Title of the Multiple Categories Page';
    }
    else {
    echo 'Normal code that outputs category title';
    }

    If you do not do the above, when people go to the MultiCat category page, they will see a random title from one of the multiple categories you want to show on the page, which is not the behavior you want.

  5. Below is the main code that outputs your posts. The if clause at the top allows us to know we are on the multiple categories page (we cannot use other methods such as checking category ID, since that will return a random category’s ID from the multiple categories we want to show).
    
    
    
    
    
    
    
    Here lies the code that outputs your post content
    
    
    
    
    
    Here is the loop that outputs your normal categories
    
    
    

    The $args array contains the query we use to pull posts from the database. We are pulling posts from the categories with the IDs of 3, 4, 671 and 672. Notice that in Step 2 we used category slugs, while in this step we are using category IDs. They have to match, and order may matter.

That’s all.

Caveats

The RSS feed of the category page will be the RSS feed of one of the categories shown on the MultiCat page. This may be fixable through using RSS-specific filters, but in my case I had no need for RSS and did not try to find a fix.