Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris David Miles chrisdavidmiles

View GitHub Profile
@chrisdavidmiles
chrisdavidmiles / PostMessageToSlackChannel.php
Created Jun 6, 2020 — forked from nadar/PostMessageToSlackChannel.php
Post a message to a slack channel with PHP
View PostMessageToSlackChannel.php
<?php
/**
* Send a Message to a Slack Channel.
*
* In order to get the API Token visit: https://api.slack.com/custom-integrations/legacy-tokens
* The token will look something like this `xoxo-2100000415-0000000000-0000000000-ab1ab1`.
*
* @param string $message The message to post into a channel.
* @param string $channel The name of the channel prefixed with #, example #foobar
@chrisdavidmiles
chrisdavidmiles / bulk_dig.sh
Last active Apr 15, 2021
Bulk DNS Lookup bash script
View bulk_dig.sh
#!/bin/bash
# Bulk DNS Lookup
# Generates a CSV of DNS lookups from a list of domains.
#
# File name/path of domain list:
domain_list='domains.txt' # One FQDN per line in file.
#
# IP address of the nameserver used for lookups:
ns_ip='1.1.1.1' # Is using Cloudflare's 1.1.1.1.
#
View onion.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View port-listener.py
'''
Simple socket server using threads
'''
import socket
import sys
HOST = '' # Symbolic name, meaning all available interfaces
PORT = 8888 # Arbitrary non-privileged port
@chrisdavidmiles
chrisdavidmiles / functions.php
Created Jul 5, 2017
Reduce Jetpack wp-cron usage
View functions.php
add_filter( 'jetpack_sync_incremental_sync_interval', function() { return 'hourly'; } );
add_filter( 'jetpack_sync_full_sync_interval', function() { return 'daily'; } );
@chrisdavidmiles
chrisdavidmiles / tor-redirect.js
Created Jul 3, 2017
Detect Tor Browser users and redirect them to the .onion version of my site.
View tor-redirect.js
var myoniondomain = 'chrisdm326o2d7iq.onion';
var thecurrentdomain = window.location.hostname;
if (myoniondomain != thecurrentdomain) {
function isTorBrowser() {
var img = document.createElement('img');
img.src = 'data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==';
var canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = 1;
var ctx = canvas.getContext('2d');
@chrisdavidmiles
chrisdavidmiles / wp-config.php
Created Jul 1, 2017
Dynamically set WordPress home and siteurl
View wp-config.php
define('WP_SITEURL', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']);
@chrisdavidmiles
chrisdavidmiles / functions.php
Created Jun 14, 2017
Disable WordPress password authentication. User/Pass combination will always return false, even if correct password is used. Use only if alternate login methods are in place.
View functions.php
remove_filter('authenticate', 'wp_authenticate_username_password', 20, 3);
@chrisdavidmiles
chrisdavidmiles / functions.php
Created Jun 14, 2017
Disable WordPress password reset notification email
View functions.php
add_filter( 'send_email_change_email', '__return_false' );
@chrisdavidmiles
chrisdavidmiles / .htaccess
Created Jun 13, 2017
301 redirect http:// to https:// for specified domain
View .htaccess
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www.)?example\.com$
RewriteRule ^(.*)$ "https\:\/\/example\.com\/$1" [R=301,L]