doingword.com

Archive for February, 2007

How to compress a directory with tar

Wednesday, February 21st, 2007

Hi Guys,
If we need make a backup of a directory, the best options is use tar.
For example, you have a directory called /home/emanuelq/files and you would like to compress this directory,you can type tar command as follows:

  1. tar -zcvf backup.tar.gz /home/emanuelq/files

The above command will create an archive called backup.tar.gz in the current directory.
If you want to extract the content of the file you need to run this command.

  1. tar -vxfz backup.tar.gz

The above command will be extract the files in the current directory.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Posted in Linux | No Comments »

Function to convert an hexadecimal to rgb value

Friday, February 16th, 2007

Params:$hex: Hexadecimal value
Return:Array with the decimal value for red, gren and blue.

function hexToRgb($hex)
  1. {
  2. //Delete the # char (if exist)
  3. if (0 === strpos($hex, '#')) {
  4. $hex = substr($hex, 1);
  5. } else if (0 === strpos($hex, '&H')) {
  6. $hex = substr($hex, 2);
  7. }
  8. //get the 3 hex values
  9. $cutpoint = ceil(strlen($hex) / 2)-1;
  10. $rgb = explode(':', wordwrap($hex, $cutpoint, ':', $cutpoint), 3);
  11.  
  12. //Convert to  decimal
  13. $rgb[0] = (isset($rgb[0]) ? hexdec($rgb[0]) : 0);
  14. $rgb[1] = (isset($rgb[1]) ? hexdec($rgb[1]) : 0);
  15. $rgb[2] = (isset($rgb[2]) ? hexdec($rgb[2]) : 0);
  16.  
  17. return  $rgb;
  18. }
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Posted in Functions, Php | No Comments »