Use HOME as your GOPATH

How and why I normalised my Go paths and personal/local home paths.

Like many people, I have my own scripts and stuff in a bin directory in my home directory. Actually it’s a symlink to ~/.local/bin because I saw there was a ~/.local/share which some programs use to store user-specific things and I wanted to be consistent.

Then I saw some people have ~/bin and ~/src and I thought that looked like a tidy way to organise things. So far my approaches have been putting code in ~/Scripts ~/Projects/Programming or more recently ~/Work and ~/Hacking. The capitalisation being inspired by the Free Desktop common User Directories style, e.g. Music, Desktop, and so on.

And then Go, which is inflexible in where you place your code, requires you to specify a $GOPATH to a directory containing src/, pkg/ and /bin. I initially misunderstood this to be some useless path for internal use by Go tools and not needed by the user, so I put it in ~/.go where it wouldn’t bother me. It turns out that you actually keep all your source code there and use it every day. It’s so common for people to put their code in ~/go that starting with Go 1.8 this will be the default $GOPATH if you don’t specify one.

On the other hand, grouping your files by what language they were written in is silly. Imagine ~/Work/Java Projects/ ~/Work/PHP Projects/ instead of grouping them sensibly based on what they’re for instead of how they’re written. Or imagine /bin/c/ls /bin/bash/ /bin/go/docker

From the “How to Write Go Code” document:

Another common setup is to set GOPATH=$HOME.

And so that’s what I did.

I moved everything from ~/go to ~ and I moved my own scripts and stuff from ~/.local/bin to ~/bin, symlinking ~/bin back to ~/.local/bin so that anything expecting it there can find it.

Go requires you to organise your programs under src/ by host and then by author (raising some new issues, like what if it’s unhosted) which seems like a reasonable way of organising lots of things, conveniently also keeping work separate from free-time open-source stuff on GitHub. And since it’s inflexible about it, I might as well make lemonade from lemons and use it for everything else.

I’ve just scratched a 5 year itch and that’s where I am now. This seems neater than before, let’s see how it works!

Rooting Samsung Galaxy Mini

Samsung Galaxy Mini

Samsung Galaxy Mini

My wife’s phone (Samsung Galaxy Mini GT-S5570I) doesn’t get system updates any more, so I need to manually move Google’s updates into ROM to make space for regular apps. You need root privileges to do this, so I was following these instructions on the XDA Forum which almost work fine. You need to download and apply a file but the problem is the update script inside doesn’t include S5570I in the list of phone models it checks for, so the script aborts.

All you need to do is edit /META-INF/com/google/android/updater-script inside and include this phone model in the assertion list, for example, I duplicated lines 15 and 16 and just added an I to the end:

getprop("ro.product.device") == "GT-S5570" ||
getprop("") == "GT-S5570"  ||
getprop("ro.product.device") == "GT-S5570I" ||
getprop("") == "GT-S5570I"  ||

Everything works completely fine after that. Obviously this is not a general solution when rooting, you can’t just blindly add your own phone model into any not knowing what’s in it, but since this was from a post for specifically this model and it already had several very similar models listed, I thought it was worth the risk and it turned out just fine. Woop! 😎

grml zsh inPlaceMkdirs

I keep forgetting this, but it’s really useful when working in the command line so I’m writing it down now. I use the grml zsh configuration in my shell and it has several very good features; a cool one I’d use more often if I could remember the shortcut is “in-place mkdir”. The key sequence is:

Ctrl-X, Shift-M

That’s Ctrl and x, followed by an uppercase M.

Here’s an example use case: Imagine you’re writing a command to do something with a very long path, like moving a file deep into a source tree

mv src/something/very/long/

except half-way in your realise some of the directories in that path don’t exist. No problem! Usually you’d have to cancel that command, create the missing directories and then type it again. Now you can just type Ctrl-X, Shift-M, the directories are created and you can just press enter to use them. Much less annoying! This can even work for different directories in the same command; move the cursor to the directory you need and zsh will create that one!

