Skip to content

Instantly share code, notes, and snippets.

@donwilson
donwilson / strip_zalgo.php
Created February 12, 2019 19:04
function to strip zalgo/"scary" text from regular strings
<?php
// zalgo text/scary text stripper
// https://stackoverflow.com/a/32921891/103337
function strip_utf8_zalgo_text($string="") {
$string = preg_replace("~(?:[\p{M}]{1})([\p{M}])+?~uis", "", $string);
return $string;
}
@donwilson
donwilson / .htaccess
Created April 12, 2019 19:21
.htaccess block .git directory, .gitignore, and composer files
RedirectMatch 404 ^/\.git
RedirectMatch 404 ^/composer\.(json|lock|phar)$
@donwilson
donwilson / split_text_to_sentences.php
Created May 10, 2017 19:08
Extract first X sentences from WordPress post content for post excerpt
<?php
/**
* Extract out first X sentences from uncleaned raw text
* @param string $text Raw text
* @param int $num_sentences Optional. Number of sentences
* @return string
*/
function extract_sentences_from_text($raw_text, $num_sentences=3) {
$text = $raw_text;
$text = strip_tags($text);
@donwilson
donwilson / server_commands.txt
Last active December 8, 2020 21:10
Server Setup Helper
#################################
# General Program Installations #
#################################
yum -y install htop screen bzip2 unzip parallel wget nano dos2unix nmap iotop
###########################
# Install Git from Source #
###########################
@donwilson
donwilson / rclone-backup-script.sh
Created May 26, 2017 23:24
Back up WWW, MySQL DB and separate content folder to S3 using rclone
#!/bin/bash
###
# Backup Script
###
# Toggle debug mode for CLI output - "YES" or "NO"
DEBUG="YES"
@donwilson
donwilson / php-serialized-column.php
Last active December 26, 2022 02:11
PHP Serialized Data previewer in Adminer Editor
<?php
/** Display PHP serialized values as table in edit. Using Jakub Vrana and Martin Zeman's JSON Adminer plugin (https://raw.githubusercontent.com/vrana/adminer/master/plugins/json-column.php) as a skeleton for this plugin.
* @link https://www.adminer.org/plugins/#use
* @author Don Wilson, https://pyxol.com/
* @author Jakub Vrana, https://www.vrana.cz/
* @author Martin Zeman (Zemistr), http://www.zemistr.eu/
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/
class AdminerPHPSerializedColumn {