Monday, 4 December 2017

Linux: tmux conf file (~/.tmux.conf)

unbind C-b
set -g prefix C-a
bind C-a send-prefix

# 0 is too far from ` ;)
set -g base-index 1

# Automatically set window title
#set-window-option -g automatic-rename on
#set-option -g set-titles on

#set -g default-terminal screen-256color
#set -g status-keys vi
set -g history-limit 20000

setw -g mode-keys vi
#set-window-option -g mode-keys vi
#setw -g monitor-activity on

bind-key v split-window -h
bind-key s split-window -v

#bind-key J resize-pane -D 5
#bind-key K resize-pane -U 5
#bind-key H resize-pane -L 5
#bind-key L resize-pane -R 5

#bind-key M-j resize-pane -D
#bind-key M-k resize-pane -U
#bind-key M-h resize-pane -L
#bind-key M-l resize-pane -R

# Vim style pane selection
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# Use Alt-vim keys without prefix key to switch panes
bind -n M-h select-pane -L
bind -n M-j select-pane -D
bind -n M-k select-pane -U
bind -n M-l select-pane -R
# Use Alt-vim keys without prefix key to switch panes
bind -n M-h select-pane -L
bind -n M-j select-pane -D
bind -n M-k select-pane -U
bind -n M-l select-pane -R

# Use Alt-arrow keys without prefix key to switch panes
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

# Shift arrow to switch windows
bind -n S-Left  previous-window
bind -n S-Right next-window

# No delay for escape key press
set -sg escape-time 0

# Reload tmux config
bind r source-file ~/.tmux.conf

# THEME
set -g status-bg black
set -g status-fg white
set -g window-status-current-bg white
set -g window-status-current-fg black
set -g window-status-current-attr bold
set -g status-interval 60
set -g status-left-length 30
set -g status-left '#[fg=green](#S) #(whoami)'
set -g status-right '#[fg=yellow]#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=white]%H:%M#[default]'

Tuesday, 20 March 2012

Linux: vi editor settings through ~/.vimrc file

From your linux command prompt, type vi ~/.vimrc
Insert below lines into it.

"set shiftwidth=4 tabstop=4 expandtab softtabstop=4
set sw=4 et sts=4

"set autoindent ignorecase incsearch showmatch smartindent
set ai ic incsearch sm si

"in order to convert W to w while giving :W command to save file
cmap W w
"in order to convert Q to q while giving :Q command to quit from editor
cmap Q q

"some mappings for split window in vi editor
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l

"to display tab characters and trailing spaces by pressing ,s
set listchars=tab:>-,trail:.

" by typing usedd will convert to use Data::Dumper

ab usedd use Data::Dumper;

"mapping for syntax check for current file
map <F4> <esc>:! perl -c %<Enter>
"to run current file using perl
map <F5> <esc>:! perl %<Enter>
 

" to convert splitted window from vertical to horizontal split
map <F6> <esc>:windo wincmd K<Enter>
" to convert splitted window from horizontal to vertical split
map <F7> <esc>:windo wincmd H<Enter>

"to indent selected text by pressing tab key
vmap <tab> >gv
"to un-indent selected text by pressing shift + tab key
vmap <s-tab> <gv

" paste mode - this will avoid unexpected effects when you
" cut or copy some text from one window and paste it in Vim.
set pastetoggle=<F8>

Wednesday, 14 September 2011

Oracle: Get the size of a CLOB column

Assume the table structure is as below:

Table Name: Table_A
Column        Datatype
XMLID           NUMBER
XMLDATA      CLOB

Sample Records/Data:
XMLID   XMLDATA
123        Some text1 stored in CLOB
135        Some text2 stored in CLOB
  

1. If output of size of CLOB column needed in bytes:
SQL>  SELECT XMLID, DBMS_LOB.GETLENGTH(XMLDATA) AS SIZE_IN_BYTES FROM TABLE_A;

Output:
XMLID      SIZE_IN_BYTES
--------      -----------------------
123          25
135          25


2. If output of size of CLOB column needed in kilo bytes (KB) by rounding it off to two decimal places:
SQL>  SELECT XMLID, ROUND(DBMS_LOB.GETLENGTH(XMLDATA) / 1024, 2) AS SIZE_IN_KB FROM TABLE_A;
 
Output:
XMLID      SIZE_IN_KB
--------      --------------------
123          .02
135          .02

Friday, 26 August 2011

Oracle: List all foreign key constraints for a table

In SQL below, replace the <TABLE_NAME> with the table name for which you want to list out all the referential integrity constraints:

 SELECT
    AC.CONSTRAINT_NAME,
    ACC.COLUMN_NAME,
    AR.TABLE_NAME,
    ARC.COLUMN_NAME
FROM ALL_CONSTRAINTS AC,
    ALL_CONSTRAINTS AR,
    ALL_CONS_COLUMNS ACC,
    ALL_CONS_COLUMNS ARC
WHERE AC.CONSTRAINT_TYPE = 'R'
    AND AC.R_OWNER = AR.OWNER
    AND AC.R_CONSTRAINT_NAME = AR.CONSTRAINT_NAME
    AND AC.CONSTRAINT_NAME = ACC.CONSTRAINT_NAME
    AND AC.OWNER = ACC.OWNER
    AND AR.CONSTRAINT_NAME = ARC.CONSTRAINT_NAME
    AND AR.OWNER = ARC.OWNER
    AND AC.TABLE_NAME = UPPER('<TABLE_NAME>');