Thursday, August 16, 2007

bash shortcuts

Here is a list of bash shortcuts, credit to this blog.
alt-f -- move forward one word
alt-b -- move backwards one word
ctrl-a -- takes you to the begining of the command you are currently typing.
ctrl-b -- move backwards one character
ctrl-c -- kills the current command or process.
ctrl-d -- kills the shell.
ctrl-e -- takes you to the end of the command you are currently typing in.
ctrl-f -- move forward one character
ctrl-h -- deletes one letter at a time from the command you are typing in.
ctrl-l -- clear screen
ctrl-r -- does a search in the previously given commands so that you don't have to repeat long command.
ctrl-u -- clears the typing before the hotkey.
ctrl-z -- puts the currently running process in background
esc-b -- takes you back by one word while typing a command.
esc-p -- like ctrl-r lets you search through the previously given commands.
esc-. -- gives the last command you typed.

Another good reference.
Here "2T" means Press TAB twice

$ 2T - All available commands(common)
$ (string)2T - All available commands starting with (string)
$ /2T - Entire directory structure including Hidden one
$ 2T - Only Sub Dirs inside including Hidden one
$ *2T - Only Sub Dirs inside without Hidden one
$ ~2T - All Present Users on system from "/etc/passwd"
$ $2T - All Sys variables
$ @2T - Entries from "/etc/hosts"
$ =2T - Output like ls or dir

Wednesday, July 18, 2007

Regex back references

When use Intellij to search/replace by using Regex, you need to notice that the back reference is $n rather than \n.
Refer to Intellij Help on search/repalce.
Refer to here.

Replace File Explorer with XPlorer 2

Need a tabbed file explorer?
Try Xplorer 2 out.
Please refer to here.
Aslo: need tabbed console? here you are.

Tuesday, June 19, 2007

This attribute does not support request time values when using JSTL

When I tried to upgrade our jstl library from 1.0 to 1.1, I got the following error:
This attribute does not support request time values
The solution is

  • include JSTL 1.1 by changing the taglib-URIs in include.jsp from
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" >
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt">
    to
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core">
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt">

Does JSTL forEach apply to array?

The answer is yes. Please see here.

Tuesday, May 08, 2007

Turn on Olite SQL Trace

Want to tune your sql on Olite database? You can put the following parameter in your polite.ini file, [All databases] segment:
OLITE_SQL_TRACE = TRUE

You should see a trace file: oldb_trc.txt in your mobile client bin directory, if you are using msql to run your sql script on the Olite DB.

Monday, May 07, 2007

Oracle change xmltype column lob tablespace

One friend asked me this question today: How do you chnage xmltype column lob tablespace?

  1. xmltype is an object type, it contains XMLDATA which is a CLOB object, you can treat "column.XMLDATA" as a clob object. please refer to here.
  2. How to move a lob from one tablespace to another? The answer is to use 'alter table move lob(...) ...'; please refer to here.
To put everything together, here is how you can setup and test it:
  1. Create a test table with xmltype column:
    • CREATE TABLE xwarehouses (
      warehouse_id NUMBER,
      warehouse_spec XMLTYPE)
      XMLTYPE warehouse_spec STORE AS CLOB
      (TABLESPACE catusedt
      STORAGE (INITIAL 6144 NEXT 6144)
      CHUNK 4000
      NOCACHE LOGGING);
  2. Alter the table to change the LOB tablespace:
    • alter table xwarehouses
      move LOB(warehouse_spec.XMLDATA)
      STORE AS xwarehouses_seg
      (TABLESPACE catusedpht
      STORAGE (INITIAL 6144 NEXT 6144)
      CHUNK 4000
      NOCACHE LOGGING);

Friday, May 04, 2007

Error queue - records with "Client was out of sync" message

