Skip to content

Instantly share code, notes, and snippets.


Emyr Thomas emzo

  • Llandudno, UK
  • Twitter @emyrt
View GitHub Profile
emzo /
Created Oct 7, 2019 — forked from embayer/
set python default encoding to utf-8

change default encoding

cd ~/.virtualenvs/myvirtualenv/lib/python2.x/site-packages
echo 'import sys;sys.setdefaultencoding("utf-8")' >

set default encoding for each new virtualenv

to automatically create a every time you create a virtualenv, edit your

emzo /
Created Jul 29, 2019
Undelete files form Amazon S3 (versioned buckets only)
aws s3api list-object-versions --bucket $BUCKET --prefix $PREFIX --output text |
grep "DELETEMARKERS" | while read OBJECTS
KEY=$( echo $OBJECTS| awk '{print $3}')
VERSION_ID=$( echo $OBJECTS | awk '{print $5}')
emzo / gist:cda9cfc61031395c570373d165773241
Last active Oct 30, 2022
Make Offline Mirror of a Site using `wget`
View gist:cda9cfc61031395c570373d165773241
Sometimes you want to create an offline copy of a site that you can take and view even without internet access. Using wget you can make such copy easily:
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent
Explanation of the various flags:
--mirror – Makes (among other things) the download recursive.
--convert-links – convert all the links (also to stuff like CSS stylesheets) to relative, so it will be suitable for offline viewing.
emzo / gist:81acf12356e66cf4e4420b26e29e950d
Created Apr 24, 2019
Restart Bluetooth via terminal on macOS Mojave 10.14
View gist:81acf12356e66cf4e4420b26e29e950d
sudo launchctl stop

Keybase proof

I hereby claim:

  • I am emzo on github.
  • I am emzo ( on keybase.
  • I have a public key ASAroVczH5_U9AmuvtuCcsIxVrvPCXQlB70lXJTFP0d-uwo

To claim this, I am signing this object:

View mailgun-test-mode.php
add_action( 'phpmailer_init', function( $phpmailer ) {
$phpmailer->addCustomHeader("X-Mailgun-Drop-Message: yes");
View post_thumbnail_body_class.php
function darpar_body_class( $classes ) {
if ( is_singular() && has_post_thumbnail() ) {
array_push( $classes, 'has-thumbnail' );
if ( is_product_category() && get_woocommerce_term_meta( get_queried_object_id(), 'thumbnail_id', true ) ) {
array_push( $classes, 'emyr' );
emzo / wp_mail_smtp_custom_options.php
Created Jun 14, 2016
Alow SSL conections to sites with self-signed or problematic certificates
View wp_mail_smtp_custom_options.php
add_filter('wp_mail_smtp_custom_options', function( $phpmailer ) {
$phpmailer->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
emzo / wp_link_query_term_linking.php
Created Jun 14, 2016
Allow linking to taxonomy terms as well as posts when performing internal linking
View wp_link_query_term_linking.php
emzo / soliloquy-slug.php
Created Feb 4, 2013
Add slider slug name to css attributes of soliloquy container div
View soliloquy-slug.php
// Add slug in CSS class of all sliders
add_filter( 'tgmsp_slider_classes', 'clinicoftcm_slider_classes', 10, 2 );
function clinicoftcm_slider_classes( $classes, $id ) {
$slider = get_post( $id, ARRAY_A );
if( $slider['post_name'] )
$classes[] = 'soliloquy-' . $slider['post_name'];
return $classes;