TK Studios Blog

Disable WP’s Automatic Paragraphs

June 20th, 2011

A quick hack to disable the wpautop() function’s tendency to mangle your WordPress-based HTML posts with extra markup:

Add the following to your functions.php:

function custom_autop($p, $br = 1) {
  if (stristr($p, '<!--noautop-->')) {
    return str_ireplace('<!--noautop-->', '', $p);
  } else {
    return wpautop($p, $br);
  }
}
remove_filter('the_content','wpautop');
add_filter('the_content','custom_autop');

That’s it. Now when you add <!–noautop–> to a post, it’ll disable the wpautop() function.

Incidentally, wpautop has a parameter called “$pee” and a loop that reads “foreach( $pees as $tinkle )” …

Quick JS experiment: Function Overhead

November 3rd, 2010

Probably common knowledge, but I just slapped together a quick test script to determine what kind of overhead there is between a) writing a function inline, b) keeping the function as part of an object (say, utility.isObject), and c) same as b, but get a reference to the function first. Each approach was iterated a total of 100,000,000 times to get usable time values. Tests were performed in Chrome 7, so YMMV. Read the rest of this entry »

phpScenario & Listy.us updates

October 27th, 2010

First, phpScenario has been updated to 0.1.1 (change log here), so that’s cool. It helps when the library you release actually works, right?

Second, I’ve been posting some related tutorials in the project’s forums:

So, if you’re interested in split testing via php, I’d recommend checking the project and tutorials out.

Third, I’m finally getting started on the rewrite of Listy.us’s editor. Where the old editor was a single, sparsely-commented 1400-line javascript file, the new one is spread across several files using RequireJS, and uses QUnit for unit testing. It is, essentially, a project in itself, and I’m finding it much, much nicer to work with.

Introducing phpScenario

October 18th, 2010

Last night I launched the project I’d mentioned a couple days ago. It’s a fairly early version of a free (BSD licensed) split testing library I’ve named phpScenario. The usage has changed a little bit since then; the code samples should still work, but they’ve been simplified even further so the main tasks (getting a treatment, setting it as complete, rendering results) can be done with single statements.

You can check out the free split testing library in all it’s beta glory at www.phpscenario.org and post any questions on the discussion boards. It’s version 0.1 beta, as in “Well, it works for me, but could probably use some tuning.”

Read the rest of this entry »

phpScenario, a split testing library

October 6th, 2010

I’m closing in on the first release of what you might call a by-product of Listy.us; phpScenario is a free split-testing library created out of the need to have a way of testing various ideas on Listy.us without relying on paid products or offsite solutions. I’m going to release it for free, though I haven’t chosen a license yet. (update: New BSD license!)

Read the rest of this entry »

Fixing Doctrine’s Geographical template precision

April 27th, 2010

(Note that this blog post is about Doctrine 1.2. At the time of this minor update—Nov 16, 2010—I can’t seem to actually FIND a Geographical behavior in Doctrine 2. So, if you’re using Doctrine 2, this post probably isn’t for you. It sucks, I know, this behavior was friggin’ handy.)

Doctrine, an ORM library, has a convenient little behavior that you can attach to your tables to give them awesome superpowers of geolocation. It’s the Geographical template, and it resides in Doctrine/Template/Geographical.php. What it does is add two fields to your table: Latitude and Longitude, and extends your model with the ability to discern distances between any two of these locations.

That’s all well and good, except that as of 1.2.2, Doctrine’s default precision for a floating point field is 2. That doesn’t allow for very accurate geolocation, as it truncates something like “+33.544622″ down to “33.54″. Not good.

Read the rest of this entry »

PHP hashing performance experiment

April 25th, 2010

Today, in the never-ending quest to tweak server performance by a few milliseconds, I decided to do a bit of testing of various php hashing methods. I therefore wrote a quick script under php (5.2.11 currently, I need to update), which ran each test case 10,000 times to achieve a decent min/avg/max for each case, on strings of 10KB, 100KB, and 1,000KB in size.

Read the rest of this entry »

Changelog ala Listy

March 27th, 2010

I put together a change log for Listy.us IN Listy.us. And here it is. Read the rest of this entry »

Southwest Understands Conversation

March 24th, 2010

I’m probably a bit late to the party on this one, but I flew Southwest up to & back from the MD/VA area this past week. It was unlike any prior flying experiences, and as far as I can tell, they know they’re doing it. It’s intentional. The staff are happy and conversational with passengers. They joke with you, they aren’t afraid to laugh. Probably the best customer experience out there as far as feeling like a person, rather than cash-dispensing cattle.

Read the rest of this entry »

Listy.us – Now with Embedding!

March 23rd, 2010

Today marks the first “Huge” update to Listy.us. It is now a paid service, handles uploaded files, and allows public lists to be embedded on any page. Like so:

Read the rest of this entry »