We are seeing Client was out of sync in our Oracle Lite Server Error Queue, my colleague found this post, which helps us understand how to fix this kind of problem. Here are my notes regarding to it:
  1. Login to Mobile Manager; goto Error Queue; select the Transaction ID you are interested in; Publication Items.
  2. Select the Publication Item you are interested in; View records; The DML Operation most likely will show 'Error'; Check th rows you would like to change the Update DML ; Select the desired 'Update DML' from the top left drop down(to choose between insert and update, depends whether that row exists in your application database), then Click Go; You should see the DML Operation changed to the desired one, rather than Error.
  3. Click 'Apply'; You should see Confirmation: Changes were applied successfully.
  4. Repeat step 2 and 3 for all the publication items in that transaction.
  5. Back to Error Queue, select the Transaction you worked on, click Execute.
  6. Go back to Mobile Manager home page you should see your transaction in the In Queue(1).
  7. Refresh the page to see the MGP active, then return to Idle, make sure your Transaction does not reenter to the Error Queue.

Wednesday, May 02, 2007

Using keepalives to prevent disconnection after idle for some time

Connection to some remote Unix server get disconnected too often? Try to set the PUTTY sending null packet in the Connection configuration Category

Please refer to here.

Set the JVM platform default character encoding to UTF-8

You could set the JVM platform defalult character encoding to UTF-8 by using the following JVM option:
-Dfile.encoding=UTF-8

Make sure this flag come before your Main program name, especially when you are calling org.apache.tools.ant.Main.

Please refer here.

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.

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

Tuesday, March 27, 2007

Setup svnserve for personal usage

It is handy to have your own SVN server for you own small projects.
Here are the steps I used to setup a SVN server on Windows XP:
1. Download the Subversion binary for Windows from here, and unzip it to your local drive. Note: I was using 1.4.3
2. Create your own repository like: svnadmin create /svn-win32-1.4.3/repos/dliurepo
3. Setup the svnserve as Windows service: X:\svn-win32-1.4.3\bin>sc create svnserve binpath= "c:\dev\svn-win32-1.4.3\bin\svnserve.exe --service -r X:\svn-win32-1.
4.3\repos\dliurepo" displayname= "svn server"
4. Edit the svnserve.conf in your repository conf directory add the following texts:
[general]
password-db = userfile
anon-access = read
auth-access = write
realm = test svn realm
5. Create a new file named userfile in the same directory where svnserve.conf locates with the following content:
[users]
user1=password1

Further references:
Setup svnserve as windows service.
Version Control with Subversion.

Notes: sc command's option name includes the equal sign. Do NOT forget to put space after the option name '='.

Dump the SVN repository:
svnadmin dump <repository> > dumpfilename

Load dump into SVN repository:
svnadmin load <repository> < dumpfilename

Setup home Subversion Server with Apache.
Subversion and Apache
Having any Subversion Problem or Question? Search SVNForum

Wednesday, March 21, 2007

Copy, paste, and cut text block in VI

Copy block in vi:
Mark Beginning of Block : mx set mark x (x may be any letter)
Mark End of Block and "Copy'' : y`x yank from here to mark x into buffer
Mark End of Block and "Cut'' : d`x delete from here to mark x into bufferFor the whole file try:

Goto to line one: 1G
Sort from current line to end of file: !Gsort<cr>
Or if you want to think of it as one command: 1G!Gsort<cr>

Sort a range:
Move Cursor to last line to sort
mark the line with mark 'a': ma
move cursor to first line to sort
sort from current line to mark 'a': !'asort<cr>

Now what does the special chars above mean.

'!' is the vi filter command, it is followed by a movement command
that says what is being filtered. That is followed by the actual
filter cmd. The filter cmd can be any executable. In this case sort.
Since vi does not know how long the filter command name is, you have
to hit carriage return to initiate the filter.

G by itself means go to the end of the file

ma means set mark a to this line. (marks a-z exist)

'a means goto mark a.

XMLSPY 4.4U external XSL transformer

Add SAXONb89n as external XSL transformer for XML Spy
Toos->Options->XSL->External XSL transformation program: C:\LearningZone\SAXON\SAXONb89n\bin\transform.exe -o %2 -s %1 %3

Add SAXONb89j as external XSL transformer for XML Spy
Toos->Options->XSL->External XSL transformation program:

X:\tools\java\j2sdk1.5.0_06-win32\bin\java -jar C:\LearningZone\SAXON\saxon8.jar -o %2 -s %1 %3

To use saxon 6.5.3:
X:\tools\java\j2sdk1.5.0_06-win32\bin\java -jar C:\LearningZone\SAXON\saxonDTS.jar -o %2 %1 %3

Monday, March 12, 2007

