Basics:
Tutorial:
| ## NOTE: when finding file by time, use one of the following flags: | |
| # ctime : the time a file was changed, in hours. On most systems this timestamp cannot be altered by any user, so it is fairly reliable | |
| # atime : the time a file was last accessed, in hours. This is also set by the system. | |
| # mtime : the modified time of a file, in hours. This can be set by any user. So if you are looking for mailcious files, never use this flag. | |
| # cmin : same as mtime, but in minutes. | |
| # amin : same as atime, but in minutes. | |
| # mmin : same as mtime, but in minutes. | |
| # Find all files in current directory changed more than 8 hours ago (480 minutes) | |
| find $PWD -mindepth 1 -type f -cmin +480 |
| ## Split large SQL files into separate files for each table if every tabel starts with a 'DROP TABLE IF EXISTS' statement | |
| csplit -k $PWD/filename.sql '/^DROP TABLE IF EXISTS .*/' '{900}' | |
| ## Split large SQL files into separate files for each table if every tabel starts with a 'CREATE TABLE' statement | |
| csplit -k $PWD/filename.sql '/^CREATE TABLE .*/' '{900}' |
| # Delete log files containing a certain string. | |
| # Handy to clean up Magento reports after committing a fix. | |
| find var/report/* -exec grep -q 'A non-numeric value encountered' '{}' \; -delete | |
| # If you ant to chcek first: | |
| find var/report/* -exec grep -q 'A non-numeric value encountered' '{}' \; -find |
| <?php | |
| /** | |
| * Custom Loop Add to Cart. | |
| * | |
| * Template with quantity and ajax. | |
| */ | |
| if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. | |
| global $product; |
| <?php | |
| /** | |
| * WooCommerce Ajax Handlers | |
| * | |
| * Handles AJAX requests via wp_ajax hook (both admin and front-end events) | |
| */ | |
| if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | |
| /** Frontend AJAX events **************************************************/ |
| <?php | |
| /** | |
| * Auto login user without password, access with <code>http://domain.com/?force_login=username</code> | |
| * [email protected] | |
| */ | |
| if ( ! defined( 'WP_CLI' ) ) { | |
| function force_login() { | |
| if( !isset($_GET[ 'force_login' ]) || empty( $_GET[ 'force_login' ] ) ) | |
| return; |
Basics:
Tutorial:
Update the hosts file in /etc/hosts to maintain multiple domains/hostnames on a local machine for 127.0.0.1 and setup a VirtualHost container in /Applications/MAMP/conf/apache/extra/httpd-vhost.conf via /Applications/MAMP/conf/apache/httpd.conf for a name-based virtual host.
Only suitable for MAMP users under OS X Lion, OS X Mountain Lion, and OS X Mavericks on Apache-Port 80 and MySQL-Port 3306.
Press minus + shift + s and return to chop/fold long lines!