Enable mcrypt on ubuntu 14.04

Credit to this SO post: http://askubuntu.com/questions/460837/mcrypt-extension-is-missing-in-14-04-server-for-mysql

Should show it located at /etc/php5/mods-available

Edit mcrypt.ini and change extension to match the path to mcrypt.so, example:

Now this:

Verify that new files exists here (they should be auto created from the issue above)

Otherwise do the following
Create symbol links now

Restart Apacahe

Angualr js directive to preload data from the server

I needed to preload a twig template with data server side but required the data to be available from within the angualr js app.

This directive looks for a pre-load attribute then simply loads the ng-model found on the element with the preload data. The directive also checks that the ng-model path follows std javascript naming conventions… in case some clever dude figures out a way to hack the directive with their own dodgy code.

With this directive in place the following sets the ng-model with the data in the preload attr:

As the directive builds a path to the scope based on the ng-model, you can go as deep into the expected object as needed, eg:

Natural sort for MySQL

Given the list:

1
2
3
10
11
12a
12b
12c
Alpha
Beta
Charlie

If running a normal ORDER BY it will order the list:
1
10
11
12a
12b
12c
2
3
Alpha
Beta
Charlie

You can CAST the results to UNSIGNED during the ORDER BY to achieve naturally sorted results as shown in the first list.