<?xml version="1.0" encoding="UTF-8"?><feed
  xmlns="http://www.w3.org/2005/Atom"
  xmlns:thr="http://purl.org/syndication/thread/1.0"
  xml:lang="en"
  >
  <id>http://livingcode.org/feed/atom</id>
  <updated>2009-11-13T19:33:25Z</updated>
  <title type="text">Living Code</title>
  <subtitle type="text">Programming for the Fun of It</subtitle>
  <link rel="self" type="application/atom+xml" href="http://livingcode.org/feed" />
  <link rel="alternate" href="http://livingcode.org" />
  <rights type="text">Copyright 2009</rights>
  <generator uri="http://wordpress.org/" version="2.8.6">WordPress</generator>
      <entry>
    <id>http://livingcode.org/2008/useful-javascript-references</id>
    <title type="html"><![CDATA[Useful Javascript References]]></title>
    <updated>2008-09-13T17:28:33Z</updated>
    <published>2008-09-13T17:28:33Z</published>
    <author>
      <name>Dethe</name>
      <email>delza@livingcode.org</email>
<uri>http://livingcode.org/</uri>    </author>
    <link rel="replies" type="application/atom+xml" href="http://livingcode.org/2008/09/13/useful-javascript-references/feed" thr:count="0"  />
    <link rel="alternate" href="http://livingcode.org/2008/09/13/useful-javascript-references" />
    <category scheme="http://livingcode.org" term="Python" />
    <summary type="html"><![CDATA[I&#8217;ve been getting more Javascript questions, both at work and elsewhere, so I thought I&#8217;d post some of the resources I rely on, in case it is helpful to others, and so I have something to point folks to.
Mozilla Developer Center is hard to navigate or search to find useful information, which is too bad, [...]]]></summary>
      <content type="html" xml:base="http://livingcode.org/2008/09/13/useful-javascript-references"><![CDATA[<p>I&#8217;ve been getting more Javascript questions, both at work and elsewhere, so I thought I&#8217;d post some of the resources I rely on, in case it is helpful to others, and so I have something to point folks to.</p>
<p>Mozilla Developer Center is hard to navigate or search to find useful information, which is too bad, because there are some gems hidden away in it.  One of the ones I come back to again and again is the <a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference">Core Javascript Reference 1.5</a>.  Javascript 1.5 is out of date now, but in this case it just means this reference is useful across more browsers.</p>
<p>I have become a major fan of jQuery, so the <a href="http://docs.jquery.com/">docs</a> for it have found a place on my bookmark bar as well.</p>
<p>A key site for looking up web standards info is <a href="http://w3schools.com/">W3Schools</a>, and their <a href="http://w3schools.com/js/default.asp">Javascript</a> section is sometimes helpful, although their <a href="http://w3schools.com/htmldom/default.asp">HTML DOM</a> section is even better, especially for the semi-standard DOM Level 0 stuff like <code>window</code> and <code>location</code>.</p>
<p>For questions about the DOM, I still go back to the <a href="http://www.w3.org/TR/DOM-Level-3-Core">W3C DOM Spec</a>, especially <a href="http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/ecma-script-binding.html">Appendix H</a>, which is the ECMAScript (Javascript) Binding, or API.</p>
<p>Finally, I sometimes find that the Microsoft <a href="http://msdn.microsoft.com/en-us/library/ms533050(vs.85).aspx">documentation</a> for IE is helpful.  They often reorganize their site, and their search isn&#8217;t very helpful, so the best way I&#8217;ve found to find information is to use google search with the term <code>site:msdn.microsoft.com </code>in addition to your search term(s). I don&#8217;t know how anyone at Microsoft finds things on their own site, but I expect they end up using Google too.</p>
<p>Those are the essential references I use.  None of them are particularly helpful for learning Javascript in the first place, or for developing a good style and using more advanced techniques, or taking advantage of browser specific features.  If there is interest, I can write about those another time.</p>
]]></content>
        </entry>
    <entry>
    <id>http://livingcode.org/2005/tidbits</id>
    <title type="html"><![CDATA[Tidbits]]></title>
    <updated>2008-01-25T05:51:00Z</updated>
    <published>2005-05-26T05:46:02Z</published>
    <author>
      <name>Dethe</name>
      <email>delza@livingcode.org</email>
