Skip to content

Instantly share code, notes, and snippets.

View kbcarte's full-sized avatar

K.B. Carte kbcarte

View GitHub Profile
@kbcarte
kbcarte / disk_usage.md
Last active April 6, 2022 18:48
ssh view disk usage

To view disk usage via cli.

$ df -h --total

Example Output:

Filesystem      Size  Used Avail Use% Mounted on
udev            992M     0  992M   0% /dev
tmpfs           201M   23M  178M  12% /run
/dev/vda7 50G 39G 8.6G 82% /
@kbcarte
kbcarte / wp-rocket_cli.md
Created April 6, 2022 15:27
Install wp-rocket cli and import a previously exported json settings file.

wp cli is usually installed as just wp, but sometimes you may find it called wp-cli instead.

/path/to/wp-rocket-settings-backup.json is the exported json file from wp-rocket. Replace with the path and file name of the json file on your server or cluster.

  • $ wp package install --allow-root wp-media/wp-rocket-cli:trunk
  • $ wp rocket import --file=/path/to/wp-rocket-settings-backup.json
@kbcarte
kbcarte / reset-node_moduels.md
Created March 30, 2022 18:45
nuke node_modules and go again
$ sudo rm -rf package-lock.json node_modules
$ sudo npm cache clean --force
$ npm install
@kbcarte
kbcarte / find-gravity-forms.md
Last active April 4, 2022 15:52
Find all posts and pages in WordPress containing gravity forms

For ALL gravity forms

SELECT `guid`, `post_title` FROM `wp_posts` WHERE `post_content` LIKE '%[gravityform%'

For gravity form by ID

Replace <ID HERE> with the id number found in wp-admin

SELECT `guid`, `post_title` FROM `wp_posts` WHERE `post_content` LIKE '%[gravityform id="<ID HERE>"%'
@kbcarte
kbcarte / security_headers.md
Last active June 2, 2022 17:26
Security Headers .htaccess Example
<IfModule mod_headers.c>
    Header set X-Frame-Options SAMEORIGIN
    Header set X-XSS-Protection "1; mode=block"
    Header set X-Content-Type-Options "nosniff"
    Header set Referrer-Policy "strict-origin-when-cross-origin"
    Header set Strict-Transport-Security "max-age=86400; includeSubDomains;" env=HTTPS
    Header set Permission-Policy "accelerometer=Origin(), autoplay=(), camera=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), publickey-credentials-get=(), usb=()"
    Header always unset X-Powered-By
 Header always unset server
@kbcarte
kbcarte / remove_vc_shortcodes.py
Created March 21, 2022 20:03
Python Removes the old "[vc_]" shortcodes found in the db during migrations. If other shortcodes not specific to vc_* are preset, the regex pattern will need to be updated.
# Python script to find-replace an exported DB
# For use when the php version timeout's or exceeding memory limits
# export db you want to update, rename it to backup.sql
# place backup in same dir as this script
# run script
# import the out.sql file
import re
from pprint import pprint
@kbcarte
kbcarte / remove_vc_shortcodes.php
Last active March 21, 2022 20:01
PHP Removes the old "[vc_]" shortcodes found in post_content during migrations. If other shortcodes not specific to vc_* are preset, the regex pattern will need to be updated.
<?php
// Add to functions.php
// Remove the "[vc_*]" shortcodes usually found during migrations
// Add this shortcode to a debug/test page and visit it
// The page will render and dump all new post/pages to the screen
// This can take a long time if there are a lot of pages/posts
add_shortcode('remove-vc-shortcodes', 'remove_vc_shortcodes');
function remove_vc_shortcodes() {
$pattern = '/\[\/?vc_.*\]?/i';
@kbcarte
kbcarte / wp_allow_svg.php
Created March 16, 2022 16:56
Allow svg upload per WPEngine
<?php
// Allow svg: https://wpengine.com/resources/enable-svg-wordpress/
add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
global $wp_version;
if ( $wp_version !== '4.7.1' ) {
return $data;
}
$filetype = wp_check_filetype( $filename, $mimes );
return [
'ext' => $filetype['ext'],
@kbcarte
kbcarte / sushi-tips.md
Last active February 14, 2022 18:29
general sushi tips

General Tips

  • Use short grain rice, helps more if label for sushi
    • can be medium grain only if you can't find short grain
  • wash rice in COLD water, do not rub or crush rice just gently move around
    • drain and wash again usually 4-5 times, water need to run mostly clear
    • again, COLD water and be gentle
  • use a rice cooker, it will be 200% easier and better in every way
    • let rice cool to room temp or just above, do not work with hot ingredients
    • store bought sushi vinegar or "seasonsed rice vinegar" is fine, no need to do your own or add sugar
  • cucumbers should ALWAYS be english cucumbers, they are used for the really low moisture content.
@kbcarte
kbcarte / cookie-example.html
Created January 19, 2022 18:41
cookieconsent banner