Skip to content

Instantly share code, notes, and snippets.


James Hunt thetwopct

View GitHub Profile
thetwopct / cors.json
Created Jul 9, 2021
Allow Cross-origin resource sharing (CORS) for Laravel Livewire JS
View cors.json
"AllowedHeaders": [
"AllowedMethods": [
thetwopct /
Created Jul 1, 2021
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. php@7.4
brew search php
# install it
thetwopct / colors.scss
Last active Jun 18, 2021
SASS function to loop through color palette and spit out classes
View colors.scss
// color palette.
$palette: (
primary: (
400: #1bb1e4,
700: #4d84c8,
900: #7ea0c3,
secondary: (
400: #a66aae,
700: #5f61a9,
thetwopct / styles.css
Last active Jun 9, 2021
CSS Snippets for Tax Toggle for WooCommerce
View styles.css
/* 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 / .htaccess
Created May 22, 2021
WordPress - Using .htaccess to load images from production server
View .htaccess
# 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)$$0 [R=302,L]
thetwopct / functions.php
Last active May 14, 2021
Translate Tax Toggle for WooCommerce
View functions.php
<?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 / .wp-env.json
Created May 13, 2021
wp-env JSON example
View .wp-env.json
"phpVersion": "7.1",
thetwopct /
Created Apr 28, 2021
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"
thetwopct / .gitignore
Created Mar 3, 2021
Git Ignore (.gitignore) for WordPress development
View .gitignore
## Config
## Development
thetwopct / experimental-theme.json
Last active Mar 10, 2021
An actual working experimental-theme.json as the WordPress documentation is utter shit
View experimental-theme.json
"templateParts": {
"header": {
"area": "header"
"footer": {
"area": "footer"
"settings": {