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