The Myth of the Muttering Madman is a project in self-realization.

Wednesday, June 28, 2006

krugle is kool

A friend at work showed me this today. I'm so behind the times, but check out www.krugle.com. It indexes code in open source projects so there is a whole bunch of languages it can give you very useful code snippets for - for me that's java, perl and C# - for all the pretend programmers that's JavaScript :P

Amazery! Check it!

Saturday, June 24, 2006

Vim for Windows Programmers

I've been oscillating between different editors lately. At home I tended to use Vim for my programming tasks. At work I used a combination of Notepad++, XEmacs, Vim, and IDEs like Visual Studio 2005 for .NET work. I've finally had a gutful and have decided to use Vim as my primary editor (especially for programming tasks).

I think Vim is a really great editor on any platform. It certainly feels very natural on *nixs and there is a Vim port for Mac OS X. This tutorial however is targetted at the total Vim beginner who is interested in giving Vim a try on Windows. It explains how to install and configure Vim (for Windows XP), how to use some of its basic features and how to get further information.

Installation

  1. Download a Vim from www.vim.org. I suggest getting Vim 7.0 as this is currently the latest version. The self-installing executable is available here.

  2. Run the installer

  3. Do a custom install

  4. Click "Create .bat files for command line use"

  5. Make whatever other modifications you like to the installer configuration

  6. Hit the magic button!

Configuring Vim (_vimrc and _gvimrc)

Vim is a very powerful editor. As such it has a dizzying array of options which can be customised. In fact Vim can even be scripted, and this allows you to extend it in very cool ways. This section will describe some of the most basic customisations that you can make to setup the editor as you see fit.

All configuration for gVim is kept in a single file, _gvimrc. This file will probably have been created in your HOME directory. For me on Windows XP, this is C:\Documents and Settings\snarkyboojum. If you can't find a _gvimrc file there create one. _gvimrc is where you configure the graphical version of Vim (as opposed to the terminal version which you can run in a Command prompt - try typing "vim" at the command prompt and you'll see what I mean). The other configuration file you should be interested in is _vimrc. This file configures the terminal version of vim. Many options specified in one can be specified in the other. There are a few options that are only relevant for gVim, but the configurations I'll specify below are interchangable between both Vims.

_gvimrc configuration

The first thing you want in your _gvimrc file is:

set nocompatible

This improves the usefulness of (g)Vim by not trying to make it more compatible with Vi. There are subtle differences between Vi and Vim for a reason. If you want Vim to behave more closely to Vi you'll want to set compatible.

Without going into a rant about tabs vs. spaces I really do prefer expanding my tabs to spaces. I tend to use 4 spaces to represent a tab and I like for my code to autoindent while I'm writing it and have this indented by 4 spaces aswell. To set this up add the following to your _gvimrc file:

set autoindent
" replace a tab with 4 space characters
set tabstop=4
" configure autoindent to indent using 4 spaces aswell
set shiftwidth=4
set expandtab

Every programmer I've met or know loves syntax highlighting. I know I do. To turn this on by default in Vim add the following to your _gvimrc file

syntax on

In Vi, the backspace key didn't allow you to backspace over newlines amongst other things. This will quickly drive you crazy if you don't "fix" that. To make backspace work as you would expect add:

set backspace=indent,eol,start

To highlight search matches when performing a search and to enable incremental search where potential matches are found as you type the search pattern add

set hlsearch
set incsearch

Fonts are an important element of text editing. Programming fonts are usually different to standard word processing fonts in that they clearly distinguish between such characters as 0 and O. I like a proggy_fonts font called "Proggy Clean". To change the font used by default in gVim, add the following:

set guifont=ProggyCleanTT:h12:cANSI

where ProggyCleanTT is the name of the font, h12 is the height of the font in points (this can be a floating point number), and cANSI is the character set used. You can specify more than one font here in case a font isn't found. For fonts with spaces in the name just use the \ character to escape the space in the name. E.g. Andale\ Mono. On Windows a _ character can be used to replace spaces in font names too.

I like the mouse to hide when I'm typing text so I also add the following

set mousehide

It is possible to define the size of the gVim window when Vim starts aswell. This option is controlled by specifying the number of rows and columns to use. E.g.

" open a long window
set lines=55

So after all that, you should have a better idea on how customizable Vim is. This isn't even stratching the surface of what Vim can do. A good way to find out how to improve your configuration is to visit www.vim.org and check the massive collection of tips they have there. Another good way to learn about this stuff is to find other people's configs. To find out what any given setting does just type :help <command> in Vim and you'll be taken straight to the relevant help section for that command e.g. :help softtabstop. For reference, here is what my _gvimrc looks like:

" Snarkyboojum's Vim configuration
" Last updated: 24/06/2006

set nocompatible

" turn syntax highlighting on and change tabs to 4 spaces
syntax on
set autoindent
set tabstop=4
set shiftwidth=4
set expandtab
" make the spaces feel like tabs when moving over them
set softtabstop=4

" turn the annoying visual bell off
set novb

" set up search behaviour
set showmatch
set incsearch
set hlsearch

