2013-09-27

Vim configuration

My Vim configuration. Probably the only non-obvious thing is to use list to show whitespaces and listchars to display each tab as ">-". See Vim Wikia Highlight unwanted spaces for more information.

set guifont=Consolas:h10:cANSI
set ignorecase
set list
set listchars=tab:>-
set nobackup
set nowritebackup
set printfont=Courier:h8
set shiftwidth=2
set tabstop=2

2013-09-20

Concatenating two specific lines in sed

I wanted to concatenate specific rows of data so that I could analyse and chart them in Excel. My data had rows starting with a date and a keyword:

01/01/2013
12
46
79
xyz 0.1
02/01/2013
56
23
xyz 0.5

And the output I wanted is:

01/01/2013 xyz 0.1
02/01/2013 xyz 0.5

Below is a sed script to concatenate those two lines and ignore the others:

# Use: sed -n -f Concat.sed test.log
# H Hold <- Hold + \n + Pattern
# h Hold <- Pattern
# g Pattern = Hold
# First pattern
/..\/..\/..../ {
 h
}
# Second pattern
/xyz/ {
 H
 g
 s/\n/ /
 p
}

The "trick" is to collect the rows that I need into the hold space first then transfer it to the pattern space where the line break can be replaced by a space.

2013-09-19

Cannot read CHM file in Windows 7

If you can't read pages in a CHM (Compiled HTML) file on a Windows 7 computer, you might have to "unblock" the file. Seems to be a security feature to prevent scripts running.

  1. Show the CHM file properties.
  2. In the General tab, press the Unblock button. Note: After you do this, the button no longer appears for this file.

Thankfully, you only need to do this one time for the CHM file.

See longer write-up in StackOverflow.

2013-09-13

Portable GnuWin32

How to make GnuWin32 portable.

  1. Install all the GnuWin32 packages you require on a "build" computer. The packages are normally installed in a "GnuWin32" folder.
  2. Copy the GnuWin32 folder from your "build" computer to your portable drive or target computer.
  3. On your target computer, add the path to the GnuWin32\bin folder to your user (not system) PATH environment variable.

(Moving to portable applications to save time installing programming tools each time I have to work on another computer, especially when I don't have administrator rights.)