Have trouble to start Oracle Server Console?

After dormant long time, now I start to pick up the Oracle Lite installed on top of OAS. All of sudden the Oracle Application Console will not start. Here are the steps I used to diagnose the problem:

Where is the log file?
/export/home/catused/oracle/ora_j2ee/sysman/log/emiasconsole.nohup

How to start Oracle Server Console?
/export/home/catused/oracle/ora_j2ee/bin/emctl start iasconsole

Control the behaviour of Servlet Filter Chain

One of my colleague is upgrading the java application server to JBoss 4.05, he ran into the problem that the secured resources protected by declarative security defined in web.xml, but it does not forward to the login form defined filter. Finally, I help him find out the reseaon, there is ways to control the filter chain behaviour in Servlet 2.4:
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>

Please refer to here.

Friday, March 09, 2007

How to exclude the name space from xslt result?

One of my colleague asked me how to avoid the result xml file include the annoying name space from the elements when you are using xsl:copy.
Here is the solution:
add exclude-result-prefixes="saxon v00" into your xsl:stylesheet element in your xsl file.

omit-xml-declaration specifies whether the XSLT processor should output an XML declaration; the value must be yes or no. Please refer to here.

Tuesday, February 27, 2007

GVim: changing DOS style end of line to UNIX, or vise-versa

How to use GVim to change DOS style end of line to UNIX, or vise-versa?
To save the file in DOS style:
:set fileformat=dos
:w
To save the file in UNIX style:
:set fileformat=unix
:w
Please refer to here.

Turn off variable substitution in SQL*Plus

I got a phone call from one of my friends in Montreal ask me how to turn off the variable substitution in SQL*Plus, here is how it should be done:
SET DEFINE OFF
* You can prevent variable substigution of ampersand character(&) in SQL script, when running it in SQL*Plus.

Monday, February 26, 2007

Find the list of SAP Transaction codes

There are three ways to find out the list of SAP transaction codes:
  1. SE11; TSTC table or TSTCT table.
  2. SM01
  3. SE93
Please refer to here.

Friday, February 23, 2007

How to change SAP default client

To change default client for SAP system, I found the following way:
In file explorer: open the instance profile, for example: D:\usr\sap\C11\SYS\profile\C11_DVEBMGS00_win2k3
add login/system_client=800.
Stop and restart the SAP system.

NOTE: directly edit the file is not sugguested by SAP, the correct way to change a parameter is to use Tools->CCMS ->Configuration->Profile Maintenance.
  1. RZ10
  2. Import the profiles; Utilities->Import profiles->Of active servers
  3. Extended maintenance the profile; Change
  4. Create new parameter or edit existing parameter
  5. Save, activate, and restart the server.
References:
Some SAP parameters.
How to change SAP default client?

Thursday, February 22, 2007

Oracle CharacterSet

1. What is impact of NLS_LANG variable setting of user session while import/export the data ?

On export, the data will be converted from the database character set to the character set specified by NLS_LANG. In import, the database will assume that the data is in the character set specified by NLS_LANG and use that value to perform the conversion to the database character set if the two values to not match.

2. Why do we need to set this NLS_LANG user session variable before export/import ?

If your database character set is the same as your OS, you don't necessarily have to set NLS_LANG. For instance, if you have a US7ASCII db, and your OS locale is set to AMERICA_AMERICAN.US7ASCII, there won't be any problems. The only time it's really important to set this is when the db and OS settings don't match.

3.If NLS_LANG variable is not set (doesnot have any value) what would happen ?

If your database character set doesn't match your OS, the data could be garbled because the db will incorrectly transcode the data on import/export.

4. If I have to set NLS_LANG varible, what should I set it to?

Depends on what your database character set is set to (see below).

5. How can I see the characterset of my database?

select * from nls_database_parameters and look for the value set for the NLS_CHARACTERSET parameter. Don't get confused by the NLS_NCHAR_CHARACTERSET, that's for NCHAR datatypes.

