Wordle

Was checking out the new WordPress Foundation site and saw in the sidebar it said their header image was generated with Wordle. Curious, I checked it out and found Wordle is a Java Applet that creates a graphic word matrix based on the number of recurring words in any RSS feed. There are a bunch of fonts and layout algorythms you can choose from and you can create custom color palette as well. Here is one I generated from underblob.com’s RSS:



Pretty cool!

AS3 Listeners — Loader.COMPLETE vs MovieClip.ENTER_FRAME

Trying to load a directory of hundreds of images into separate movie clips using the AS3 Loader class. By assigning an Event.COMPLETE listener to the Loader, the callback function only has a reference to the Loader and not to the image that’s being loaded or the parent that it’s being loaded into. So if I need to Tween on this image after the load is completed, no dice. Instead, assign an Event.ENTER_FRAME to the parent MovieClip and dig a byte comparison out of the contentLoaderInfo object…

 

for each ( var imgPath in imgXML.elements () ) {
	var imgLoader:Loader = new Loader ();
	imgClip.addChild ( imgLoader );
	imgClip.addEventListener ( Event.ENTER_FRAME, imgLoading );
	imgLoader.load ( new URLRequest ( imgPath ) );
}

function imgLoading ( e:Event ):void {
	var bL:Number = e.target.getChildAt ( 0 ).contentLoaderInfo.bytesLoaded;
	var bT:Number = e.target.getChildAt ( 0 ).contentLoaderInfo.bytesTotal;
	if ( bT == bL ) {
		e.target.removeEventListener ( Event.ENTER_FRAME, imgLoading );
		e.target.parent.Tweener // etc.
	}
}


WP Access to Template Tags

I make a form in a Custom Template in my WordPress Theme. I submit the form to a PHP script in the theme directory via bloginfo ( ‘template_directory’ ). I want to be able to generate an email and have it sent to the admin email address that’s set in the WP installation. How can I access the Template Tags in the stand-alone submission script? By pure dumb luck I found the right two lines of code to paste into my script:

require_once ( $_SERVER[ 'DOCUMENT_ROOT' ] . '/wp-load.php' );
 wp ();

Now I created a reusable script that I can drop into any WordPress Theme by inserting the Site Name via get_bloginfo ( ‘name’ ) into the subject and sending the email to the Site Admin via get_bloginfo ( ‘admin_email’ ).

Links

WordPress.org/Template_Tags
PHP.net/mail-function

Apartment on Fire with Obama

I live in an apartment building in London. The flat is dirty and disheveled. There are anonymous roommates and my room is full of expensive electronics and equipment. The back wall of my room has a window that reveals a view of the internal wall. We are moving out today. Everyone is packing up their stuff and I go into my room to pack my belongings. In the window that views into the wall, there is a fire. I start to panic and call 911. The line is busy. I call back and get an operator and tell her that my apartment is on fire, send the fire department. “My fucking apartment is on fire! Help! Send help!” The operator is uninterested and annoyed that a Yankee doodle is bothering her.

I go outside and cross the street to wait for the fire department and see president Obama on the sidewalk.”My apartment is on fire and the 911 operator doesn’t care. I’m not sure the fire department is going to come,” I say.

He looks into my eyes and earnestly speaks, “we must intercede in these times of crisis.”

WP SQL Categories

Here is how to get WordPress Post categories via straight SQL query:

 

SELECT 
	wp_term_taxonomy.description, 
	wp_terms.term_id, 
	wp_terms.name, 
	wp_terms.slug
FROM wp_term_taxonomy
	JOIN wp_terms ON ( wp_term_taxonomy.term_id = wp_terms.term_id )
WHERE wp_term_taxonomy.taxonomy = 'category'

Getting Category Info in WP Theme

In WordPress, there isn’t a simple template tag to get the category slug or description if you’re making a category.php template. Here is a little work-around:

$cat = get_query_var ( 'cat' );
$catslug = get_category ( $cat )->slug;
$catdesc = get_category ( $cat )->description;