Skip to content

Instantly share code, notes, and snippets.

View sftsk's full-sized avatar

Lukas Jakob Hafner sftsk

View GitHub Profile
@sftsk
sftsk / how-to-set-up-stress-free-ssl-on-os-x.md
Created July 10, 2016 15:51 — forked from jed/how-to-set-up-stress-free-ssl-on-os-x.md
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

https://getgrav.org/blog/mac-os-x-apache-setup-ssl

$ sudo nano /etc/apache2/httpd.conf In this file you should uncomment both the socache_shmcb_module, ssl_module, and also the include for the httpd-ssl.conf by removing the leading # symbol on those lines:

LoadModule socache_shmcb_module libexec/apache2/mod_socache_shmcb.so ... LoadModule ssl_module libexec/apache2/mod_ssl.so ...

rsync -avzh -e 'ssh -i /Users/sftsk/.ssh/torggler.bz.pem' ./ ubuntu@ec2-52-16-237-101.eu-west-1.compute.amazonaws.com:/var/www/torgglerbz_staging/current/web/app/plugins/OAuth1
@sftsk
sftsk / custom-search-acf-wordpress.php
Created August 11, 2016 15:06 — forked from charleslouis/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request
<?php
/**
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* @return [array] [list of custom fields]
*/
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
}

http://awcdev.com/how-to-change-the-notification-email-to-new-users-in-wordpress/

The notification email that new users receive from WordPress can be changed by creating a simple plugin.

First, create a plugin file in your plugins folder. Name it whatever you like (for example, change-new-user-email-notification.php).

Then, add the code below, which is borrowed from https://codex.wordpress.org/Function_Reference/wp_new_user_notification. In this example the new content for the notification email is on lines 46-50. Change those lines to suit your own needs. You can ignore the rest of the code and leave it as is.

<?php
// put array in here
$array = array (
'key' => 'group_54624ad06f391',
'title' => 'Company List',
'fields' => array (
array (
'key' => 'field_54624aff43237',
'label' => 'Companies',
@sftsk
sftsk / pll_copy_post_metas.php
Created August 25, 2016 11:05 — forked from qstudio/pll_copy_post_metas.php
WP / PolyLang / Un-Sync Specified Custom Fields
<?php
// filter to exclude specified post_meta from Polylang Sync ##
add_filter( 'pll_copy_post_metas', 'q_pll_copy_post_metas' );
/**
* Remove defined custom fields from Polylang Sync
*
* @since 0.1
* @param Array $metas
@sftsk
sftsk / gist:bdcea9f35b883f322d0eadcaf317a1be
Created September 26, 2016 12:13
issues pll string translations
[26-Sep-2016 13:10:42 Europe/London] PLL_Language Object
(
[term_id] => 54649
[name] => Deutsch
[slug] => de
[term_group] => 0
[term_taxonomy_id] => 54649
[taxonomy] => language
[description] => de_DE
[parent] => 0
@sftsk
sftsk / gist:5a0f1f6df7c5202e7fb487a09be8787a
Created November 8, 2016 10:58
Browser language based forward .htaccess
# redirect first visitors basing on their language or redirect if language not specified
# in URL. If italian, redirect to italian
# if lang is Italian use it
RewriteCond %{THE_REQUEST} !\s/(de|it|app|wp)/ [NC]
RewriteCond %{HTTP:Accept-Language} ^it [NC]
RewriteRule ^ /it%{REQUEST_URI} [L,NC,R=301]
# otherwise use German
RewriteCond %{THE_REQUEST} !\s/(de|it|app|wp)/ [NC]
RewriteRule ^ /de%{REQUEST_URI} [L,NC,R=301]
@sftsk
sftsk / nginx-multisite-fix.conf
Last active June 21, 2022 11:38
fix nginx multisite redirect loop using roots/bedrock
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) /wp$2 last;
rewrite ^(/[^/]+)?(/.*\.php) /wp$2 last;
}