<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="/templates/default/atom.css" type="text/css" ?>

<feed 
   xmlns="http://www.w3.org/2005/Atom"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/">
    <link href="http://kendsnyder.com/feeds/atom.xml" rel="self" title="Ken Snyder" type="application/atom+xml" />
    <link href="http://kendsnyder.com/"                        rel="alternate"    title="Ken Snyder" type="text/html" />
    <link href="http://kendsnyder.com/rss.php?version=2.0"     rel="alternate"    title="Ken Snyder" type="application/rss+xml" />
    <title type="html">Ken Snyder</title>
    <subtitle type="html">PHP, JavaScript, CSS</subtitle>
    <icon>http://kendsnyder.com/templates/bulletproof/img/s9y_banner_small.png</icon>
    <id>http://kendsnyder.com/</id>
    <updated>2010-03-12T05:55:08Z</updated>
    <generator uri="http://www.s9y.org/" version="1.3.1">Serendipity 1.3.1 - http://www.s9y.org/</generator>
    <dc:language>en</dc:language>

    <entry>
        <link href="http://kendsnyder.com/archives/44-Will-Mobile-Devices-Make-Flash-Stronger.html" rel="alternate" title="Will Mobile Devices Make Flash Stronger?" />
        <author>
            <name>Ken Snyder</name>
                    </author>
    
        <published>2010-03-08T16:52:39Z</published>
        <updated>2010-03-12T05:55:08Z</updated>
        <wfw:comment>http://kendsnyder.com/wfwcomment.php?cid=44</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://kendsnyder.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=44</wfw:commentRss>
    
            <category scheme="http://kendsnyder.com/categories/1-Linux" label="Linux" term="Linux" />
            <category scheme="http://kendsnyder.com/categories/2-Web-Development" label="Web Development" term="Web Development" />
    
        <id>http://kendsnyder.com/archives/44-guid.html</id>
        <title type="html">Will Mobile Devices Make Flash Stronger?</title>
        <content type="xhtml" xml:base="http://kendsnyder.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>Yesderday I was playing Flash games with my 5 year old on our Ubuntu desktop. As you may know, Flash support on Linux is dismal. Specifically I was using the Adobe plugin on Firefox 3.6 in Ubuntu 9.10 with a powerful NVIDIA GeForce 9600-series graphics card and a speedy Intel Core2 Duo. We played games on <a onclick="javascript: pageTracker._trackPageview('/extlink/flonga.com');"  href="http://flonga.com">flonga.com</a>.</p>

<p>Here are some of the problems that made games unplayable:</p>
<ul>
<li>Gets stuck in a loop on the splash screen</li>
<li>Annoying flicker</li>
<li>Buttons don't work (e.g. clicking "Play" does nothing)</li>
<li>CPU usage was intense and game was slow</li>
</ul>

<p>The problems seemed to crop up somewhat related to UI complexity, but I get the feeling that many of the problems are due to poor programming and a poor Flash implementation for Linux.</p>

<p>If these problems exist on powerful desktop hardware on Linux, I can only imagine the challenges of implementing Flash on Android or OSX mobile devices which have processors of 1 GHz or less and run on the equivalent of two AA batteries.</p>

<p>Recently I formed the opinion that mobile devices would kill flash Flash as Steve Jobs is pushing for. But playing the games made me realize that Flash on mobile could make Flash stronger!</p>

<p>See, I stayed away from any game that was unplayable. With a high number of users making the same choices, Flash developers and Adobe will adapt or die. Flash developers will avoid unnecessary UI complexity and slow animations. Adobe will re-factor slow code. Flash on mobile could make Flash stronger!</p>

<p>We've already seen that Adobe is chomping at the bit to get Flash on mobile devices; they've added interfaces for reading mobile-device-specific hardware such as accelerometers and GPSs.</p>

<p>Keep an eye out, especially as Mobile Flash rolls out to Android devices in the next few months.</p> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://kendsnyder.com/archives/43-Wrangling-MS-Words-HTML.html" rel="alternate" title="Wrangling MS Word's HTML" />
        <author>
            <name>Ken Snyder</name>
                    </author>
    
        <published>2009-10-27T22:55:57Z</published>
        <updated>2009-10-28T15:47:00Z</updated>
        <wfw:comment>http://kendsnyder.com/wfwcomment.php?cid=43</wfw:comment>
    
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://kendsnyder.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=43</wfw:commentRss>
    
            <category scheme="http://kendsnyder.com/categories/5-HTML" label="HTML" term="HTML" />
            <category scheme="http://kendsnyder.com/categories/3-PHP" label="PHP" term="PHP" />
            <category scheme="http://kendsnyder.com/categories/2-Web-Development" label="Web Development" term="Web Development" />
    
        <id>http://kendsnyder.com/archives/43-guid.html</id>
        <title type="html">Wrangling MS Word's HTML</title>
        <content type="xhtml" xml:base="http://kendsnyder.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>Oh boy.</p>
