sabato 10 agosto 2013

Vim : An Indentation Problem

Hi all

Today a little big problem.
Every time that i copy and past every thing on vim session i have an indentation problem, for example :

1) I want copy this :

Pippo
Pluto
Paperino
Topolino

2) After a copy result is this :

Pippo
         Pluto
                Paperino
                         Topolino                 

Solution ?????
A simple "set paste" can resolve this hateful problem.

Stay tuned.


lunedì 24 giugno 2013

Sorting a file with pipe-delimited fields using unix sort

Hi All

Today a simple command to sort a file with pipe-delimited fields.

My file is :

EG|TW|SA|04/05/2009||
EG|NA|EN|02/05/2003||
SS|TW|SA|04/05/2009||
CD|DC|TI|30/12/2004||
ET|EG|TI|02/05/2003||
NI|SS|EN|18/02/2005||
EG|ET|TI|02/05/2003||
IN|ET|TI|21/09/2000||
SS|SS|SA|28/02/2005||
IN|PR|EN|01/11/2003||
PR|TW|SA|04/05/2009||
SS|EN|TN|18/02/2005||
EG|DC|TI|17/09/2010||
EG|EI|SA|04/08/2005||
NA|IN|SA|21/09/2000||

To sort all records by third field.
I can use these simple command :

sort -t"|" -k 3 [file_name]

Where -t is an option where u can explain field separator and with -k you can explain third field.

Stay tuned.





venerdì 21 giugno 2013

Women in computer science

Hi all

Today a beautiful article about women in science :
http://womenrockscience.tumblr.com/post/53348538718/hey-i-saw-a-post-that-was-credited-to-you-and-i-lost
In a field dominated by men there are and there were many women  without which the computer science would not be the same.
Bottom a beautiful picture about :


Here some wikipedia's links about these great science women :

Ada Lovelace
Hedy Lamarr
Grace Hopper

Stay tuned.

lunedì 13 maggio 2013

Hierarchical data in a relational database

Hi All

Today an interesting article about how represents hierarchical data in a relational database.

 http://fungus.teststation.com/~jon/treehandling/TreeHandling.htm

Interesting this concept :




Every node must have a node identify and a "Child of" identify. So the key of every object is formed by two keys :

  • ID_NODE
  • CHILD_OF

For example (represents image above) :

ID_NODE  CHILD_OF
1
1
2
1
3
1
4
2
5
3
6
5


Stay tuned.







giovedì 9 maggio 2013

How To Identify If a Port Is Listening on a Unix Server



Hi all

To see if a port is listening on a Unix Server command is :

           netstat -an | grep port number | grep LISTEN

To see what process is using a port the command is :

           lsof -i tcp:port number

Here a simple perl programm to open a port and check a connection from a client web :


#!/usr/bin/perl -w
        use IO::Socket;
        use Net::hostent;              # for OO version of gethostbyaddr
        $PORT = 8080;

        $server = IO::Socket::INET->new( Proto     => 'tcp',
                                         LocalPort => $PORT,
                                         Listen    => 5,
                                         Reuse     => 1) or die "can't setup server" unless $server;

    printf("\nSERVER Waiting for client connection on port $PORT");

         while ($client = $server->accept()) {

          printf("\nClient Connected\n");

          $client->autoflush(1);
          print $client " Connected You are connected on port $PORT";

          close $client;
        }

Stay tuned


lunedì 29 aprile 2013

How check if a unix script was killed

Hi all

Today a simple mode to check if a process was killed.

It is adding at the end of your script these two rows :

...
...
...
exitvalue=$?
echo  "exit code of my program is " $exitvalue

When script ends it'll show his exit code.
For example if it was killed (kill -9) appears this message :

exit code of my program is  137

The exit code 137  is 128 + 9 so process ended for a "kill -9" command.

This is a table of HPUX Signal :


       Signal  Value    Action   Comment
       -------------------------------------------------------------------------
       SIGHUP     1             Term    Hangup detected on controlling terminal
             or death of controlling process
       SIGINT     2              Term    Interrupt from keyboard
       SIGQUIT     3              Core    Quit from keyboard
       SIGILL     4              Core    Illegal Instruction
       SIGABRT     6              Core    Abort signal from abort(3)
       SIGFPE     8              Core    Floating point exception
       SIGKILL     9              Term    Kill signal
       SIGSEGV    11     Core    Invalid memory reference
       SIGPIPE    13     Term    Broken pipe: write to pipe with no readers
       SIGALRM    14     Term    Timer signal from alarm(2)
       SIGTERM    15     Term    Termination signal



Stay Tuned.

martedì 9 aprile 2013

Check Mid Year Objectives

Hi all Today middle year check of my 2026's goals. 1. ENGLISH Improve listening comprehension (So and So)   See at least one or two film...