Evan Martin (evan) wrote in evan_tech,
Evan Martin

evening hack

Evening hack: searchable Stranger valentines.

(per lazyweb request by joshc)

Update: a bit more on the "technology". I tried a few different approaches for making this fast. One important one was that the actual entries themselves were originally generated using innerHTML -- for the non-Javascript-savvy, you can assign to this attribute DOM nodes and the HTML you provide is parsed -- but this was slow (likely because of the parsing) and instead I create a prototypical element straightforwardly in the HTML and then clone it and modify its text to create the valentines themselves.

The other major bottleneck seemed to be filling the page with these nodes. I eventually capped it (because you don't really need more than 75 nodes anyway) but before that I tried some other things, including iterating through the list in reverse and repeatedly prepending rather than doing presumably the O(n^2) repeated appends.

I was also thinking of doing some fancy searching (in fact, my original idea involved using XMLHttp to have the processing done on a server) but when I tried the simple "search every entry" approach it appeared to be fast enough to work.

  • dremel

    They published a paper on Dremel, my favorite previously-unpublished tool from the Google toolchest. Greg Linden discusses it: "[...] it is capable…

  • google ime

    Japanophiles might be interested to learn that Google released a Japanese IME. IME is the sort of NLP problem that Google is nearly uniquely…

  • ghc llvm

    I read this thesis on an LLVM backend for GHC, primarily because I was curious to learn more about GHC internals. The thesis serves well as an…

  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.