Crea sito

Archivio per giugno 2011

Client TCP with PHP

Here there is a simple example of tcp client written in php that tries to connect to a server, sends to it 2 messages and prints the server replies <?php /* Get the port for the WWW service. */ $service_port = getservbyname(‘www’, ‘tcp’); /*if you already know the destination port, you don’t need getservbyname, you can […]

Tags: , , ,

Server TCP with PHP

Here there is a simple example of tcp server written in php that accepts a connection from a client and for each message that the client sends to the server, it reply with the same message. <?php /* Allow the script to hang around waiting for connections. */ set_time_limit(0); /* Turn on implicit output flushing […]

Tags: , , ,

How to use a string as input of awk

How can you use a string as input of awk? Usually awk takes as input the path of the file that you want to process. Here there is a very simple solution to give to process a string with awk without the necessity of store that string into a file: echo “string that you want to […]

Tags: , , ,

How to use php to extract xml value

How to use php to extract a value of a field from an xml file: -Example of xml file: <?xml version=”1.0″ encoding=”UTF-8″?> <o> <meta class=”object”> <id>200</id> </meta> </o> -PHP script that will print the value of meta class and id: <?php $input_file = “path of xml file”; $xml = @simplexml_load_file($input_file) or die (“no file loaded”) […]

Tags: ,

How to run php script on linux shell

How to run a php script on a Linux shell as a normal script: -name of the script:    script_name.php -Inside the script: #!/usr/bin/php <?php Here you can insert your php code ?> -On the shell: chmod +x script_name.php ./script_name.php -Done!!

Tags: , , ,

How to replace special character as ‘%^$& using sed

How to replace or delete special characters as ‘ % ^ & … from a string (stored into a text file) using the command “sed” : sed s/”character that has to be replaces“/”string that will replaced the character“/g input_file Examples: -replace character & with other_string from each line of input_file sed s/”&”/”other_string”/g  input_file.txt     […]

Tags: , , , ,

Xml and json. Convert xml to json and json to xml

How to manipulate xml and json files so that you can pass from .json to .xml and from .xml to .json Here you can find a link to an useful tool in java that can: -convert a xml file to a json file -convert a json file to a xml file https://github.com/tobrien/sample-json-parsing

Caricare foto, video e note su Facebook dal proprio telefono

Per caricare delle foto o dei video dal cellulare al proprio account di Facebook e’ possibile utilizzare il proprio indirizzo e-mail di caricamento personalizzato. I contenuti caricati verranno visualizzati nell’album Caricamenti dal cellulare. L’oggetto dell’e-mail verrà usato come didascalia della foto o del video o, se il messaggio non contiene foto e video, per aggiornare […]

Tracker per uTorrent, come aggiungerli

Prima di parlare di come aggiungere un tracker ad uTorrent, ecco a voi una brevissima introduzione ai tracker, che vi spieghera’ cosa sono e a cosa servono: Un tracker di *.Torrent è un server a cui ogni client della rete deve connettersi. Prima di iniziare il download il client deve comunicare col tracker così come […]

Tags: , , ,