Live data from Hacker News

As much Stack Overflow as possible in 4096 bytes

danlec.com

51–60 of 77 posts

Re: As much Stack Overflow as possible in 4096 bytes

#51

First off, nice work. I've noticed that St4k is loading each thread using ajax, where-as stackoverflow actually opens a new 'page', reloading a lot of webrequests. Disclaimer I've got browser cache disabled. E.g on a thread click: St4k: GET https://api.stackexchange.com/2.2/questions/21840919 [HTTP/1.1 200 OK 212ms] 18:02:16.802 GET https://www.gravatar.com/avatar/dca03295d2e81708823c5bd62e75... [HTTP/1.1 200 OK 146m…

[deleted]

Re: As much Stack Overflow as possible in 4096 bytes

#52
post #12

Code is formatted in a serif font, instead of monospace, which seems like a rather important difference. Otherwise, it is quite impressive.

You most likely don't have Consolas, or Monaco then. That font family should have been Consolas,Monaco,monospace Rather then Consolas,Monaco,serif But what ever :)

Yep: but fixing breaks the 4096 barrier:

    $ curl -s http://danlec.com/st4k | gzip -cd | sed 's/serif/monospace/' | gzip -9c | wc
        14      94    4098

Re: As much Stack Overflow as possible in 4096 bytes

#55
post #2

Some of the workarounds he mentions at the end of his Trello in 4096 bytes[1] post seem really interesting: - I optimized for compression by doing things the same way everywhere; e.g. I always put the class attribute first in my tags - I wrote a utility that tried rearranging my CSS, in an attempt to find the ordering that was the most compressible [1] http://danlec.com/blog/trello-in-4096-bytes

It sounds like the goal was to reduce the entropy of the code as much as possible, to within whatever the windows of the algorithm were set to.

I've seen similar ideas in the demoscene 4k competition world, where code and music is arranged to have as many repeating self-similar patterns as possible so the executable compressors can shrink them optimally.

Re: As much Stack Overflow as possible in 4096 bytes

#56
>"I threw DRY out the window, and instead went with RYRYRY. Turns out just saying the same things over and over compresses better than making reusable functions"

I would love to investigate this further. I've always had a suspicion that the aim to make everything reusable for the sake of bite size actually has the opposite effect, as you have to start writing in support and handling tons of edge cases as well, not to mention you now have to write unit test so anyone who consumes your work isn't burned by a refactor. Obviously, there's a place for things like underscore, jquery, and boilerplate code like Backbone, but bringing enterprise-level extensibility to client code is probably mostly a bad thing.

Re: As much Stack Overflow as possible in 4096 bytes

#57
Looks broken on my Android mobile, but seriously this is incredible!

Wonder how we can unobfuscate the source. It would be great if there is a readable version of the source as well, just like we have in Obfuscated C Code Contests. Or perhaps, some way to use the Chrome inspector for this.

Re: As much Stack Overflow as possible in 4096 bytes

#58
Very very awesome.

I'd take some trade-off between between crazy optimization and maintainability, but I'd definitely rather do this than slap on any number of frameworks because they are the new 'standard'.

Of course, the guy who has to maintain my code usually ends up crying like a little girl.

Re: As much Stack Overflow as possible in 4096 bytes

#59
post #57

Looks broken on my Android mobile, but seriously this is incredible! Wonder how we can unobfuscate the source. It would be great if there is a readable version of the source as well, just like we have in Obfuscated C Code Contests. Or perhaps, some way to use the Chrome inspector for this.

Using HTML prettify on the source is a start at least:

https://github.com/victorporof/Sublime-HTMLPrettify

Re: As much Stack Overflow as possible in 4096 bytes

#60
post #5

Earlier quoted context omitted.

> - I optimized for compression by doing things the same way everywhere; e.g. I always put the class attribute first in my tags Compression algorithms can do a better job when they're domain-aware. An HTML-aware algorithm could compress HTML much better than a general-use plain-text compression algorithm, without requiring the user to do things like put the class attribute first. Of course, that also requires the de…

> that also requires the decompression algorithm to be similarly aware, which can be a problem if you're distributing the compressed bits widely. Well not necessarily... An HTML-aware algorithm could for example rearrange attributes in the same order everywhere because it knows it doesn't matter . Actually that would be a nice addition to the HTML "compressors" out there.

I actually do just that with a pre-processor on my site, it's only a single line of ruby with a regex, a split, a sort and a join.

The reason for doing it wasn't so much the compression benefit but some of the nanoc code that generates the site did not always order the tags the same way and then it had to rsync up more than it needed to

Post reply on HN