
Snake in a QR Code - phit_
https://itsmattkc.com/etc/snakeqr/
======
skrebbel
If you want to see a variation of this concept in the wild, in active use by
lots of people, check out PICO-8 cartidges.

PICO-8 is a virtual game console. I.e. it's an emulator for an oldschool game
console that doesn't exist in reality. It's designed to be easy to code for
while maintaining the limits and aesthetics of old game computers

PICO-8 games are, of course, distributed on cartridges. However because it's a
virtual console, the cartridges are virtual too: they're PNG files.

Try browsing PICO-8 games here:
[https://www.lexaloffle.com/bbs/?sub=2&cat=7](https://www.lexaloffle.com/bbs/?sub=2&cat=7)

Press the play button the play a game right inside the web browser, but be
sure to click the little "Cart" link right below the playing area to see
what's going on. You'll see it open a little PNG file.

That PNG file _is_ the cartridge. It contains the entire game.

The file format is explained here:
[https://pico-8.fandom.com/wiki/P8PNGFileFormat](https://pico-8.fandom.com/wiki/P8PNGFileFormat).
Obviously, because PICO-8 carts are purely digital, the format doesn't need
any of the contrast, the error correction features or the orientation markers
that QR-codes have. You can't take a picture of a cart with your phone and
play it. You need the exact same, byte-for-byte PNG file. But it's still super
cool.

~~~
muxator
This is the coolest thing in ages. The game's code is steganographically
embedded in a PNG image containing the screenshot of the game! Wow

~~~
read_if_gay_
Steganography is cooler for sure, but can't PNGs already store arbitrary data
in the header? IIRC, the game Spore did that so you can exchange creatures by
sending images.

~~~
nacs
I think the issue with that is that many image hosting sites optimize their
images or at the least strip unnecessary data and EXIFs.

So at any point while being copied from person to person, that game data could
be lost.

------
rob74
Cool, so all the 1k demos/intros from Assembly
([https://archive.assembly.org/2019/1k-intro](https://archive.assembly.org/2019/1k-intro))
could also be distributed via QR code... the 4k intros unfortunately not.
Maybe it's time for a new category ;)

~~~
banana_giraffe
Or a QR-code paging system.

(I feel a little evil for even suggesting that)

~~~
J5892
The most interesting applications I've seen of QR-codes have been the most
wildly impractical or useless.

When I still used my Pebble watch, my favorite watch face was just a QR-code
of the time. So to tell what time it is, you have to scan your watch with your
phone.

~~~
banana_giraffe
I love that idea. I couldn't resist mocking one up in Python:

[https://pastebin.com/erFSAUvH](https://pastebin.com/erFSAUvH)

~~~
J5892
I love that it updates every second. It makes it that much harder to actually
use.

------
gitgud
I wonder if _snake_ could fit in a data uri, like this:

[https://bytex64.net/code/datasnake/](https://bytex64.net/code/datasnake/)

~~~
paulpauper
that is amazing

------
Taniwha
I crossed my eyes and stared for ages, still could not see the snake, I hate
these magic eye things

------
MStrehovsky
Here's another Snake game that can fit in a QR code, this one written in C#:
[https://twitter.com/MStrehovsky/status/1214955696556515331](https://twitter.com/MStrehovsky/status/1214955696556515331)

(It doesn't need a .NET runtime; it's fully self-contained and runs on Windows
as a native app.)

------
kevincox
I wish more QR-scanners supported data URLs. I think it would be very cool to
distribute tiny web-apps via QR code.

~~~
toyg
Yeah, let’s make it even easier for people to run random executables that
cannot be vetted, preferably on devices tightly coupled to their identities.
What could go wrong?

~~~
read_if_gay_
Smartphones are locked down pretty tightly, so I'm not sure how much could
actually go wrong compared to what can go wrong with regular apps anway.

~~~
ant6n
Well regular apps are vetted.

------
squid_demon
Don't worry. There is no malicious code contained within this QR code!

~~~
Shared404
That's what I thought about as soon as I read this. Seems like a great malware
installation vector.

Just print out stickers and put them up at restaurants, stores...

~~~
avree
For which 99.99999% of users will be using mobile clients to scan the QR code
that have no capability of executing the code...

~~~
pugworthy
Yes, embedding a Windows app is essentially pointless for mobile users, but
there are many other delivery vectors available from QR codes.

There are some interesting approaches listed at [https://news.sophos.com/en-
us/2019/10/17/beware-the-square-h...](https://news.sophos.com/en-
us/2019/10/17/beware-the-square-how-to-spot-malicious-qr-codes/)

------
outadoc
Too bad virtually no one will flash it using a Windows device.

------
bovermyer
Might be interesting to print this on business cards and distribute at
conventions or something like that.

~~~
fyfy18
"Please run this binary from my business card". I guess it's easier than
leaving USB drives in the parking lot...

~~~
z3t4
You could run it in a VM.

~~~
pugworthy
YOU could perhaps, but your average target hasn't much of a clue what a VM is,
let alone how to set one up.

And keep in mind, malicious software is going to be challenging, and there are
much more clever ways to use QR codes.

E.g., imagine some store that has QR codes on the product aisles to access
information on a product via a URL. I make a fake website that spoofs the
legit product page, but offers the user a special "Buy online and save 25%"
offer, which of course they are very tempted by due to the steep discount.

------
aarondf
If you want to play snake in Excel, you can do that too!

[https://aaronfrancis.com/2013/remaking-cellphone-snake-in-
mi...](https://aaronfrancis.com/2013/remaking-cellphone-snake-in-microsoft-
excel)

------
fiatjaf
I'm still waiting for someone to make an app that encodes and decodes large
data into multiple QR codes that are displayed in a moving sequence.

That would be the best way to transfer files in physical locations.

~~~
memco
Apple has something like this for their new iOS device setup. I don’t think
it’s to encode larger amounts of data, but for security they have this circle
that constantly changes shape (see around 0:50 in this video for a demo:
[https://youtu.be/iE03ypWD5xs](https://youtu.be/iE03ypWD5xs)). I don’t know
for sure how it works, but my first thought was a constantly changing QR-like
code.

~~~
xav0989
Someone asked a very similar question on the apple stack exchange[1]. Apple
also filed (at least) two patents on the technology[2][3].

[1]: [https://apple.stackexchange.com/questions/301563/what-is-
the...](https://apple.stackexchange.com/questions/301563/what-is-the-
technology-used-in-ios-11-settings-migration-moving-blue-dots-par)

[2]: [http://patft.uspto.gov/netacgi/nph-
Parser?Sect1=PTO2&Sect2=H...](http://patft.uspto.gov/netacgi/nph-
Parser?Sect1=PTO2&Sect2=HITOFF&u=%2Fnetahtml%2FPTO%2Fsearch-
adv.htm&r=2&p=1&f=G&l=50&d=PTXT&S1=\(235%2F469.CCLS.%20AND%2020150505.PD.\)&OS=ccl/235/469%20and%20isd/5/5/2015&RS=\(CCL/235/469%20AND%20ISD/20150505\))

[3]: [http://patft.uspto.gov/netacgi/nph-
Parser?Sect1=PTO2&Sect2=H...](http://patft.uspto.gov/netacgi/nph-
Parser?Sect1=PTO2&Sect2=HITOFF&u=%2Fnetahtml%2FPTO%2Fsearch-
adv.htm&r=1&p=1&f=G&l=50&d=PTXT&S1=\(235%2F469.CCLS.%20AND%2020150505.PD.\)&OS=ccl/235/469%20and%20isd/5/5/2015&RS=\(CCL/235/469%20AND%20ISD/20150505\))

------
ariasemi
Really cool!

He also made a video about it:
[https://www.youtube.com/watch?v=ExwqNreocpg](https://www.youtube.com/watch?v=ExwqNreocpg)

------
pxi
It's a cool idea. Here's another one; a Mira fractal generator in SmallBASIC:

[https://smallbasic.github.io/images/screenshots/mira.bas.png](https://smallbasic.github.io/images/screenshots/mira.bas.png)

------
brassattax
I was looking for the snake in the QR code itself (and found it!) before
reading the article

~~~
codetrotter
Wait, you found a snake? I am confused. Anyways, I too looked for it at first
because I expected the game to be visually embedded in the QR code as well. I
was a little disappointed that it was not the case. Imagine a game embedded in
the QR code that when you load it, either directly is able to reconstruct the
QR visual itself, so like some sort of quine
[https://en.m.wikipedia.org/wiki/Quine_(computing)](https://en.m.wikipedia.org/wiki/Quine_\(computing\))
but with the visual QR being considered the “source” kind of in this case and
the thing bring output. Or weaker but still cool if the game uses the camera
to load a QR and then you play on it.

~~~
codetrotter
Thinking about it a bit more it could be like the PICO-8 mentioned elsewhere
ITT but instead of a PNG the QR fantasy console would work by loading programs
from QR and initializing the display with the QR visual itself and then the
code from the QR is exectuted and is able to access the “video memory” to read
in the starting state and then you can play a game where you consume the QR
visuals for example with snake. Probably needs to make the snake colored so
that you can tell eatable QR visuals apart from your snake. Other games
include Breakout and perhaps Pong. Frogger. Etc etc

------
tgsovlerkhgsel
The HTML5 version converted to a data URL would be a more accessible demo than
a windows executable I think, especially if it supported mobile input.

Unfortunately, scanning large QR codes doesn't seem to work too well in
practice :(

------
agumonkey
a new vector emerges

~~~
devy
I was thinking about the same thing! Although the original QR code spec did
allow binary payloads[1], smartphones and cameras weren't ubiquitous in mid
90s. But they are now. Transmitting computer virus or malware within the QR
code binary payload might just be as easy as pointing your camera lens to the
QR code. Since the QR code image is only machine readable not human readable,
it would be indistinguishable, neither any digital signature to prevent it
from being altered.

[1]:
[https://en.wikipedia.org/wiki/QR_code#Storage](https://en.wikipedia.org/wiki/QR_code#Storage)

------
captn3m0
Am I the only one who thought this would be a game with the roaming around
inside a QR code?

~~~
strikelaserclaw
nah, i also thought the same

------
qwertox
Initially I was looking at the QR-code and thinking about punchcards, code
golf and javascript, but reading that it contains a Windows executable was a
surprise.

------
inlined
Am I the only one unwilling to run a non-sandboxed process I found on a tech
demo?

~~~
athorax
especially with the included disclaimer

    
    
      ...slightly larger than the executable shown in the video because I decided to add a little more functionality

