Monthly Archives: October 2012

Mac: How to copy files from hard disk to USB drive through command line ?

In order to copy really big files or full directory coping through command line is good idea.
It will be fast and easy. In your mac you can find source directory easily but how to find destination directory?

Go to root and check the volume directory. /Volumes
Now its time to check where is your destination directory and where you want to keep your files.
In my case /Volumes/Seagate Backup Plus Drive/my_download

cp -R 1_j_download/ /Volumes/"Seagate Backup Plus Drive"/my_download 

There are 2 points
A. cp has -R which is used to copy entire directory.
B. “Seagate Backup Plus Drive” directory in my case has quote because of space. If you don’t use quote probably it will not work! However you can name your drive without space.

It will take few minutes to copy really big chunks of data… Still it depends on size.

Share

PHP: How to dynamically resize image in your page?

Every php programmer/developer have to resize images in web pages.
There are a lot of ways available through JavaScript, jQuery and PHP.
Here is very simple way to resize image temporarily but proportionally.
You can still keep big image file in you in your folder but when you are displaying you can make is smaller.

Jquery and java script some times does not work. So PHP way is very useful.


 ($inputwidth/$inputheight)) {
            $outputwidth = $inputwidth;
            $outputheight = ($inputwidth * $height)/ $width;
        }

        elseif (($width/$height) < ($inputwidth/$inputheight)) {
            $outputwidth = ($inputheight * $width)/ $height;
            $outputheight = $inputheight;
        }

        elseif (($width/$height) == ($inputwidth/$inputheight)) {
            $outputwidth = $inputwidth;
            $outputheight = $inputheight;
            }

echo '';

?>
Share

How to save remote image in server or save image from a url?

Saving images from any live url is very easy with php.
Here are three ways to do this.
1. Using Curl
2. Using File functions
3. Using GD library functions.

Condition is in your server php.ini should have “allow_url_fopen” On. check you php setting using phpinfo() function.

Create a folder name “images_saved” to save your images.

Using Curl

Image ' . basename($i) . ' Downloaded Successfully';
    }else{
        echo '

Image ' . basename($i) . ' Download Failed

'; } } function image_save_from_url($my_img,$fullpath){ if($fullpath!="" && $fullpath){ $fullpath = $fullpath."/".basename($my_img); } $ch = curl_init ($my_img); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); $rawdata=curl_exec($ch); curl_close ($ch); if(file_exists($fullpath)){ unlink($fullpath); } $fp = fopen($fullpath,'x'); fwrite($fp, $rawdata); fclose($fp); } ?>

Using File functions


Using GD library functions.


Share