" make command line two lines high
set ch=2
" hide the mouse when typing text
set mousehide
" make backspace behave the way I'd expect it to
set backspace=indent,eol,start
filetype plugin on

" setup font and window size
set guifont=ProggyCleanTT:h12:cANSI
set lines=55

" make it obvious when there are nasty tabs and trailing whitespace in a file
set list listchars=tab:»·,trail:·

Using Vim

Still being written

Further information and other resources

The Vim homepage. There is a wealth of information about Vim here. The tips and scripts sections are very very useful.
Vim documentation including links to a PDF version of Steve Oualline's Vim book.
Vim for Perl developers. Good intro to some interesting Vim stuff for the Perl geeks.
Seven habits of effective text editing by Bram Moolenaar (the creator of Vim)

Exams are over...

Exams are over and I feel FUCKING FINE.

Fat little stubby dwarf people...

Fat little stubby dwarf people live across from me. They waddle back and forth across the road. For a long time I couldn't understand why they'd walk out of one house, across the street and into another house. People don't just enter into each others house willy nilly do they? They have some kind of monopoly over this corner of Short St. It smacks of too much community. But then I live in The Mondrian, designed by a famous architect whose name I don't know and I don't talk to anyone.

Tuesday, June 20, 2006

Google Trends...

Check out Google Trends. Someone should write a tool like this for blogs :P

And now for the honest truth about what makes the world go 'round.

Who woulda thunk it?

Sunday, June 11, 2006

Guantanamo suicides are 'acts of war' now?

Read this article today and became really indignant and angry. These people are treated inhumanely, tortured, locked away in little more than cement holes and are told they are being held indefinitely. The whole process is illegal and most detainees must know it. Anyone's psychological health would take a beating after even a few months of this kind of treatment. So news hits that three of them have hanged themselves. These guys have been in Guantanamo for 4 years. You'd expect some empathy and concern, or at least some kind of investigation, but the best the base commander can come up with is:-

"They have no regard for human life," he said. "Neither ours nor their own. I believe this was not an act of desperation but an act of asymmetric warfare against us."

I can't conceive of an ideology or philosophy egotistical or twisted enough to come up with something like that and really believe it. America really has got it's head up it's ass.

"To help prevent more suicides, guards will now give bed sheets to detainees only when they go to bed and remove them after they wake up in the morning"

I can think of a novel idea. Give them a trial. Treat them like human beings. Give them half decent living conditions. The sooner someone wakes up over there the better. Arghh.. So fucking unjust. The whole thing is just fucking insane.

Sunday, June 04, 2006

Saturday, June 03, 2006

I'll give you binary in a minute!

Measuring the speed of an electric motor using an AVR microprocessor and displaying it on an LCD screen.

Can anyone else see the rabbit?

:020000020000FC
:100000000C9423000C9429000C9422000C942200E0
:100010000C9422000C9422000C9422000C942200D8
:100020000C9422000C9422000C9422000C942200C8
:100030000C9422000C9422000C9422000C942200B8
:100040000C94340018950FEF0DBF00E10EBF0C9417
:1000500059000F930FB70F9301E0100F0027201FD7
:100060000F910FBF0F9118950FB70F93DF93CF9399
:100070009F938F93C0E0D1E08991988101968D3054
:100080000EE0900769F4269517952695179561E07F
:1000900064D025D0002708830A931127222702C0A5
:1000A00098838A938F919F91CF91DF910F910FBF8A
:1000B0001895002701BB0FEF02BB02E000936A0016
:1000C00009B7016009BFC0E0D1E0002709930883A8
:1000D00002E003BF01E007BF789474D0FFCF33275D
:1000E000103107E2200720F0105127423395F8CF56
:1000F000632F00E3600F4BD03DD03327183E03E061
:10010000200720F0185E23403395F8CF632F00E3DB
:10011000600F3DD02FD03327143600E0200720F0A9
:10012000145620403395F8CF632F00E3600F2FD093
:1001300021D033271A3000E0200720F01A50204049
:100140003395F8CF632F00E3600F21D013D0612FD8
:1001500000E3600F1CD00ED0089568BB00270BBBD6
:100160000000DA9A000000000000DA9800000000A9
:100170000000089568BB08E00BBB0000DA9A00009D
:1001800000000000DA980000000000000895002739
:1001900007BB08BB02E00BBB0000DA9A00000000BE
:1001A000000006B3DA9807FDF7CF00270BBB0FEF6F
:1001B00007BB08957150804000000000000000005F
:1001C000C9F708950FEF07BB0ABB78E98AE3F2DFAE
:1001D00068E3C3DF74E080E1EDDFBFDF74E680E059
:1001E000E9DFBBDFBADFD3DF68E0B7DFD0DF61E094
:1001F000B4DFCDDF66E0B1DFCADF6EE0AEDF0895C9
:00000001FF

Thursday, June 01, 2006

Thank god for video instruction...



The sound effects are entirely convincing. Limitless replay potential. I'll be right back.

UPDATE: Ok, thanks to an (obviously) twisted friend of mine this takes the cake.

about me