Skip to content

Instantly share code, notes, and snippets.

@andcam
andcam / gist:8772442
Created February 2, 2014 18:15
convert existing MySQL table to utf8
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8 COLLATE 'utf8_unicode_ci';
@andcam
andcam / gist:8933333
Created February 11, 2014 11:40
find all the .htaccess files
find / -type f -name .htaccess 2>/dev/null -print -exec cat {} \;
@andcam
andcam / Cron script to back up Linux webserver to Google Drive
Last active August 29, 2015 14:07
update to remove newline chars
#!/bin/bash
#for file names
WDAY=`/bin/date +%w`
FDATE=`/bin/date +%Y%m%d`
BACKUPPATH="/tmp"
WEBDIR="/var/www"
SITES=`ls $WEBDIR`
Section: AUTH
mailgun_login:
driver = plaintext
public_name = LOGIN
hide client_send = : [email protected] : password
Section: ROUTERSTART
mailgun:
driver = manualroute
domains = ! +local_domains
yum -y update
yum groupinstall -y 'development tools'
yum install -y zlib-devel openssl-devel sqlite-devel bzip2-devel
yum install xz-libs
wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
xz -d Python-2.7.12.tar.xz
tar -xvf Python-2.7.12.tar
cd Python-2.7.12
./configure --prefix=/usr/local
make; make altinstall
@andcam
andcam / functions.php
Last active November 7, 2018 17:46
Wordpress - redirect all attachment pages to parent post or home page
// redirect attachment pages to home
function ljxdm_redirect_attachment_pages() {
if(is_attachment()) {
global $post;
if($post && $post->post_parent) {
wp_redirect(esc_url(get_permalink($post->post_parent)), 301);
exit;
} else {
wp_redirect(esc_url(home_url('/')), 301);
exit;
@andcam
andcam / functions.php
Created November 8, 2018 12:22
Wordpress - strip all HTML comments
class ljxdmStripComments
{
public function __construct() {
add_action('get_header', array($this, 'start'), 100);
add_action('wp_footer', array($this, 'end'), 100);
}
private static function strip($html) {
return preg_replace('/<!--(.|\s)*?-->/','',$html);
}
@andcam
andcam / linux open ports
Last active July 24, 2019 12:18
various methods to find and list open ports
# tcp ports and services
egrep -w '(80|22|443)/tcp' /etc/services
# netstat list of open ports
sudo netstat -tulp | grep LISTEN
# -t – List all TCP ports on Linux
# -u – List all UDP ports on Linux
@andcam
andcam / functions.php
Created October 27, 2020 11:26
Wordpress - allow SVG media uploads
function ljxdm_upload_mime_types( $mimetypess ) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'ljxdm_upload_mime_types' );
@andcam
andcam / gist:05829e404f47319dc7c1dd51d903e53a
Created June 21, 2021 13:12
Wordpress: Allow HTML in term descriptions (disable KSES filter)
/*
* Allow HTML in term descriptions.
* https://developer.wordpress.org/reference/functions/wp_filter_kses/
*
*/
function ljxdm_disable_kses_on_terms() {
if ( current_user_can( 'unfiltered_html' ) ) {
foreach ( array( 'pre_term_description' ) as $filter ) {
remove_filter( $filter, 'wp_filter_kses' );