Dave James Miller

Software Developer. Computer Geek. INTJ.

Page 4 of 7

Abingdon-on-Thames

Resize an image on the fly with PHP and cache it (like Drupal’s ImageCache)

This script takes an image and resizes it to the given dimensions, then saves that version on the filesystem so Apache can serve it directly in the future.

Store WordPress post password cookies for the browser session only (instead of 10 days)

WordPress saves post password cookies for 10 days, and there is no setting or filter to change that, but you can use this code to replace the form action entirely.

Rain, Rain, Go away!

Magpie Eating Bread

Christ Church College, Oxford

Birds in the Garden

Experimenting with my new DSLR

Olympic Torch, Oxford

Fully restart Ruby on Rails app under Phusion Passenger during Capistrano (cap) deploy

Most instructions for using Capistrano tell you how to make it restart Phusion Passenger by touching the restart.txt file, but this doesn’t immediately restart the app – instead the first person to try to use the application will cause it to be…

Zip a dynamically generated file in PHP

// Generate the contents of the file somehow $content = ‘…’; // Zip the file $zipFile = tempnam(sys_get_temp_dir(), ‘zipfile’); $zip = new ZipArchive; $zip->open($zipFile, ZipArchive::OVERWRITE); $zip->addFromString(‘sample.txt’, $content); $zip->close(); // Do something with the file (e.g. attach it to an email)…

Cookie Manager

git.djm.me

Library to manage opting in/out of cookies (due to EU cookie law). I wrote this to use at work.

Cookies law deadline passes with updated guidance from the ICO

In May 2011, the Information Commissioner’s Office (ICO) gave UK organisations 1 year to comply with the new cookies law, which requires them to get permission before using cookies on websites.

1 year later, that law is now fully in effect. In this article we look at the latest updates from the ICO, and see what solutions other websites have used.

New Forest 2012

Off-the-shelf vs. bespoke software development

alberon.co.uk/articles

When a business is looking for a software package, there are two main options available – buy an off-the-shelf software package, or have a bespoke solution developed. Here we look at the pros and cons of each.

Allow access by IP address with CanCan in Ruby on Rails

This is what I used to get CanCan to allow users on the local network to access parts of our intranet without having to log in.

Download data from Ruby on Rails production database to development server using Replicate

Replicate is a Gem that lets you dump and load relational objects between Ruby/Ruby on Rails environments, e.g. dump data from your production database and load it in your development database. The examples in the README use shell scripts to do this. I…

Automatically push changes to Git repository before deploying with Capistrano (cap deploy)

I use this Capistrano task so I don’t have manually do git push before cap deploy. It includes some error checking to make sure I’m on the right branch (master) and don’t have any uncommitted changes.

ruby-debug-passenger

git.djm.me

Adds a rake debug task to Ruby on Rails to restart Phusion Passenger with an interactive debugger connected.

Sleep/suspend/hibernate computer automatically when TV is switched off using AutoHotKey

I wrote this AutoHotKey script to automatically switch off my PC when the TV is switched off so when I watch TV in bed (using VLC) I only have to press one button to switch it all off, rather than…

Toggle hidden files and/or file extensions in Windows Explorer with a keyboard shortcut using AutoHotKey

This is part of my AutoHotkey script that allows me to toggle hidden files with Ctrl+Alt+H and file extensions with Ctrl+Alt+E.

Hide the permalink and Edit button on the WordPress Edit Post admin page

This hides the permalink and edit button on the Edit Post page in WordPress. It is useful for when permalinks are not editable (e.g. if it uses the post ID only) in that case its really just taking up screen…

Hide the title box on the Edit Post page in the WordPress admin

This hides the title textbox in the Edit Post page in WordPress. It is possibly useful when using a theme like P2 that doesn’t actually display the title, so you don’t want to be going to the trouble of writing one.

Create a symlink on a remote server when ‘ln’ is disabled

This is a script I used when I wanted to create a symlink on a remote web server, but that web server had the ln command disabled (using cPanel’s Jailshell).

Script to delete and re-create a Linux test user account

I use this script to repeatedly delete and re-create a Linux (Debian/Ubuntu) user account for testing my dotfiles installation script.

Automate backup to an external hard drive with AutoIt and Beyond Compare

This is a pair of scripts I used to back up my computer using Beyond Compare (which I highly recommend) and AutoIt.

Create a new file with Ctrl+Alt+N keyboard shortcut in Windows Explorer with AutoHotKey

