Linux Command Line

Another Magento Installer Update!

0

It took me long enough but I finally updated the Magento installer to handle the newest stable version of Magento. Check out the updated post here.

Magento 1.5.0.1 Installer

Simple Setup of PEAR on a DreamHost Account

0

While DH installs a basic set of PEAR modules it’s a common situation need others, when that situation comes up you’ll often be referred to the PEAR article on the DH wiki. I’ve taken the instructions found there and created a shell script you can download and execute, it’ll do the following:

  1. Creates a .pearrc file in your home directory.
  2. Sets the download_dir, cache_dir, and temp_dir to folders within your /home/user/pear directory
  3. Sets the PHP_PEAR_PHP_BIN variables by adding “export PHP_PEAR_PHP_BIN=/usr/local/php5/bin/php” to your .bash_profile
  4. Modifies your PATH variable by adding “export PATH=/home/user/pear:/usr/local/php5/bin:$PATH” to your .bash_profile. This change also sets the PHP5 binary as the default for your shell.

Next time you call pear you’ll be using your custom settings and when you attempt to install any modules it will be done within your home directory. Now in order to use these PEAR modules in your application you will need to add the following to your app:

$pear_user_config = '/home/user/.pearrc';
set_include_path('.' . PATH_SEPERATOR . '/home/user/pear/php' . PATH_SEPERATOR . get_include_path());

Make sure to update “user” in the path to the actual user you are using and you’ll be set.

Download and Execute the Script

Just execute the following in a shell session:

wget http://files.gimmesoda.com/dreamhost/install_pear.sh; chmod 0744 install_pear.sh; ./install_pear.sh;

You can download and review the shell script from here, just open it up in a text editor of your choice.

How-to Display a Debian Server’s RSA Fingerprint

0

Need to verify a rsa host fingerprint for a debian server? Have someone connect and run the following command:

ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key

-bash: /bin/rm: Argument list too long (AKA: Too Many Files)

0

find /path/to/directory/ -exec rm {} \;

So apparently that command is magical! Alright, so it’s not magical but it was able to delete over 200,000 spam messages from a users Maildir/ when the rm command failed. “-bash: /bin/rm: Argument list too long”, it complained! So asking around I found out about that beauty of a command and how rm can only take a certain amount of arguments before failing.

Nice to know, as my journey of learning more about Debian Linux (and Linux in general) continues.

Image Resizing Using PHP and the GD library

0

I’m developing a new system core, can’t really say what it’s about but I’m having some fun doing it. Coding it is interesting, I’m getting to pull out and update some of my php code. Below is some code for image resizing, I use config files to set some default information like directories to save to and max width/height requirements. Also the entire system uses language files so I don’t output the text directly either, except for what I’m going to remove which is the uploaded file information.

Resize JPG images using the GD library and PHP.

function get_image_information($key) {
global $thumbnail_dest, $image_dest, $thumb_max_height, $thumb_max_width, $image_max_height, $image_max_width;
$filename = $_FILES[$key]["name"];
$file_type = $_FILES[$key]["type"];
$file_tmpname = $_FILES[$key]["tmp_name"];
$file_error = $_FILES[$key]["error"];
$file_size = $_FILES[$key]["size"];

if($file_error == 0 && $file_size > 0) {
if($file_type == “image/pjpeg” $file_type == “image/jpeg” $file_type == “image/jpg”) {
$image_name = md5(time() . rand(1001,10000)) . “.jpg”;
$thumb_dest = $thumbnail_dest . $image_name;
$image_dest = $image_dest . $image_name;
create_image($file_tmpname, $thumb_max_height, $thumb_max_width, $thumb_dest);
create_image($file_tmpname, $image_max_height, $image_max_width, $image_dest);
return “thumbs/” . $image_name;
} else {
$success .= file_upload_success_1 . $filename . file_upload_success_2 . “
“;
$success .= “We can only accept jpg uploads. Upload Failed.”;
return $success;
}
} else {
if($file_error == 1) {
echo $file_upload_fail_1;
} elseif($file_error == 2) {
echo $file_upload_fail_2;
} elseif($file_error == 3) {
echo $file_upload_fail_3;
} elseif($file_error == 4) {
echo $file_upload_fail_4;
} elseif($file_error == 6) {
echo $file_upload_fail_6;
}
return false;
}
}
function create_image($image, $max_width, $max_height, $dest) {
$image = imagecreatefromjpeg($image);
if ($image === false) {
die (‘Unable to open image’);
}

$width = imagesx($image);
$height = imagesy($image);

if($width < $max_width && $height < $max_height) {
$new_width = $width;
$new_height = $height;
} else {
$scale = min($max_width/$width, $max_height/$height);
$new_width = floor($scale * $width);
$new_height = floor($scale * $height);
}

$image_resized = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($image_resized, $dest, 90);
}

Go to Top