Links like this…

When I first started using Vim, I watched a fascinating talk given by the author, Bram Moolenaar, titled “7 Habits For Effective Text Editing 2.0” (click the link to see the presentation. It’s 80 minutes long so maybe grab a coffee first ;-) ). One of the ideas he talks about, and something which seems to be a pervasive philosophy of Vim, is the “Three basic steps”:

1. Detect inefficiency
2. Find a quicker way
3. Make it a habit

I think this is an excellent philosophy for computing in general – why do something repetitive yourself, when the computer can do it much more quickly and accurately? An obvious (and trivial) example is “search & replace”, which saves you from having to scroll through a file to find all the occurences of a string, then manually type in its replacement.

Since watching that talk, and as I got more familiar with Vim, I started “detecting” such inefficiencies everywhere; often in apps which are not nearly as flexible, which usually makes these inefficiencies more frustrating because they are harder to solve. I had one of these moments while browsing stackoverflow today.

Stackoverflow is a great resource, with lots of good information, however there is so much discussion that you could never read it all. That’s why every now and then I like to browse the Hottest Questions This Week, which does a pretty good job of distilling out the good stuff.

Now, I like to browse all those articles in full because it’s difficult to tell from the question whether or not it’s going to have one of those “gem” answers. So I started middle clicking all the links down the page to open them in new tabs as I normally do, when I suddenly realised how inefficient I was being. If only there was some kind of macro that could open all these links for me…

Well as it turns out, there’s an extension for that! It’s called Links Like This and does exactly what it sounds like it should. Just right click on a link, select “Open Links Like This…”, and all the similar links on the page are highlighted, with the option to open them all presented in a very slick interface. I’m not sure what heuristics it uses to determine which links are alike, but it does exactly what I want it to do: open all the “Hottest Questions This Week” in new tabs, saving me a full minute of my life and 48 mouse clicks. It even differentiates between visited links and unvisited links, so if I view the page twice in one week, it can open only those links that I haven’t visited! Awesome :D .

This illustrates to me a couple of things. Firstly, for repetitive computing tasks there is always an easier way. I wonder where else am I doing something manually which is more suited to some clever code?
And secondly, this is the power of open source software. Firefox’s value lies in it’s openness and the ease of writing extensions. There is no other browser which can compete with firefox’s features, because whenever someone sees an inefficiency or wants to add a feature, mozilla has made it simple for them to code a solution and share it with the world. I doubt very much that any other browser (especially a proprietary one like IE or Opera) would add support for a feature like this.

That’s also why I think KDE’s plasma is so important and exciting: it’s doing for the desktop just what firefox is doing for the web. Plasma widgets are really just “extensions” for your desktop, and you can code them in Javascript (just like a firefox extension), as well as Python, C, C++ and Ruby. Anyway, enough of a braindump. Back to work.

git: simple!

I’ve been working on a project at home, using git for source control, and needed to make the project available from anywhere, so that I could work on it wherever I needed to. I have an ssh account at the university, so I decided I’d try setting up a git repo I could access through that. I was expecting it to be complicated and difficult, but in fact it was incredibly simple.

Google found these instructions, which I based my setup off; most of what’s below is quoted from that article, but I’ll put it here anyway for reference.

# login to remote server
ssh -l myUsername REMOTE_SERVER
# once logged in
mkdir /path/to/example.git
cd /path/to/example.git
git init

Note: the link above recommends

git --bare init

in the last line. using the –bare switch will create a repo without a working tree, which is great if you don’t need to work on the code on the machine where the repository is housed. However I need to work on the code on that machine too when I’m at uni.

Then, on my home machine I just run:

git remote add origin myUsername@REMOTE_SERVER:/path/to/example.git
git push origin master

The first command adds a the remote repository we just created and names it ‘origin’. The second command then pushes your ‘master’ branch to the remote repo.

And that’s it! You can now push/pull/clone from this repo to your heart’s content. For example after I work on the code at uni then want to work on it at home with those changes I just do:

git pull origin master

Simple!