RubyGreenBlue

New Photo Blog

Posted by keith 5 months ago

Not really Ruby related, but I'd like to announce the existence of my new photography weblog. Taking photos is a passion for me and I'm excited to have a new outlet for that passion in the form of a weblog.

I look forward to posting images from shoots there as well as photography tips and whatever else it evolves into.


External diff with Subversion using BBEdit

Posted by keith about 1 year ago

BBEdit has a great Find Differences function. You get a list of description of differences that you can click on to see the two affected files. You can also do things like apply the difference to either the new or the old file.

Subversion's differences output is of course command-line only, but subversion does support using external diff tools.

Enter bbdiff from John Gruber.

bbdiff is a command line interface to BBEdit's Find Differences command.

Download bbdiff from John Gruber's site, and follow his install instructions (very easy, copy it to where you want it and chmod it to be executable)

You will need to setup subversion to actually use an external diff command. To do this we will need to write a quick interface between the svn diff command and the bbdiff command as the argument lists do not match.

The arguments we want from the svn diff command are $6 (old file) and $7 (new file).

The bbdiff usage states:

Usage: /usr/local/bin/bbdiff [-b -i -s] oldfile newfile
-b keep BBEdit in the background
-i case insensitive comparison
-s ignore leading and trailing whitespace on lines

So we see that we need to pass in params $6 and $7 from the svn diff command in the order that they appear. Write a script that calls bbdiff with those params. Mine is called svndiff2bbdiff:

/usr/local/bin/bbdiff $6 $7

Make sure you chmod your svndiff2bbdiff file to be executable (chmod +x svndiff2bbdiff).

In your ~/.subversion/config file, search for the [helpers] section and create a line like:

diff-cmd = /usr/local/bin/svndiff2bbdiff

assuming your svndiff2bbdiff is in /usr/local/bin/

Test it out: svn diff -r PREV <file_name>.


No Database? Sometimes it feels right.

Posted by keith about 1 year ago

In No Database, Tim Bray talks about why he doesn't want to use a database for storing comments in a blog system.

Tim says:

...there is a psychology out there in our profession,which says: if you have data that you want to store and retrieve, that means you need a database. But sometimes you don’t. And sometimes you come out ahead on one or both of the less-work and runs-fast metrics by not having one.

I agree with Tim here. I'm not saying no databases, ever! I use databases almost all the time, but there are times when not using a database feels like the right way to do it. It's all a matter of the requirements and what you are modeling.

This blog runs on a system that uses subversion to store it's data. To edit posts I don't need to use a web interface or some client talking to a database. I just edit files.

This gives me the freedom to edit my posts in my favourite text editor from anywhere I like. I just need a working copy of my blog repository. And of course with subversion I can edit offline.

As Tim does, I like the semantics of the Unix filesystem and for writing blog articles, it just feels totally right for me.


Public Key Authentication with SSH

Posted by keith over 2 years ago

Here's how to setup public key authentication over ssh.

  1. Generate the keys

    First create a directory on your local machine ~.ssh/ if it is not already there.

    ssh-keygen -t dsa
    ssh-keygen -t rsa
    

    ssh-keygen will ask for the filename to save to. Just press ENTER to use the default values. It will then ask for a passphrase. A blank passphrase can be entered but this is obviously less secure and the same result can be achieved by using an ssh-agent.

    Private and public keys will then be generated. The public keys have a .pub extension.

    Your private keys should be kept private so you should make sure they are only readable by you (chmod 0600).

  2. Copy the Keys

    Now you should copy the public keys to each machine you will want to connect to. The contents of the public key needs to be appended to ~.ssh/authorized_keys on the remote machine. You could upload them using scp then login to the remote machine and append the contents but these commands can do all of that from your local machine:

    cat .ssh/id_dsa.pub | ssh username@newmachine "cat >> .ssh/authorized_keys"
    cat .ssh/id_rsa.pub | ssh username@newmachine "cat >> .ssh/authorized_keys"
    
  3. Configure the SSH daemon

    You need to make sure the SSH daemon (sshd) is configured to allow the use of public keys.

    cd /private/etc/
    sudo vi sshd_config
    

    Make sure the sshd_config file contains these options:

    PubkeyAuthentication yes
    AuthorizedKeysFile .ssh/authorized_keys
    
  4. Test it out:

    ssh username@host
    

    You will now be asked for you passphrase (not your password for the remote machine).

    To avoid having to type in the passphrase, setup an ssh-agent which will effectively do that for you each time you connect to a remote machine that knows about public keys. If you're on a Mac, SSHChain is an excellent utility.