Skip to content

Instantly share code, notes, and snippets.

View vguerrerobosch's full-sized avatar

Victor Guerrero vguerrerobosch

View GitHub Profile
@vguerrerobosch
vguerrerobosch / README.md
Last active October 24, 2022 16:39
Configure Sendmail on Laravel Forge

Edit your hosts file

sudo nano /etc/hosts

and add your domain

127.0.0.1 domain.com www.domain.com
@vguerrerobosch
vguerrerobosch / curl-test-smtp.sh
Last active June 28, 2022 10:09
Curl test SMTP
curl --ssl-reqd smtp://smtp.office365.com:587 \
--mail-from [email protected] \
--mail-rcpt [email protected] \
--user '[email protected]:password' \
-T <(echo -e 'From: [email protected]\nTo: [email protected]\nSubject: Curl Test\n\nHello')
@vguerrerobosch
vguerrerobosch / wp-cleanup.md
Last active October 6, 2022 10:24
WordPress database clean up
-- Delete all but posts and attachments
delete
from wp_posts
where post_type not ('post', 'attachment')

-- Select orphan post meta
select *
from wp_postmeta 
left join wp_posts on wp_posts.ID = wp_postmeta.post_id
@vguerrerobosch
vguerrerobosch / wp-image-functions.md
Last active June 2, 2022 09:42
WordPress image functions cheatsheet

Since WordPress function naming is an absolute mess (and so the documentation is) and after +10 years I can't manage to remember any of them, here is a quick cheatsheet I hope makes things easier in the future:

  • Display an HTML img element of the post thumbnail
the_post_thumbnail($size = 'post-thumbnail', $attr = '')
  • Get an HTML img element of the post thumbnail
get_the_post_thumbnail($post = null, $size = 'post-thumbnail', $attr = '')
@vguerrerobosch
vguerrerobosch / wpml-override-translators.md
Last active February 16, 2022 11:37
Allow WordPress users to translate content without setting up WPML translators

Allow WordPress users to translate content without setting up WPML translators

In recent versions of the WordPress plugin WPML you need to manually setup translators, otherwise non-admins will see the message You don't have the rights to translate from {lang} to {lang} when attempting to edit any translation. You can bypass this by adding the following filter in your functions.php

add_filter('wpml_override_is_translator', '__return_true');

Cheers!

@vguerrerobosch
vguerrerobosch / mailchimp.sh
Created February 15, 2021 16:11
List interests in Mailchimp Audience
# List interest categories
curl -X GET \
'https://{server}.api.mailchimp.com/3.0/lists/{list_id}/interest-categories' \
--user 'apikey:API_KEY'
# List interests in category
curl -X GET \
'https://{server}.api.mailchimp.com/3.0/lists/{list_id}/interest-categories/{interest_category_id}/interests' \
--user 'apikey:API_KEY'
(?:__|\@lang)\((?:'|\")(.*)(?:'|\")\)
@vguerrerobosch
vguerrerobosch / duotone.sh
Created June 20, 2020 19:31
Create duotone images with ImageMagick
# Create Color Look Up Table
convert -size 1x1 xc:#008cff xc:#ffffff +append clut.gif
# Create gradient
convert -size 20x256 gradient: -rotate 90 clut.gif -interpolate bilinear -clut gradient.gif
# PNG to JPG
mogrify -format jpg *.png
# Convert to grayscale