Live data from Hacker News

Show HN: URL Snake

github.com

11–20 of 36 posts

Re: Show HN: URL Snake

#11

Edit: I've actually managed to get the javascript down to a measly 859 bytes now. Pretty happy with some of the code golfing techniques I came up with

You should be able to change e.addEventListener("keyup"... to e.onkeyup=... but I haven't tested it.

Ooh! Don't know how I missed that, I'll give it a go! Cheers!

Re: Show HN: URL Snake

#12
Here is one I did a while ago, this is the colored version (so not the smallest) Still under 1024bits which was my goal

Y=200;P='o';J=' ';N=15;C='#';E='+';m=[];X=C.repeat(N+2);for(T in X)m[T]=C+J.repeat(N)+C;m[0]=m[0].slice(0,-2)+E+C;m.unshift(X);m.push(X);function s(a,b,c){return a.substring(0,b)+c+a.substring(b+1)}function f(){e=setInterval(function w(){if(!z){R=p.length-1;if(h=p[R][0],j=p[R][1],h=1==d?h-1:h,h=-1==d?h+1:h,j=2==d?j-1:j,j=-2==d?j+1:j,p.push([h,j]),g=p.length-1,l=m[h][j],r){if(J!=l)if(E==l){x=y=0;for(t++,k=1;J!=m[x][y];)with(Math)x=~~(random()N+2),y=~~(random()N+2);m[x]=s(m[x],y,E);Y-=5}else z=1,P='x';!k&&t

Re: Show HN: URL Snake

#14
post #13

If you want to make clickable links with this code, you can use URL Pages. https://github.com/jstrieb/urlpages It's a small JavaScript application to store entire web pages in URLs. I made it after learning that links with data URLs are no longer clickable.

Shameless plug: my (free, ad-free) side project does this too: https://codewich.com

Re: Show HN: URL Snake

#16
post #2

HN doesn't linkify data: URLs data:text/html;charset=utf-8,%3Cbody%3E%3Cscript%3Eeval(atob(%22bGV0IGU9ZG9jdW1lbnQsdD1lLmJvZHkscj1NYXRoLGw9J1ByZXNzIHNwYWNlIHRvIHN0YXJ0L3BhdXNlL3Jlc2V0LCBhcnJvdyBrZXlzIHRvIG1vdmU8YnI+PGJyPjxjYW52YXMgaWQ9ImEiPjxzdHlsZT5jYW52YXN7Ym9yZGVyOiAxcHggc29saWQgYmxhY2s7fWJvZHl7YmFja2dyb3VuZDojY2NjO308L3N0eWxlPicsaT00MCxvPTQwMCxuPW8scz0wLGY9MSxkPTAsYz0xLGg9MCxwPVtbMywzXSxbNCwzXSxbNSwzXV0sdT1wLHk9Wz…

https://news.ycombinator.com/formatdoc says that between angles it should work, but it does not. Or i don't know how to use it, it doesn't seem to do anything.

Re: Show HN: URL Snake

#17

And ChatGPT can tell that it's a game of Snake from the URL. https://www.tiktok.com/@y.i.t.z.i/video/7186055378977803521 "When decoded, the script appears to be a Snake game implemented using JavaScript and the HTML5 canvas element. The script creates an HTML page with a canvas element and adds event listeners for arrow keys and space bar to control the game."

Wow that's impressive. Is ChatGPT updating its model fast enough that this repo could have been included or is it really figuring out what this is from the code itself?

Re: Show HN: URL Snake

#19

And ChatGPT can tell that it's a game of Snake from the URL. https://www.tiktok.com/@y.i.t.z.i/video/7186055378977803521 "When decoded, the script appears to be a Snake game implemented using JavaScript and the HTML5 canvas element. The script creates an HTML page with a canvas element and adds event listeners for arrow keys and space bar to control the game."

Wow that's impressive. Is ChatGPT updating its model fast enough that this repo could have been included or is it really figuring out what this is from the code itself?

ChatGPT had it's last update on 15th Dec 2022, but the main scrape of the web for training data was ~2020.

Try asking it about someone famous from 2021 and it usually doesn't know.

Re: Show HN: URL Snake

#20

And ChatGPT can tell that it's a game of Snake from the URL. https://www.tiktok.com/@y.i.t.z.i/video/7186055378977803521 "When decoded, the script appears to be a Snake game implemented using JavaScript and the HTML5 canvas element. The script creates an HTML page with a canvas element and adds event listeners for arrow keys and space bar to control the game."

Wow, that's actually impressive. Any idea how chat gpt would know that? Surely it's not making the request for it and surely it's not actually decoding any base64 right?

You'd be right a good chunk of the time if you said it was a snake game just by seeing that it was a data URL and had the word 'canvas' in.
Post reply on HN