Tuesday, November 22, 2005

Supress count in isql

To supress "X rows affected" from printing with isql, do:


set nocount on


before the select

Tuesday, November 08, 2005

Excel keyboard shortcuts...

The one I wanted to know was to delete a cell (or a column or row)... because <Delete> just clears the cell contents...

The keyboard shortcut is <Ctrl--> (Control+Minus) (Hyphen)

http://www.ozgrid.com/Excel/ExcelKeyBoardShortcutKeys.htm

Monday, November 07, 2005

Replacing with ^M in vim

If you want to remove ^M (<Ctrl-M> or Carriage Return) in vim (or vi) you can just do:


s/^M//g


To get the ^M use ^V^M

If you do


s/<TEXT>/^M/g


the <TEXT> is replaced with a newline character (i.e. ^J or \n) instead :o(

If you want to replace text with an actual ^M do:


s/<TEXT>/\^M/g


Of course if you're on Windows using gvim the ^V^M doesn't work, it's just the same as pressing -
on Windows you need to use CTRL-Q instead of CTRL-V to escape the special character on the ex command line or to do a blockwise visual selection

From the documentation:

(usr_24.txt)

Note:
On MS-Windows CTRL-V is used to paste text. Use CTRL-Q instead of
CTRL-V. On Unix, on the other hand, CTRL-Q does not work on some
terminals, because it has a special meaning.

(gui_w32.txt)
*CTRL-V-alternative* *CTRL-Q*
Since CTRL-V is used to paste, you can't use it to start a blockwise Visual
selection. You can use CTRL-Q instead. You can also use CTRL-Q in Insert
mode and Command-line mode to get the old meaning of CTRL-V. But CTRL-Q
doesn't work for terminals when it's used for control flow.

Saturday, October 29, 2005

Making a list of directories with perl...


perl -e 'for(1..12){my $dir=sprintf("%02i ",$_);mkdir"2005/$dir"}'

Thursday, October 20, 2005

vi move line

<ESC>:11m32<Enter>

will move line 11 to 32. :o)

(works in standard vi too)

<ESC>:11,15m32<Enter>

works too...

*just* found it by accident after all these years!
(thanks vim command history so I could see what I typed instead of 11,32!!!)

Thursday, October 13, 2005

NIS commands


$ nisgrep username passwd.org_dir
username:ENCRYPTPASSWD:1000305537:10:User Name:/home/username:/bin/ksh:13063:1:63:14:::

$ getent passwd username
username:x:1000305537:10:User Name:/home/username:/bin/ksh

$ niscat -o '[name=username]passwd.org_dir'
Object Name : "passwd"
Directory : "org_dir.domain.com."
Owner : "username.domain.com."
Group : ""
Access Rights : ----r-----------
Time to Live : 12:0:0
Creation Time : Wed Aug 3 13:10:33 2005
Mod. Time : Fri Oct 7 10:39:27 2005
Object Type : ENTRY
Entry data of type passwd_tbl
[0] - [8 bytes] 'username'
[1] - [14 bytes] Encrypted data
[2] - [11 bytes] 'XXXXXXXXX'
[3] - [3 bytes] '10'
[4] - [14 bytes] 'User Name'
[5] - [14 bytes] '/home/username'
[6] - [9 bytes] '/bin/ksh'
[7] - [17 bytes] Encrypted data

$ ypmatch USER passwd

Perl inline edit...

http://www.rice.edu/web/perl-edit.html

autovivification

exists => nasty...

if ( $HASH{'key1'}{'key2'} );

Will define $HASH{'key1'}

If you don't want to do that you need to do:

if ( $HASH{'key1'} && $HASH{'key1'}{'key2'} );