<p>Handling a paste from a Word document into a browser-based WYSIWYG editor is a pain in the butt. I'm using CKEDITOR, which does have a built-in tool for stripping Word's nasty HTML, but it doesn't work well. I also had no success using PHP's HTMLPurifier, htmLawed or Tidy alone.</p>

<p>For a taste of Word HTML, see the section following this article. If you write HTML, a little part of you will die inside every time you see MS Word HTML.</p>

<p>One of the hard parts is extracting ordered and unordered lists. Especially since that varies so much between browsers.</p>

<p>For this PHP project, I needed to accept HTML from a WYSIWYG editor to save into a CMS system. The HTML needed to be quite restricted; e.g. to disallow changing font faces and font colors. Anyway, here is the algorithm I ended up with:</p>

<ol>
<li>Find and replace common entities that seem to get mangled in a normal DOMDocument conversion</li>
<li>Remove comments</li>
<li>Remove nested FONT tags since DOMDocument discards content inside nested FONT tags</li>
<li>Extract ordered and unordered lists with regular expressions</li>
<li>Convert B and I tags to EM and STRONG and disallow any attributes in any of those</li>
<li>Replace TABLE tags with a simple tag containing a css class and cellspacing of 0</li>
<li>Load into DOMDocument</li>
<li>Remove any tags not on the whitelist</li>
<li>Remove any attributes not on the whitelist</li>
<li>Disable href and src attributes that do not contain an http, https or relative link</li>
<li>Strip out disallowed css styles from the style attribute</li>
<li>Remove css classes that Word commonly uses</li>
<li>Dump back to HTML</li>
<li>Remove DOCTYPE, HTML and BODY tags that DOMDocument automatically adds</li>
<li>Use Tidy to clean up any additional problems, add P tags to plain text and remove duplicate white space</li>
<li>Remove the linefeeds that Tidy leaves (we are sending content to Adobe Flex which parses HTML but interprets all white space literally)</li>
<li>Remove spans that have no attributes and thus no effect</li>
<li>Remove empty paragraphs</li>
</ol>
<p>It feels good to get that worked out!</p> <br /><a href="http://kendsnyder.com/archives/43-Wrangling-MS-Words-HTML.html#extended">Continue reading "Wrangling MS Word's HTML"</a>
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://kendsnyder.com/archives/42-Flashs-UEber-Compatibility.html" rel="alternate" title="Flash's Über Compatibility" />
        <author>
            <name>Ken Snyder</name>
                    </author>
    
        <published>2009-10-22T22:13:58Z</published>
        <updated>2009-10-22T22:38:06Z</updated>
        <wfw:comment>http://kendsnyder.com/wfwcomment.php?cid=42</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://kendsnyder.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=42</wfw:commentRss>
    
            <category scheme="http://kendsnyder.com/categories/5-HTML" label="HTML" term="HTML" />
            <category scheme="http://kendsnyder.com/categories/4-JavaScript" label="JavaScript" term="JavaScript" />
            <category scheme="http://kendsnyder.com/categories/2-Web-Development" label="Web Development" term="Web Development" />
    
        <id>http://kendsnyder.com/archives/42-guid.html</id>
        <title type="html">Flash's Über Compatibility</title>
        <content type="xhtml" xml:base="http://kendsnyder.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>Here is the <a onclick="javascript: pageTracker._trackPageview('/extlink/kb2.adobe.com/cps/415/tn_4150.html');"  href="http://kb2.adobe.com/cps/415/tn_4150.html" target="_blank">HTML that Adobe Recommends</a> to embed a flash file:</p>

<pre>&lt;OBJECT classid=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot; codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0&quot; WIDTH=&quot;550&quot; HEIGHT=&quot;400&quot; id=&quot;myMovieName&quot;&gt;&lt;PARAM NAME=movie VALUE=&quot;myFlashMovie.swf&quot;&gt;&lt;PARAM NAME=quality VALUE=high&gt;&lt;PARAM NAME=bgcolor VALUE=#FFFFFF&gt;&lt;EMBED href=&quot;/support/flash/ts/documents/myFlashMovie.swf&quot; quality=high bgcolor=#FFFFFF WIDTH=&quot;550&quot; HEIGHT=&quot;400&quot; NAME=&quot;myMovieName&quot; ALIGN=&quot;&quot; TYPE=&quot;application/x-shockwave-flash&quot; PLUGINSPAGE=&quot;http://www.macromedia.com/go/getflashplayer&quot;&gt;&lt;/EMBED&gt;&lt;/OBJECT&gt;</pre>

