Wednesday, September 2, 2015

PL SQL Gems

I will start posting some interesting snippets for PL SQL similar to UNIX GEMS that can be used as a quick reference.
 

Tuesday, September 1, 2015

Google's New Logo


The world's favourite search engine Google has new logo from today. The same has been doodled on its home page as well. 

Monday, June 15, 2015

Visiting Jurassic World!

Will be watching the much awaited movie tomorrow, getting the same feeling that I got as a kid before the show for the original Jurassic Park..


Sunday, May 17, 2015

UNIX Gem 3: How to display, segreggate file types:


We have several types of files in a directory (txt,pdf,.pl,.c etc) and we want UNIX to seggregate the file based on their types. How can we achieve this. UNIX has a command file. If we want to display the file type for txt file, just type in
>file filename.txt
If we want to display types for entire files:
file *
If we want to display set of files:
file file1 file 2 file 3
sample output:
file *
sound:                   directory
speech-dispatcher:       directory
ssh:                     directory
ssl:                     directory
sudoers:                 regular file, no read permission
sudoers.d:               directory
sysctl.conf:             ASCII English text
sysctl.d:                directory
systemd:                 directory
terminfo:                directory
thunderbird:             directory
timezone:                ASCII text
ts.conf:                 ASCII text
ucf.conf:                ASCII English text
udev:                    directory
ufw:                     directory
updatedb.conf:           ASCII text
update-manager:          directory

Sunday, May 10, 2015

Unix gem: Truncating file

We know how to truncate a table in SQL,i.e. retain the structure of the table removing the contents of the table.
In UNIX ,lets say we want to remove the contents of the file and retain the empty file (zerobyte file). How can we achieve this.

➡ One way is to delete the file completely and recreate it.

➡The second method is to open the file using an editor such as vi and delete each line and save.

But what if we want to truncate the file on the fly?

Consider the problem statement:

Check if the file called dataflow has been sent by upstream and count the number of records. If records exceed threshold (value of 10,000) truncate the file and FTP it to the remote server indicating threhold breach-incorrect records. Else FTP the file as it is.

UNIX has a command for this:

We can use
cat >dev >null dataflow

This would make the file zero byte

A simple hueristic for the above problem will be

If exists file then
If
wc -l dataflow gt threshold
cat >dev >null dataflow
Ftp servername (pick credentials from .netrc)
Put dataflow
Bye
Else
Ftp file intact.

Unix Gems

In the next posts time and time I will brush up some important Unix related stuff that can be used as a quick reference. These are some important commands,info that are dug from the grounds of Unix. And hence gems

Saturday, May 9, 2015

20 reasons as How I wonder Why Jurassic movie again

Coming to the next ten reasons
11. Jurassic World is said to be homage to Jurassic Park. This sounds optimistic.
12. Jurassic World would bring back old memories and nostalgic values..wish we were kids again.
13.The featurette had Spielberg himself praising the movie..
14. It would be refreshing to see 'Jurassic' dinos again on the screen.
15.It might ignite Jurassic Franchise again....
16.T rex is back from the original?
17.Chaos theory returns...
18. Waiting to see real dinosaurs in fully functional theme park..
19.Good to have a blast from the past..
20.Lets see what latest technology is to offer through the film.
I am looking forward to review every aspect of the movie once it hits the screen as it is being decreed as the most awaited movie of 2015.