Blog

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.

Page 3 of 4
1 2 3 4