Useful shortcuts for vi editor

Thursday, 11 December 2014

Basic Calculator VBS example

MsgBox("Calculator!")
a=CInt(InputBox("First number:","Enter number"))
b=CInt(InputBox("Second number:","Enter number"))
c=a+b
msgbox(a & "+" & b & " = "&c)

How to run Visual Basic Script file in Windows?

Please follow the instructions:
  1. Run notepad 
  2. Copy below text into notepad
  3. Save as .vbs format
  4. Double click the file
Example VBS file:

Dim objFS, objFolder
Dim strDir
strDir = CStr(InputBox("Create a directory tool:","Input your new directory"))
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.CreateFolder(strDir)
WScript.Echo "I created the folder " & strDir & " using with this powerful tool!"
WScript.Echo "powered by ozsoyler.blogspot.com"
WScript.Quit

Wednesday, 10 December 2014

How to use secure copy in Linux Terminal?

To upload:
$ scp [desired files] [login_user]@[host]:/[remote path]
e.g.
$ scp *.txt alper@10.10.10.10:/home/alper/mynewtextfiles

To download:
$ scp [login_user]@[host]:/[remote path] [local directory] 
e.g.
scp alper@10.10.10.10:/home/alper/mynewtextfiles/* /home/alper2/mydirectory/ 

Tuesday, 9 December 2014

How to know hostname from IP in Terminal?

$ nmblookup -A <IP>
e.g. nmblookup -A 10.10.10.10

e.g. nmblookup -A $(who | awk -F\( '{ print $2}' |  rev | cut -c 2- | rev )

Monday, 8 December 2014

Alexa Rank

Global rank: 6,859,462

How to know system hardware and software information?

to get os version:
cat /etc/*release*

to get os kernel version:
cat /proc/version

to get cpu info:
# cat /proc/cpuinfo
or
# lscpu

to get ram info:
# cat /proc/meminfo

Wednesday, 3 December 2014

How to find full path of a program in Windows?

CMD> where ping
C:\Windows\System32\PING.EXE
CMD> where sqlplus
D:\instantclient_11_2\sqlplus.exe

Tuesday, 2 December 2014

What are taskmgr.exe keyboard shortcuts?

1st way: CTRL + ALT + DEL
2nd way: CTRL + SHIFT + ESC

Friday, 28 November 2014

What is Sticky Bit?

If sticky bit is active, that file can be only deleted by root or owner.

to activate;
chmod +t file.txt
-rw-r--r-T
to unactivate;
chmod -t file.txt
-rw-r--r--

You may also want to read this entry;
http://ozsoyler.blogspot.com/2015/01/what-is-suid-and-guid.html

Saturday, 22 November 2014

Useful shortcuts for vi editor

  • vi myfile.txt
    to open file with vi editor
  • vi + myfile.txt
    cursor goes to end of the file
  • vi +200 myfile.txt
    cursor goes to 200th row
  • :set list
    :set nolist

    see hidden characters or not
  • :set number
    :set nonumber
    see number of lines or not
  • :set paste
    activate paste option before get into insert mode (to resolve the commented lines problem)
  • :set nopaste
    deactivate paste option before get into insert mode
  • :[line_number]
    cursor goes to desired line
  • l, k, h, j
    cursor goes to right, up, left, down
  • w
    cursor goes to next word
  • b
    cursor goes to start of the current word
  • gg
    go top
  • shift + g
    go bottom
  • dd
    remove row
  • p
    paste the clipboard data
  • x
    remove one char
  • yy
    copy the row
  • u
    undo last operation
  • o
    add new row
  • :%d
    delete all lines
  • /hello
    find "hello" word
    n
    go to next searched word
    N
    go to previous searched word

How to unlock database user account?

Please run the sql lines in SQL Editor as "sys" user;

SQL> ALTER USER "alper" ACCOUNT UNLOCK;

Wednesday, 19 November 2014

What are RAID levels 0/1/5/10?

Level Minimum Disk Req. Performance Redundancy Suggestions
0 2 Excellent None Not recommended for critical systems
1 2 Good Excellent
5 3 Good Good Best cost effective option providing both performance and redundancy. Use this for DB that is heavily read oriented. Write operations will be slow.
10 4 Excellent Excellent If you can afford the dollar, this is the BEST option for any mission critical applications (especially databases).
Ref: http://www.thegeekstuff.com/2010/08/raid-levels-tutorial/

Friday, 14 November 2014

What is Oracle doing when you run commit?

The basic flow like that;
  1. Oracle writes that "Commit has been executed" in related table from UNDO tablespace. 
  2. SGA buffer cache - calling LGWR (Log Writer)
  3. LGWR writes changed data (delta) to REDO log files
  4. Tables' locks are released and marked as "TRANSACTION is completed" by Oracle

Wednesday, 12 November 2014

How to use Intersect function?

For instance, you want to see same jobs for employees that belong to different manager in employees table.

Please run the sql lines in SQL Editor as "hr" user;

SELECT job_id FROM employees
WHERE manager_id = 121
INTERSECT
SELECT job_id FROM employees
WHERE manager_id  = 122;

Used Database User: HR

Wednesday, 5 November 2014

Linux date function examples

e.g.
date -d now
date -d today
date -d yesterday
date -d mon
date -d tue
date -d wed
date -d thu
date -d fri
date -d sat
date -d sun
date --date="1 day ago"
date --date="1 week ago"
date --date="1 month ago"
date --date="1 year ago"
date -d "+10 days"
date -d "+10 weeks"
date -d "+10 months"
date -d "+10 years"

[CONCAT] How to merge two strings as a single string?

Please run the sql lines in SQL Editor as "hr" user;

e.g.
select CONCAT('Bilgi havuzu ','at ozsoyler.blogspot.com') from dual;
result
Bilgi havuzu at ozsoyler.blogspot.com

Used database user: hr
Used database server: oracle xe

Monday, 3 November 2014

[INITCAP] How to make uppercase the first character of each word in a string?

Please run the sql lines in SQL Editor as "hr" user;

e.g.
select INITCAP('ozsoyler.blogspot.com') from dual;
result
ozsoyler.Blogspot.Com

Used database user: hr
Used database server: oracle xe

Tuesday, 28 October 2014

[ADVICE] Free Windows Disk Defragmenter Alternative

I strongly recommend to use Smart Defrag tool instead of classical Windows Defragmenter tool.

Sunday, 26 October 2014

How to check NTFS file system in CMD?

Only you need to run this command.

e.g. chkntfs C:

C:\Windows\system32>chkntfs C:
The type of the file system is NTFS.
C: is not dirty.

How to defrag disk partiton in CMD?

Only you need to run this command as Administrator.

e.g. defrag C: