Evan Martin (evan) wrote in evan_tech,
Evan Martin
evan
evan_tech

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.
Subscribe

  • memcache job offers

    I get occasional recruiter spam that specifically calls out "my work on memcached". This is pretty funny because all I did was make some trivial…

  • application stack

    "Put yourself in 1995. I'm going to tell the you of 1995 that in 2010, there will be a software platform with the following properties:" Luis Villa…

  • socks5 proxying flash via ssh

    Suppose you're in Germany and want to watch some Flash-based videos that are IP-limited to the US for whatever reason. At first you'd think you could…

  • Post a new comment

    Error

    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.
  • 4 comments