PHP Google Site Search

Google’s free site search is better and easier to setup than anything you can host on your own server. However, the “branding” allowed doesn’t really go far enough. You want your search results to look like the rest of your site. And the search results URL should be on your server, not Google’s.

To solve this problem I have written a simple site search in PHP that uses the Google Search API behind the scenes to give you Google’s search, but your site’s look and feel.

Download PHP Google Site Search (165KB).

von Neumann on Programming

  1. Conceptualize the problem mathematically and physically and give a rigorous but perhaps implicit set of equations describing it.
  2. Select a numerical algorithm, that is, an explicit arithmetical procedure (which may be approximate) to replace these rigorous mathematical expressions.
  3. Do a numerical analysis to estimate the precision of the approximation process by means of an investigation of the role of errors introduced by the procedure (truncation errors) and by the machine (round-off errors).
  4. Determine the scale factors so that the mathematical expressions do not assume values that fall outside the fixed range of the computer at any time during the course of the computation.
  5. Do the dynamic analysis by drawing a flow diagram.
  6. Write the static code and enter it into the machine.

Description of programming from ‘Planning and Coding of Problems for an Electronic Computing Instrument’ by Goldstine and von Neumann, 1947-48. Quoted in ‘John von Neumann and the Origins of Modern Computing’ by William Aspray (MIT Press, 1990).

von Neumann on Software Patents

‘ … they are a commercial group with a commercial patent policy. On the basis of the information before me, I have to conclude that we cannot work with them directly or indirectly, in the same open manner in which we would work with an academic group which has no such interests. I certainly intend to do my part to keep as much of the field “in the public domain” (from the patent point of view) as I can. This is my own inclicnation … ‘

‘ … If you wish to maintain the same type of close contact with the [commercial] group – which is for you and you alone to decide – then you should not put yourself into an incompatible position by communicating with us too. I would apprecitate your making your choice in this respoect before we continue our discussions further.’

— John von Neumann to Frankel, 29 October 1946. Quoted in ‘John von Neumann and the Origins of Modern Computing’ by William Aspray (MIT Press, 1990)

Every command in /bin and /usr/bin

I read Stiff’s questions for great programmers. One of his interviewees was Steve Yegge.

I really like Steve’s blog and his earlier “rants”. One answer he gave included:

Every programmer should learn how to use every tool in /bin and /usr/bin.

As a fairly recent convert to desktop linux that sounded like a challenge to be met. A quick

ls -1 /usr/bin | wc -l

reveals that there are 1509 commands in my /usr/bin directory. Perhaps a bit much to take on all at once. /bin contains 102. That sounds like a more manageable number.

A bit of shell script magic later:

#!/bin/sh
for CMD in `ls -1 /bin`; do
    man $CMD 2>/dev/null | head -20 | grep " - "
done

and I have this list of commands and what they do:

arch - print machine architecture
bash - GNU Bourne-Again SHell
bzcat - decompresses files to stdout
bzcmp, bzdiff - compare bzip2 compressed files
bzexe - compress executable files in place
bzgrep, bzfgrep, bzegrep - search possibly bzip2 compressed files for a
bzip2, bunzip2 - a block-sorting file compressor, v1.0.3
bzip2recover - recovers data from damaged bzip2 files
bzmore, bzless - file perusal filter for crt viewing of bzip2 com

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?