Skip to content

Instantly share code, notes, and snippets.

docker run -d -p <PORT_OF_YOUR_CHOICE>:6379 redis
@sander1
sander1 / wp_kses_post_tags.php
Created August 20, 2017 19:02 — forked from bjorn2404/wp_kses_post_tags.php
WordPress allow iFrames with wp_kses_post filter
<?php
/**
* Add iFrame to allowed wp_kses_post tags
*
* @param string $tags Allowed tags, attributes, and/or entities.
* @param string $context Context to judge allowed tags by. Allowed values are 'post',
*
* @return mixed
*/
@sander1
sander1 / preview.sh
Last active August 29, 2019 09:22
Video preview script from https://davidwalsh.name/video-preview
sourcefile=$1
destfile=$2
# Overly simple validation
if [ ! -e "$sourcefile" ]; then
echo 'Please provide an existing input file.'
exit
fi
if [ "$destfile" == "" ]; then
@sander1
sander1 / gist:e38b7fa7686468646c8edc765232511f
Created February 17, 2017 14:25
WordPress: Change Mail From and Return Path
add_filter('wp_mail_from', function($email) {
return 'you@your-domain.com';
});
add_filter('wp_mail_from_name', function($name) {
return get_option('blogname');
});
class email_return_path {
function __construct() {
@sander1
sander1 / gist:e7bd6d5c1445667fbba8991d44cf9f0e
Created February 17, 2017 14:24
WordPress: Disable JSON REST API
add_filter('json_enabled', '__return_false');
add_filter('json_jsonp_enabled', '__return_false');
remove_action('wp_head', 'rest_output_link_wp_head', 10);
remove_action('template_redirect', 'rest_output_link_header', 11, 0);
@sander1
sander1 / gist:c8dd59792597bed18cbe1d14604ff369
Created February 17, 2017 14:23
WordPress: Cleanup Head Tag
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'wp_shortlink_wp_head');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'feed_links_extra', 3);
@sander1
sander1 / gist:08f12332d85bd87b3143c5b2058a5387
Created February 17, 2017 14:20
WordPress: Hide Author Usernames
add_action('template_redirect', 'bwp_template_redirect');
function bwp_template_redirect() {
if (is_author()) {
wp_redirect(home_url());
exit;
}
}
@sander1
sander1 / notify_newip_short.py
Last active February 15, 2017 13:47 — forked from blacktwin/notify_newip_short.py
If IP address is new use Pushover Agent (agent_id =7)
# 1. Install the requests module for python.
# pip install requests
# 2. Add script arguments in PlexPy.
# {user} {user_id} {ip_address}
import requests
import sys
user = sys.argv[1]
user_id = sys.argv[2]
@sander1
sander1 / pushover-notify.local
Last active February 7, 2024 16:28
Send Pushover notification from Fail2Ban
# Fail2Ban configuration file
#
[Definition]
# Notify on Startup
actionstart = /usr/bin/curl -s -F "token=<token>" -F "user=<user>" -F "title=[Fail2Ban] <name>" -F "message=Jail <name> has been started successfully." https://api.pushover.net/1/messages
# Notify on Shutdown
actionstop = /usr/bin/curl -s -F "token=<token>" -F "user=<user>" -F "title=[Fail2Ban] <name>" -F "message=Jail <name> has been stopped." https://api.pushover.net/1/messages
@sander1
sander1 / nginx.local
Last active January 23, 2024 15:40
fail2ban filters for nginx
# fail2ban filter configuration for nginx, by Sander
# 1) Catch WordPress related requests (we don't have WordPress on this server)
# 2) Catch requests for certain scripts we don't host
# 3) Catch script requests we don't host
# 4) Catch referer spam
[Definition]
failregex = ^<HOST> .* "(GET|POST|HEAD) /+(?i)(wp(-|/)|xmlrpc\.php|\?author=1)
^<HOST> .* "(GET|POST|HEAD|PROPFIND) /+(?i)(a2billing|admin|apache|axis|blog|cfide|cgi|cms|config|etc|\.git|hnap|inc|jenkins|jmx-|joomla|lib|linuxsucks|msd|muieblackcat|mysql|myadmin|n0w|owa-autodiscover|pbxip|php|pma|recordings|sap|sdk|script|service|shell|sqlite|vmskdl44rededd|vtigercrm|w00tw00t|webdav|websql|wordpress|xampp|xxbb)