Dave James Miller

Software Developer. Computer Geek. INTJ.

Page 5 of 7

Installing PHP 5.2 FastCGI on Debian 6 (Squeeze)

Debian Squeeze comes with PHP 5.3. This is good, because PHP 5.2 is no longer maintained, but causes problems for old applications that can’t support it (e.g. ViArt 3, because it uses Zend Encoder). Rather than permanently downgrade PHP for the whole server,…

Set WordPress site URL in the config file instead of the database

WordPress stores the site URL in the database by default (which I have never understood), and its a pain to have to type out the UPDATE SQL or search in phpMyAdmin to change it. This is a simple way to…

Detect Cygwin in a shell script

Every now and then you need to work out if a script is running in Cygwin…

The Woman in Black

Run a program with a keyboard shortcut with AutoHotKey

These are a few examples from my AutoHotkey script that run various programs when you press certain keyboard shortcuts. Add as many of these as you want to a .ahk file, and set that to be run at startup.

Turn monitor off with a keyboard shortcut with AutoHotKey

This is part of my AutoHotkey script that turns off my monitor when I press Win+\. It also turns the screensaver on at the same time, so that Windows Live Messenger (and any other programs) know I am away.

Sleep/suspend/hibernate computer with a keyboard shortcut using AutoHotKey

This is part of my AutoHotkey script that puts my computer to sleep when I press Win+F12.

Paste the current date into any program using AutoHotKey

This is part of my AutoHotkey script that pastes the current date into any program when I press Ctrl+Alt+Shift+D.

Get the domain name from a URL for display purposes in PHP

This is a very simple function to convert a user-supplied URL to just the domain name.

Automatically enable plugins in new WordPress Multisite blogs

There are three options (that I know of) for automatically enabling a plugin in new sites.

Automatically generate subdomain for new WordPress Multisite blogs

When you create a new WordPress Multisite blog from the admin area, you have to enter three things: Site address (subdomain or folder name), Site title and Admin email…

Set site/plugin options for all blogs in a WordPress Multisite network

I used this code snippet as part of a WordPress Multisite plugin, to allow me to quickly set some options for all blogs in the network.

List of all blogs in a WordPress Multisite network

This code was used to generate a menu showing all blogs on a WordPress Multisite installation.

Alternative to the_category() in WordPress that works correctly with nested categories

The WordPress function the_category() doesnt work particularly well when you have hierarchical categories.

Set default category / tags for a new WordPress post using links

I used this code to automatically set the default post title, category and tags for a new WordPress post based on which link was clicked.

Force additional categories to be added to a WordPress post on save

On one WordPress blog I have categories for “Starred” and “Archived”, in addition to the real categories. I hacked this together to make sure the posts would still go into Uncategorised as well.

Toggle category with ajax in WordPress theme (frontend)

This is a follow-up to Toggle “Starred” Category in WordPress – making it more generic and usable for multiple categories.

Set default theme for new WordPress Multisite blogs

Even if you disable all but one theme, WordPress seems to default to TwentyTen when creating a new Multisite blog. The fix is simple though – add this to wp-config.php.

Prevent WordPress sending any emails

I did this simple hack on a private WordPress Multisite blog, to stop it sending me emails every time I created a new blog. It’s definitely overkill to stop all emails, but unfortunately I couldn’t find any hooks that let…

Winter Onederland

Christmas & New Year 2010/11

Bug fix for Filosofo Comments Preview WordPress plugin – increment the number of comments when previewing

Filosofo Comments Preview is a WordPress plugin that lets you preview comments on your blog before you submit them. In the current version (1.5) it doesnt increment the number of posts, so it still says there are no comments when you…

Display all posts from one category in a sidebar widget in WordPress

This is a modification to the theme’s functions.php that adds a widget to list all of the posts in the “Starred” category.

Redirect to post/page after publishing in WordPress

This redirects to the post/page itself after publishing or updating a post in WordPress.

Toggle “Starred” Category in WordPress theme (frontend)

How to add a simple “star” flag to posts (a la Gmail).

Snow and Christmas Lights

Alberon Christmas Dinner 2010

djmFiles

git.djm.me

Functions for handling files & file uploads.

Why I should never let my sister near my stuff

djmWebDirConfig

git.djm.me

Load per-directory PHP config files (similar to Apache .htaccess files but containing PHP code).

The Grounds of Stowe School

djmFramework Template

git.djm.me

Skeleton application using my standard site framework and libraries.

djmErrors

git.djm.me

Setup error handling to log or display depending on the DEBUG environment variable.

djmSecurityCheck

git.djm.me

Check settings for register_globals & magic_quotes_gpc.

Dotfiles

git.djm.me

Config files and scripts for Bash, Vim, Git and other Linux software.

Doodle Pig

djmCountries

git.djm.me

Country list and associated functions & Smarty plugins.

djmCSV

git.djm.me

Converts an array of data to a CSV file.

djmPassword

git.djm.me

Store passwords as SHA-256 hashes with a random salt.

djmIndexU

git.djm.me

Functions to help with modifying Nicecoder IndexU.

Salcombe, Devon

Becks Having Fun on the Beach

Splitting up PHP Mate

I have decided to split up PHP Mate, my “general-purpose” PHP library, into several smaller libraries…

djmFlashMessage

git.djm.me

Stores flash messages in the user session and clears automatically when displayed.

djmLinkify

git.djm.me

PHP functions to make URLs clickable in plain text input.

djmNonce

git.djm.me

Generate & check nonces to protect against CSRF attacks.

djmSingletons

git.djm.me

Base class for holding singleton objects, automatically instantiating them when required.

Detect pipe/file input in a Bash/shell script

How to detect whether input is from keyboard, a file, or another process. Useful for writing a script that can read from standard input, or prompt the user for input if there is none.

djmUtil

git.djm.me

General utility functions and Smarty plugins.

djmDB

git.djm.me

Custom subclasses of Zend_Db (database abstraction layer).

© 2021 Dave James Miller — Powered by WordPress

Theme by Anders NorenUp ↑