Sunday, 5 June 2016
Set the timezone in a script
date_default_timezone_set('Asia/Kolkata');
For a list of timezones: http://php.net/manual/en/timezones.asia.php
Monday, 8 December 2014
Fedora: how to restart nginx and php-fpm
sudo service nginx restart
sudo service php-fpm restart
sudo service php-fpm restart
Monday, 1 December 2014
PHP file browser
http://sourceforge.net/projects/autoindex/
Monday, 24 November 2014
Check if an array is multi-dimensional
if (count($array) == count($array, COUNT_RECURSIVE))
{
echo 'array is not multidimensional';
}
else
{
echo 'array is multidimensional';
}
http://stackoverflow.com/questions/145337/checking-if-array-is-multidimensional-or-not
Filtering data with PHP (Sanitizing data) and Validation
http://www.phpro.org/tutorials/Filtering-Data-with-PHP.html
http://code.tutsplus.com/tutorials/sanitize-and-validate-data-with-php-filters--net-259
http://www.sitepoint.com/input-validation-using-filter-functions/
To filter arrays:
http://stackoverflow.com/questions/19637210/post-variable-array-and-filter-input
http://php.net/manual/en/function.filter-input.php
http://php.net/manual/en/filter.constants.php
http://php.net/manual/en/function.filter-input-array.php
http://php.net/manual/en/filter.filters.php
http://php.net/manual/en/filter.filters.validate.php
http://code.tutsplus.com/tutorials/sanitize-and-validate-data-with-php-filters--net-259
http://www.sitepoint.com/input-validation-using-filter-functions/
To filter arrays:
http://stackoverflow.com/questions/19637210/post-variable-array-and-filter-input
http://php.net/manual/en/function.filter-input.php
http://php.net/manual/en/filter.constants.php
http://php.net/manual/en/function.filter-input-array.php
http://php.net/manual/en/filter.filters.php
http://php.net/manual/en/filter.filters.validate.php
Get url query string parameters using Javascript only
http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
Difference between array merge and array + array
http://stackoverflow.com/questions/5394157/whats-the-difference-between-array-merge-and-array-array
Responsive Design: Screen resolution reference
http://spirelightmedia.com/resources/responsive-design-device-resolution-reference
Using rems
https://bugsnag.com/blog/responsive-typography-with-rems
http://snook.ca/archives/html_and_css/font-size-with-rem
http://snook.ca/archives/html_and_css/font-size-with-rem
CSS Clear Fix
http://perishablepress.com/lessons-learned-concerning-the-clearfix-css-hack/
Parallax websites
http://moz.com/blog/parallax-scrolling-websites-and-seo-a-collection-of-solutions-and-examples
Single Page Website
http://searchengineland.com/single-page-websites-seo-182506
Install both OpenJDK and Oracle Java on Fedora
Use the "alternatives" app to switch between the two.
http://www.if-not-true-then-false.com/2010/install-sun-oracle-java-jdk-jre-7-on-fedora-centos-red-hat-rhel/
http://www.if-not-true-then-false.com/2010/install-sun-oracle-java-jdk-jre-7-on-fedora-centos-red-hat-rhel/
Assign event to Escape keypress
$(document).keyup(function(e) {
if (e.keyCode == 27) { some_code_here } // esc
});
CSS 3 resize property
https://developer.mozilla.org/en-US/docs/Web/CSS/resize
https://developer.mozilla.org/samples/cssref/resize.html
Doesn't work on iframes in Firefox 33
https://developer.mozilla.org/samples/cssref/resize.html
Doesn't work on iframes in Firefox 33
Prevent link from doing default action
http://api.jquery.com/event.preventdefault/$( "a" ).click(function( event ) {event.preventDefault();});
Make link open in parent of iframe
window.parent.location.href= "http://www.google.com";
Saturday, 8 November 2014
Restrict web site access to specific IP addresses in Apache
order deny,allow
deny from all
allow from 111.222.333.444
Put the above code in the .htaccess in the root. You can add more "allow from" lines for more ip addresses.
http://stackoverflow.com/questions/4400154/htaccess-deny-all-allow-only-one-ip
Friday, 7 November 2014
Word wraping by word breaking
.break-word {
word-wrap: break-word;
}
http://webdesignerwall.com/tutorials/word-wrap-force-text-to-wrap
word-wrap: break-word;
}
http://webdesignerwall.com/tutorials/word-wrap-force-text-to-wrap
Friday, 31 October 2014
Linux: Change permissions recursively of only directories or only files
For directories:
For files:
Another way:
http://superuser.com/questions/91935/how-to-chmod-755-all-directories-but-no-file-recursively
However, this seems to be the best solution, when you do not need to unset execute permissions on files:
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 {} +
http://superuser.com/questions/91935/how-to-chmod-755-all-directories-but-no-file-recursively
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.
Subscribe to:
Posts (Atom)