Thursday, May 22, 2008

HTML prettyprint, cont.

Came to realization that I am trying to anticipate browser failures from lack of whitespace, but I would know nothing about it until I start rendering a few dozen pages programmatically. So skip the whitespace tom-foolery. Trim all the whitespace, normalize all to spaces, just use "textwrap" to wrap nicely. The idea, since the general algorithm has the potential to be exponential, is to use heuristics at the tips of the branches and the base of the tree, then clean up. Then use recursive algorithm, but with checks before descending if a computation is deemed to be "likely expensive". Going to add "minimum_total_charlength", because easy to calculate. Why did I forget to clean "tail" along with "text"?

Wednesday, May 21, 2008

more work on HTML prettyprint

today did not have chance to work on HTML pretty print was going to first lay out all the "text" and "tail" in a line seperated by the "whitespace preserving" tags
text tail text tail text text <whitespace preserving> text tail <whitespace preserving> text tail
then we have the: 1) empties 2) only whitespace 3) printing characters 4) printing characters with some whitespace at ends we only care about the whitespace that seperates printing characters, for the most part, printing characters in the "text" and seperating whitespace in the immediately following "tail" might be too much work, but, I would not be surprised if ran into issue later (all this work is not in vain, also I will need such stuff when I start programmically generating Python code, to compare my Python bytecode generation against Python's own, against the same algorithm, because of the work I am planning to do with AST, either Python's own in 2.6, or my own form)

Cats and Coffee



I do not endorse placing cats into giant cups of coffee. I think that is so wrong. It is an impractical way to flavor-enhance, and it aggravates the cat, usually. This particular cat seems to enjoy coffee immersion.

Monday, May 19, 2008

ideas for pretty print HTML/XML

Now, over the weekend, I was thinking about pretty printing HTML/XML I figgered, armed with the desired right margin first find the "elements" that definitely need "breaking up" into multiple lines start in the "deepest" part of the tree, why not make it simple these are all the different ways can print element

1) <tag>tagtext</tag>tail

2) <tag>tagtext</tag>
   tail
  
3) <tag>
     tagtext
   </tag>
  
4) <tag>
   tagtext
   </tag>
  
5) text<markup>moretext</markup>texttext

6) <tag1><tag2>tagtext</tag2></tag1>

hmm...

Indian Wedding, Western Perspective


My thoughts on Indian Weddings, having endured one (slightly Westernized, only took 2 hours). My sunburn was delicious.

Lisp and the Day Zero Problem

A brief diagram illustrating the in-memory rep...Image via Wikipedia

When a programmer finally gets his head around "code is data", it is best to call that day "Day Zero" and move on from there. The problem with the Lisp boys is they get stuck there -- they never make it past "Day Zero", and they never get around to coding programs to provide human value.
Reblog this post [with Zemanta]

Friday, May 16, 2008

Bubbles vs. Non-Bubbles: science of prognostication

Bubbles vs. Non-Bubbles Thought experiment: imagine you had a magical device, hooked up to a klaxon, that rang out before the market bubble burst. But, when it rang, you didn't know if the bubble would burst in 5 seconds, or in 3 months. It had some randomizer inside, and you didn't have access to know the setting. There are some unknown number of such devices held by other investors. Maybe a dozen, maybe hundreds, maybe thousands. Each has a reason to keep the existence of their ownership of the device a secret. You are waken at 3 A.M., by a terrible ringing. What do you do? Every second you wait, after the klaxon rings, before the bubble actually bursts, you are making money. How long after the klaxon rings, do you pull the trigger? The point is, even with this magical device, there would be a temptation to procrastinate on selling your whole position, there would be a temptation to try to time the market to the second. Somebody, in possession of this wonderful device, will get caught with their pants down. How the hell will this supposed science of bubble prognostication be any better than this magical device? It can only be worse, with worst results.

"Empty" tags in HTML

These are the "empty" tags in HTML: area, base, basefont, br, col, frame, hr, img, input, isindex, link, meta, param ...sometimes p important if you are outputting HTML from an XML dom

Overcoming shortfalls in Pownce

Pownce is good pownce.com/manuelg but search is terribly lacking in search capability. Until they fix that, I will have to put some notes here.