reCaptcha Plugin v0.8.0

reCaptcha is a plugin for CakePHP 1.2 to allow the easy use of reCaptcha.net's captcha library.

It may not work under all circumstances, but it is currently used in several production sites.

Usage:
(in the controller)

  1. var $components = array(array('Recaptcha.Captcha', array(
  2. 'private_key' => PRIVATE_KEY_FROM_RECAPTCHA_DOT_NET,
  3. 'public_key' => PUBLIC_KEY_FROM_RECAPTCHA_DOT_NET)));
  4. var $helpers = array('Recaptcha.CaptchaTool');

(in the view)

  1. <?php echo $captchaTool->show(); ?>

Requires:

  • CakePHP 1.2
  • PHP >= 5.2
  • PECL json >= 1.2.0 (to use reCaptcha configuration options)
  • Keys from reCaptcha.net

© 2009 Jason Burgess
reCaptcha plugin is licensed under an MIT style license.

autogrow.js v0.1

/* 
 * AutoGrow <textarea />
 * Version 0.1
 * A Prototype extension.
 * 
 * by Jason Burgess (www.holostek.net)
 *
 * Based on a jQuery plugin by Chrys Bader (www.chrysbader.com)
 * and a mooTools plugin by Gary Glass (www.bookballoon.com)
 * 
 * Copyright (c) 2009 Jason Burgess
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses. 
 *
 * NOTE: This script requires Prototype 1.6.0 or later.
 *
 * USAGE:
 *		new AutoGrow(element);
 * where 'element' is the id of a textarea element. For example:
 *		new AutoGrow('myTextarea');
 */
var AutoGrow = Class.create();
AutoGrow.prototype = {
	dummy : null,
	textarea : null,
	executer : null,
	options : {
		/* minimum height of textarea */
		minHeight : 46,
		/* update interval in seconds */
		interval : 0.3,
		/*
		 * gap (in px) to maintain between last line of text and bottom of
		 * textarea. Using our line-height should work well.
		 */
		margin : 16
	},
	object : null,
 
	initialize : function(textarea, options) {
		var style, styles = [ 'font-size', 'font-family', 'width',
				'line-height', 'padding' ], newStyle = {
			'overflow-x' : 'hidden',
			'position' : 'absolute',
			'top' : 0,
			'left' : '-9999px'
		}, x, l;
 
		this.textarea = $(textarea);
		this.options.minHeight = Math.max(this.options.minHeight, this.textarea.clientHeight);
 
		Object.extend(this.options, options || {});
 
		// Don't want to show scrollbars.
		this.textarea.setStyle({overflow: 'hidden'});
 
		this.dummy = new Element('div');
		for (x = 0, l = styles.length; x < l; ++x) {
			style = styles[x];
			newStyle[style] = this.textarea.getStyle(style);
		}
		this.dummy.setStyle(newStyle);
 
		document.body.insert(this.dummy);
		this.executer = new PeriodicalExecuter(this.resize,
				this.options.interval);
		this.executer.object = this;
		this.object = this;
	},
 
	resize : function(force) {
		var ag = this.object, text, newHeight, triggerHeight;
 
		text = ag.textarea.getValue().replace(/\n|\r\n/g, '<br>X');
		if (force === true || ag.dummy.innerHTML.toLowerCase() != text.toLowerCase()) {
			ag.dummy.update(text);
			triggerHeight = ag.dummy.getHeight() + ag.options.margin;
			if (ag.textarea.clientHeight != triggerHeight) {
				newHeight = Math.max(ag.options.minHeight, triggerHeight);
				ag.textarea.setStyle( {
					'height' : newHeight
				});
			}
		}
	}
 
};

FatSorter v1.0.4

What is it?

A "simple" program to sort files on a FAT file system. The target scenario for it is to sort the files and folders on a USB flash drive alphabetically, so they are loaded properly on devices that read them.

But why?

I bought a cheap car stereo about a year ago that plays MP3 files from either CD or from a USB flash drive or a compact flash memory card. However, it plays them in the order that they were added to the device.

Sometimes, Windows doesn't copy the files over in the right order, or if files are added at a later date, they stay at the end. When I listen to full albums in the car, it bugs me when they play out of order.

I searched around for a utility to correct the problem, but none of them supported recursion of subfolders. So I decided to make one.

Why it is necessary?

The FAT file system doesn't support sorting directory entries. However, this is the only file system for USB flash drives that is widely supported. Unless the hardware or software accessing the device (like your computer) resorts them for display, the files will show in the order they were added to the directory.

How we get around it?

To get around the problem, we cheat. By making a temporary directory, moving all the files to it, and then moving them back, in the new order, we effectively resort the directory. We then repeat the process in each directory listed. Sorter does this in reverse order, but not for any reason other than it makes the progress bar more accurate, because it knows how many files are there before it starts.

Why do you say it's a "simple" program?

The actual sorting process is fairly straight forward. However, it offered me an excuse to play with technologies I hadn't gotten to use yet, like WPF (Windows Presentation Framework) and threading. I've also added basic support for localization, but as I don't speak any other languages, I haven't made any translations for it. With all that in mind, the program ended up quite a bit more complicated than necessary, but it doesn't hurt anything.

What does it require?

The program requires Windows XP or later and the .NET Framework 3.5. It will allow you to download the framework when you install it, so you don't have to install it beforehand.

Where can I get it?

You can download the file here. It also includes (most of) the source code for the program, if you want to take a look. I've released it as open source (see the included license for details).

Syndicate content