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

venerdì 5 aprile 2013

Regular Expression Library Site

Hi

I want report today the site http://regexlib.com/ about "Regular Expression".

A very good source of more than 3500 regular expression from thousand contributors.

Site presents a good search engine and is well done.

So to enjoy regex.

Stay Tuned.



martedì 2 aprile 2013

Oracle Nested Table - Create, Insert and Select

Hi all

Today i want to speak about oracle nested table.
Basically you can define in oracle a field that is a table inserted in other table. In Oracle system tables there are two tables used to manage this particular type of columns :
  • USER_NESTED_TABLES              : Nested Table List
  • USER_NESTED_TABLE_COLS    : Nested Table List Columns


Now an example to test it.

1) Creation a Type :

CREATE OR REPLACE TYPE VALUELIST AS TABLE OF VARCHAR2(20);

2) Creation Table :

CREATE TABLE NESTED_TABLE
(  ID            NUMBER           NOT NULL,
   FIELD1   VALUELIST)
NESTED TABLE FIELD1 STORE AS field1_tab;

3) Inserting values in table :

INSERT INTO nested_table VALUES (1, valuelist('Red'));
INSERT INTO nested_table VALUES (2, valuelist('White', 'Brown'));
INSERT INTO nested_table VALUES (3, valuelist('Blue', 'Orange','Yellow'));

4) Select values :

SELECT id, COLUMN_VALUE FROM nested_table t1, TABLE(t1.field1) t2;

5) Result :

ID    COLUMN_VALUE
1 Red
2 White
2 Brown
3 Blue
3 Orange
3 Yellow

In select statement you must reference a pseudo-column called "COLUMN_VALUE". To select values from a nested table, always you must explain mother table too.

Stay tuned.

sabato 30 marzo 2013

Easter egg

Hi all

Today i want speak about "Easter egg".
In Information Technology, "Easter eggs are secret responses that occur in response to an undocumented set of commands." how is correct defined in Wikipedia.



Basically an "Easter egg" is  a programmer's signature, a way to be recognized.

Here some internet examples :

You Tube : Try to write "do the harlem shake" in the search bar and find it.
http://theoatmeal.com/ : Try to see source html code
http://www.entercomputers.com/ : Visit this website and type 'penguin' on the hompage. Note animated penguin. Then wait for something else to happen.
http://www.miniusa.com : Type ‘reverse’ in the search field and then hold down Shift and click on the gear lever.

There are many internet sites about, for example here.

Stay tuned.


giovedì 28 marzo 2013

cron4j - Java cron scheduler like unix/linux cron utility

Hi all

Today i want to speak about an open source java library called "cron4j".
It's an Italian open source project, that allows scheduled tasks using a cron-like syntax in java.


There is a good manual here that explains how to implement it with examples.

Here is a little explanation of unix/linux cron utility.

Stay tuned


mercoledì 27 marzo 2013

Regular Expression

Hi all

Today i want speak about "Regular Expression".

As well described on Wikipedia : "In computing, a regular expression is a specific pattern that provides concise and flexible means to "match" (specify and recognize) strings of text, such as particular characters, words, or patterns of characters."

A good reference site for "Regular Expression" is http://www.regular-expressions.info/, there are presents examples, references, books, etc ....


Behind my desk I posted this Quick Guide really useful, above posted :


To test my regular expression i use a good web site : http://tools.netshiftmedia.com/regexlibrary/#, is a javascript regular expression validator that permits insert two test strings.

Regular expression are been inserted in Oracle Database from 10th version with four functions :


  • REGEXP_LIKE
  • REGEXP_INSTR
  • REGEXP_REPLACE
  • REGEXP_SUBSTR
Here you can find more information about.


It's all.

Stay tuned.








martedì 26 marzo 2013

Oracle OCI C - Wrapper OCILIB

Hi all

Today i want report a great open source project.
I've used and improved it for several years in many personal and professional processes.

For me is the best Oracle OCI C wrapper, easy to use and with a very good documentation.


I test it on several environment : HP/UX PaRisc, Itanium, Linux, Windows XP,7 and with differents ORACLE DB versions : 9,10,11.

I recommend it, you can find it in this link.

Stay tuned

lunedì 25 marzo 2013

Open Source Blogging Platform

Hi all

Today i want speak about an Open Source Blogging Platform named Bloglooks used in my friend blog http://blog.casaricci.it/.



It is a very very light and minimal Platform built on the PHP framework Yii.

It  use as backend any database supported by Yii .
For style is used Bootstrap.

Main functions :

