Skip to content

Instantly share code, notes, and snippets.

View jacobmc's full-sized avatar

Jacob McKinney jacobmc

View GitHub Profile
@jacobmc
jacobmc / .htaccess
Created February 25, 2022 20:16
Proxy for Production Images on Localhost
# BEGIN Dev Image
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.localhost$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^\/app\/uploads\/(?!beaverbuilder)[^\/]*\/.*$
RewriteRule ^(.*)$ https://www.example.com/$1 [QSA,L]
</IfModule>
@jacobmc
jacobmc / .htaccess
Created October 22, 2021 18:46
Rewrites file paths to come from production if they don't exist locally. Add to top of .htaccess
# BEGIN Dev Image
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.localhost$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^\/app\/uploads\/(?!beaverbuilder)[^\/]*\/.*$
RewriteRule ^(.*)$ https://www.example.com/$1 [QSA,L]
</IfModule>
@jacobmc
jacobmc / run-updates.sh
Last active October 4, 2022 15:29
Bash Script for starting an updates feature for a Bedrock WordPress site
#!/bin/bash
read -p "Have you pulled the latest changes? (y/N)" pulled
## Exit if user has not pulled latest changes
if [ "$pulled" != "y" ]; then
echo "exiting..."
exit
fi
@jacobmc
jacobmc / anchor-link.js
Last active August 13, 2021 20:19
Fix for using anchor links with a fixed header
@jacobmc
jacobmc / script.js
Created March 29, 2021 15:30
Convert string to camel case in Javascript
/**
* Converts string to camel case
*
* Changes characters following a hyphen, underscore, space, or period.
*
* Thanks @vitaly-t for this function (https://stackoverflow.com/questions/2970525/converting-any-string-into-camel-case#answer-57927739)
*/
function camelize(text) {
text = text.replace(/[-_\s.]+(.)?/g, (_, c) => c ? c.toUpperCase() : '');
return text.substr(0, 1).toLowerCase() + text.substr(1);
@jacobmc
jacobmc / .htaccess
Created February 19, 2021 17:01
Getting Production Images Locally - WordPress Bedrock
# BEGIN Dev Image
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.localhost$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^\/app\/uploads\/(?!beaverbuilder)[^\/]*\/.*$
RewriteRule ^(.*)$ https://www.example.com/$1 [QSA,L]
</IfModule>
@jacobmc
jacobmc / bedrock-migration.sh
Last active February 22, 2022 02:19
Bedrock Migration CLI Commands
# Commands for updating the WordPress database for a migration
# from a flat WordPress install to a Bedrock install
wp search-replace /wp-content /app --all-tables
wp search-replace /wp-admin /wp/wp-admin --all-tables
wp search-replace /wp-login.php /wp/wp-login.php --all-tables
wp search-replace /xmlrpc.php /wp/xmlrpc.php --all-tables
# Chained Commands
wp search-replace /wp-content /app --all-tables && wp search-replace /wp-admin /wp/wp-admin --all-tables && wp search-replace /wp-login.php /wp/wp-login.php --all-tables && wp search-replace /xmlrpc.php /wp/xmlrpc.php --all-tables
function var_error_log( $object=null ){
ob_start(); // start buffer capture
var_dump( $object ); // dump the values
$contents = ob_get_contents(); // put the buffer into a variable
ob_end_clean(); // end capture
error_log( $contents ); // log contents of the result of var_dump( $object )
}
$object = new MyObject();
var_error_log( $object );

Keybase proof

I hereby claim:

  • I am jacobmc on github.
  • I am jacobmc (https://keybase.io/jacobmc) on keybase.
  • I have a public key ASA1BiecECFNC-X99Cf4fhIG8V9x_9FcGii4cwy_3oKzUgo

To claim this, I am signing this object:

@jacobmc
jacobmc / woocommerce-buttons.scss
Created March 14, 2018 05:02
Woocommerce Button SASS
.woocommerce,
.woocommerce-page {
input.button,
input.button.alt,
a.button,
a.button.alt,
button.button,
button.button.alt {
background-color: $purple;
color: $white;