<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet
			type="text/xsl"
			href="http://nedbatchelder.com/rssfull2html.xslt"
			media="screen"
		?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://purl.org/rss/1.0/">
    <channel rdf:about="http://nedbatchelder.com//blog">
        <title>Ned Batchelder's blog</title>
        <link>http://nedbatchelder.com/blog</link>
        <description>Ned Batchelder's personal blog.</description>
        <dc:language>en-US</dc:language>
        <image rdf:resource="http://nedbatchelder.com/pix/rss-banner.gif"/>
        <items>
            <rdf:Seq>
                
                    <rdf:li resource="http://nedbatchelder.com/blog/200811/quick_links_gromit_splitter_typealyzer.html"/>
                
                    <rdf:li resource="http://nedbatchelder.com/blog/200811/pathological_backtracking.html"/>
                
                    <rdf:li resource="http://nedbatchelder.com/blog/200811/victoria_marcus_olds_19112008.html"/>
                
                    <rdf:li resource="http://nedbatchelder.com/blog/200811/presentation_tools.html"/>
                
                    <rdf:li resource="http://nedbatchelder.com/blog/200811/tabblo_at_the_cambridge_django_meetup.html"/>
                
                    <rdf:li resource="http://nedbatchelder.com/blog/200811/us_on_abcnewscom.html"/>
                
                    <rdf:li resource="http://nedbatchelder.com/blog/200811/president_obama.html"/>
                
                    <rdf:li resource="http://nedbatchelder.com/blog/200811/gear_cube.html"/>
                
                    <rdf:li resource="http://nedbatchelder.com/blog/200811/stackoverflow_social_dynamics.html"/>
                
                    <rdf:li resource="http://nedbatchelder.com/blog/200810/the_first_servers.html"/>
                
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="http://nedbatchelder.com/pix/rss-banner.gif">
        <title>Ned Batchelder's blog</title>
        <link>http://nedbatchelder.com/blog</link>
        <url>http://nedbatchelder.com/pix/rss-banner.gif</url>
    </image>
    
    
    <item rdf:about="http://nedbatchelder.com/blog/200811/quick_links_gromit_splitter_typealyzer.html">
        <title>Quick links: Gromit, splitter, typealyzer</title>
        <link>http://nedbatchelder.com/blog/200811/quick_links_gromit_splitter_typealyzer.html</link>
		
        <dc:date>2008-11-20T07:47:33-05:00</dc:date>
        <description><![CDATA[<p class="quick">
		¶  
A new <a class="offsite" href="http://www.wallaceandgromit.com/forum/read/20652/1">Wallace &amp; Gromit</a>, at last!</p><p class="quick">
		¶  
<a class="offsite" href="http://www.kongregate.com/games/EvgenyKarataev/splitter/">Splitter</a>, yet another fun physics-based game.</p><p class="quick">
		¶  <a class="offsite" href="http://www.typealyzer.com/">Typealyzer</a>, an automatic Myers-Briggs
analyzer for blog content. Also, <a class="offsite" href="http://www.genderanalyzer.com/">GenderAnalyzer</a>
to determine if the author is male or female.</p>
]]></description>
    </item>
    
    <item rdf:about="http://nedbatchelder.com/blog/200811/pathological_backtracking.html">
        <title>Pathological backtracking</title>
        <link>http://nedbatchelder.com/blog/200811/pathological_backtracking.html</link>
		
        <dc:date>2008-11-19T08:14:18-05:00</dc:date>
        <description><![CDATA[<p>At work we've been using the well-regarded <a class="offsite" href="http://www.feedparser.org/">feedparser</a>
module to parse RSS feeds, and it works great for the most part, but we'd occasionally
get a stuck server process.  The CPU would spike to 100%, and wouldn't make any progress.
</p><p>We discovered a particular feed would cause a particular regular expression in
the code to spin endlessly.  The regex was intended to determine if a style
attribute is valid CSS:</p><blockquote class="code"><tt><span class="p_word">if</span><span class="p_default">&#160;</span><span class="p_word">not</span><span class="p_default">&#160;</span><span class="p_identifier">re</span><span class="p_operator">.</span><span class="p_identifier">match</span><span class="p_operator">(</span><span class="p_string">"^(\s*[-\w]+\s*:\s*[^:;]*(;|$))*$"</span><span class="p_operator">,</span><span class="p_default">&#160;</span><span class="p_identifier">style</span><span class="p_operator">):</span><br/>
<span class="p_default">&#160;&#160;&#160;&#160;</span><span class="p_word">return</span><span class="p_default">&#160;</span><span class="p_character">''</span><br/>
</tt></blockquote><p>Breaking this out into
<a href="http://nedbatchelder.com/blog/200304/verbose_python_regular_expressions.html">verbose regex syntax</a>
shows how it matches valid CSS:</p><blockquote class="code"><tt><span class="p_tripledouble">"""(?x)&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;#&#160;use&#160;verbose&#160;regex&#160;syntax</span><br/>
<span class="p_tripledouble">&#160;&#160;&#160;&#160;^(</span><br/>
<span class="p_tripledouble">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;#&#160;A&#160;single&#160;CSS&#160;clause&#160;is:</span><br/>
<span class="p_tripledouble">&#160;&#160;&#160;&#160;\s*&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;#&#160;&#160;&#160;leading&#160;whitespace</span><br/>
<span class="p_tripledouble">&#160;&#160;&#160;&#160;[-\w]+&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;#&#160;&#160;&#160;a&#160;dash-word,&#160;the&#160;property&#160;name</span><br/>
<span class="p_tripledouble">&#160;&#160;&#160;&#160;\s*:\s*&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;#&#160;&#160;&#160;space,&#160;colon,&#160;space</span><br/>
<span class="p_tripledouble">&#160;&#160;&#160;&#160;[^:;]*&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;#&#160;&#160;&#160;anything&#160;but&#160;:;,&#160;the&#160;value</span><br/>
<span class="p_tripledouble">&#160;&#160;&#160;&#160;(;|$)&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;#&#160;&#160;&#160;ends&#160;with&#160;a&#160;semi&#160;or&#160;the&#160;end&#160;of&#160;the&#160;string</span><br/>
<span class="p_tripledouble">&#160;&#160;&#160;&#160;</span><br/>
<span class="p_tripledouble">&#160;&#160;&#160;&#160;)*&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;#&#160;Valid&#160;CSS&#160;is&#160;any&#160;number&#160;of&#160;clauses</span><br/>
<span class="p_tripledouble">&#160;&#160;&#160;&#160;$</span><br/>
<span class="p_tripledouble">"""</span><br/>
</tt></blockquote><p>And here's the snippet discovered in the feed that spun us hard (with
whitespace added for readability):</p><blockquote class="code"><tt>&lt;var style="COLOR: #fffafe; coming: ; basket: ; philologist: ; gradually: ;<br>encyclic: ; whitechapel: ; left: ; albino: ; lamelliform: ; foment: ;<br>adjuvant: ; Room:  ; Milk:  ; buynow: ; wheelwork: ; unseal: ; reasons: ;<br>socalled: ; dazed: ; Brain:  ; Kaleidoscope:  ; hardheaded: ; asthenic: ;<br>preferred: ;  Barbecue:  ; Comet:  ; Nail:  ; lubberly: ; School:  ;<br>Mist:  ; undercurrent: ; intwine: ; isotonic: ; Chief:  ; miscellaneous: ;<br>Book:  ; Shoes:  ; Chocolates:  ; deuced: ; you: ; Man:  ; federalize: ;<br>Rainbow:  ; Satellite:  ; Printer:  ; amicus: ; tautophony: ; taking: ;<br>regrater: ; waggon: ; prescient: ; God:  ; prosing: ; Bank:  ; hariolation: ;<br>patriarchs: ; Pyramid:  ; Data Base:  ; PaintBrush:  ; ingenu: ; Rope:  ;<br>parenchyma: ; price: ; Alphabet:  ; Circle:  ; seeks: ; frankhearted: ;<br>vituperate: ; dysmeromorph: ; Shop:  ; firm: ;  imperforation: ; lane: ;<br>Gemstone:  ; slatternly: ; Fire:  ; impudence: ; Carrot:  ; Fan:  ;<br>inoccupation: ; uncover: ; Liquid:  ; drawee: ; Pocket:  ;barbacan: ;<br>fornicatress: ; chimes: ; Crystal:  ;innovation: ; years: ; untiring: ;<br>Freeway:  ;desertful: ; unreined: ; Compass:  ; Hose:  ;prelusive: ;<br>impenetrability: ; Fruit:  ; direct: ; "&gt;&lt;/var&gt;<br></tt></blockquote><p>(yes, it's garbage, and yes, spam sucks.)</p><p>It's hard to see the problem here, but this is not valid CSS because they used
"Data Base" as a property name about half-way through and spaces aren't allowed
in property names.</p><p>The CPU spins because when the regex encounters the failure to match "Data Base",
it backtracks to reconsider previous matches in the hopes that it can still make
the regex work.  In fact, it isn't in an infinite loop, just a very very very long
one.  Eventually this regex will finish and decide that the string doesn't match.</p><p>But we don't need it to backtrack: going back to re-match previous CSS clauses
isn't going to help.</p><p>Some regex libraries offer solutions to this problem.
<a class="offsite" href="http://www.regular-expressions.info/possessive.html">Possessive quantifiers</a>
let you use *+ to mean, match as many as possible, and once matched, don't try
matching fewer during backtracking.  They're called possessive because once the
operator claims part of the string, it won't give it back for other operators to
match later.</p><p>But Python doesn't offer possessive quantifiers
(<a class="offsite" href="http://bugs.python.org/issue2636">yet</a> <a class="offsite" href="http://bugs.python.org/issue3825">yet</a>).
So we have to choose a different technique than trying to match the whole string
in one large regex. In this case, since we don't need the match data, we're just
checking that the whole string matches, so we can use re.sub to remove matching
clauses and then check that there's nothing left over:</p><blockquote class="code"><tt><span class="p_word">if</span><span class="p_default">&#160;</span><span class="p_identifier">re</span><span class="p_operator">.</span><span class="p_identifier">sub</span><span class="p_operator">(</span><span class="p_string">"\s*[-\w]+\s*:\s*[^:;]*;?\s*"</span><span class="p_operator">,</span><span class="p_default">&#160;</span><span class="p_character">''</span><span class="p_operator">,</span><span class="p_default">&#160;</span><span class="p_identifier">style</span><span class="p_operator">):</span><br/>
<span class="p_default">&#160;&#160;&#160;&#160;</span><span class="p_word">return</span><span class="p_default">&#160;</span><span class="p_character">''</span><br/>
</tt></blockquote><p>Because re.sub grabs matches, performs the replacement, and moves on, there's
no needless backtracking to throw a wrench in the works.  Now our crazy CSS spam
is speedily dispatched as invalid.</p><p>As an interesting side effect, if the string is not empty, what remains is
the invalid part of the string.</p>
]]></description>
    </item>
    
    <item rdf:about="http://nedbatchelder.com/blog/200811/victoria_marcus_olds_19112008.html">
        <title>Victoria Marcus Olds, 1911–2008</title>
        <link>http://nedbatchelder.com/blog/200811/victoria_marcus_olds_19112008.html</link>
		
        <dc:date>2008-11-18T19:14:08-05:00</dc:date>
        <description><![CDATA[<p>My grandmother died this morning.  She was 97 years old, a good long life.
She lived in New York City most of my life, but lived in a nursing home near me
in Boston for the last year, so I saw her a few times, and
<a href="http://nedbatchelder.com/text/victoria-olds.html">those visits taught me some things about her</a>.
</p>
]]></description>
    </item>
    
    <item rdf:about="http://nedbatchelder.com/blog/200811/presentation_tools.html">
        <title>Presentation tools</title>
        <link>http://nedbatchelder.com/blog/200811/presentation_tools.html</link>
		
        <dc:date>2008-11-18T06:24:20-05:00</dc:date>
        <description><![CDATA[<p>I've had presentations on my mind lately, and that has caused me to search
out a good tool for doing them.  I have a Windows laptop, so PowerPoint is always
an option, but I wanted to try other alternatives first.  Unfortunately, I found
them all lacking.
</p><p>I want a way to author and show slides, and then a way to export them for
use in a web page.  I've got a goal of putting the presentations online not just
as a deck of images, but as a text transcript, illustrated with slides.  I've never
been able to watch other people's presentations online because I don't have the
patience to watch an hour-long video in real time, and a slide deck with none
of the actual talk behind it is pretty spare.</p><p><a class="offsite" href="http://meyerweb.com/eric/tools/s5/">S5</a> (A Simple Standards-Based
Slide Show System) is all HTML, CSS, and Javascript, runs in the browser, and
was created by Eric Meyer, a very nice pedigree.  Remarkably, the thing I like
least about it is that when I display the slides in a full-screen Firefox, they
look horrible. The text is either too small or too large, and the line-spacing
too tight, while the slide title overlaps the text in the wrong way, exposing
some of the structure of the divs.</p><p>I would have hoped that a CSS-based slideshow by the king of CSS
would be a shining example of how information could be cleanly authored and then
sparklingly displayed.  S5 seems to miss this mark, especially since there don't
seem to be many themes available for it, another surprise given how CSS should have
made it accessible to lots of designers.  Also, although (or perhaps because)
the format is native to the web, it's not possible to get the slides as illustrations.</p><p>I tried <a class="offsite" href="http://www.openoffice.org/product/impress.html">OpenOffice Impress</a>,
and was initially impressed.  It's got a lot of presentation features, notably
all sorts of animations.  When I started using it, though, I ran into some problems:
there's no way to create a text style, so any code samples have to be tediously
formatted by hand.  Although there are tons of slide animations, a bullet list
that reveals one bullet at a time is not among them.  I briefly considered the
scripting capability, but it seems arcane and under-documented.
</p><p>Also, I have to say that OpenOffice's themes are cheesy, and though I found
<a class="offsite" href="http://extensions.services.openoffice.org/project/simpletemplateone">one
that looked good</a>, when I installed it, it didn't work.</p><p>I briely tried <a href="http://nedbatchelder.com/blog/200806/280slides.html">280 Slides</a> again,
and it is very impressive, but too slow to run in my browser.</p><p>So I may be using PowerPoint...</p>
]]></description>
    </item>
    
    <item rdf:about="http://nedbatchelder.com/blog/200811/tabblo_at_the_cambridge_django_meetup.html">
        <title>Tabblo at the Cambridge Django meetup</title>
        <link>http://nedbatchelder.com/blog/200811/tabblo_at_the_cambridge_django_meetup.html</link>
		
        <dc:date>2008-11-12T11:20:02-05:00</dc:date>
        <description><![CDATA[<p>Tomorrow night, Thursday November 13, <a class="offsite" href="http://blog.pobblelabs.org/">Dave St. Germain</a>
and I will be talking about <a class="offsite" href="http://tabblo.com">Tabblo</a> at the
<a class="offsite" href="http://django.meetup.com/6/calendar/8976490/">Cambridge Django meetup</a>.
We aren't that organized, so I hesitate to call it a presentation.</p><p>Tabblo.com is a fairly large site, but since being acquired by Hewlett-Packard,
we've built a number of other sites running on the same code base.  We'll be talking
about some of the things we've had to do to keep flexible and light on our feet
while building and maintaining our web experiences.</p><p>If you're interested, drop in.</p>
]]></description>
    </item>
    
    <item rdf:about="http://nedbatchelder.com/blog/200811/us_on_abcnewscom.html">
        <title>Us on abcnews.com</title>
        <link>http://nedbatchelder.com/blog/200811/us_on_abcnewscom.html</link>
		
        <dc:date>2008-11-10T23:05:13-05:00</dc:date>
        <description><![CDATA[<p>Back in June, Susan and I did an interview with abcnews.com for a feature
they were doing on autism families.  The piece is finally up on their site:
<a class="offsite" href="http://abcnews.go.com/Health/AutismCommunity/popup?id=5528497">Autism Voices and Views</a>.
We talked about Nat's involvement in Special Olympics, and they took pictures
at a swim practice.  I think they did a good job capturing us.
</p><p align="center"><a href="http://abcnews.go.com/Health/AutismCommunity/popup?id=5528497"><img src="http://nedbatchelder.com/pix/abcnewsbanner.png" alt="ABCnews Autism Voices and Views" width="273" height="40"></a></p><p>In one of the shots, I am walking on the pool deck, holding my hand above
Nat while he swims the back stroke.  This is a swim coach hack I invented to try
to get him to lower his head into the water.  He naturally swims with his head
held up out of the water, as if he's trying to see his feet.  To get him to
put his head back, I tried walking the deck ahead of him, telling him to look at
my hand.  It worked for a little while, until he realized there was nothing very
interesting about my hand!</p><p>This is one of the interesting things about raising a special needs child: you
come up with your own techniques, because even the specialists will need
to invent stuff specially for each child, and you know yours better than anyone,
so you've got a good shot of coming up with the successful tricks.</p><p>And then you realize that this is true of all your children!</p>
]]></description>
    </item>
    
    <item rdf:about="http://nedbatchelder.com/blog/200811/president_obama.html">
        <title>President Obama</title>
        <link>http://nedbatchelder.com/blog/200811/president_obama.html</link>
		
        <dc:date>2008-11-05T06:22:07-05:00</dc:date>
        <description><![CDATA[<p>I am very pleased that Obama has been elected president.  It's been a very long
election, and of course there have been fights and probably hard feelings. I hope
Obama can truly unite people.  Of all of the practices of the last eight years
that I want Obama to reverse, the most important one is to lead so that 100% of the
people feel like he is their leader, rather than just the 52% who voted for him.
</p><p>I don't know if that is possible, since it will require effort from everyone,
including the people.  Reining in an overwhelmingly Democrat congress may be
difficult, but it is crucial.  Of all the reasons Obama won, the most important
may be that people were punishing the Republicans for their excesses when they
controlled all of government.  If the Democrats are smart, they will learn from
that.  If they do not, we may just see another whipsaw election next time around.
</p><p>Many have said that Obama will have a very hard time leading, given the economic
crisis, and the war to deal with one way or another, and that is very true.
I hope that he can do more than just run the ball a few yards down the field, I
hope that he can genuinely lead.
</p>
]]></description>
    </item>
    
    <item rdf:about="http://nedbatchelder.com/blog/200811/gear_cube.html">
        <title>Gear cube</title>
        <link>http://nedbatchelder.com/blog/200811/gear_cube.html</link>
		
        <dc:date>2008-11-04T19:55:06-05:00</dc:date>
        <description><![CDATA[<p>Haruki Nakamura has made a truly outstanding gear cube out of paper:</p><object width="425" height="344">
    <param name="movie" value="http://www.youtube.com/v/qfspDCpVDTw&amp;hl=en&amp;fs=1">
    <param name="allowFullScreen" value="true">
    <param name="allowscriptaccess" value="always">
    <embed src="http://www.youtube.com/v/qfspDCpVDTw&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344">
</object><p>I want one of these!</p><p><a class="offsite" href="http://www.geocities.jp/kamikara1967/paperart.htm">Nakamura's site</a>
is unfortunately all Japanese, and doesn't offer instructions.  It does have
photos of other fascinating work, though...</p>
]]></description>
    </item>
    
    <item rdf:about="http://nedbatchelder.com/blog/200811/stackoverflow_social_dynamics.html">
        <title>Stackoverflow social dynamics</title>
        <link>http://nedbatchelder.com/blog/200811/stackoverflow_social_dynamics.html</link>
		
        <dc:date>2008-11-04T09:20:16-05:00</dc:date>
        <description><![CDATA[<p><a class="offsite" href="http://stackoverflow.com">Stackoverflow</a> is a new programmer's
question and answer site from <a class="offsite" href="http://codinghorror.com">Jeff Atwood</a>
and <a class="offsite" href="http://joelonsoftware.com">Joel Spolsky</a>, and it's a very nice
site: cleanly designed, with lots of dynamic page goodness.</p><p>The part that interests me about it, though, are the social dynamics. They've
done a clever job with their reputation system: users on the site earn
<a class="offsite" href="http://stackoverflow.com/faq">reputation points</a> based on their
participation, for example, based on how other community members vote up or down
on answers. The points don't mean anything, you can't cash them in, but having
them displayed next to your name everywhere on the site is a powerful motivator,
especially for quantitative engineer-types.</p><p>In addition to reputation points, there's a large collection of
<a class="offsite" href="http://stackoverflow.com/badges">badges</a> you can earn, for example
by asking a popular question, or doing a lot of re-tagging.</p><p>Put together, reputation and badges are powerful motivators.  They turn the
site into a game, where being useful members of the community gives you
tangible (though virtual) points. Questions are answered within seconds of being
asked, as eager developers try to pounce and be the first with the correct answer.
Questions with widely-known answers frequently have a half-dozen correct responses
within minutes.</p><p>I don't see much on the site that will engender a real community, though.
In fact, the questions are strictly policed to be about programming, and any off-topic
discussion is quickly curtailed.  This might be a mistake: off-topic threads are
an important part of building a larger sense of place. On the other hand,
ensuring all discussion is "useful" will make the site much more appealing to
new people who aren't won't get the in-jokes.</p><p>The primary goal of stackoverflow is to be a useful repository of answers to
programming questions, and I think it will succeed at that.  Time will tell if
it goes in other directions and becomes something larger.</p><p>BTW, one other dynamic: since Jeff and Joel are Windows developers, their
readership is very Windows-heavy, and as a result, the stackoverflow crowd is
heavily tilted in that direction as well.</p>
]]></description>
    </item>
    
    <item rdf:about="http://nedbatchelder.com/blog/200810/the_first_servers.html">
        <title>The first servers</title>
        <link>http://nedbatchelder.com/blog/200810/the_first_servers.html</link>
		
        <dc:date>2008-10-29T07:08:13-04:00</dc:date>
        <description><![CDATA[<p>Doing some research into the theory of load testing and traffic loads, I
read about the <a class="offsite" href="http://en.wikipedia.org/wiki/Poisson_distribution">Poisson distribution</a>,
which led to <a class="offsite" href="http://en.wikipedia.org/wiki/Agner_Krarup_Erlang">Agner Krarup Erlang</a>,
which led to early phone switches.
</p><p>It's fascinating to realize that the work we do every day with web servers,
which seems like a recent modern technology, was predated by guys like Erlang
working with early phone switches over 100 years ago.  Phone switches were 
the first servers: central machines connected to a large number of potential clients.
In building these switches, the early engineers had to figure out from scratch
how to anticipate the possible work load, so they could build switches large enough
but not too large.  The whole of <a class="offsite" href="http://en.wikipedia.org/wiki/Queueing_theory">queueing theory</a>
springs from the theories worked out by telephone switch engineers.</p><p>And they were clever guys, even adjusting the UI to lighten the load on the
switches.  When dialing a rotary phone, the particular digits determined how long the
switch was engaged before the call could be routed.
So when they <a class="offsite" href="http://en.wikipedia.org/wiki/North_American_Numbering_Plan">allocated area codes,</a></p><blockquote><div><p>
the biggest population areas [got] the numbers that took the shortest time to
dial on rotary phones. That is why New York City was given 212, Los Angeles
given 213, Chicago 312, and Detroit 313, while Vermont received 802 (a total of
20 clicks, 8+10+2). Four areas received the then-maximum number of 21 clicks:
South Dakota (605), North Carolina (704), South Carolina (803), and Nova
Scotia/Prince Edward Island in the Canadian Maritimes (902).
</p></div></blockquote>
]]></description>
    </item>
    
</rdf:RDF>