So, for instance, if your NLS_CHARACTERSET value is set to UTF8, you would set NLS_LANG to .UTF8 (the dot is important because that's actually shorthand for territory_language.characterset, or language_territory.characterset, I can never remember which comes first. In any case, use the dot). For example:

setenv NLS_LANG .UTF8


6. Where can I get more info about database charaterset and What are the valid values for database characterset and NLS_LANG varibale ?

It's all in the Oracle documentation.

Monday, February 19, 2007

Copy table structure and content (data)

I just started to read the book 'Sams Teach Yourself ABAP/4® in 21 Days', the first problem I ran into is how to copy table structure and content(data) from a standard table to a z_table. I found partial of the answer here:
How can I copy a standard table to make my own z_table. Go to transaction SE11. Then there is one option to copy table. Press that button. Enter the name of the standard table and in the Target table enter Z table name and press enter.
However, that is only partial answer to the question, it only copied the table structure, but without the content-data of the table, to copy the content(data), you may need to write small ABAP program to achieve the goal:

Example:
REPORT Z_COPYTABLEDATA .
tables lfa1.
select * from lfa1.
insert ztxlfa1 from lfa1.
endselect.
write 'data copied.'.

Friday, February 09, 2007

.Net form ComboBox SelectedIndex = -1 seems does not work.

I ran into a problem in programming ComboBox on .Net Windows Form, we were clearing the ComboBox and then set the ComboBox.SelectedIndex = -1, which supposed to deselect the SelectedItem. However, the ComboBox still showing the old SelectedItem.

I found a workaround, first set the ComboBox.SelectedIndex = -1 before you call ComboBox.Items.Clear()

Wednesday, January 24, 2007

Shrinking Oracle table sizes

This morning I ran into this great post, when I was wandering on the internet.
It points out that Oracle does not free storage space with the delete statement. You can use alter table ... move defragments and rebuild the indexes.

How do I enable autotrace for oracle

If you run into the following error messages when you try to set autotrace on in sqlplus for oracle, you may need to enable autotrace for oracle and grant plustrace role to the user you are using.
SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report

  1. Run plustrce.sql in SYS schema if it did not run before, $ORACLE_HOME\sqlplus\admin\plustrce.sql
  2. Grant plustrace role to
Please refer to here.

Oracle v$session_longops view

During one meeting, one of my colleagues mentioned Oracle's v$session_longops view.
"This view displays the status of various operations that run for longer than 6 seconds (in absolute time). These operations currently include many backup and recovery functions, statistics gathering, and query execution, and more operations are added for every Oracle release."
Further reference is here and here.

Wednesday, January 17, 2007

How to decide whether any of the two strings is null in Oracle?

I ran into a problem in my project, I have to decide whether there is a string in a list of strings is null or not. The problem is we have two columns from the Oracle DB: first_name, last_name, both of them could be null, we need to format the fullname like "last_name, first_name", but we do not to have the ',' if either last_name or first_name is null. Here comes my solution:
select last_name || nvl2(length(last_name) * length(first_name), ',', null) || first_name from contact_info;

The terminal server has exceeded the maximum number of allowed connections?!

From time to time, I ran into the following warning(errors) when I tried to remote desktop to one of our development box. Here is something I found to figure out who has left his connected connections on the desktop, maybe you can boot them out, if you have permission:
1. mstsc /v:00.00.00.00 /console
Replace 00.00.00.00 with your server's IP Address.
2. Start Terminal Services Manger (Administrative Tools -> Terminal Services Manager, or tsadmin.exe).

Here are some details.

Thursday, January 11, 2007

Having trouble to install Oracle Lite Win32?!

Senario1: For some unknown reason, I screwed up my local installation of the Oracle Lite Win32 client.
Every time when I try to install Oracle Lite Win32 client on my desktop, the setup program always stops at "Stopping clients", finally I found out a workaround for it:
Just remove or rename the c:\windows\odbc.ini and c:\windows\polite.ini file, give the installation a retry.
Now you should have a smoother ride ;-)
Senario2: If your Oracle Lite WIN32 uninstallation program halt on "Loading 'Oracle Lite WIN32'", then you could try to kill the Oracle Lite Device Manger process (dmagent), retry the uninstallation process. You can use command line: taskkill /F /T /IM dmagent.exe

Full Guide for using Bitnami Prometheus Operator Helm Chart with Additional Scrape Configuration

"The Prometheus Operator for Kubernetes provides easy monitoring definitions for Kubernetes services and deployment and management of...