<uri>http://livingcode.org/</uri>    </author>
    <link rel="replies" type="application/atom+xml" href="http://livingcode.org/2005/05/25/tidbits/feed" thr:count="0"  />
    <link rel="alternate" href="http://livingcode.org/2005/05/25/tidbits" />
    <category scheme="http://livingcode.org" term="Python" />
    <summary type="html"><![CDATA[My posts have been infrequent, in part because I&#8217;ve been working on lots of things to talk about. I&#8217;m in the last stages of putting together info on creating NSStatusItems (tools which show up in the menu bar across all applications in OS X) in PyObjC. I&#8217;ve also got some cool Quicktime and iSight tools [...]]]></summary>
      <content type="html" xml:base="http://livingcode.org/2005/05/25/tidbits"><![CDATA[<p>My posts have been infrequent, in part because I&#8217;ve been working on lots of things to talk about. I&#8217;m in the last stages of putting together info on creating NSStatusItems (tools which show up in the menu bar across all applications in OS X) in PyObjC. I&#8217;ve also got some cool Quicktime and iSight tools coming soon. And I&#8217;ve renamed ZenPaint to DrawingBoard, but it&#8217;s working and just waiting for a little GUI cleanup before I post the first binary and source.</p>
<p>Two of my back-burner projects, better blue-screening, and easy lightsabre effects, have been done by others recently. Inspired by the same BoingBoing piece on rotoscoping your own lightsabres as I was, but <a href="http://www.lamarchefamily.net/nakedsoft/">Naked Software</a> actually sat down and wrote the code. It&#8217;s pretty slick, too. For blue-screen effects (and many more), check out Sam Kass&#8217; <a href="http://www.samkass.com/blog/">Quartz Composer Compositions</a>. Very neat stuff, Tiger-only though [Update: now Leopard]. Some of the compositions require a newer system with a higher-end video card than my three-year-old PowerBook.</p>
<p>But to be honest, the real point of this post is not to tease with coming attractions, but to point out my first paid publication. My friend <a href="http://gnosis.cx/publish/">David Mertz</a> asked me to collaborate with him on his <a href="http://www-128.ibm.com/developerworks/views/xml/libraryview.jsp?search_by=xml+matters:">XML Matters</a> column for IBM developerWorks, and my first column went live last Friday: <a href="http://www-128.ibm.com/developerworks/xml/library/x-matters41.html">Beyond the DOM</a>.</p>
<p>I&#8217;ve wanted to be a writer for as long as I can remember, with poetry notebooks and 200 pages of a novel gathering dust on my bookshelves, so finally getting around to finishing something and having it published leaves me pleased as punch. And more <strong>will</strong> be forthcoming.</p>
]]></content>
        </entry>
    <entry>
    <id>http://livingcode.org/2004/dom-back-to-xml-in-python</id>
    <title type="html"><![CDATA[DOM back to XML in Python]]></title>
    <updated>2008-01-26T06:15:36Z</updated>
    <published>2004-09-18T06:11:54Z</published>
    <author>
      <name>Dethe</name>
      <email>delza@livingcode.org</email>
<uri>http://livingcode.org/</uri>    </author>
    <link rel="replies" type="application/atom+xml" href="http://livingcode.org/2004/09/17/dom-back-to-xml-in-python/feed" thr:count="0"  />
    <link rel="alternate" href="http://livingcode.org/2004/09/17/dom-back-to-xml-in-python" />
    <category scheme="http://livingcode.org" term="Python" />
    <summary type="html"><![CDATA[OK, time to crank up to speed, it&#8217;s been a lot longer than I intended between posts.
In the last episode we learned how to initialize many of the DOMs and DOM-like tools for Python from an XML document. Today we&#8217;re going to see how to convert these back to XML from the DOM. So fasten [...]]]></summary>
      <content type="html" xml:base="http://livingcode.org/2004/09/17/dom-back-to-xml-in-python"><![CDATA[<p>OK, time to crank up to speed, it&#8217;s been a lot longer than I intended between posts.</p>
<p>In the last episode we learned how to initialize many of the DOMs and DOM-like tools for Python from an XML document. Today we&#8217;re going to see how to convert these back to XML from the DOM. So fasten your seatbelts and let&#8217;s go.</p>
<pre class="code">import domParse</pre>
<pre class="code">from xml.dom.ext.c14n import Canonicalize</pre>
<pre class="code">
def stringMinidom(filename):</pre>
<pre class="code">    return Canonicalize(domParse.parseMinidom(filename))</pre>
<pre class="code"></pre>
<pre class="code">def string4Dom(filename):</pre>
<pre class="code">    return Canonicalize(domParse.parse4Dom(filename))</pre>
<pre class="code"></pre>
<pre class="code">def stringDomlette(filename):</pre>
<pre class="code">    return Canonicalize(domParse.parseDomlette(filename))</pre>
<pre class="code"></pre>
<pre class="code">def stringLibXml(filename):</pre>
<pre class="code">    # pretty-printed, which may not be what you want,</pre>
<pre class="code">    # depending on the XML in question</pre>
<pre class="code">    return domParse.parseLibXml(filename).serialize(encoding='utf-8', format=True)</pre>
<pre class="code">    # 4DOM c14n breaks because libXML doesn't give you a DOM</pre>
<pre class="code">    # return Canonicalize(domParse.parseLibXml(filename))</pre>
<pre class="code"></pre>
<pre class="code">def stringPxDom(filename):</pre>
<pre class="code">    import pxdom</pre>
<pre class="code">    serializer = pxdom.LSSerializer()</pre>
<pre class="code">    return serializer.writeToString(domParse.parsePxDom(filename))</pre>
<pre class="code">    #return Canonicalize(domParse.parsePxDom(filename))</pre>
<pre class="code"></pre>
<pre class="code">def main(filename):</pre>
<pre class="code">    print '4DOM:', string4Dom(filename)</pre>
<pre class="code">    print 'Domlette:', stringDomlette(filename)</pre>
<pre class="code">    print 'MiniDom:', stringMinidom(filename)</pre>
<pre class="code">    print 'LibXml:', stringLibXml(filename)</pre>
<pre class="code">    print 'PxDom:', stringPxDom(filename)</pre>
<pre class="code">if __name__ == '__main__': main(domParse.small_filename)</pre>
<pre></pre>
<p>As you can see, there&#8217;s not much to it. This codes does require that you&#8217;ve installed the PyXML package, but if you&#8217;re serious about XML in Python, that will already be the case. In our next outing we can explore some of the less DOM-like, but more Pythonic ways to play with XML.</p>
<p>PyXML: <a href="http://pyxml.sourceforge.net/">http://pyxml.sourceforge.net/<br />
</a><br />
4Suite: <a href="http://4suite.org/index.xhtml ">http://4suite.org/index.xhtml </a></p>
<p>libxml: <a href="http://www.xmlsoft.org/">http://www.xmlsoft.org/</a> (instructions for the python bindings are linked from this page)</p>
<p>pxdom: <a href="http://www.doxdesk.com/software/py/pxdom.html ">http://www.doxdesk.com/software/py/pxdom.html </a></p>
<p>You may now return your trays to their upright positions.</p>
]]></content>
        </entry>
    <entry>
    <id>http://livingcode.org/2004/initializing-a-dom-in-python</id>
    <title type="html"><![CDATA[Initializing a DOM in Python]]></title>
    <updated>2004-09-16T06:15:38Z</updated>
    <published>2004-09-16T06:15:38Z</published>
    <author>
      <name>Dethe</name>
      <email>delza@livingcode.org</email>
<uri>http://livingcode.org/</uri>    </author>
    <link rel="replies" type="application/atom+xml" href="http://livingcode.org/2004/09/15/initializing-a-dom-in-python/feed" thr:count="0"  />
    <link rel="alternate" href="http://livingcode.org/2004/09/15/initializing-a-dom-in-python" />
    <category scheme="http://livingcode.org" term="Python" />
    <summary type="html"><![CDATA[There are many DOM options in Python, and I have trouble remembering how to load a document into the various DOMs. Here are a few common ones, although there are many variations on them (loading from URL or string, different configurations, etc.). This should provide a starting point.
# Examples for reading in various DOMs from [...]]]></summary>
      <content type="html" xml:base="http://livingcode.org/2004/09/15/initializing-a-dom-in-python"><![CDATA[<p>There are many DOM options in Python, and I have trouble remembering how to load a document into the various DOMs. Here are a few common ones, although there are many variations on them (loading from URL or string, different configurations, etc.). This should provide a starting point.</p>
<pre class="code"># Examples for reading in various DOMs from an XML file</pre>
<pre class="code"># MiniDOM</pre>
<pre class="code">def parseMinidom(filename):</pre>
<pre class="code">    try:</pre>
<pre class="code">        from xml.dom.minidom import parse</pre>
<pre class="code">        doc = parse(filename)</pre>
<pre class="code">        return doc</pre>
<pre class="code">    except Exception, e:</pre>
<pre class="code">        return 'parseMinidom() failed with exception %s' % e</pre>
<pre class="code"># 4DOM</pre>
<pre class="code">def parse4Dom(filename):</pre>
<pre class="code">    try:</pre>
<pre class="code">        from xml.dom.ext.reader.Sax2 import Reader</pre>
<pre class="code">        f = file(filename)</pre>
<pre class="code">        reader = Reader(validate=0, keepAllWs=0, catName=None)</pre>
<pre class="code">        doc = reader.fromStream(f) # slow!</pre>
<pre class="code">        f.close()</pre>
<pre class="code">        return doc</pre>
<pre class="code">    except Exception, e:</pre>
<pre class="code">        return 'parse4Dom() failed with exception %s' % e</pre>
<pre class="code"># Domlette</pre>
<pre class="code">def parseDomlette(filename):</pre>
<pre class="code">    try:</pre>
<pre class="code">        from Ft.Xml.Domlette import NonvalidatingReader as reader</pre>
<pre class="code">        f = file(filename)</pre>
<pre class="code">        uri = 'file:///%s' % filename # suppress warning</pre>
<pre class="code">        doc = reader.parseStream(f, uri)</pre>
<pre class="code">        f.close()</pre>
<pre class="code">        return doc</pre>
<pre class="code">    except Exception, e:</pre>
<pre class="code">        return 'parseDomlette() failed with exception %s' % e</pre>
<pre class="code"># libXml</pre>
<pre class="code">def parseLibXml(filename):</pre>
<pre class="code">    try:</pre>
<pre class="code">        import libxml2</pre>
<pre class="code">        f = file(filename)</pre>
<pre class="code">        data = f.read()</pre>
<pre class="code">        f.close()</pre>
<pre class="code">        doc = libxml2.parseDoc(data)</pre>
<pre class="code">        return doc</pre>
<pre class="code">    except Exception, e:</pre>
<pre class="code">        return 'parseLibXml() failed with exception %s' % e</pre>
<pre class="code"># pxDom</pre>
<pre class="code">def parsePxDom(filename):</pre>
<pre class="code">    try:</pre>
<pre class="code">        import pxdom</pre>
<pre class="code">        doc = pxdom.parse(filename)</pre>
<pre class="code">        return doc</pre>
<pre class="code">    except Exception, e:</pre>
<pre class="code">        return 'parsePxDom() failed with exception %s' % e</pre>
<pre class="code">def main():</pre>
<pre class="code">    import sys</pre>
<pre class="code">    filename = sys.argv[1]</pre>
<pre class="code">    print '4DOM:', parse4Dom(filename)</pre>
<pre class="code">    print 'Domlette:', parseDomlette(filename)</pre>
<pre class="code">    print 'MiniDom:', parseMinidom(filename)</pre>
<pre class="code">    print 'LibXml:', parseLibXml(filename)</pre>
<pre class="code">    print 'PxDom:', parsePxDom(filename)</pre>
<pre class="code">if __name__ == '__main__': main()</pre>
]]></content>
        </entry>
  </feed>