<p>It is compatible with IE3 and Netscape 2. Really? Do we need <em>that level</em> of compatibility? I mean really!</p>

<p>And if you want something more "automated" you can <a onclick="javascript: pageTracker._trackPageview('/extlink/kb2.adobe.com/cps/127/tn_12701.html');"  href="http://kb2.adobe.com/cps/127/tn_12701.html" target="_blank">use Adobe's AC_RunActiveContent.js JavaScript file</a>. Oh boy!</p>

<p>So I looked at the popular video sites and their "embed source" links. All are shorter and simpler. <a onclick="javascript: pageTracker._trackPageview('/extlink/blip.tv');"  href="http://blip.tv" target="_blank">Blip.tv</a> was the shortest. Here is what Blip.tv uses:</p>

<pre>&lt;embed src=&quot;http://blip.tv/play/AYGPzDgC&quot; type=&quot;application/x-shockwave-flash&quot; width=&quot;480&quot; height=&quot;300&quot; allowscriptaccess=&quot;always&quot; allowfullscreen=&quot;true&quot;&gt;&lt;/embed&gt;</pre>
<p>More examples are below.</p>

 <br /><a href="http://kendsnyder.com/archives/42-Flashs-UEber-Compatibility.html#extended">Continue reading "Flash's Über Compatibility"</a>
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://kendsnyder.com/archives/41-pathConcat.html" rel="alternate" title="pathConcat" />
        <author>
            <name>Ken Snyder</name>
                    </author>
    
        <published>2009-10-21T15:24:28Z</published>
        <updated>2009-12-12T03:32:36Z</updated>
        <wfw:comment>http://kendsnyder.com/wfwcomment.php?cid=41</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://kendsnyder.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=41</wfw:commentRss>
    
            <category scheme="http://kendsnyder.com/categories/3-PHP" label="PHP" term="PHP" />
            <category scheme="http://kendsnyder.com/categories/2-Web-Development" label="Web Development" term="Web Development" />
    
        <id>http://kendsnyder.com/archives/41-guid.html</id>
        <title type="html">pathConcat</title>
        <content type="xhtml" xml:base="http://kendsnyder.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>I developed the following php function after writing <code>trim($path,'/')</code> too many times. It took me a lot of iterations to pass all the unit tests, but it works with URI and file paths for all OSs. It goes as far as to account for the strange possibility of a path containing an escaped slash. It runs pretty quickly--less than twice as long as a simple use of join: <code>join('/',$parts)</code>.</p>
<p>Much of the time, simply joining with a slash is acceptable--file systems and web servers treat consecutive slashes as one. When comparing two paths for equality, spurious slashes are a problem. Or when running rewrite rules, an extra slash may throw the application into an entirely different path.</p>
<div class="php" style="text-align: left"><span style="color: #000000; font-weight: bold;">function</span> pathConcat<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />&#160; <span style="color: #0000ff;">$parts</span> = <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/func_get_args');"  href="http://www.php.net/func_get_args"><span style="color: #000066;">func_get_args</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; <span style="color: #0000ff;">$base</span> = <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/array_shift');"  href="http://www.php.net/array_shift"><span style="color: #000066;">array_shift</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$parts</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; <span style="color: #0000ff;">$base</span> = <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/str_replace');"  href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\/</span>'</span>,<span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\x</span>01"</span>,<span style="color: #0000ff;">$base</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; <span style="color: #0000ff;">$base</span> = <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/rtrim');"  href="http://www.php.net/rtrim"><span style="color: #000066;">rtrim</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$base</span>, <span style="color: #ff0000;">'/'</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; <span style="color: #0000ff;">$paths</span> = <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/array');"  href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; <span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$parts</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$part</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; <span style="color: #0000ff;">$part</span> = <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/str_replace');"  href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\/</span>'</span>,<span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\x</span>01"</span>,<span style="color: #0000ff;">$part</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; <span style="color: #0000ff;">$part</span> = <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/trim');"  href="http://www.php.net/trim"><span style="color: #000066;">trim</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$part</span>, <span style="color: #ff0000;">'/'</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/strlen');"  href="http://www.php.net/strlen"><span style="color: #000066;">strlen</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$part</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; <span style="color: #0000ff;">$paths</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #0000ff;">$part</span>;<br />&#160; &#160; <span style="color: #66cc66;">&#125;</span><br />&#160; <span style="color: #66cc66;">&#125;</span><br />&#160; <span style="color: #0000ff;">$fullpath</span> = <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/join');"  href="http://www.php.net/join"><span style="color: #000066;">join</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$paths</span>, <span style="color: #ff0000;">'/'</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; <span style="color: #0000ff;">$fullpath</span> = <span style="color: #0000ff;">$base</span> . <span style="color: #ff0000;">'/'</span> . <span style="color: #0000ff;">$fullpath</span>;&#160; <br />&#160; <span style="color: #0000ff;">$fullpath</span> = <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/str_replace');"  href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\x</span>01"</span>,<span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\/</span>'</span>,<span style="color: #0000ff;">$fullpath</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$fullpath</span>;<br /><span style="color: #66cc66;">&#125;</span></div>