For other useful shortcuts, see the reference card.

Switch Colours in the GIMP

GIMP Colour SwitcherAfter my previous discovery I thought surely there should also be an easy keyboard shortcut for swapping the foreground and background colours in the GIMP, even though it doesn’t seem to be documented anywhere. There is. Just press X.

Actually I think it would be useful if this was shown in the tooltip text when you hover over the colour switching button, like it does with the other tools. If you’re curious, here is a list of 74 keyboard shortcuts for the GIMP (including this one) that you might not have known otherwise. I think keyboard shortcuts are great for editing pictures because you can change tools (and now also swap colours) without moving your cursor away from where you’re drawing!

CSS for TODO Elements

I wrote a small CSS class .todo for cases when you want to mark HTML elements on a page that you still want to work on later. Add this class to elements that aren’t ready yet, to mark them so that you won’t forget about them and ship the site unfinished. See the Gist’s description on GitHub for more information on how to use it. Here’s the code:

/* CSS for adding TODO notes on WIP pages */
div.todo { /* style the text in a bright box */
  color: red;
  font-size: large;
	background-color: yellow;
	text-align: center;
	border: 3px solid red;
	border-bottom: 1px solid red;
	margin-bottom: 0;
	padding: 1px;
div.todo:before { /* prepend the word TODO to the text */
	font-weight: bold;
	content: "↓ TODO: "
div.todo+* { /* style the following element in a bright box too */
	border: 3px solid red;
	border-top: 0;
	margin-top: 0;

Running Sparkup Vim Plug-in on Arch Linux

The sparkup plugin for vim lets you write HTML markup faster by Zen Coding, in which you write short code, resembling CSS selectors, which is then expanded to HTML by the editor. For example, writing


would give you:

<div id="nav">
    <ul id="menu">
        <li class="item"></li>
        <li class="item"></li>
        <li class="item"></li>

This is obviously extremely useful, as it saves a lot of typing. However, I encountered a bit of trouble using this plugin on my laptop, which runs on Arch Linux. It’s easily solved though. Continue reading

Safe and Easy Passwords

I was reading something by a friend of mine about an easy way to remember a large number of passwords. I had some comments on it but I was writing a bit too much to fit in a comment box so I’ve moved it here instead.

The basic idea is that because it’s inadvisable to use the same password across multiple networks because, possibly amongst other things, if someone knows one of your passwords then they have access to everything you do online! So it was suggested that you pick something memorable, for instance you might be a proud supporter of Liverpool F.C., so you take the word “liverpool” and prepend the first letter of whatever service the password is for to that. For example:

Twitter: tliverpool
Facebook: fliverpool
Identica: iliverpool
Gmail: gliverpool
Jabber: jliverpool
And so on…

Now, while in principle this might be an easy way to remember passwords, there are some problems with it, so I’d like to add a bit more. Continue reading

Installing Ubuntu

A tutorial on how to install Ubuntu on your computer is completely redundantbecause it’s really that easy. I’ve installed Windows 7 for people and I’ve installed Ubuntu, as well as several other things. Based on my observation Ubuntu’s installer is the easier of the two.This is what you have to do: Download the disk image from the Ubuntu Website, burn it to a CD, put the CD in your computer and restart the computer. Welcome to Ubuntu!

Edit: Based on some feedback there are some things I would like to add:

  • The last step of the installation is to set a good password for your account
  • There’s a countdown to the next Ubuntu release; Ubuntu Natty Narwhal
  • If you’re looking for a reason to install Ubuntu you can find some there too
  • You can download an Ubuntu install disk from their downloads page
  • You can download it in 64 or 32 bit, Intel or AMD and other stuff
  • You can download it directly or torrent it (legally of course; Ubuntu is free software)
  • You can choose between a desktop, netbook or server edition
  • There’s an alternate installer with no graphics that uses less resources

Continue reading