Stop vi Complaining

Whenever you try and open a file that’s already open in vi you receive the interminable message that ends:

Swap file “.la.swp” already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

You have to scroll to the end of the message and then choose an option. And I always choose to abort.

I wrote this little shell script that doesn’t force you to choose one of the options but just aborts with a short helpful message.

if [ -e ".$1.swp" ]
then
  echo "A swapfile for $1 exists.  Already open?"
else
  vi "$1"
fi

Then just alias vi or vim or whatever to the shell script and no more annoying message.

(You can do this within vim with a setting but I have found that to be less reliable and less useful. Plus this way you can use vi and get the old behaviour should you need it.)

help.bluebones.net – Free Computer Advice

I get asked for a lot of computer help and advice. I send step-by-step instructions via email on a regular basis.

It seems like a waste for this information to be locked up in email when it could be shared on the web.

So I’ve created help.bluebones.net where I can record all the advice I give. Hopefully other people who don’t have access to someone like me will stumble across in their Google searches and it will help them out too.

Also, it stops me repeating myself – I can just point people at a URL!

Automatic Translation

I find Google Translate frustrating. Why do I need to tell it what language my text is in, or what language I want it translated to? Can’t it work it out?

http://bluebones.net/translate/ is a wrapper for Google’s translator that automatically detects the language of source text or web site and translates to your language (based on browser settings).

You might also find this bookmarklet useful. It translates the page you are currently on into your language. Drag the link to your Firefox toolbar: Translate

I was inspired to do this by Mike Linsvayer’s post on the same subject.

Do Not Reply

I don’t think I will ever stop being annoyed by receiving emails from do-not-reply@ email addresses.

Sometimes they are from companies (like eBay) who genuinely feel they get too much email from customers as it is and would really rather avoid it. I don’t like that attitude, but at least they are conscious of what they are doing.

What’s even more surprising is that you get email like that from startups and other groups who are crying out for feedback and have a spiffy feedback form that’s linked from every page on their site. Or from applications that are otherwise super-usable and super-friendly.

Whoever answers your emails from your feedback form can surely also answer replies to your automated emails. Can’t they?

Data as Procedures with No Data

Further to my post on data as procedures, I’ve translated to Common Lisp the implementation of cons, car and cdr as procedures with no data, not even numbers.

This comes from lecture 5b of the Structure and Interpretation of Computer Programs video series, with the necessary (funcall) adjustments for Common Lisp.

(defun my-cons (x y)
    (lambda (m) (funcall m x y)))

(defun my-car (x)
  (funcall x (lambda (a d) a)))

(defun my-cdr (x)
  (funcall x (lambda (a d) d)))

(print (my-car (my-cons 35 47)))
(print (my-cdr (my-cons 77 22)))

Output is:

35
22

Data as Procedures

I was watching lecture 2b of the SICP lectures and it shows an implementation of cons, car and cdr in Scheme as procedures. So I thought I’d write the equivalent in Common Lisp to test my understanding:

(defun my-cons (a b)
  #'(lambda (c)
      (cond ((= c 0) a)
            ((= c 1) b))))

(defun my-car (x) (funcall x 0))

(defun my-cdr (x) (funcall x 1))

(print (my-car (my-cons 'gold 'silver)))
(print (my-cdr (my-cons 'everything 'nothing)))

Output is:

$ clisp pairs.lisp

GOLD
NOTHING

Crazy. “Constructed out of thin air”, as Abelson says.

The scheme implementation is definitely nicer. See What Is Meant by Data? Scheme has only one namespace so there’s no need for the #' and funcall clutter.

Thresholding del.icio.us/popular

I really like delicious’ “popular” page and I particularly like that it is available as an RSS feed. But keeping up with it could really take over your life.

To get around this I’ve set up a “very popular” feed. To qualify an item has to be on the delicious popular page AND have 100+ recent votes. You can subscribe at:

http://bluebones.net/very-popular/rss/

If you want a different threshold just add ?threshold=n to the end of the URL where n is the number of votes a link has to have had to qualify.