* Multilingual (Also on articles and pages)
* Manual change language (Browser's default language)
* User privileges (User, editor, admin)
* Comments (Only by registered users; possibility of approvation by editor or admin)
* Integration with Google+ for pictures
* Markdown syntax
* RSS and Atom feeds

Stay tuned.



sabato 23 marzo 2013

iStella - Italian Social Search Engine

Hi all

A good news for Italian Web world, a new "Italian Social Search  Engine" has been created by Tiscali, an italian web provider.
Renato Soru, Tiscali owner say about iStella "We want to create a valid alternative to Google!!!".

Istella Layout is similar to Microsoft BING how you can see above :


Images used in iStella Layout are italian landscapes.

Here you can read a little italian tutorial about.

Basically why would you choose iStella and not Google?

I hope that iStella  will really be a valid alternative to Google, unlike others unlucky italian projects such as Volunia.

Stay tuned.

Wireless

Hi all

A good joke to start this day.



"It has wifi" !!!!  hahahahaha

Stay tuned

Mennea is dead

The best all time italian runners is dead.
His 200mt records was effective for 17 long years.
In the facts he was the last big white runner.

Below a beautiful tribute done for athletic children in Rome for his obsequies.



I don't knew him, but in every interviews he appears like a modest and simple person.

Bye great sportman,

Stay tuned.


venerdì 22 marzo 2013

WhatsApp Alternatives and Similar Software

Hi All

Recently WhatsApp messaging mobile application for smartphone declare that will be introduce a little annual payment for his service.
This news sparked a search for a valid alternative free.
From "La Repubblica" article  i want underline some solutions :

Today i want report a valid alternative for ANDROID smartphone (for now), KONTALK.
It is an open source project with a great potential. It's present on Android Market.

The network infrastructure and protocol have been designed from scratch to be immune from any attempt to centralize the network. All servers inside the network will have the same power and capabilities over each other - the network will be able to maintain itself and make itself safe.

I invite you to test it on your smartphone devices.

Stay tuned.







Oracle Function to get a specific field from a String contains fields characters delimited



Hi All

Today a simple function to extract a field from a String contains characters delimited fields.
I want use regexp_substr function but there are some problems for null fields to extract, so i develop this simple function.

CREATE OR REPLACE FUNCTION
  get_field (iString IN VARCHAR2, iSeparator IN VARCHAR2, field_num IN NUMBER)
RETURN VARCHAR2
IS
   oField VARCHAR2(1024);
   position_field NUMBER;
   position_field_start NUMBER;
   position_field_end NUMBER;
BEGIN

  IF field_num = 1 THEN
     position_field :=  INSTR(iString,iSeparator);
     IF position_field > 0 THEN
        SELECT SUBSTR(iString,1,INSTR(iString,iSeparator)-1) INTO oField FROM DUAL;
     ELSE
        oField := iString;
     END IF;
  ELSE
      position_field_start :=  INSTR(iString,iSeparator,1,field_num-1);
      position_field_end :=  INSTR(iString,iSeparator,1,field_num);

      IF position_field_start > 0 THEN
      
            IF position_field_end = 0 THEN
               position_field_end := length(iString)+1;
            END IF;
           SELECT SUBSTR(iString,position_field_start+1,position_field_end-position_field_start-1) INTO oField FROM DUAL;
      ELSE
         oField := null;
      END IF; 
  END IF;

  RETURN (oField);
END;

For example you have this string '10;12;34;233;12' delimited by ';' character and you wont get third field.
You can call this oracle function in this way :

SELECT GET_FIELD('10;12;34;233;12',';',3) FROM DUAL;

Results will be : '34'.

I hope can help someone with same problem.

Stay tuned


martedì 22 gennaio 2013

An Idiot's Guide to C++

Hi

Today i want share a very good guide to C++ : An Idiot's Guide to C++.

In this guide, C + + concepts are explained very clearly, read it.

Stay tuned.

G

giovedì 3 gennaio 2013

Year 2013


Another year :-) 2013.

2013 started three day ago and it's time to cheack my 2012 objectiveSee :

  • Improve my English Level                                    : Failed (It's one year ago level)
  • Improve my Chess Level                                     : OK (In 2012 i have win my first chess tournment)
  • Improve my incomes                                           : Failed
  • Be a better Christian                                            : So and so
  • Learn at least two new programming languages    : Failed (No new language learned)

One objective over 5 very very bad.

My new objectives for 2013 are (similar to 2012) :

  • Improve my English Level      
  • Improve my Chess Level       
  • Improve my incomes        
  • Be a better Christian        
  • Learn Android or a mobile languages (QT, jme, ...) 
  • Write more posts on this blog

I hope that in January 2014 results will be better ;-)

Stay tuned.


Check first quarter 2024

 Hi all Today, 1st May I'll check my 2024 goals. This is the first time I check it. For me it's a good way to reach more objective p...