Tuesday, November 10, 2009

Replacing tag based class definitions with inline styles

Again, this can be useful for parsing HTML bound for rich text email, where you need to use inline styles -- for example when sending to a gmail account. this will scoop out the styles and plop them into the tag itself, it also will replace double quotes with single quotes for those pesky font familes that include spaces in the name

// PHP 4
// attempt to replace tag based class definitions with inline styles
// add tags to the array to expand the scope

$sar = array('a','h1','h2','h3','h4','p','ul','li');

$i = 0;
$sarsize = sizeof($sar);
$tag = $sar[$i];
$pattern = '/(?<='.$tag.'.\{)[^}]*/i';
$style = preg_match ($pattern, $file, $smem);
$attributes = $smem[0];
if ($attributes){
$attributes = str_replace('"',"'",$attributes);
$attributes = preg_replace('/\s+/i', ' ', $attributes);
$attributes = trim($attributes);
$file = str_replace('<'.$tag,'<'.$tag.' style="'.$attributes.'"',$file);
$i = 0;

Monday, August 17, 2009

The 99¢ economy

The Apple store demonstrates how infinite resources drive price down to a convenience fee

The apple app store is a great tool to study pricing effects. Game developers are learning that $9.99 might seem like a fair price, yet by reducing the price by 90%, the net dollar amount of sales skyrocket. When the price is reduced to a sub dollar amount, the potential marketplace expands exponentially. If something is infinitely reproducible for zero cost, the economics get a little nutty, and that's what software developers are beginning to figure out. If you have a popular consumer digital product, It's actually in your best interest to charge as little as possible in order to maximize your sales. The issue many marketing types don't yet get is that in a digital marketplace, the more valuable your product is, the lower it's price — and as the price drops your profits go up, not down.

In a perfect supply and demand economy all digital prices will fall to that of a convenience fee, lets say for example, 99¢. It won't matter what you are selling, whether it's an app that makes your telephone play back fart sounds, or a word processor, or a 3 hour long science fiction movie, a hit record, or even software that allows you to do 3D design and drafting for heavy industry. If it's a popular app or genre, someone is going to undercut you with a better product for a lower price until the price reaches that of a convenience fee. Think Redbox.

The profitability comes from keeping the price intentionally low, yet steadily adding value to the product in order to increase popularity. Would Adobe earn more money by reducing the price of Photoshop from $861.00 to 99¢? — 6 billion humans on the planet? — I bet they would, but until they figure out that in a digital economy price and value have a inverse relationship, I would not bet on it.

Tuesday, April 7, 2009

Replacing CSS styles with inline style for rich email

Ever get frustrated when you use a "dreamweaver" style markup system, just to find that class definitions don't show up in certain email rendering environments?

The trick is to swap the declared classes for inline styles. I found another solution on the web that was way more complex than it needed to be, so here is a simpler way to do it:

note: in PHP and where $file is your HTML code:

// replace dreamweaver CSS class definitions with inline styles
if (preg_match("/class=/i", $file) ){
$wer = preg_match_all("/\.style[^\}]*\{*\}/i", $file, $hello);
foreach(array_unique($hello[0]) as $rest) {// rest is now the whole style class declaration
$rest = str_replace("\n"," ",$rest);
preg_match_all("/\.style\S*.(?=\s+\{?)/i", $rest, $h2); // $h200 should now be just the .style45654 part
preg_match_all("/(?<=\{)[^}]*/i", $rest, $h3); // $h300 should now be just the definitions within the style
$styledef = trim ($h3[0][0]);
$simplestylename = trim ($h2[0][0]);
$simplestylename = str_replace('.','',$simplestylename);
$clssub = 'class="'.$simplestylename.'"';
$clsrp = 'style="'.$styledef .'"';
$file = str_replace($clssub,$clsrp,$file);