The Fourth and Fifth Dimension

Relativity
Watched Interstellar (2014) recently. It led me to ask some questions about our universe itself. What is time? What is space? I watched a video on YouTube explaining the concept of relativity:

From what i understood, all speeds are relative to another point except that speed of light is constant independent of who is observing it and whether they are in motion. We usually think of time as same for everyone. But the Theory of Relativity allows time to be dilated or go faster.

The Fourth Dimension
Coming back to the movie, how can someone be in the future, present and past all at the same time? Watch this video about “Imagining the Fourth Dimension”

The author of the video says time is the fourth dimension. That’s why Cooper was seeing multiple states of the library but at different point in time. How was he able to do this? You could note that it the whole universe was not available to him. When he was in one state of the library, he walked till the end, and reached another state of the library.

That why i guess we cannot travel in time. Because the universe is too large for us. We’d have to give up on part of our universe so as we can move in a limited section but in time too.

But hey! What if a take my camcorder and make a short movie? It is 2D images but with Time acting as my third dimension. When i play the movie again, i can move in time.

The Fifth Dimension
Time as the fourth dimension to our 3 dimensional world isn’t a bad idea IMO. The fifth dimension according to the video’s author is the probabilistic space that the fourth dimension is in.

I think simulation is what we do to actually move in 4D and 5D to predict the future.

Chess
Chess is a 2D game.
3D would mean someone being able to move in time to see each move.
4D would mean the set of all possible moves playable i.e. 10^120 according to some numbers i found on the internet (needs confirm)

The more a chess player goes into the fourth dimension and think about the possible moves that might be played after, the better he is 😀

A 3D game as a First Person Shooter would require 5D to actually get all possible combinations, 4D being 3D in Time

Ok. Think I’m done now :3

Mass Importing into SQL Database from .csv File

If you have to import let’s say for example Country Name and County Code into a database from a CSV file like this: (source)

Code,English Name,French Name
AD,Andorra,Andorre
AE,United Arab Emirates,Émirats arabes unis
AF,Afghanistan,Afghanistan
AG,Antigua and Barbuda,Antigua-et-Barbuda

The database schema is as follows:

country_code {country_code,country_name}

In PHP, you could have done:

(Method 1)

$file_handle = fopen(dirname(__FILE__) .
               "/countries.csv", "r");
while (!feof($file_handle) ) {
	$line = fgetcsv($file_handle, 1024);
	$line[1] = mysql_real_escape_string($line[1]); 
	$sql = "INSERT INTO country_code 
	(country_code,country_name) 
	VALUES ('{$line[0]}','{$line[1]}');";
	$db->query($sql);
}
fclose($file_handle);


But it takes about 3 seconds to import the CSV attached. If you have a file with lets say with 50,000 records, it might take hours to run. It is really annoying to have Core i7 computers with lots of RAM and yet you run a process which takes hours to run using only 0 – 1% CPU.

I/O from the Hard Drive is limiting the speed tremendously as each time a record is being read, the HDD is accessed, MySQL then accesses the HDD to save and so on. Even a Solid State Drive (SSD) doesn’t solve the problem (I tried. Still takes hours).

I had to find a way to load a somewhat big chunk of the file into memory then execute the insert query for every 1000 records. I came up with the following code:

(Method 2)

$file_handle = fopen(dirname(__FILE__) 
	. "/countries.csv", "r");
$init_sql = "INSERT INTO country_code 
	(country_code,country_name) VALUES ";
$sql = $init_sql;
$count = 1;
$i = 0;
while (!feof($file_handle) ) {
	$line = fgetcsv($file_handle, 1024);
	$line[1] = mysql_real_escape_string($line[1]);
	$sql .= "('{$line[0]}','{$line[1]}'),";
	if($count++ >= 1000){
		$i++;
		$count = 0;
		$sql = rtrim($sql , ',');
		$sql .= ";";
		$db->query($sql);
		$sql = $init_sql;
	}
}
$sql = rtrim($sql , ",");
$sql .= ";";
$db->query($sql);
fclose($file_handle);

Method 1 exec time: 3.0624158382416 s
Method 2 exec time: 0.010763883590698 s

Method 2 is 284 x faster

The import time is considerably improved. According to my benchmarks, it is 270-285x faster.

I was once importing US ZIP codes in a database. It contained between 43k records. The second method allows importing it in less than 5 seconds 😉

Activate WiFi 802.11n on your Orange Livebox

Going in Windows Task Manager > WiFi, i noticed i was connected using 802.11g despite both my laptop (Dell Inspiron 5547) and my Orange Livebox supports 802.11n.

