Index syndication
comment syndication

Archive for May, 2008

Vim Split tips

I use vim a lot of the time, mostly with splits and diffs, so the following key mappings and functions really helped me with managing the split windows. Maybe they will help you too. (Thanks to the Vim tips wiki for these).

  • If you use vertical splits, this will help move left and right across the split. Put in your ~/.vimrc
    " Map multi window keys
    set wmw=0
    " CTRL-H move to left window
    nmap <c-h> <c-w>h<c-w><bar>
    " CTRL-L move to right window
    nmap <c-l> <c-w>l<c-w><bar>
    
  • When scrolling up and down a window, you can use zz to jump the current line to the middle of the window. If you want this on always ala Scroll locking, then you can use this function. It is a toggle option. use \zz to toggle it. Put in your ~/.vimrc
    " Map \zz to lock scroll to middle of window
    map <Leader>zz :let &scrolloff=999-&scrolloff<CR>
    
  • In a window split (of any sort) if you want to maximise to the current window, this will do it for you. When you press CTRL-W then o it will maximise the current view, then when pressed again will return your split arrangement! Put in your ~/.vimrc
    " Max/unmax splits
    nnoremap <C-W>O :call MaximizeToggle ()<CR>
    nnoremap <C-W>o :call MaximizeToggle ()<CR>
    nnoremap <C-W><C-O> :call MaximizeToggle ()<CR>
     
    function! MaximizeToggle()
      if exists("s:maximize_session")
        exec "source " . s:maximize_session
        call delete(s:maximize_session)
        unlet s:maximize_session
        let &hidden=s:maximize_hidden_save
        unlet s:maximize_hidden_save
      else
        let s:maximize_hidden_save = &hidden
        let s:maximize_session = tempname()
        set hidden
        exec "mksession! " . s:maximize_session
        only
      endif
    Endfunction
    

Keyboards are worse than Toilets

I promise to no longer touch any ones keyboards at work if you all promise to keep your hands off mine.
After seeing a twitter post on this, I read an article at the Beeb on how; and I definitely quote:

Research by the University of Arizona last year found the average office desktop harboured 400 times more bacteria than the average office toilet seat.

“Should somebody have a cold in your office, or even have gastroenteritis, you’re very likely to pick it up from a keyboard.” … one of the causes of dirty keyboards was users eating lunch at their desk, with crumbs encouraging the growth of bacteria. Poor personal hygiene, such as not washing hands after going to the toilet, could also be to blame.

Read more at the BBC well before you have lunch.
This is also a good time, going into the colder months in Southern Australia, to brush up on your coughing skills; and it is about this time last year I discussed the best way to do this.

Little Brother

I just started reading Cory Doctorow’s Little Brother using one of his ebooks he has relesed under the Creative Commons license.
I have to admit that I had never heard of Cory of BoingBoing fame, or his books until I read about them via CelticBear.

As a ‘paranoid’ geeked I’m hooked on Little Brother, and if you like tech, geek and drama you should check it out as well.

Update: I went to buy a copy from a local bookstore, but it is not released in Australia yet. You can read the ebook or buy it from amazon.

the iPhone is coming

I can feel it….. Hot on the heels of iPhone release rumours, TUAW post the rumour about iPhone on Vodafone in Australia; and the SMH follow soon thereafter based upon the actual press release from Vodafone.
Made on a Mac

June is just around the corner and my current Vodafone contract runs out this month. Perfect timing.
The reason I was hoping for Vodafone is this: with a $79 cap, the $500 credit (currently) covers 3G data usage. You pay $1 per 5 minute block out of your cap. Its totally different how Telstra charge: $60 per month on top for data and $0.25 per MB.

Since I make about $100 of calls in a month, that’s $400 of included data in my cap; or 33 constant hours of 3G data. But wouldn’t it be nice if Vodafone shifted to an untimed/uncounted data plan for the iPhone. That is the ultimate Geek Nirvana.

Always encrypt your ssh private key

Recently someone I know advised other IT people to generate their SSH keypair using the default options “using just enter to answer all the questions”. This means that the Private Key generated has no password against it (and is unencrypted).

In this case your private key is stored unprotected on your own computer, and anybody who gains access to that will be able to generate signatures (login to servers) as if they were you They will be able to log in to your server under your account.
I’ll reiterate that: This will allow ANYONE holding this file to access ANY server AS YOU where you have uploaded the public keys.

This means that in the case your laptop or computer is lost or stolen, your unix accounts are effectively compromised.

For this reason, your private key is recommended to be encrypted when it is stored on your local machine, using a pass phrase of your choice. To minimise this risk you should choose a strong pass phrase to be applied to the private key when generation occurs.

There are two ways to generate a key pair.

  1. If you are using openssh then generate the keypair under your unix login as follows:

    $ ssh-keygen -C "My development key 05 May 2008" -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/lantrix/.ssh/id_rsa): 
    Enter passphrase (empty for no passphrase): **type in a strong password here**
    Enter same passphrase again: **retype in your strong password here**
    Your identification has been saved in /home/lantrix/.ssh/id_rsa.
    Your public key has been saved in /home/lantrix/.ssh/id_rsa.pub.
    The key fingerprint is:
    1a:aa:bb:44:09:38:ec:1d:1c:2d:27:c8:cc:dd:ee:ff My development key 05 May 2008
    $ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
    

    Then copy ~/.ssh/id_rsa the password protected and encrypted private key to a secure place on your client machine to use (placing it in your ~/.ssh/ folder - remember to set permissions to 600).

    If you want to use this openssh keypair with putty on a windows client, you will need to follow an extra step. Use PuttyGen menu to load your generated “id_rsa” file you transferred to your windows client.

  2. If you are only going to use putty to connect to UNIX servers it is better to generate the keypair in putty
    See the putty documentation for instructions on generating your key pair.
    Ensure you export the public keyfile to ~/.ssh/authorized_keys on each UNIX server you want to login (and chmod 600 on the file).

A Helpful tip

You can use putty to “cache” your key (to prevent constant retyping of your password when logging into servers) in a secure fashion using this component of putty.

Dont think of SSH keypairs as a means of easier logins. When used correctly it will in fact provide a more secure login; as your password is never passed over the network.