This is part of my AutoHotkey script. When you are in Windows Explorer it allows you to press Ctrl+Alt+N and type a filename, and that file is created in the current directory and opened in the appropriate editor (usually gVim in my case, but it will…

Hide “This account is managed by” in YouTube

Hides the “This account is managed by <domain>” message for Google Apps users.

Sites Manager

git.djm.me

Script to manage virtual hosts in Apache and Exim on my Debian servers.

Are you complying with the new cookies law?

In May last year a new law came into effect that requires all websites to get consent from the user before using cookies. In December the Information Commissioner’s Office (ICO) issued further guidance, which you must comply with by May 2012.

Installing PHP FastCGI with suEXEC on Debian

Most of the time I’m happy with mod_php. It’s certainly the most efficient way to run PHP. But there is one major downside – all scripts are run as the Apache user (www-data). We can get around this by using…

Installing Ruby on Rails 3.1 + Ruby 1.9 on a cPanel 11.30 server

cPanel 11.30 doesn’t support Ruby 1.9 or Ruby on Rails 3.0/3.1, only Ruby 1.8 and Rails 2.3. They are working on supporting Rails 3 in cPanel 11.34, but that could be 12 months away still, so for now we have to install…

Automatically mounting a Samba share at boot on Debian

First you’ll need somewhere safe to put the username & password. We’ll store them in /etc/sambapasswords, and make that only readable by root.

Generating a self-signed SSL certificate for Apache

1. Generate a private key, 2. Generate a certificate signing request, 3. Self-sign the certificate, 4. Configure Apache…

The Checklist Manifesto – Summary

The Checklist Manifesto is a very good book about effectively using checklists. This is my summary of the advice, in the form of a checklist

Write tweets in your own words instead of retweeting

Sometimes retweeting is good – you can quickly share something you’re interested in with your followers. If you want to say exactly the same thing as the original author, retweeting makes it very easy. But sometimes wouldn’t it be better…

Paste clipboard contents as plain text with AutoHotKey

This is part of my AutoHotkey script that pastes the contents of the clipboard as plain text when I press Ctrl+Alt+Shift+V.

HTML to PDF conversion in PHP using wkhtmltopdf (and Smarty)

Recently I was asked to generate PDF invoices for an online shop. I looked at various PHP PDF generators, but wasn’t particularly impressed with any of them. Then I found (via Stack Overflow) a command-line HTML-to-PDF convertor called wkhtmltopdf, which…

Stop inbox turning bold when unread in Gmail

There is a Gmail lab to turn off the unread counter, but the “Inbox” link still turns bold so you can still see that there are new emails! This user style forces it to be not bold.

Create a new file from a template, prompting the user for the filename, in Windows with AutoHotKey

This is an AutoHotKey script that prompts the user for a filename, creates that file (by copying a template), then launches that file. The way I use this is I have a folder full of Word documents, with a script right…

Sarah Feeding the Penguins at Birdland

Feeding the penguins at Birdland

Hide close button on Firefox add-ons bar (status bar)

Based on this user style. /* ==UserStyle== @name Hide close button on Firefox add-ons bar (status bar) @namespace djm.me @version 1.0.0 @author Dave James Miller (https://djm.me/) @homepageURL https://djm.me/code-snippets/2011/06/hide-close-button-on-firefox-add-ons-bar-status-bar @license Unknown ==/UserStyle== */ @namespace url(“http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul”); #addonbar-closebutton { display: none !important; }

Penguins at London Zoo

London Zoo

Autohide Firefox bookmarks toolbar

This is a customised version of this user style. /* ==UserStyle== @name Autohide Firefox bookmarks toolbar @namespace djm.me @version 1.0.0 @author Dave James Miller (https://djm.me/) @homepageURL https://djm.me/code-snippets/2011/05/autohide-firefox-bookmarks-toolbar @license CC BY-NC-SA ==/UserStyle== */ @namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul); #PersonalToolbar { visibility: hidden !important; opacity:…

Bash General-Purpose Yes/No Prompt Function (“ask”)

This is a general-purpose function to ask Yes/No questions in Bash, either with or without a default answer. It keeps repeating the question until it gets a valid answer.

Connecting PHP to Microsoft SQL Server on Linux

Here is how to get PHP 5.2 on Linux (specifically Debian/Ubuntu) talking to a Microsoft SQL Server database

Slightly larger font in Google Reader

Sets font size to 116% (about 15px) and line height to 1.4 in Google Reader. Only affects the content column, not the subscriptions list, but includes the post titles in list view. /* ==UserStyle== @name Slightly larger font in Google…

Grey out completed tasks in TeuxDeux

Make completed TeuxDeux tasks turn grey immediately (instead of waiting until the following day), so they’re less noticable than those not completed yet.

© 2021 Dave James Miller — Powered by WordPress

Theme by Anders NorenUp ↑