Skip to content

Instantly share code, notes, and snippets.

@phillipwilhelm
phillipwilhelm / linux_find_size_modified_date_and_remove_files.sh
Created April 1, 2020 04:31 — forked from joostvanveen/linux_find_size_modified_date_and_remove_files.sh
Linux commands to find all files modified older than a certain date or time, remove, find largest files or folder in a human readable way.
## 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
@phillipwilhelm
phillipwilhelm / csplit.sh
Created April 1, 2020 04:31 — forked from joostvanveen/csplit.sh
Split large SQL files into separate files for each table
## 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}'
@phillipwilhelm
phillipwilhelm / delete_files_continaing_a_string.sh
Created April 1, 2020 04:31 — forked from joostvanveen/delete_files_continaing_a_string.sh
Delete log files containing a certain string. Handy to clean up Magento reports after committing a fix.
# 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
@phillipwilhelm
phillipwilhelm / add-to-cart.php
Created March 31, 2020 23:19 — forked from claudiosanches/add-to-cart.php
WooCommerce - Template add-to-cart.php with quantity and Ajax!
<?php
/**
* Custom Loop Add to Cart.
*
* Template with quantity and ajax.
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
global $product;
@phillipwilhelm
phillipwilhelm / woocommerce-ajax.php
Created March 28, 2020 23:59 — forked from qutek/woocommerce-ajax.php
[Wordpress] [Woocommerce] WooCommerce Ajax Handlers
<?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 **************************************************/
@phillipwilhelm
phillipwilhelm / force-login.php
Created March 28, 2020 21:16 — forked from qutek/force-login.php
[ Force Login ] Force login WordPress user without password, use it as plugin or place the code under mu-plugins / wp-config.php ( after `require_once(ABSPATH . 'wp-settings.php');` )
<?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;
@phillipwilhelm
phillipwilhelm / README.md
Created March 28, 2020 06:07 — forked from hofmannsven/README.md
SQL analyzing business metrics
@phillipwilhelm
phillipwilhelm / README.md
Created March 28, 2020 06:06 — forked from hofmannsven/README.md
Virtual Hosts with MAMP on OS X

Virtual Hosts

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.

@phillipwilhelm
phillipwilhelm / README.md
Created March 28, 2020 06:06 — forked from hofmannsven/README.md
This is my global Git/Bash userprofile. All files are named with a dot at the beginning (e.g. ~/.bash_profile, ~/.git-completion.bash, ~/.git-prompt.sh, ~/.gitconfig, ~/.gitignore_global)
@phillipwilhelm
phillipwilhelm / README.md
Created March 28, 2020 06:05 — forked from hofmannsven/README.md
Git Cheatsheet