News for hackers. Stuff that matters.
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by stcredzero on Friday December 31, 2010 @12:44PM (#2055898)
Perhaps this could be a good start for another coding contest: The most inefficient webpage.

The object: take a copy of the Google search page and represent it in the most inefficient, bloated way possible. There would be two divisions: time-bloat and space-bloat.

Rules: Every piece of code must be involved in displaying something visibly on the page. Every statement in the Javascript must be making forward progress toward displaying the page.

The functionality of the page must be exactly the same as the original.

Any other rules?

(There wouldn't be any loading and waiting on external resources, of course.)

Re:Show HN: I wrote a script to turn a webpage into bitmap H... by viraptor on Friday December 31, 2010 @01:02PM (#2055944)
Calculate `h=SHA256(original_page)` and `n=len(original_page)`.

    do
      page = gen_random_bytes(n)
    while (h != SHA256(page))
    print page
It can be even generated client-side!
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by wwortiz on Friday December 31, 2010 @01:23PM (#2055993)
Can't the same hash mean different data?
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by viraptor on Friday December 31, 2010 @02:52PM (#2056268)
Well, sure. But if you add another check for likelihood that `page` is fairly-correct html in utf8, there should be around one correct result really :) If you get 2, the other one is probably a <form> you can use to sell your soul to satan - do not hit submit if you get it.
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by stcredzero on Friday December 31, 2010 @08:28PM (#2056996)
The problem with this, is that the random bytes in one iteration of the loop might be closer to the page than the next iteration, so there would be reverse progress in that instance. This entry would be disqualified.
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by meric on Friday December 31, 2010 @10:37PM (#2057156)

    page_bytes = bytes(size_of(bytes_of(page)))
    do
      page_bytes += 1
    while (page_bytes != bytes_of(page))
    print page
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by roadnottaken on Friday December 31, 2010 @02:54PM (#2056280)
This is cool, but when I first clicked it I thought it was transforming my current webpage into HTML/bitmap somehow. I was amazed. Then I realized it's a statically generated page. If you could make this into a bookmarklet that transformed the current page, then I'd be REALLY impressed. :)
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by proexploit on Friday December 31, 2010 @02:08PM (#2056119)
Then turn it back into HTML with an experiment of mine: https://github.com/andershaig/img-con - It takes an image, writes a span with a background-color for each pixel. Turns a 100x100 image into a 7 MB HTML file.
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by elliottkember on Friday December 31, 2010 @02:31PM (#2056197)
Uh - that's exactly what this script does!
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by proexploit on Friday December 31, 2010 @03:03PM (#2056296)
You're right and I should have paid more attention. I had thought you were generating just the image from a web page. Having actually worked on something similar, I can say I'm very very impressed with the load time.
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by elliottkember on Friday December 31, 2010 @04:41PM (#2056533)
Probably mostly the Gzip - the code is very repetitive. The RLE helps too.
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by wzdd on Friday December 31, 2010 @12:47PM (#2055905)
Bonus points for apparently using RLE for same-colour runs of pixels. :)
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by elliottkember on Friday December 31, 2010 @01:09PM (#2055964)
Thanks! I did it without first, but it was way too big and crashed the browser.
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by StavrosK on Friday December 31, 2010 @12:12PM (#2055819)
Oh, the humanity. Why would you do this (apart from "Because I can")?
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by viraptor on Friday December 31, 2010 @12:48PM (#2055908)
Finally a pixel-perfect display on any browser! With no-license font embedding.
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by aj700 on Saturday January 01, 2011 @12:29AM (#2057280)
I laughed.

But, there's another way - use a damn scripted gif or png</obvious>

...or for monochrome pages, is an xbm smaller?

update: oh yeah, i forgot, xbm files are C, though I suppose you could meta script them with more C.

people who really dont want their text stolen are going to see the massive bandwidth we have now and start just using images. protects it from anything but ocr.

Re:Show HN: I wrote a script to turn a webpage into bitmap H... by elliottkember on Saturday January 01, 2011 @06:21AM (#2057505)
Wolfram Alpha does this. I think it helps with writing formulae.
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by ronnier on Friday December 31, 2010 @01:06PM (#2055951)
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by darrenkopp on Friday December 31, 2010 @04:30PM (#2056515)
and all of the sudden, the new years clock done in sql seems useful.

hope you don't go over your bandwidth quota ;)

Re:Show HN: I wrote a script to turn a webpage into bitmap H... by ph0rque on Friday December 31, 2010 @04:36PM (#2056526)
I think it's to early to call this a startup... you need to think about your potential revenue sources. ;~)
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by biot on Friday December 31, 2010 @08:30PM (#2056999)
Bandwidth deals? :)
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by flawawa2 on Friday December 31, 2010 @11:59AM (#2055783)
If you are just looking to make a self-contained file that has the page as image, I would suggest you simply embed the image as base64.

I made a bitmap -> <table> once, that was pure hell like this. ;-)

Re:Show HN: I wrote a script to turn a webpage into bitmap H... by zbanks on Friday December 31, 2010 @01:43PM (#2056055)
Why didn't we think of doing this before we had Canvas!

...oh that's why.

Re:Show HN: I wrote a script to turn a webpage into bitmap H... by jcapote on Friday December 31, 2010 @04:03PM (#2056453)
Nice! this reminds of a script I wrote that turned images into svg: https://gist.github.com/761332
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by EGreg on Friday December 31, 2010 @11:36AM (#2055726)
how?
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by citricsquid on Friday December 31, 2010 @12:15PM (#2055829)
I would assume he takes a screenshot of the page (xbrow.se is one utility for it) and then picks the colour from each point and displays it... quite simple to do, why is probably a better question :p
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by EGreg on Friday December 31, 2010 @12:32PM (#2055869)
I thought he said he does it with javascript!
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by citricsquid on Friday December 31, 2010 @01:02PM (#2055945)
I just looked via Twitter and found he has posted it on Github, seems I was right: https://github.com/elliottkember/img2html.rb
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by emilsedgh on Friday December 31, 2010 @07:05PM (#2056834)
And you'd be amazed to know that khtml (KDE's rendering engine, used by Konqueror) renders it instantly!
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by templaedhel on Saturday January 01, 2011 @01:57AM (#2057334)
Now if only links worked. Then you would have created a modern image mapping service. I like it.
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by slouch on Friday December 31, 2010 @01:28PM (#2056011)
this week, i've been converting HTML output into PNG images. i used the preview feature of an HTML to PDF dll we have lying around.
Re:Show HN: I wrote a script to turn a webpage into bitmap H... by aj700 on Saturday January 01, 2011 @12:28AM (#2057277)
basically doesn't get rendered at all in ie9. big surprise.