Skip to content

Instantly share code, notes, and snippets.

Sam Sargent samsargent

  • Vivo Group
  • Brisbane, Australia
Block or report user

Report or block samsargent

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@samsargent
samsargent / wget-crawl.sh
Created Feb 13, 2019
wget crawl and download local mirror of site and all files
View wget-crawl.sh
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent http://domain.com/
View clear-drupal-cache.php
<?php
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_flush_all_caches();
?>
View database_size.sql
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;
View Server Log File helpers
=-+=-+=-+=-+=-+=-+=-+=-+=-+=
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 / Image Optimise Commands
Created Mar 16, 2018
Image Optimise Commands - pngquant jpegoptim
View Image Optimise Commands
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 Mar 16, 2018
Rsync remote to local
View Rsync
rsync -ravzv -e ssh user@externalserver.com:/home/user/test/* --include=".*" /home/user/test
@samsargent
samsargent / Gravity Forms Delete Entires.php
Created Jul 11, 2017
Remove entries from Gravity Forms
View Gravity Forms Delete Entires.php
add_action( 'gform_after_submission', 'site_gform_after_submission', 10, 2 );
function site_gform_after_submission ( $entry, $form ) {
GFAPI::delete_entry( $entry['id'] );
}
View Parsely.js Mobile Number Validation
<input type="text" class="text" name="mobilePhone" id="mobilePhone" value="" parsley-regex-message="Please enter a valid Australian mobile phone number." parsley-regexp="^\(?(?:\+?61|0)4\)?(?:[ -]?[0-9]){2}\)?(?:[ -]?[0-9]){5}[0-9]$"/>
@samsargent
samsargent / .bash_profile
Last active Jun 15, 2017
SSH Shortcuts & Helpers
View .bash_profile
# 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 ' ' | \
View GA EVent Tracking on PDF's.js
$('a[href$=".pdf"]').click(function(){
ga('send', {
hitType: 'event',
eventCategory: 'Download',
eventAction: 'PDF',
eventLabel: this.href
});
});
You can’t perform that action at this time.