Not So Popular

My experiment in thresholding del.icio.us has not proved entirely successful.

It turns out that the links that are really, really popular are actually the bad ones. So I’ve added a new feature to my del.icio.us RSS feed.

You can now add a parameter to the feed URL to put a maximum (instead of a minimum) on the number of votes for an item to be included like this:

http://bluebones.net/very-popular/rss/?threshold=50&minor=true

Meanwhile, Jon Aquino (who wrote the brilliant yubnub) has created descriptious which tries to give a bit more information about each link in the feed.

Stock Ticker Feed

Stock Ticker Feed Screenshot

A few years ago Yahoo created beta stock ticker RSS feeds. Then they withrdrew them and they haven’t been heard of since. They have provided CSVs of their data for a long time. So I’ve turned the CSVs into RSS feeds. The address is like this:

http://bluebones.net/ticker/feed/?s=SYMBOL

Where SYMBOL is something like KO (for Coca Cola).

One other minor feature is that you can get localised times by adding &n=uk (or es or fr or any other country code that has a Yahoo! Finance). So for example to get Vodafone’s share price with UK times use:

http://bluebones.net/ticker/feed/?s=VOD.L&n=uk

You might want Yahoo’s symbol lookup.

I just knocked this up very quickly so it may be buggy. If you use it, or find a problem, leave me a comment.

ssh – My Setup

This is the shell script I use as my alias for ssh:

#!/bin/bash
ssh-agent
ssh-add
case $1 in
    marge* ) SSHCOLOR=1 ;;
    bluebones.net ) SSHCOLOR=1 ;;
    barney* ) SSHCOLOR=7 ;;
    lisa* ) SSHCOLOR=6 ;;
    homer* ) SSHCOLOR=3 ;;
    * ) SSHCOLOR=5 ;;
esac
if [ $1 ] ; then
    tput setab $SSHCOLOR
    \ssh $*
    tput setab 9
else
    echo "Usage: $0 [HOST]"
fi

The background colour shows me at a glance which machine I am on.

Five Programming Languages You Really SHOULD Learn Right Now

eweek.com’s article on ten programming languages you should learn right now is the most ill-informed pieces I’ve read in a while. Here’s my (hopefully better) attempt.

Five Programming Languages

  1. Scheme. If you come from a “curly braces” background you should learn a functional language. As Eric Raymond says about the very similar Lisp:

    LISP is worth learning for a different reason — the profound enlightenment experience you will have when you finally get it. That experience will make you a better programmer for the rest of your days, even if you never actually use LISP itself a lot.

    I prefer Scheme because it is purer (no need for funcall).

  2. Erlang. Another functional language. Concurrency done right. In the multiprocessor future this could be very important indeed.

  3. Ruby. A conscious attempt to make a programming language that is a joy to use. String handling from Perl, OO from Smalltalk, closures from Lisp/Scheme.

  4. Javascript. The only way to create a rich UI in current web browsers.

  5. C. For when things must be fast. Use with Ruby, Python and many other languages when you need to optimize a section of your code for performance.

C, Ruby and Javascript are on the original eweek list. As for the other seven on there:

Maybe

PHP – Quick and dirty. Yes, it’s quick, but it’s dirty.

Python – Dynamic, fairly intuitive, list comprehensions are great. But explicit self? No ternary if? Significant whitespace? The OO feels tagged on.

No

VB.NET – Hidebound, moribund offering from equally hidebound and moribund company. Plus it is inferior to it’s sibling C# in every conceivable way.

C# – Java with a little extra syntactic sugar. Not worth paying the Microsoft price for.

Perl – Somewhat deserved reputation as “write only”. Other languages (Ruby) have absorbed the lessons of perl (mainly – have brilliant regex support) and moved on. Once important, but less so every day.

Java – Bruce Tate wrote “Bitter Java” (2002), then he wrote, “Better, Faster, Lighter Java” (2004), then he wrote, “Beyond Java” (2005). You get my point.

Agree? Disagree? Think I’m a lunatic? Make a comment!

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!