Skip to content

Instantly share code, notes, and snippets.

View samsargent's full-sized avatar

Sam Sargent samsargent

View GitHub Profile
@samsargent
samsargent / wget-crawl.sh
Created February 13, 2019 01:41
wget crawl and download local mirror of site and all files
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent http://domain.com/
@samsargent
samsargent / database_size.sql
Created August 28, 2018 22:53
Database Size
SELECT table_schema "DB Name",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
FROM information_schema.tables
where table_schema='REPLACE_WITH_DATABASE_NAME'
GROUP BY table_schema;
@samsargent
samsargent / Image Optimise Commands
Created March 16, 2018 07:33
Image Optimise Commands - pngquant jpegoptim
JPEGS
find uploads/ -type f -iname '*.jpg' -exec jpegoptim --strip-all {} +
PNG
find uploads/ -iname "*.png" -exec pngquant --force --quality=40-100 --skip-if-larger --strip --verbose \{} --output \{} \;
@samsargent
samsargent / Rsync
Created March 16, 2018 06:17
Rsync remote to local
rsync -ravzv -e ssh user@externalserver.com:/home/user/test/* --include=".*" /home/user/test
=-+=-+=-+=-+=-+=-+=-+=-+=-+=
List all IP's hitting any domain
=-+=-+=-+=-+=-+=-+=-+=-+=-+=
less /home/*/access-logs/* | awk '{print $1}' | sort | uniq -c | sort -n
=-+=-+=-+=-+=-+=-+=-+=-+=-+=
List all IP's hitting POSTING to any domain
=-+=-+=-+=-+=-+=-+=-+=-+=-+=
@samsargent
samsargent / Gravity Forms Delete Entires.php
Created July 11, 2017 04:36
Remove entries from Gravity Forms
add_action( 'gform_after_submission', 'site_gform_after_submission', 10, 2 );
function site_gform_after_submission ( $entry, $form ) {
GFAPI::delete_entry( $entry['id'] );
}
@samsargent
samsargent / .bash_profile
Last active June 15, 2017 01:31
SSH Shortcuts & Helpers
# add this to your .bash_profile
export PATH=$PATH:$HOME/bin
_complete_ssh_hosts ()
{
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
@samsargent
samsargent / .bash_profile
Created January 24, 2017 02:20
SSH Autocomplete
_complete_ssh_hosts ()
{
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
sed -e s/,.*//g | \
grep -v ^# | \
uniq | \
grep -v "\[" ;
@samsargent
samsargent / Tar GZ - Exclude directory
Created July 10, 2016 22:14
Tar GZ - Exclude directory - good for copying down a live WP install and ignoring uploads
tar -czvf filename.tar.gz /full/path/to/directory --exclude "/full/path/to/directory/to/exclude/wp-content/uploads"
Use this on local /wp-content/uploads:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) http://domain.com/wp-content/uploads/$1
</IfModule>
@samsargent
samsargent / Reset Permissions 755 644
Created July 10, 2016 22:11
Reset Permissions Folders 755 Files 644
find . -type d -exec chmod 0755 {} \; && find . -type f -exec chmod 0644 {} \;