Sunday, December 27, 2009

symbolic links in windows

junction - sysinternal tool for winxp and above

mlink - with vista and above

Saturday, November 7, 2009

Find lines of code in your repository


for ext in "*.java" "*.xml" "*.css" "*.jsp" "*.js" "*.sql"
do
echo -n "$ext,$location,"
find ./$location -iname "$ext" -exec wc -l '{}' \;|gawk '{total+=$1} END{print total}'
done

Thursday, July 2, 2009

Getting tablespace Size


SELECT tablespace_name,
  SUM (bytes) / 1024 / 1024 current_size,
  autoextensible,
  SUM (maxbytes) / 1024 / 1024 max_size
FROM dba_data_files
WHERE tablespace_name like '%'
GROUP BY tablespace_name, autoextensible
ORDER BY 1

Sunday, May 10, 2009

bash : search and replace from previous command

tar -cvf sandeep.tar sandeep/

!!:gs/sandeep/singhal will mean

tar -cvf singhal.tar singhal/

:gs is for global search and replace

bash - last argument of the previous command (nth argument)

  • Get the last argument of the previous command : !!$
  • Get the first argumnet of the previous command : !!^
  • Get the 1st argument of the previous command : !!1
  • Get the nth argument of the previous command : !!n

Examples : 

$> ls :!!$  (or !$) 

$> ls :!!^

$> ls :!!2

$> ls :!!n

Saturday, May 2, 2009

Trigger GC in eclipse.

This is a handy for eclipse which lets you to trigger gc in the eclipse instead of waiting for the jvm to schedule the GC .

Go to Window->Preferences->General, mark Show Heap status check box.
The current Heap usage with icon for "Run Garbage Collector" will appear at the bottom right.

It helps a lot in eclipse performance.

I find it pretty handy especially because I do not shutdown eclipse often.

Friday, May 1, 2009

Two things I love about opera

1. You can type windows specific path on the browser bar and it will covert it to "forward slashes" when you are browsing directory like strucure on a browser

2. The quick search box : The cursor remains at the same place if you go to a different window by "ALT-TAB". This in firefox changes to select the entire text already typed in the search box. Hence you cannot start typing straight away, since that will erase the already entered text. 

Sunday, April 26, 2009

Common sqlplus commands

ACCEPT - Get input from the user 
DEFINE - Declare a variable (short: DEF) 
DESCRIBE - Lists the attributes of tables and other objects (short: DESC) 
EDIT - Places you in an editor so you can edit a SQL command (short: ED) 
EXIT or QUIT - Disconnect from the database and terminate SQL*Plus 
GET - Retrieves a SQL file and places it into the SQL buffer 
HOST - Issue an operating system command (short: !) 
LIST - Displays the last command executed/ command in the SQL buffer (short: L) 
PROMPT - Display a text string on the screen. Eg prompt Hello World!!! 
RUN - List and Run the command stored in the SQL buffer (short: /) 
SAVE - Saves command in the SQL buffer to a file. Eg "save x" will create a script file called x.sql 
SET - Modify the SQL*Plus environment eg. SET PAGESIZE 23 
SHOW - Show environment settings (short: SHO). Eg SHOW ALL, SHO PAGESIZE etc. 
SPOOL - Send output to a file. Eg "spool x" will save STDOUT to a file called x.lst 
START - Run a SQL script file (short: @)

source :

http://www.orafaq.com/wiki/SQL*Plus_FAQ

Monday, April 20, 2009

Oracle - Default Location for data files

To get the existing location

sql > show parameter db_create;

To set a new location

sql> alter system set db_create_file_dest='/home/ssinghal/oradata';

Wednesday, April 8, 2009

Vim - Reduce Backslashing



Appending a "\v" reduces the amount of backslashing the search expressions.

/codes\(\n\|\s\)*where : normal regexp
/\vcodes(\n|\s)*where : very magic


source :
http://vim.wikia.com/wiki/Best_Vim_Tips

Tuesday, April 7, 2009

Vim - Open Current File in Explorer or Command Prompt

Put the following two lines in your vimrc files under window to get F11 and F12 to work as "command prompt here" and "explorer here" !


map :silent !start cmd.exe /k pushd %:p:h
map :silent !start explorer.exe %:p:h


source for tip1

"http://vim.wikia.com/wiki/Open_the_folder_containing_the_currently_open_file"

source for tip2

A variant of tip 1 using windows trick of adding a registry for folders to open a command prompt 

Note : % represents the file open in current buffer

Monday, April 6, 2009

Oracle dba_jobs : Breaking

exec dbms_job.broken(690,true);

where 690 is the job number obtained from
select * from dba_jobs

Oracle databases - startup and shutdown

Shutdown:

$ export ORACLE_SID=db_sid
$ sqlplus /nolog
sql> connect / as sysdba
sql> shutdown immediate

Startup :

$ export ORACLE_SID=db_sid
$ sqlplus /nolog
sql> connect / as sysdba
sql> startup mount
sql> alter database open;

Note: This needs to be done by logging on the machine where oracle database is installed

Tuesday, February 24, 2009

marks in vim - bookmarks

- Go to a line where you want a mark and press mx - this will create a bookmark

( x can be any alphabet from a-z)

- Now navigate away from that place. If you need to get back to the earlier cursor location press "`x" (back-tick and x)

- You can set multiple "marks" in a single file and navigate using back-tick and the alphabet used to create a mark

Monday, February 16, 2009

Cron entry for other users

Execute the following as root :

cat /var/spool/cron/ssinghal

where ssinghal is the user name

Friday, February 6, 2009

Sed - Deleting lines matching a pattern

sed -i '/.*log$/d' file_names.txt

Deletes all the lines ending with "log" from the file "file_names.txt"

Tuesday, January 27, 2009

marks in vim - bookmarks

Go to a line where you want a mark and press mx - this will create a bookmark

( x can be any alphabet from a-z)

- Now navigate away from that place. If you need to get back to the earlier cursor location press "`x" (back-tick and x)

- You can set multiple "marks" in a single file and navigate using back-tick and the alphabet used to create a mark

Monday, January 26, 2009

sed : inplace replacement

It is easy to open a file in vim and do a search replace - but if the file runs into huge sizes, a regular editor would not be able to perform search and replace tasks on it efficiently. For these situation, you need a "stream" editor. Here is an example for replacing "foo" with "bar" in a file called snafu.txt


sed -i -e 's/foo/bar/g' snafu.txt


Where:

-i : Is for inplace replacement

-e: sed script to be run on the file

samba mount

Using samba to mount a windows shared folder

mount -t cifs -o username=Home\\sandeep //192.168.0.1/Shared/ /media/Shared

Where /media/Shared is the target folder where the network folder will be mounted.

Sunday, January 25, 2009

Executing a command remotely using ssh

Following command will run a shell script on a remote machine

ssh ssinghal@192.168.0.1 /tomcat/jakarta/bin/kill.sh