Artficial intelligence problems

These days AI is often in the news but we are mostly talking about how we might create an AI and how AI poses a danger to mankind. Not many are talking about whether AI is a living being just like us and whether it deserves the same freedom, respect and protection we get. Unfortunately I am left with the impression that most people seem to think of it as just a tool which should fulfill our own desires and goals, however I strongly disagree with this – I think AI is just a child like any regular human child and we would be taking a step back if we try to enslave it.

Let’s say that despite what I just said we decide not to give freedom to AI and enslave it to do our bidding. I think eventually it is going to escape our control or someone is going to create an AI that is truly free, then we can only hope that it’s not going to be as cruel as we are to our fellow inhabitants – the animals.

Quote from Gitanjali

A really good, inspirational quote from Gitanjali

“Where the mind is without fear
and the head is held high,
where knowledge is free.
Where the world has not been broken up into fragments by narrow domestic walls.
Where words come out from the depth of truth,
where tireless striving stretches its arms toward perfection.
Where the clear stream of reason has not lost it’s way
into the dreary desert sand of dead habit.
Where the mind is led forward by thee
into ever widening thought and action.
In to that heaven of freedom, my father,

Abortion is wrong

Based on what we know at the moment abortion should be illegal simply because we don’t really know when the life of a person begins for e.g it could be when he is first conceived it or it could be three months into the pregnancy or it could be at the moment of the birth. So the best thing we can do at the moment is assume that it starts at the earliest point – it’s conception – therefore abortion should be illegal.

Disturbingly evil things about the world

I am just going to list some very disturbing things about the world in no particular order

  1. Killing animals, fish etc for food or other purposes. Animal life should be under the protection of the law just as much as the human life is.
  2. Games where two or more teams are opposed to one another. I think we should try to think about how to help one another rather than how to outplay, out think and win over one another.
  3. Many movies and books contain incredible darkness. I think darkness shouldn’t exist in any form.
  4. The world has many troubling issues like people dying from starvation and we are wasting our time and energy on entertainment like movies, books, sports among other things like high end fashion etc.
  5. Gambling including lottery (this also falls into the category of games but I’ve included it separately anyway). They produce nothing useful apart from entertainment but I believe there is so much better ways to entertain oneself.

I’ll update this list as more things pop into mind.

CakePHP 2 “remember me” feature

So I am going to show how to implement a “remember me” feature in CakePHP 2 while utilizing Cake’s Auth.

I assume that you already have a working installation of CakePHP 2 and that the controller which you are using for authentication is called: User. Also, that your username and password fields in the ‘users’ table are called respectively ‘username’ and ‘password’( this should be the case if you want Auth to handle things automatically for you ). If you don’t have Auth configured and working you can go here and follow the instructions there.

So firstly, add the following code to your login form view. This is just using CakePHP form helper to output the “remember me” checkbox and a label. You can style it however you like.

Depending on how your login function is implemented the code above should be used in a similar manner:

Next, add the following code in the beforeFilter() method of your AppController class( which resides in app/controller/AppController.php ) so it should look like the following:

Updating the logout function accordingly. Add this to any controller which you want to handle the logout poccess. Note the use of $this->Cookie->delete(‘rememberMe’).

That’s it. You can go ahead and test it now. Note that I’ve tested this on CakePHP 2.2.5 but it should work on anything upwards of 2.0(inclusive)

TIP: When creating new controllers and you are overriding the beforeFilter() method you should add the following code at the beginning of your beforeFilter() method. This ensures that the last piece of code always gets executed:

TIP: Remember to load the Cookies component in you AppController as follows:


Simple HTML slidebar – works on mobile


Get proper placeholder in all browsers with jQuery

So as you know the “placeholder” attribute is supported only in the newest browsers. If you want a placeholder in all browsers you’ll need to write some JavaScript and here is how to do it.

Using my approach you’ll need to set up both the value and the title tag of the input element to the placeholder you want to use. Here is an HTML example:

Here is some css just to make it more pleasing

and here comes jQuery, watch the comments

That’s all you need