<p>Examples:</p>
<div class="php" style="text-align: left">pathConcat<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'one'</span>,<span style="color: #ff0000;">'two'</span>,<span style="color: #ff0000;">'three/'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// 'one/two/three'</span><br />pathConcat<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'one'</span>,<span style="color: #ff0000;">''</span>,<span style="color: #ff0000;">'two'</span>,<span style="color: #ff0000;">'/'</span>,<span style="color: #ff0000;">'three/'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// 'one/two/three'</span><br />pathConcat<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'http://one/'</span>,<span style="color: #ff0000;">'/two/'</span>,<span style="color: #ff0000;">'//three/'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// 'http://one/two/three'</span><br />pathConcat<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'/one'</span>,<span style="color: #ff0000;">'/two/'</span>,<span style="color: #ff0000;">'//three.php'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// '/one/two/three.php'</span><br />pathConcat<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'c:/one/two/'</span>,<span style="color: #ff0000;">'/../three/'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// 'c:/one/two/../three'</span><br />pathConcat<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"bats<span style="color: #000099; font-weight: bold;">\\</span>/"</span>,<span style="color: #ff0000;">"like"</span>,<span style="color: #ff0000;">"thedark"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// &quot;bats\\//like/thedark&quot;</span><br />pathConcat<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"bats<span style="color: #000099; font-weight: bold;">\\</span>//like"</span>,<span style="color: #ff0000;">"caves"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// &quot;bats\\//like/caves&quot; </span></div>





 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://kendsnyder.com/archives/40-Multiple-Codebases-on-localhost.html" rel="alternate" title="Multiple Codebases on localhost" />
        <author>
            <name>Ken Snyder</name>
                    </author>
    
        <published>2009-10-19T17:13:05Z</published>
        <updated>2009-10-19T17:23:02Z</updated>
        <wfw:comment>http://kendsnyder.com/wfwcomment.php?cid=40</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://kendsnyder.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=40</wfw:commentRss>
    
            <category scheme="http://kendsnyder.com/categories/2-Web-Development" label="Web Development" term="Web Development" />
    
        <id>http://kendsnyder.com/archives/40-guid.html</id>
        <title type="html">Multiple Codebases on localhost</title>
        <content type="xhtml" xml:base="http://kendsnyder.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                
<p>After writing my last article about using apache's RewriteCond to work with multiple codebases on localhost, a coworker
pointed out a far simpler method using apache VirtualHosts.</p>

<p>On my dev machine, I'm lazy about server admin and just use wamp. To work with multiple codebases below is my simple and easy configuration.</p>

<p>In httpd.conf:</p>
<pre>&lt;VirtualHost *:80&gt;
   DocumentRoot &quot;c:/wamp/www&quot;
   ServerName localhost
&lt;/VirtualHost&gt;

&lt;VirtualHost *:80&gt;
   DocumentRoot &quot;c:/wamp/www/app1/&quot;
   ServerName app1
&lt;/VirtualHost&gt;

&lt;VirtualHost *:80&gt;
   DocumentRoot &quot;c:/wamp/www/app2&quot;
   ServerName app2
&lt;/VirtualHost&gt;</pre>

<p>In hosts file (c:/WINDOWS/system32/drivers/etc/hosts):</p>
<pre>127.0.0.1    localhost
127.0.0.1    app1
127.0.0.1    app2</pre>

<p>Access in the browser:</p>
<pre>http://app1/
http://app2/</pre>

<p>It can't get much easier.</p>


 
            </div>
        </content>
        
    </entry>

</feed>