Charlie, or not be? (Censored Version)

Note: I had written an R rated version previously which my friends told me was too sensible. I’m writing a summary for the public release πŸ˜›

A Public Figure does has the right to be questioned, talked and analysed based on their actions.

The prophet of Islam was a public figure. He not only affects the Saudi Arabia but his impact was worldwide and throughout ages (1300+ years). In my humble opinion, I believe anyone can either agree or disagree with his actions. Freedom of belief.

With satire, we can know what people are actually thinking. We can have to opportunity to clarify misunderstandings (if any).

A Message to the New Government

I didn’t want Mauritius a fully dictated country. So now you came on power.

Should I congratulate you for winning or should celebrate the departure of the dictator?

You have won the elections and the more than Rs 100,000 salary. But the people haven’t won anything yet.

Can you keep us happy for the next 1800 days? Ofcourse, ups and downs do occur in life naturally.

Med-point? Ile Plate inaccessible? I’ve heard you no angel as I heard the dictator was no angel too.

Should you fail in your duties,

lepep pu tir to manzer!

Work for your country. Our country. Don’t sell it.

Mauritius is not only for tourists to enjoy the beautiful beaches and natural reserves while Mauritians live in the digestive system in the form of microbes and “moutouk”.

Let’s move to a better Mauritius. A Mauritius for Mauritians πŸ™‚

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