Running your own Mail Server with iRedMail

apt-get update && apt-get -y dist-upgrade && apt-get clean hostnamectl set-hostname mail nano /etc/hosts hostname # get latest download link from http://www.iredmail.org/download.html wget https://bitbucket.org/zhb/iredmail/downloads/iRedMail-0.9.5-1.tar.bz2 tar jxf iRedMail-0.9.5-1.tar.bz2 cd iRedMail-0.9.5-1/ bash iRedMail.sh # long wait reboot amavisd-new showkeys # install dkim in domains DNS, name=dkim._domainkey type=TXT value=”v=DKIM1; p=k32hkj…” (remove the quotes and spaces at line breaks) […]

Setting up a radio with IceCast and EZstream

hostnamectl set-hostname radio nano /etc/hosts apt-get update && apt-get -y dist-upgrade && apt-get -y install gcc libcurl4-gnutls-dev libvorbis-dev libxslt1-dev pkg-config libtheora-dev libspeex-dev openssl last 3 are optional (libtheora-dev libspeex-dev openssl), not sure about pkg-config cd /usr/src/ wget http://downloads.xiph.org/releases/icecast/icecast-2.4.3.tar.gz tar -xzvf icecast-2.4.3.tar.gz cd icecast-2.4.3/ ./configure make make install # libshout cd /usr/src/ wget http://downloads.xiph.org/releases/libshout/libshout-2.4.1.tar.gz tar -xzvf […]

Using UTM parameters in forms and anywhere shortcodes can be used

// Shortcode for retrieving Session params if ( ! shortcode_exists(‘get_cookie’) ) { function readycat_get_cookie( $atts ) { // check for shortcode param if ( empty( $atts[‘key’] ) ) return ‘Please specify a key=whatever_value in the shortcode.’; $default = !empty( $atts[‘default’] ) ? $atts[‘default’] : ”; if ( ! empty( $_GET[ $atts[‘key’] ] ) ) { […]

Restore Default User Roles in WordPress

This is a pretty goofy function, but a client once deleted the default user roles using some plugin, and I just threw this into functions.php to re-create them. It’s hooked onto admin_init, so it runs when you load any back-end page.  I set a transient that keeps the function from running more than once (and […]

Forcing SSL with Apache mod_rewrite

Paste this into your .htaccess file # BEGIN Force SSL <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} =off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] </IfModule> # END Force SSL I once had the needed to exclude a directory, so http:// versions would still be served. This was just one extra line: RewriteCond %{HTTPS} =off RewriteCond %{REQUEST_URI} !^/directory/ RewriteRule […]

Add Media for Contributors

function add_theme_caps() { $trans = ‘1’; if ( get_transient(‘update_entries’ ) === $trans ) return; set_transient( ‘update_entries’, $trans, 1e5 ); $role = get_role(‘contributor’); $role->add_cap(‘upload_files’); } add_action( ‘admin_init’, ‘add_theme_caps’);

VS Code doesn’t select the $$$

When using Microsoft Visual Studio Code / Monaco for PHP it’s really annoying to me how double-clicking a variable doesn’t include the dollar sign in the selection. Go to the settings and search for editor.wordSeparators: Word Separators Characters that will be used as word separators when doing word related navigations or operations. You can simply […]

Add a spinner to a submit button for slow forms

If you have a form that is slow to submit, this is a simple way to replace the submit button with a spinner. You may need to change the two selectors in the Javascript to be more specific, or different. Border-color may also want to be different, that’s the color of the spinner. <script>document.querySelector(‘form’).addEventListener(‘submit’,function(){ document.querySelector(‘[type=submit]’).className+=’ […]

Delete Wordpress post revisions older than x days

Delete post revisions older than 10 days: DELETE FROM wp_posts WHERE post_type = ‘revision’ AND post_modified_gmt < DATE_SUB(NOW(), INTERVAL 10 DAY) Delete post revisions older than 2 months: DELETE FROM wp_posts WHERE post_type = 'revision' AND post_modified_gmt < DATE_SUB(NOW(), INTERVAL 2 MONTH)