Thursday, April 26, 2007

while loop on unix shell command line

Would like to repeat the ls -l command on unix command line every 30 seconds?
$ while true; do ls -l; sleep 30; done;

Wednesday, April 25, 2007

How to turn on QuickEdit Mode for cygwin

Want to get right button copy and left button drag select works in cywin?
Here are the steps:
Right click on the icon in the upper left of the title bar
and select properties Under Options, select 'QuickEdit Mode',
hit ok Select 'Modify shortcut that started this window'

Tuesday, April 24, 2007

How to select a element without specific attribute?

I ran into this simple question in one of my task:
Here is how you select an element without a specific attribute:
B[@C=''] selects B that has no C attribute or has attribute
with empty value.

B[not(@C)] seelcts b that don't have a C attribute

B[not(@*)] selects B that have no attribute.
Please refer to here.

Tuesday, April 17, 2007

How to check the Solaris last boot time?

$ who -b
or
$ uptime

Please refer to here.

Wednesday, April 11, 2007

vi replace with confirmation and replace with regex group

Search from every line, replace confirmation (with [y]es)
:%s/search_string/replace_string/gc

Replace with regex group:
:%s/<img alt="\(.\+\)"\ssrc=.\+/\1/gc

Vi simple tutorial

Some examples:
You have [admin, admin1, user3], and you would like to change it to ['admin','admin1','user3']; here your are:%s\(\w\+\)/'\1'/gc

Monday, April 09, 2007

IntelliJ supports UTF-8?

One of my colleague complained that the IntelliJ does not support UTF-8 correctly:
  1. System.out.println("Dealer Caterpillar ciężkiego używanego wyposażenia i używanych części"); when you run it, the special character corrupted.
  2. After you safe the java file, restart the Intellij, the special character corrupted.
Here is my trick: In Intellij Settings->General->Default encoding, choose UTF-8 and restart, the java file will be stored in UTF-8 encoding.

Thursday, April 05, 2007

Gvim: encoding puzzles.

You can reload a file using a different encoding if vim wasn't able to detect the correct encoding:
:e ++enc=<encoding>
for example:
:e ++enc=utf-8

Choose a font type like Courier New.

You can achieve both of these by adding the following lines in your gvim startup configuration file .vimrc:

set enc=utf-8
set guifont=Courier_New:h11:cDEFAULT

How to comment multiple lines in vim?

Place cursor at the beginning of the first line you want to change.
Press Ctrl+v
Move the cursor down to the last line you want to change.
Press I (The capital letter after H and before J)
Type in the text you wish to insert
Press Esc

Now all lines selected should show the inserted text.

Want to insert new line in file?
try \r, like:
%s/,/,\r/gc

WireShark to capture loopback traffic

Please refer to this link.

How to add newline (line feed) in XSLT result xml file

Please try to add:
<xsl:text>&#xa;</xsl:text>

Tuesday, April 03, 2007

Disabling Windows' native Zip folder support

To prevent Windows XP from treating compressed Zip files as a folder, go to "Start > Run" and type the following:
regsvr32 /u zipfldr
If you wish to restore native Zip support in Windows, just go back to "Start > Run" and type the following:
regsvr32 zipfldr

Thanks to this blog entry.

IDEA does not follow the Goto Implementation for EJB?

Check whether your module is correcly configured as an EJB module.
Project Structure->Modules->XXXEJB module->Ejb Module Settings
check whether your EJB module deployment descriptor setting exists or not, if not, then Add it.

Monday, April 02, 2007

Using FireFox Web Developer Extention to create or overwrite a cookie

Recently we need to test our application behavior with different cookie values, but the cookie is not create by our site, it is create by a third party website. The problem is how can I manipulate the cookie content easily to test our application behavior?

I found that the Web Developer extension of FireFox is perfect for this task, you can create/overwrite the cookie as you want:
Just go directly to Cookie->Add Cookie