Friday, July 13, 2007

SQL Reference

Import a sql file
==================
source ~/dump.sql


SQL Commands -
==================
ALTER TABLE PRODUCT CHANGE PRODUCT_NAME PRODUCT_NAME VARCHAR(255);

Give all rights
==================
CREATE USER 'dbAdmin'@'%' IDENTIFIED BY 'some pass';
GRANT ALL PRIVILEGES ON *.* TO 'dbAdmin'@'localhost' IDENTIFIED BY 'newpasswd' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'dbAdmin'@'%' IDENTIFIED BY 'newpasswd' WITH GRANT OPTION;

SQL Reference -
==================
http://www.1keydata.com/sql/sql.html
http://www.w3schools.com/sql/default.asp

SVN Commands

svn up -r1123
svn info
svn cleanup
svn commit
svn revert
svn copy -q -m "Created branch for Some New Integration" https://xyz.com/svn/project/trunk https://xyz.com/svn/project/branches/integration


SVN

Remove all .svn folders from the directory and all its sub-directories
==================
for dirname in `find . -name ".svn"`; do rm -Rf $dirname; done

F:\Program Files\Apache\Apache2\bin>htpasswd -m D:\svn\etc\svn-auth-file username


DAV svn
SVNPath d:/svn/tswb

AuthzSVNAccessFile d:/svn/tswb/conf/authz

AuthType Basic
AuthName "Subversion TSWB Repository"
AuthUserFile d:/svn/etc/svn-auth-file

Require valid-user

vi Reference Sheet

Visual Display Editor(vi) Command Reference Sheet

Starting vi
Command Meaning
vi filename Open or create a file
vi Open a new file to be named later
vi –r filename Recover a crashed file
view filename Open a file as read-only

Three Modes of operation in vi
1 Command mode: Allows positioning and editing commands to perform functions. Entered via Esc, from entry mode, or Ret from Last-line mode.
2 Entry mode: Allows you to enter text. Entered via typing; A i I o O c C s S or R from command mode.
3 Last-line mode: Initiated from command mode by entering advanced editing commands like :, /, ?, !.

