Category Archives: Uncategorized

[quickie] Regex for tags missing attribute

So to find images missing alt attributes:

There are groups in there so you can do a find/replace and insert the missing tag:

Now it is trivial to find the missing alt=”” tags, add them, and then fill them in by then searching for the empty attribute…

Set Diffmerge as Diff/Merge tool for Git

From the command line run each of these. You don’t need to be in particular directory.

Thus will work for *nix flavours including OSX. May not work on Window boxes or flower beds.

Now, whenever you want it to launch diffs just use difftool where you’d normally use diff:

N.B. These commands need to be run from the relevant directory for the project

To resolve merge conflicts, just run git mergetool:


Literary Javascript

A most amusing post comparing the theoretical code authoring styles of famous authors.

*nix: “Multi-terminal” Screen config

I’ve been using screen a lot lately for it’s ability to have multiple terminal ‘windows’ open in one ssh session.

I came across this .screenrc file – at – and I’ve found it quite useful – the handiest thing is having the screen status bar by default.

Just save it as .screenrc in your home directory

Prism – JS/CSS Syntax Highlighting

Looks great.

Well, the dark theme is a bit, shall we say, chocolate-y, and the funky theme is a horrific 80’s headfuck (if slightly amusing), but hey, CSS is CSS so you can change that. The default theme is perfectly tasteful. More importantly it’s lightweight, fast and extensible. I should add it to this blog sometime.

[edit 2016-07] I use Crayon for wordpress these days, but Prism is still a great highlighter for adding to your own build  [/edit]

Cleaning up PHP – Terminal conditions with continue;/return;

PHP (or any language where code blocks are indented) can get a bit messy sometimes

OK, that’s not a literal example, but it does happen. If your condition is terminal, that is: if it is not met, no further action is taken; then there is no need to wrap a massive chunk of code in curly braces and indent it yet further. Break out of the cycle! If you are in a loop, you can just continue; – for example instead of:

you can do this:

In this ridiculously abbreviated example, it does look longer, and yes it will always result in more code, but where you have several terminal conditions in a section of logic which are separated by a number of lines, this technique can save you one hell of a lot of indenting, making your code that much more readable. Our original example, while longer, would be a lot simpler to follow:

In a similar way to loops, if you are in a function, you can simply return; (or return true/false; as appropriate) earlier rather than doing it in an else statement; Shocking? No. A revelation? Hardly, these are not new constructs. But common? Not from the code I see. Give it a go. I will…