WordPress-ish JavaScript Code Standard – ESlint Config

I’m spending a lot of time with JavaScript these day, and find linting tools to be invaluable for spotting some mistakes. I started off with JShint plugged in to Sublime Text via this JSHint plugin.

More recently I’ve switched to ESlint. It seems to identify more issues and formatting problems than before, is easy to configure, and is also extensible.

I’m gradually tweaking an ESlint configuration file that somewhat matches the WordPress coding standards (with some of my own amendments), and thought I’d release it here:

https://gist.github.com/johngodley/b2114d8ff65a6b0767b6

It’s not perfect yet by any means, so make of it what you can. Hopefully it will improve with time.

Finding bad and out-of-date passwords in 1password

I use 1password to keep track of all my passwords. Over the years I’ve built up a lot of logins and a lot of passwords, and for various reasons some of them are not so good.

With the recent news about LinkedIn and Last.fm password leaks, it’s worth keeping an eye on your passwords. 1password has a nice feature called smart folders. You can use these to quickly find susceptible passwords.

Click the cog button in the bottom left of the 1password screen and pick ‘New Smart Folder‘:

At the top of the data area, configure a set of rules to be ‘kind is login‘ and ‘password strength is less than or equal to 60‘ (you can change the minimum password strength to suit).

Save the folder and it appears in the folders section on the left on the 1password window. Clicking on this folder will show all your bad passwords. Time to get updating!

You can also create a smart folder that shows passwords that you haven’t updated in over a year by setting the smart rule to ‘modified before date’.

14.7% of the web

14.7% of the top million websites in the world, up from 8.5%, and the latest data show 22 out of every 100 new active domains in the US are running WordPress.Matt Mullenweg, 2011

That’s quite some reach! Better get a few of those plugins updated…

Setting up Sublime Text 2 for PHP

I’ve mentioned Sublime Text 2 before. Although it’s in beta, and a little rough around the edges, it’s become my editor of the moment. Being a TextMate user it’s showing a lot of promise, and fortunately has a much more rapid development schedule. Did I mention it also works on OS X, Windows, and Linux?

Anyway, I thought I’d share how I’ve set it up for PHP development.

Installing Git

This is an optional part, but if you want to keep your plugins up-to-date you should install Git using this handy installer.

Fairly simple – download and run.

Zen Coding

The first plugin to install is Zen Coding. This is available for most editors and if you’ve never used it, it takes some of the tedium out of repetitive HTML.

You’ll need to download the plugin first (get the ‘tip’ version). Unpack the file into your packages directory and you’re set. Details of how to use Zen Coding can be found around the internet, but the specific shortcuts for Sublime Text are here. Pressing tab will expand any HTML, and ctrl+alt+enter will open the interactive editor (shown above).

Sublime Lint

Next up is Sublime Lint. This plugin validates the file you are editing for basic PHP syntax errors. Any errors are shown immediately with a red box around the offending area, saving you a wasted round-trip effort of save/refresh/re-edit just to fix a missing semi-colon.

Installation is from GitHub. Either download the package and unzip, or use git and check it out directly:

git clone git://github.com/lunixbochs/sublimelint.git

When installed you will see a red box outline around syntax errors:

The status bar will show the specific error message when the cursor is in the area.

Sublime CodeIntel

This is an interesting plugin, and uses the libraries from Open Komodo to provide proper symbol definitions and project wide auto-complete. That is, you can click on a function name and be taken immediately to its definition (it even understands classes and PHP5). You can also have auto-suggestion for functions outside of the current file.

Additionally, the status bar will show parameter prompting when you use a function.

Installation is much the same as Sublime Lint. Grab the code from GitHub, or install via git:

git clone git://github.com/Kronuz/SublimeCodeIntel.git

You will then be able to alt+click on a function name to jump to the definition, and use the standard cmd+space for auto-complete. It may take a while for the plugin to scan your code.

Soda Theme

Soda is a UI theme that affects the editor itself rather than the editing area. It generally improves the look and feel of Sublime Text by using sharper icons and better contrasting elements.

The theme can be found on GitHub as well, and can be downloaded or installed via git:

git clone https://github.com/buymeasoda/soda-theme/ "Theme - Soda"

Although the installation guide suggests you can activate it from Sublime Text, I’ve only been able to activate it by editing Preferences -> Color Scheme -> User and manually enabling the theme. Details of this can be found on the GitHub page.

Icon

Yes, the default Sublime Text 2 icon is terrible. Fortunately it’s simple to replace. If you search through the Sublime Text forum you’ll find many contributions from users (this is my favourite). Download whichever you like and using the Finder, locate the Sublime Text application in your Applications folder. Right click it and pick show info. Drag the new icon onto the icon in the top left corner of the info window.

London riots touch Camden

The pointless rioting happening in London touched Camden last night. This morning I had a look.

Domino’s was first.

A little further down the road and Evans Cycles was badly damaged:

Unmarked police cars were arriving at the scene.

Sainsbury’s was next, where I buy milk.

So they went for pizza (ignoring the sushi next door), skipped an ice-cream shop and the Salvation Army, hit a bicycle shop, missed out the Belgium and Italian restaurants, and went to the supermarket. Apparently they went on to trash the Electric Ballroom, but my adventures were done for the day.

Added:

Social media to the rescue – catch your own idiot. Catch A Looter

Published
Categorized as General

Lego Brick Flats

Seen from the Ngong Ping cable car in Hong Kong. From the distance the photos were taken it almost looks like a toy. An incredible concentration of lives.

Taro – Purple Potatoes

I came across a vegetable in the supermarket the other day that I’ve not seen since China.

I always referred to it as a taro, but it seems it has several varieties, and this one was an eddoe.

Wikipedia refers to the flavour as:

…an acrid taste that requires careful cooking…

It’s a lot like a potatoe, but when cooked it goes crumbly and purple, and tastes kind of like… ice cream. Hard to describe really. In China it’s very popular, both fried as a main course, and as a dessert.

Cutting the skin releases some slightly toxic chemicals so you have to be careful! Cooking removes the toxins and you’re left with an unusual food.

Published
Categorized as General Tagged

Pegasus Mail

My first real exposure to the internet came via a University email address, and Pegasus Mail – a DOS based email client. The email address is long gone, but it seems that Pegasus Mail has been going strong ever since:

So now we’re about to enter the third decade of Pegasus Mail. Will it make it to 30? Who knows, but I really hope so: I still enjoy working on it, and even though the Pegasus Mail Thousand hasn’t had entirely the response I might have hoped for, I’ll keep working on Pegasus Mail and Mercury for as long as I can.

Pegasus Mail – Twenty Years Old And Counting.

Big Trak Returns!

As a boy I spent many a happy hour wishing I had a Big Trak, a programmable toy moon buggy thing. Maybe it was an early sign of geekness, or maybe it was the fact that it was just really cool and I imagined myself getting it to do all kinds of exciting things.

I was surprised to see that it’s back in production and now being sold as a kitsch nostalgia toy for grown-ups!

Image taken from the Wikipedia entry with CC Share Alike license