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 at the top called “! New.ahk”. I can simply double-click that to create a new file, which will be a copy of “zzz Template.docx”, which is right at the bottom of the list.
This folder is synchronised using Dropbox, so it was important that the path not be hard-coded. It uses the %A_ScriptDir% variable to get the path where the script is located.
If the file already exists then it just loads it, rather than giving an error message.
View code ›
This is how I ensure a Python script is launched as root, and automatically call sudo to re-launch it as root if not.
I found it useful to check the parameters are valid before re-launching as root, so I don’t have to enter the sudo password if there is a problem with the parameters, or I just want the help message.
View code ›
A general-purpose function to ask Yes/No questions in Bash, either with or without a default answer.
Keeps repeating the question until it gets a valid answer.
View code ›
WordPress stores the site URL in the database by default (which I have never understood), and it’s a pain to have to type out the UPDATE SQL or search in phpMyAdmin to change it.
But there is a simple way to put the URL into wp-config.php instead.
View code ›
This Devil’s Pie script removes the window decoration from rdesktop, and automatically moves it to workspace 4.
This allowed me to have rdesktop taking up the whole screen, but still show the taskbar. Then I could quickly switch workspaces to get back to other programs.
View code ›
This Devil’s Pie script automatically maximises Gnome Terminal when it is opened.
It’s a few years since I used Gnome – I guess I couldn’t find any other way to open it maximised.
View code ›
A few years ago I had Linux on my laptop, and the position of the keys on my keyboard meant I’d frequently hit F1 instead of Esc, which opened Gnome help.
I never worked out how to disable it, but I did manage to set up this simple Devil’s Pie script to close it.
It’s not ideal – there’s no way to prevent it closing Gnome help… but I never used Gnome help anyway.
View code ›
Every now and then you need to work out if a script is running in Cygwin. It’s very simple really.
I can’t remember what I used this code for, but I just came across it while clearing out some old files!
Source: Weiqi Gao
View code ›
This is part of my AutoHotkey script that pastes the current date into any program when I press Ctrl+Alt+Shift+D.
See the FormatTime reference for other date/time formats.
View code ›
This is part of my AutoHotkey script that pastes the contents of the clipboard as plain text when I press Ctrl+Alt+Shift+V.
View code ›