Hacker News new | past | comments | ask | show | jobs | submit login
World (aem1k.com)
918 points by bpierre on Sept 15, 2013 | hide | past | web | favorite | 96 comments

Here this is, formatted so it is more readable.

  p = "<" + "pre>";
  for (y in n = "zw24l6k\
  4e3t4jn`t4qj24xh2 x42kty24wrt413n243n\
  9h243pdxt41csb yz43iyb6k43pk7243nm\
  r24".split(4)) {
    for (a in t = parseInt(n[y], 36) + (e = x = r = []))
      for (r = !r, i = 0; t[a] > i; i += .05) 
        with(Math) x -= .05, 0 > cos(o = new Date / 1e3 + x / PI) && (e[~~(32 * sin(o) * sin(.5 + y / 7)) + 60] = -~r);
    for (x = 0; 122 > x;)
      p += "   *#" [e[x++] + e[x++]] || (S = ("eval" + "(z=\'" + z.split(B = "\\\\").join(B + B).split(Q = "\'").join(B + Q ) + Q + ")//m1k")[x / 2 + 61 * y - 1]).fontcolor /\\w/.test(S) && "#03B");
    document.body.innerHTML = p += B + "\\n"
* Edited for formatting

Personally, I find your comment less readable than TFA.

Whoops, I used backticks instead of spaces to mark it as code.

Tickmarks don't work here, you need to indent by two spaces.


