Friday, 31 October 2014

Linux: Change permissions recursively of only directories or only files

For directories:

find /path/to/folder -type d -exec chmod 755 {} \;

For files:

find /path/to/folder -type f -exec chmod 644 {} \;

Another way:

find /path/to/base/dir -type d -exec chmod 755 {} +
find /path/to/base/dir -type f -exec chmod 644 {} +

However, this seems to be the best solution, when you do not need to unset execute permissions on files:

chmod -R u+rwX,go+rX,go-w /path
The important thing to note here is that X acts differently to x - the man page says The execute/search bits if the file is a directory or any of the execute/search bits are set in the original (unmodified) mode. In other words, chmod u+X on a file won't set the execute bit; and g+X will only set it if it's already set for the user.

Tuesday, 28 October 2014

Apache Keep Alive Setting

This setting determines if a connection is kept alive after a single file is transferred between the server and the browser.

Default is off

Can be turned on depending on available RAM and traffic patterns:

Content Negotiation for Languages

How to configure etags

"remove the iNode portion of Etags. To do this in Apache add the following lines to your configuration file.
<Directory /usr/local/httpd/htdocs>
    FileETag MTime Size

Or choose "MTime  Size" for the Etags setting in WHM's Apache configuration

Monday, 13 October 2014

Jquery multiple selectors

jQuery( "selector1, selector2, selectorN" )

Note that the commas are within the selector.

Jquery iterating over arrays, objects, and array-like objects

var sum = 0;
var arr = [ 1, 2, 3, 4, 5 ];

$.each( arr, function( index, value ){
sum += value;

Javascript associative array

Javascript does not feature associative arrays. However, you can create something similar using object arrays.


arr={'key1': 'value1','key2':'value2'};

This array can be accessed with:

the_value = array['key2']

Values can be added or changes:


More info here:

You can iterate over the object array using Jquery:

$.each( arr, function( index, value ){
sum += value;