Live data from Hacker News

Show HN: HN Avatars in 357 bytes

news.ycombinator.com

101–110 of 536 posts

Re: Show HN: HN Avatars in 357 bytes

#101
post #43

This is fun. One suggestion.. rather than creating a canvas for each user using a querySelectorAll and a loop, I'd use an IntersectionObserver and only create the canvases as they scroll into view. That way the user's device won't need to create hundreds of elements when the code runs. let observer = new IntersectionObserver( (entries) => { entries.forEach((entry, i) => { if (entry.isIntersecting) { const p = 2; cons…

This is great, thanks. A small fix I made to stop console warnings was to change:

  x.fillStyle = '#' + ((r >> 8) & 0xffffff).toString(16).padStart(0, 6);
to:

  x.fillStyle = '#' + ((r >> 8) & 0xffffff).toString(16).padStart(6, '0');
as the pad target length is the first parameter of padStart.

Re: Show HN: HN Avatars in 357 bytes

#103

An unkown person asks you to inject code in your browser. Sorry folks, but this should be a red flag for all of you. I guess you all know enough about obfuscation to know that what you think the code does is not always what the code does. "But it has upvotes!" For all you know, the script could upvote this post.

It's running in a sandboxed environment(the web browser). The worst-case scenario is it gaining access to my HN account, and I don't really care that much about it.

It's not going to install a bootsector virus on my machine, or ransomware-encrypt all the data on my NAS. So the risk of anything important happening is small, and the same risk as visiting any website on the internet.

Re: Show HN: HN Avatars in 357 bytes

#104
post #38

Earlier quoted context omitted.

UTF-encode the maliscious snippet and disguise it as the regex pattern haha

Doesn't UTF-8 just give you the exact same letters, since it's already ASCII?

I think it was meant to be UTF-8 escape codes, as in \u0000 etc.

Re: Show HN: HN Avatars in 357 bytes

#108

Reply here if you just want to see how your username looks like, so we avoid noise and keep that Show HN on the top. comments are really interesting

I like the idea, hope someone makes a userscript. Edit: my yellow avatar was a bit hard to see, though

Re: Show HN: HN Avatars in 357 bytes

#109

Looks way better if you add style="image-rendering: pixelated;" to the canvas. Crisp edges on every display.

Yup, definitely second that. With that change I can definitely imagine this as a user option in the settings. Reading is so much easier.

(also wanted to see my avatar)

Post reply on HN