19 Aug 2009

PHP APC for Windows Download

PHP 14 Comments

PECL 4 Win has been down for quite a while making the search for some PHP extensions unnecessarily difficult. I’m offering this permanent APC download for not only my records, but to help others searching for it. As of August 19th, 2009, 3.1.3 is the latest beta version, and 3.0.19 is the latest stable.

Download php_apc (Windows 3.0.19 Stable)

Download php_apc (Windows 3.1.3 Beta)

For more information on APC, please visit the PECL page.

18 Aug 2009

Wordpress & jQuery: “$ is not a function”

jQuery 37 Comments

If you are trying to add your own jQuery code to Wordpress, and have had the error “$ is not a function” show up on Firebug, here is the fix:

Convert all dollar signs ($) to ‘jQuery’

The dollar sign is reserved in Wordpress for the Prototype library, which is why it errors out. For example, instead of:

$().ready(function() {
   $("#select_me").show();
});

Change it to:

jQuery().ready(function() {
   jQuery("#select_me").show();
});
17 Aug 2009

Notepad++ FTP Synchronize vs UAC

General 4 Comments

The issue I was having dealt with FTP Synchronize not opening any files beyond the root FTP folder. There were no error messages, and no indication other than the root files were opening in a folder in Program Files. UAC is blocking the creation of files within Program Files, so the solution is to change the cache location for the FTP Synchronize files.

Solution:

  • Click the “Settings” button in FTP Synchronize

ftpsync_step1

  • Navigate to the “General” tab.
  • Check the “Use nondefault cache location if none provided by profile” box
  • Then use the browse button to navigate to a folder outside of Program Files (for example, your user folder)

ftpsync_step2

Press “OK” to save changes, then restart Notepad++. You will now be able to make edits directly to your FTP sites.

17 Aug 2009

Jcrop Large Image Previews

jQuery No Comments

Jcrop is an excellent jQuery plugin developed by Deep Liquid. It is used to easily crop images on websites without having to use any photo editing software.

There is documentation on their website on how to use boxWidth and boxHeight to deal with large resolution pictures, however it does not tie together those methods with the preview pane (visit the demo this post is referencing).

Assuming you are using boxWidth to shrink down the image to 500 pixels wide, with a thumbnail 80 pixels by 80 pixels, use the following code to correctly display the preview pane.

jQuery('#cropbox').Jcrop({
   onChange: showPreview,
   onSelect: updateCoords,
   aspectRatio: 1,
   boxWidth: 500
});

function showPreview(coords) {
   if (parseInt(coords.w) > 0) {
      var rx = 80 / coords.w;
      var ry = 80 / coords.h;

      var img_height = $("#cropbox").height();
      var img_width = $("#cropbox").width();

      jQuery('#preview').css({
         width: Math.round(rx * img_width) + 'px',
         height: Math.round(ry * img_height) + 'px',
         marginLeft: '-' + Math.round(rx * coords.x) + 'px',
         marginTop: '-' + Math.round(ry * coords.y) + 'px'
     });
   }
};

The variables img_height and img_width find the new dimensions of the image, which are unique for images with different dimensions. The variables are then used to make calculations for the width and height of the preview pane.