Dave James Miller

Developer. Computer Geek. INTJ.

Category

Code Snippets

Peer review scheduler in Prolog

Continuing my exploration of Prolog, I decided to write a program to generate a schedule for peer reviews. Read More

Getting started with SWI-Prolog

Today I decided to learn a bit about Prolog. Here is how to start using it… Read More

Docker Reference

This week I have been learning about Docker… Here is what I’ve learned so far. Read More

PHP CLI script that can also be run in a web browser

I had a command line (CLI) script written in PHP that I wanted to be able to run via the web, to save having to open a terminal and SSH connection each time. Read More

Laravel Blade @ifSection() tag

This adds an @ifSection() Blade tag to Laravel that can be used to determine whether a particular @section() is defined. Read More

Find MySQL users with no privileges

This finds MySQL users with no global or database privileges. Read More

Find MySQL users with access to databases that don’t exist (have been deleted)

Useful for finding users who had permission to access databases that have since been deleted… Read More

HipChat (Y) and (N) shortcuts for thumbs up/down using AutoHotKey

HipChat uses “(thumbsup)” and “(thumbsdown)” instead of the easier to type “(Y)” and “(N)” of MSN Messenger, so I remapped them using AutoHotKey. Read More

Display a list of a user’s Gists in WordPress

This code creates a shortcode, [gists], which displays a list of all Gists by a user, grouped into categories then listed alphabetically. Read More

Find newly created/modified files in Linux

Find files created today or recently modified... Read More

Replace URLs in the WordPress database when moving between servers

Run this to replace URLs in the database when moving a WordPress blog from one URL to another. Read More

List the number of open HTTP connections per IP in Linux

This was useful when fighting a DDoS attack on one of our web servers. Read More

Script to download MySQL database & files from live to development server

This is a script I use on a lot of sites to copy the database (MySQL) and any uploaded files to the development site, and modify the database as required. Read More

Upgrade phpMyAdmin via the command line

This script makes it easy to upgrade phpMyAdmin on one or multiple servers at the same time. Read More

Bulk (batch) rename files in Linux

rename -v s/OLD/NEW/ FILENAMES Read More

Write to standard output/error streams in PHP CLI

How to write to STDOUT and STDERR in PHP. Read More

Recursively copy a directory, including symlink support, in PHP

function copy_dir($src, $dst) Read More

Recursively delete a directory, including symlink support, in PHP

function delete_dir($dir) Read More

Split WordPress theme functions.php into multiple files and autoload them

I use this to split my theme’s functions.php into multiple smaller files on particularly complex sites, and to autoload those files (instead of having to manually require each one). Read More

Extract images from a .ico file (e.g. favicon.ico) on Linux

icotool -x -o . favicon.ico Read More

Using Gravity Forms with WP-Types custom date fields

This is a filter to take Gravity Forms format dates (dd/mm/yyyy) and convert them to WP-Types format dates (integer). Read More

Sort and filter WordPress posts query by a custom field

In this example the event start & end dates are entered as timestamps using WP-Types. It could also be modified for Advanced Custom Fields which uses strings. Read More

Keyboard shortcuts to indent/outdent and format as code in WordPress TinyMCE

This allows you to indent lists/paragraphs in the TinyMCE WYSIWYG editor using Tab, and outdent using Shift+Tab. I wrote it because I write a lot of nested lists, it’s tedious using the keyboard to indent and outdent, and I couldn’t find any… Read More

Insert a post into WordPress from an external script

With wp_insert_post() and wp_set_post_terms()... Read More

Get HTTP redirect destination for a URL in PHP

Makes a HTTP request and read the Location header(s) to determine the redirect destination. Read More

Page 1 of 3123

© 2017 Dave James Miller — Powered by WordPress

Theme by Anders NorenUp ↑