Skip to content

Instantly share code, notes, and snippets.

View thetwopct's full-sized avatar

James Hunt thetwopct

View GitHub Profile
@thetwopct
thetwopct / cors.json
Created July 9, 2021 04:58
Allow Cross-origin resource sharing (CORS) for Laravel Livewire JS
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"PUT",
"POST",
"HEAD",
@thetwopct
thetwopct / cli.sh
Created July 1, 2021 11:32
Change PHP version on MacOS with Home Brew
# show php version i.e. 7.3.8
php -v
# update brew to latest
brew update
# to show all php versions available i.e. [email protected]
brew search php
# install it
@thetwopct
thetwopct / colors.scss
Last active June 18, 2021 10:31
SASS function to loop through color palette and spit out classes
// color palette.
$palette: (
primary: (
400: #1bb1e4,
700: #4d84c8,
900: #7ea0c3,
),
secondary: (
400: #a66aae,
700: #5f61a9,
@thetwopct
thetwopct / styles.css
Last active June 9, 2021 12:33
CSS Snippets for Tax Toggle for WooCommerce
/* CSS Snippets for Tax Toggle for WooCommerce. Add these to your CSS file or to your theme via Customizer. */
/* Move down on left */
#wcvat-toggle {
top: 90%;
}
/* Move to right side of screen */
#wcvat-toggle {
left: unset;
@thetwopct
thetwopct / .htaccess
Created May 22, 2021 05:30
WordPress - Using .htaccess to load images from production server
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# If images not found on development site, load from production
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^wp-content/uploads/[^/]+/.+\.(jpe?g|jpg|png|gif)$ https://production.com/$0 [R=302,L]
@thetwopct
thetwopct / functions.php
Last active December 5, 2022 15:02
Translate Tax Toggle for WooCommerce
<?php // don't copy this opening PHP tag if you are pasting in to functions.php
/**
* Change text strings for WooCommerce Tax Toggle
*
* Translate the text used in Tax Toggle plugin.
* Copy the code below to your theme functions.php file.
*
* @param string $translated_text Translated text.
* @param string $text Text to translate.
@thetwopct
thetwopct / .wp-env.json
Created May 13, 2021 18:53
wp-env JSON example
{
"core":null,
"phpVersion": "7.1",
"plugins":[
"WordPress/WooCommerce",
"."
],
"themes":[
"WordPress/storefront"
],
@thetwopct
thetwopct / bash.sh
Created April 28, 2021 15:16
Convert animated GIFs to lightweight MP4 videos
# navigate to folder with gifs in it, then run this at CLI
# qulity is controlled by -b:v - lower the number the worse the quality
for i in *.gif;
do name=`echo "$i" | cut -d'.' -f1`
echo "$name"
ffmpeg -i "$i" -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -b:v 250K "${name}.mp4"
done
@thetwopct
thetwopct / .gitignore
Last active April 11, 2024 04:07
Git Ignore (.gitignore) for WordPress development
## Config
movefile.yml
.lando.yml
## Development
build
vendor
node_modules
package-lock.json
debug.log
@thetwopct
thetwopct / experimental-theme.json
Last active October 15, 2021 16:06
An actual working experimental-theme.json as the WordPress documentation is utter shit
{
"templateParts": {
"header": {
"area": "header"
},
"footer": {
"area": "footer"
}
},
"settings": {