Skip to content

Instantly share code, notes, and snippets.

Avatar

Rob Scott robin-scott

View GitHub Profile
@robin-scott
robin-scott / google-drive-large-wget.txt
Created Jan 7, 2020
Wget command for large files collection from Google Drive
View google-drive-large-wget.txt
// Use the below to wget in large files (over 100MB) from Google Drive. Added by Robin Scott of SiliconDales.com. See full instructions at https://silicondales.com/tutorials/g-suite/how-to-wget-files-from-google-drive/
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILE_ID' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=FILE_ID" -O FILE_NAME && rm -rf /tmp/cookies.txt
@robin-scott
robin-scott / wgetcomman.txt
Last active Jan 7, 2020
Google Drive small file wget command
View wgetcomman.txt
// Wget command to collect small files from Google Drive added by Robin Scott of silicondales.com
wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILE_ID' -O FILE_NAME
@robin-scott
robin-scott / gist:cb297a299ebe8eb8b405e32230e3c013
Last active Oct 28, 2019
Only use product tags in WooCommerce related products
View gist:cb297a299ebe8eb8b405e32230e3c013
// Remove categories and only use tags in WooCommerce related products - By Robin Scott of Silicon Dales see https://silicondales.com/tutorials/woocommerce/remove-categories-only-use-tags-related-products/
add_filter( 'woocommerce_product_related_posts_relate_by_category', '__return_false' );
@robin-scott
robin-scott / .htaccess
Created Nov 27, 2018
Codeigniter .htaccess for mod_rewrite - see https://silicondales.com/tutorials/codeigniter-htaccess/ for details
View .htaccess
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
View .htaccess
## EXPIRES CACHING - by Robin Scott of Silicon Dales, here https://silicondales.com/tutorials/seo/leverage-browser-caching-images-css-js/##
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
View SQL
update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');
View .htaccess
Order Deny,Allow
Deny from 222.222.222.222
@robin-scott
robin-scott / functions.php
Last active Nov 21, 2018
WooCommerce - Add extra weight to all cart items in a specific shipping class - Find out more here -> https://silicondales.com/tutorials/woocommerce/add-additional-shipping-weight-to-cart-items-in-a-shipping-class/
View functions.php
// By Robin Scott of Silicon Dales
// Add 6oz extra weight to all cart items in specific shipping class
// More information here: https://silicondales.com/tutorials/woocommerce/add-additional-shipping-weight-to-cart-items-in-a-shipping-class/
add_action( 'woocommerce_before_calculate_totals', 'rscott_add_custom_weight', 10, 1);
function rscott_add_custom_weight( $cart_object ) {
if ( (is_admin() && ! defined( 'DOING_AJAX' ) ) || $cart_object->is_empty() )
return;
if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 )
return;
$additionalweight = 6;
@robin-scott
robin-scott / htaccess
Created Oct 19, 2018
Deny access to wp-admin BUT allow ajax to be used in WordPress
View htaccess
// Add this to an .htaccess file at the top of the wp-admin directory to lock down this section of your site to only trusted IP addresses - BUT still allow ajax access
// By Robin Scott of Silicon Dales - details here: https://silicondales.com/tutorials/wordpress/lock-out-all-traffic-except-your-ip-from-login-admin/
<Files admin-ajax.php>
Order allow,deny
Allow from all
Satisfy any
</Files>
Order Deny,Allow
Deny from all
View htaccess
// Add this to an .htaccess file at the top of the wp-admin directory to lock down this section of your site to only trusted IP addresses
// By Robin Scott of Silicon Dales - details here: https://silicondales.com/tutorials/wordpress/lock-out-all-traffic-except-your-ip-from-login-admin/
Order Deny,Allow
Deny from all
Allow from X.X.X.X
You can’t perform that action at this time.