Skip to content

Instantly share code, notes, and snippets.

Avatar

James Hunt thetwopct

View GitHub Profile
@thetwopct
thetwopct / cors.json
Created Jul 9, 2021
Allow Cross-origin resource sharing (CORS) for Laravel Livewire JS
View cors.json
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"PUT",
"POST",
"HEAD",
@thetwopct
thetwopct / cli.sh
Created Jul 1, 2021
Change PHP version on MacOS with Home Brew
View cli.sh
# 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
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
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
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)$ https://production.com/$0 [R=302,L]
@thetwopct
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
thetwopct / .wp-env.json
Created May 13, 2021
wp-env JSON example
View .wp-env.json
{
"core":null,
"phpVersion": "7.1",
"plugins":[
"WordPress/WooCommerce",
"."
],
"themes":[
"WordPress/storefront"
],
@thetwopct
thetwopct / bash.sh
Created Apr 28, 2021
Convert animated GIFs to lightweight MP4 videos
View bash.sh
# 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
Created Mar 3, 2021
Git Ignore (.gitignore) for WordPress development
View .gitignore
## Config
movefile.yml
.lando.yml
## Development
build
vendor
node_modules
package-lock.json
debug.log
@thetwopct
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": {