I logged in 192.168.1.1. Tried to set the WiFi to 802.11n only.

802.11g

But it wouldn’t allow me to.

802.11gsave

I went on changing the encryption for my SSID.

802.11n_encrypt

And i got connected to WiFI 802.11n 😀

802.11n

My New Laptop: Dell Inspiron 5547 (Hardware)

Quick Specs:
– CPU: Core i7 up to 3.1GHz
– RAM: 8GB
– GFX: AMD Radeon with 2GB VRAM + Intel HD Graphics 4400
– HDD: 1TB
– Screen: 15.6″ @ 1366 x 768

CameraZOOM-20141120124839980

CameraZOOM-20141121220522091

Technical Specs:

CPU: Intel® Core i7-4510U Processor (4M Cache, up to 3.10 GHz)

My previous laptop had a dual-core CPU (Core i5-480M) which could achieve 2.9GHz. The current CPU despite being a Core i7, is still a dual-core which can attain 3.1GHz only. It has 4MB L3 cache which i hope helps in extra performance.

Only benchmarking can tell whether this CPU is worthwhile over my previous Core i5. (Benchmark coming soon)

RAM: 8GB

My previous laptop had 4GB RAM (it was originally 3GB). Hope the 8GB will be sufficient for the next 2 years.

Graphics: AMD Radeon R7 M260 (2GB VRAM) + Intel® HD Graphics 4400

Finally a graphic card in my house 😀 Hope I can play some games now even if games are in range of 2005 – 2010. I’m fine with that.

snapshot16

The nice thing is that the dedicated Radeon graphics can be switched off when not needed thus saving battery life 😀

Storage: 1TB HDD

No SSD drive unfortunately. You can actually *feel* the Hard Drive hindering the performance of the laptop while the CPU tells you to feed him more. Must swap the drive for an SSD in the future. Only then the real power would be unleashed!

Screen: 15.6″ @ 1366 x 768

Nothing extraordinary here. Just like any other laptop on the market. Wished it were 1080p :-/

Misc

Audio Jack

It got a single audio jack on the right. It can be quite inconvenient since i am right handed and i usually use a mouse.

CameraZOOM-20141120165452034

It doesn’t has a dedicated port for mic so i’ll have to buy a ‘jack splitter’ to be able to use my headset’s mic.

Keyboard

Kinda disappointed that the media shortcut buttons (Play/Pause, Next, Previous) do not have a button bump like my previous laptop had on Play/Pause.

Keyboard Bump on Inspiron N5010

vs

Inspiron 5000 Media Buttons

Changing music would now require me to obligatorily look at the keyboard instead of using my finger senses. Causes inconvenience in the dark or when focusing on something important.

Touchpad

This one has a huge touchpad. The surface is not as smooth as my Inspiron N5010. I feel as if my fingers would be used after sometimes. I prefer small touchpad which are fast and butterly smooth like my previous laptop

Coming Up: Getting Started with Kubuntu 14.04 LTS

Installing Kubuntu 14.04 alongside Windows 8.1 with both Secure Boot and EFI ON was a breeze.

Stay tuned…

The 3 Arrays of Life

Everything that happen to us can be classified as follows:

  1. Favour from God
  2. Test from God
  3. Punishment (Karma)

Favours

A favour is something good that happens to us. e.g. we have food in front of us. Or we get a promotion in our job. Or we have a healthy body.

Tests

A test is something which we consider as ‘undesirable’ such as property loss, getting sick, your children dying, getting a leg crushed under a truck. Theory says God is testing your patience and loyalty.

Punishment

Punishment (Karma) is a like a test but it is for people who have done a previous bad deed. For example, if one person steals then falls sick, it will be said that because he stole, he is paying for his action.

Is life fair?

By definition,

“God is good.” (Quran, Bible, etc)

If he created Satan means he created a testing tool.

Some tests end in ugly ways. Children getting exploded in Syria, Palestine; Women getting raped; Dying in famines; People born handicapped; People being mentally retarded.

How can God be still good? Different religions try to solve ‘the equations‘ by either saying: OK, there’s paradise in which the people will finally rejoice. Others say it is because they did wrong in their previous lives that karma is punishing them. Next life would be cool.

Ending…

Planet earth, if considered alone, seems to be unfair/unjust/cruel. Based on the discussion above, we see that an external entity such Paradise or Reincarnation is needed as a parameter to solve the equation of life and to be able to yet have a good God.

And for those who think the equation hasn’t been solved, theory says:

God’s wisdom is infinite (∞).

It should be enough to overpower any finite variables such as tests and punishments. Period.