Input Commands Deleting Text
Command Meaning Command Meaning
a Append text after the cursor x or dl Delete character at the cursor
A Append text at the end of the line X or dh Delete character to the left of the cursor
i Insert text before the cursor dw Delete word (or part of word to left of cursor)
I Insert text at the beginning of the line #dw Delete # of words
o Open a new line below the cursor dd Delete line containing the cursor
O Open a new line above the cursor #dd Delete # of lines
Positioning Commands D or d$ Delete line to left of cursor (from cursor position to the end of the line)
Command Meaning dG Delete to the end of the file
h, Left Arrow, or Back Space Move left one character d1G Delete from beginning of file to cursor
j or Down Arrow Move down one line :#1,#2d Delete lines #1 through #2
k or Up Arrow Move up one line Undoing Repeating and Changing Text
l, Right Arrow or Spacebar Move left (forward) one character Command Meaning
0 Move to beginning of current line cw Change word (or part of word) at cursor location to the end of the word
$ Move to end of current line #cw Change # number of words
w Move forward one word (including punctuation) c#b Change backwards # of words
W Move forward one word (past punctuation) cc or S Replace entire current line
b Move back one word (including punctuation) C or c$ Change from cursor to end of line
B Move back one word (past punctuation) c0 Change from cursor to beginning of line
e Move to end of current word s Substitute string for character(s)
E Move to end of word (past punctuation) R Overwrite or replace characters on line
( Move to beginning of sentence r Replace character at cursor with one other character
) Move to end of sentence i (Return) Break line
{ Move to beginning of paragraph J Join current line and line below
} Move to end of paragraph xp Transpose character at cursor and character to the left
]] Move to next section/function ~ Change case of letter at cursor
[[ Move to previous section/function u Undo previous command (only goes back one level.)
% Find matching ( ) or { } U Undo all changes to current line
- Move up to beginning of previous line :u Undo previous last-line command
Return Move down to beginning of next line Copying and Pasting Text
H Move to top of screen Command Meaning
M Move to middle of screen yy or Y Yank a copy of line
L Move to bottom of screen p Put yanked or deleted line below current line
G Go to last line of file P Put yanked or deleted line above current line
#G Go to # line of file :#1,#2 co #3 Copy lines #1 through #2 and put after line #3
:# Go to line # :#1,#2 m #3 Move lines #1 through #2 to line #3
CTRL-f Page forward one screen Saving and Quitting
CTRL-d Scroll down one-half screen Command Meaning
CTRL-b Page back one screen :w Save changes
CTRL-u Scroll up one-half screen :w new_filename Write buffer to new filename
CTRL-E Scroll window down one line :wq or ZZ Save changes and quit vi
CTRL-Y Scroll window up one line :q! Quit without saving changes. ('!' bang forces the system to perform action)

Setting Options Reading Files and Commands
Command Meaning Command Meaning
:set nu Show line numbers :r filename Insert (read) file at line after cursor
:set nonu Hide line numbers : # r filename Insert file after line #
:set ic Searches should ignore case :r !command Insert output from command after current line
:set noic Searches should be case-sensitive :!command Run command from subshell
:set list Display invisible characters such as Tab and end-of-line :sh Create subshell. (Exit returns to vi)
:set nolist Turn off the display of invisile characters Searching and Replacing Text
:set showmode Display current mode of operation Command Meaning
:set noshowmode Turn off mode display /string Search forward for string
:set lisp Inserts indents in appropriate lisp format ?string Search backward for string
:set nolisp Turn off lisp formatting n Find next occurrence of string
:set ai Insert mode will indent each line equal to the line above N Find previous occurrence of string
:set noai Turns off autoindent :%s/old/new/ Search and replace first occurrence of old with new
:set all Displays list of all available options :%s/old/new/g Search and replace all occurrences of old with new

Linux Commands Quick Reference

top - display top CPU processes
tail -f
man
grep
vi
scp

------------------------------------------------------------------------------------------------

SCP - Secure File Transfer between UNIX machines

Scp is a utility which allows files to be copied between machines. Scp is an updated version of an older utility named Rcp. It works the same, except that information (including the password used to log in) is encrypted. Also, if you have set up your .shosts file to allow you to ssh between machines without using a password as described in help on setting up your .shosts file, you will be able to scp files between machines without entering your password.

Usage of the Scp Command

The general form of the command is:

 % scp source-specification destination-specification

where source-specification indicates which file or directory is to be copied, and destination-specification indicates where the copied material is to be placed.

Either the source or the destination may be on the remote machine; i.e., you may copy files or directories into the account on the remote system OR copy them from the account on the remote system into the account you are logged into.

Example:

 % scp myfile xyz@sdcc7:myfile
To copy a directory, use the -r (recursive) option. Example:
 % scp -r mydir xyz@sdcc7:mydir

File Specification Formats

The format for the remote specification (source or destination) is:

 user@machine:filename

where filename is the name (path) of the file or directory relative to the home (login) directory on the remote system.

The format for file specification on the local system is just:

 filename

where fname is the name (path) relative to the current working directory on that system.

How scp is similar to cp

Just like the cp command, scp will overwrite an existing destination file. In addition, if the destination is an existing directory, the copied material will be placed beneath the directory.

Examples of remote file copies

  1. While logged into xyz on sdcc7, copy file "letter" into file "application" in remote account abc on sdcc3:
     % scp letter abc@sdcc3:application
  2. While logged into abc on sdcc3, copy file "foo" from remote account xyz on sdcc7 into filename "bar" in abc:
     % scp xyz@sdcc7:foo bar
  3. While logged into account xyz on sdcc7, copy file "garfield" from subdirectory "comix" into filename "fatcat" in subdirectory "stuff" in remote account abc on sdcc3:
     % scp comix/garfield abc@sdcc3:stuff/fatcat
  4. While logged into account abc on sdcc3, copy file "garfield" from subdirectory "comix" of account xyz on sdcc7 into subdirectory "stuff" with the same name "garfield":
     % scp xyz@sdcc7:comix/garfield stuff
  5. While logged into account abc on sdcc3 , copy subdirectory "Section" into a new subdirectory called "Section" in existing subdirectory "Chapter" in account xyz on sdcc7:
     % scp -r Section xyz@sdcc7:Chapter
  6. From account abc on sdcc3, copy entire account to ir123 on iacs5. This needs to be done from the parent directory of the account to be moved.
     % cd
    % cd ..
    % scp -r abc ir123@iacs5:abc

For more information about the scp (secure copy) command, check the on-line manual page for scp:

 % man scp


Eclipse Shortcuts

  • Alt+Up - Swap the current line with the line above it
  • Alt+Down - Swap the current line with the one below it
  • Ctrl+D - delete the current line
  • Shift+Enter - adds a blank line below the current one
  • Ctrl+Shift+Enter - adds a blank line above the current one

You can find more keyboard shortcuts by going to Window - Preferences - General - Keys

We can see the complete list of shortcuts here - http://eclipse-tools.sourceforge.net/Keyboard_shortcuts_(3.0).pdf