Posted by jlogsdon on April 14, 2010
Over the last few days I’ve been working on an animation for a client here at Cool Blue Interactive. The animation is fairly simple: rotate 7 elements around a circular shape. I got everything working great in Chrome and FireFox, but when I fired it up in Internet Explorer (surprise?) there was a JavaScript error when the animation started.
I was worried for a minute that it may have been issues with the jQuery.path Plugin, and I’m not really a fan of math when it comes to circles. I started digging in anyway, stepping through my debugger to see what was going on. Turns out I might have encountered an edge case within jQuery.curCss() where style.left causes IE to freak out. One simple modification to jQuery later and it was all working.
On line 835 (uncompressed version, obviously) you’ll find this little piece of code:
style.left = ret || 0;
Changing that one line to
style.offsetLeft = ret || 0;
made all my problems go away. Unfortunately, this now means I have modified the core of jQuery, which is something I hate doing. Fortunately, that’s all I had to do to get the animation to work! Meaning I probably saved myself rebuilding the entire thing in Flash!
I currently don’t have the time to explore what’s actually causing this behavior, though I’d like to soon. In the mean time, if anyone feels like taking a look at the code that’s causing the issue I’ve put it up here. Click on one of the blocks to start the animation.
Posted by jlogsdon on March 31, 2010
Lately, I’ve been writing a lot of command line scripts with PHP. During this time, I spent some of it looking for a ‘tool chest’ of functions for some of the more repetitive tasks like prompting for user input or showing some sort of feedback when a process takes more than a few seconds. While there are a plethora of stand-alone helpers for progress bars, there wasn’t a single collection that I could find.
Over the past few weeks I’ve been refining a set of tools I wrote to fill the gap. Finally (as of last night), PHP Command Line Tools has been released! With it you can easily prompt a user for free-form input, choice-based input or a menu as well as progress meters and ‘working’ notifications.
This is definitely an early release, and has only been tested on my Ubuntu 9.10 and Centos 5.4 boxes. If you find any issues, please report them on the GitHub Tracker. It should also be noted that the API is not solidified yet, especially the \cli\Progress class.
Usage
Using the tools is as simple as including lib/cli/cli.php in your script. An autoloader is added to the SPL stack that will automatically load any classes in the \cli namespace.
<?php
require '/path/to/php-cli-tools/lib/cli/cli.php';
$name = \cli\prompt('Enter your name');
echo "Welcome, {$name}!\n";
?>
For more examples, see example.php in the projects root folder.
Posted by jlogsdon on December 23, 2009
I just pushed a small script, which I call ‘find-large’, to github. It’s usage is loosely based on the ‘find’ command.
find-large is a small PHP script that lists the largest files in a directory. While there are many methods to do this with linux tools, my partner and I wanted something a little easier to use.
Usage: /home/jlogsdon/bin/find-large [path] [options]
Find the largest files in a path.
-n Number of files to list (default: 25)
-r Resets the default file AND directory patterns. WARNING: order matters
with this option. Any previous patterns you have added will be removed
as well.
-f File pattern to ignore, chainable (default: none)
-d Directory pattern to ignore, chainable (default: .svn, .git)
-s Minimum file size in bytes. For ease of use, you may add a suffix.
Allowed suffixes are: k, m, g. (default: 10m)
-q Quiet mode. Only outputs the list of files.
-m Print file sizes in bytes, less readable output.
File and directory patterns may contain one or more wildcards ('*'). It is suggested
you put each pattern inside of single quotes to prevent your shell from expanding the
pattern.
Example Usage
$ find-large /usr
Scanning files........
Completed scan in 25.83 seconds
Found 8 that met your criteria
53.84m /usr/lib/locale/locale-archive
19.38m /usr/lib/xulrunner-1.9/libxul.so
17.92m /usr/lib/httpd/modules/libphp5.so
16.98m /usr/local/bin/php
14.68m /usr/share/gnome-applets/gweather/Locations.xml
13.39m /usr/share/icons/Bluecurve/icon-theme.cache
12.76m /usr/share/selinux/targeted/base.pp
11.98m /usr/share/selinux/targeted/enableaudit.pp