with :(

Reminds me of the old 1992 winner of the IOCCC by Brian Westley (who consistently entered some of the most impressive programs in that contest). It doesn't spin, but it prints a map of the provided lat/long.


     H E L L O,    W O R L D! "

There is another program arranged in a similar circular shape that calculated pi experimentally using it's own source code as the circle to test.

Found it here http://www.cise.ufl.edu/~manuel/obfuscate/pi.c That's awesome.

There's a lot of talk about scalable code floating around, but it's rare to see anything as scalable as this code. Do you want more precision in your pi approximation? Then you literally scale the code up. There's few people who can truly claim to have written scalable code like that.

Speaking of "scalable code", there is another interesting obfuscated piece of code that can scale itself. akari.c[1] is an obfuscated ASCII art downsampler.

The neat thing is that the program itself is ASCII art, and downscaling the program source code will generate valid programs for 3 iterations![2]

[1] http://www.ioccc.org/2011/akari/akari.c [2] http://www.ioccc.org/2011/akari/hint.html

Yup--that's a great one. And it too is by Brian Westley...

*its own

That was a wonderful experience of multiple moments of realization. "Oh, it's an ascii globe; it looks like it just scrolls a map through the circle. No wait, it's warping as it shifts across. Wait, is it using asterisks for antialiasing? What is all of this stuff around the outsi- ... oh. Oh."

It's spinning in the wrong direction!

Reminds me of the episode of the Daily Show where Neil deGrasse Tyson informs Jon Stewart that the Earth is spinning in the wrong direction in the opening credits of the show


nice work. how did you know? For anyone wondering the difference, 0>cos on line 8 is now 0<cos.

Almost any kind of rotation in 2D or 3D graphics involves cos or sin. The spinning was going the wrong way, therefore the way to reverse it was to reverse something involving cos or sin. You can then just bruteforce it by reversing each cos until you get the effect you want. (If reversing cos seems to reverse something "perpendicular" to what you want, then you'd need to reverse the sin instead, not the cos.)

This is true in almost any context involving 2D/3D graphics, not just for this particular example. It's much more efficient than trying to sit there and think through the math or figure out what does what. But of course you learn less that way, so it's a tradeoff. And sometimes it's less efficient if there are too many combinations to efficiently bruteforce, or if it takes too long to test each iteration. But we live in the age of rapid-iteration javascript.

I'd also note that in a point on the unit circle, cosine is the x coordinate and sine is the y coordinate. A good reason to try flipping a cosine first. See this: http://en.wikipedia.org/wiki/File:Unit_circle.svg

(I still remember how people would describe trig in high school, it is a wonder more teachers didn't explain the cos = x, sin = y thing. Probably because my teachers did not understand math.)

My teachers did explain it that way. European school, if that matters.

My experience with math education in the US is that they approach it as unapproachable. It is supposed to be some sort of magic, that only limited practitioners may understand, and even then only after an incredibly slow introduction. People teaching it are usually unqualified. Then if you're like me, when you get to college you get exposed to a lot better, then you wonder what those k-12 people were thinking. But a lot of people don't make it that far, because their earlier experience makes them think math is uninteresting or they'll never be any good at it.

Note that my experience involved going to a supposedly "good" school district. There is the entirely unrelated problem of schools varying in quality based on where you live.

European school, if that matters.

Heh. Yeah, that matters.

In my experience, US highschools are very much "Okay class, today we're going to memorize these formulas."

I don't think its that easy, it depends more on the specific school and most of all on the teacher. For the record: I also had to memorize it and i went to an "european" school, or rather to an austrian one. Europe still has a wide variety of education systems.

Same with the US. Very variable.

We went through the unit circle derivation in the 8th grade and were thus showed why cos is conventionally x and sin conventionally y.

and not all systems are uniform. I went to high school in Italy and changed something like 4math teachers.

One of them explained the x/y thing, another didn't.

Couldn't help reading 'ok glass we're going to memorize these formulas'. Ahh, the future.

My highschool teachers didn't (European school, too). I found it by myself one or two years later (I hated trig in the meantime) and was very proud of my achievement. Then I went to university where all the teachers were treating it like a natural thing, and that was my first glimpse of adulthood -- I started realizing I was really stupid.

Same here, but in Australia. Unit circles made trig "click" for me (and a whole heap of other concepts... a very versatile abstraction that one).

It's spinning in the right direction if you're a satellite in a mid-altitude equatorial orbit.

Thanks for telling me! It is fixed now.

Damnit, it's fixed. I was freaking out that I had it wrong all along and then after rotating my fist a couple of time I was still damn certain it's moving correct. Parent should probably edit the comment that it has now been fixed.

Maybe it was coded on board the ISS.

This is one of the most beautiful pieces of art I've ever seen!

... and the top comment is typical negative nitpicking!

Why HN? Why?! There must be a better way!

Why do we keep calling it "typical negative nitpicking"? How about calling it "feedback"? Or maybe even "the most useful type of feedback"?

We're encouraged here to post things that add value. But that pretty much implies either criticism or going off-topic ("hey, I've seen something similar here:", etc.). There is no practical value in "positive" comments, no matter how elaborately you can write "I liked it". Yes, it will make everyone feel a little bit better, but it hardly contributes anything of value to anyone.

Not every criticism is a valuable feedback, but every valuable feedback is a kind of criticism. And I think the best thing about HN is that it has lots of civil nitpicking (usually followed by interesting discussions), instead of circle jerks and compliments.


> Why HN? Why?! There must be a better way!

There is: it's to stop taking criticism so personally and instead extract as much value from it as one can, and discard the rest. I find it to be a good attitude for life in general, not just HN.

I agree with much of what you said - there is significant value in negative feedback.

But here is where I disagree:

>... but it hardly contributes anything of value to anyone...

>... every valuable feedback is a kind of criticism...

Valuable feedback includes positive as well as negative. Negative is actionable feedback, but positive has just as much value in a different way.

Most people are aware that their own perceptions, thoughts, and ideas may be flawed. Negative feedback points out those flaws and should always be accepted. Positive feedback says that in spite of the flaws, there is something fundamentally worthwhile there.

And while upvotes can certainly serve as a form of positive feedback, words are even better.

I'm not suggesting that we should all post meaningless words of encouragement to everything that comes along. But if you're impressed by something you see, saying so only helps.

> Negative is actionable feedback, but positive has just as much value in a different way.

I guess "actionable feedback" was the phrase I was looking for.

> I'm not suggesting that we should all post meaningless words of encouragement to everything that comes along. But if you're impressed by something you see, saying so only helps.

Agree 100%. It's always nice and reassuring to get some positive feedback :).

Truly valuable "feedback" would be a discussion of the actual code used to create this. That's a far cry from the easy, low-hanging fruit of "it's spinning the wrong way". Totally missing the forest for the trees.

Because it's spinning in the wrong direction.

and why do you call this art. I think that's misusing the term. it's a data visualization.

Wha? This is not visualizing any data in particular.

It's an astonishingly clever piece of self-reproducing code. Did you miss the code and think it was just a crappy animation of the earth?

More semantic nitpicking, should be obvious by now it's epidemic here.

It's spinning in the right direction. We're just inside the earth :).

I'm not sure what you mean by this,'coz movement is relative.

Movement is relative.

Only inertial movement. Turning is still absolute. (At least in special relativity.)

While rotation spoils an inertial reference frame, this certainly could be a representation of the view of the earth while from a typical (i.e. easterly) orbit. Short of adding an ASCII accelerometer or the like, there's no test you can do on it to demonstrate otherwise. The GP doesn't deserve downvotes any more than the other glib replies above.

That's true :)


What I'd love to see is a step by step description of how this was constructed. If I have an end goal in mind, it's simple enough to hammer some characters into something a machine can use to do that end goal while still being readable by a human. But this? It floors me, and I can't even imagine where to start. I can understand the code with a bit of thought, but getting from an empty text editor to that seems beyond me.

He gave this step by step presentation at JSConf.eu today. It was really well done... I could almost follow!

I hear there will be video in a couple weeks.

Inspired by "The Qlobe", written in Ruby http://mamememo.blogspot.de/2010/09/qlobe.html

Hmm, that one says, "Copyright(C).Yusuke Endoh, 2010"

The author of this one apparently forgot to give credit.

Doesn't look like the code is that similar. Doesn't look like copyright has anything to do with it. Does Endoh have a patent? That would of course be a different matter.

I'm not alleging a law was broken -- just that the author should have given credit for inspiration.

The author did give credit for the original in his presentation.

Huh? Where?

I saw something similar in perl years ago. I can't seem to locate it now though so maybe I'm imagining things.

aside from the implementation being completely different and therefore not in violation of copyright, it would be difficult to give credit for something like this where every character is strategically placed.

How about in the bottom corner of the screen? Or in the parent directory, where there's a listing of all the demos?

He has actually given credit on Twitter - https://twitter.com/aemkei/status/379310104409296896

It looks to be a different implementation.

If you look closely you'll see that there's a parallax effect, where the lines near the equator move faster than the lines at the top, giving it a sense of depth and motion that you wouldn't expect from any ASCII art animation.

This was brilliant, just absolutely fantastic.

Saw the talk by Martin at JSConf.eu today explaining how he did it. Just brilliant! http://2013.jsconf.eu/speakers/martin-kleppe-1024-seconds-of...

I have to remember to check their YouTube channel for the talk!

If anyone finds the video, post it here please!

Can someone explain this really simply for me?

I understand that the whole thing is actual source and its manipulating the center commented area. But I am having trouble following the code.

> Can someone explain this really simply for me?

Imagine that you had to write it yourself.

First, you would create some strings approximately representing latitudes on Earth and their associated land masses -- one string for maybe 10-20 degrees of latitude, from some southerly latitude to a northerly one.

Nest, you would figure out a way to print substrings of the strings, at specific points within the strings that you would choose.

Next, you would arrange that the substring printer would wrap around to the beginning of the string in the event that it was asked to print a greater length than the remaining characters available from the specific starting point to the end. By wrapping around, you create the illusion of a circle of characters, like on a globe.

Next, you would think of a way to write into a specially formatted executable text file having a roughly circular central section that is commented out, i.e. not executable.

Next, you would arrange that the specially formatted text file be the running program, and the central comment area represent the display of the earth.

Next, just to blow minds, you would print the current form of the program text file on the console, after each animation cycle filled the comment area.

Finally, you would create the illusion that the earth is rotating clockwise as seen from the north pole (the opposite of reality) just to provoke people who know a bit of astronomy.

This is the first animated quine I've ever seen. It may be a first.

More on quines: http://en.wikipedia.org/wiki/Quine_(computing)

My jaw literally dropped, I had to check the source to make sure this was just it... Really impressive. I love these kind of works of art

A heavily refactored version of this code, for those curious how it works:


(note that it will not work like the original and make a pretty globe, because it's dependent on the exact character positioning)

I see Perl's fashion of poetic source code is being replaced by JS's fashion of animated source code! 8-)

My first thought was that's kinda cool.

Then I viewed the source. Amazing.

Amazing stuff. One quibble; There's a XXXXX in the middle of the South Pacific, midway between Australia and Chile. Whatever it is supposed to be, it's way too big.

Kudos, this is amazing.

Wow, it even works in Opera Mini!

Someone should make a version that spins in real time :O

View the source code for that. Just don't look at it for too long.

Inspecting the elements in chrome wont let me open the any of the code. Once you get past the body tags the <pre> tags just keep on flashing.

Go to the Sources tab and click the || button to pause javascript. If you're wondering where the code is, just curl the URL :) (or, with Web Inspector open, refresh the page, go to the Network tab and select the only request.

You can just look at the source (Ctrl+Alt+U in Chrome). It's an HTML document with a single script tag in it.

Just Ctrl+U

That's adorable but I wouldn't have bothered clicking if I had known what it was from the title.

Take another look. It's not just an ASCII animation; it's the source code that produces the animation.

There's a bunch of these globe animations already. But always nice. ;)

You made me eval() ... Don't be eval.

Excellent piece of code though!

Making the code look like the output!! Super cool.

You chopped off the Indian subcontinent

it's not an accurate map, showing north america as the same size as Africa :)

aemkei delivered an awesome presentation yesterday at JSConf EU.

This was his final slide.

Can someone explain this?

View the source. Usually there would be a separate script that creates the animation.

In this case, the page is the source. The animation and page are one with the source.

It's magic, not science.

Is the UK on the map?

it hypnotized me to upvote!

Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact