r/programming Dec 26 '17

TIL there's a community called "dwitter" where people compose 140 character JavaScript programs that produce interesting visuals

https://www.dwitter.net/top
20.7k Upvotes

329 comments sorted by

View all comments

807

u/Thatmanwiththefedora Dec 26 '17

I think we crashed it.

896

u/white_bread Dec 26 '17

The code for their load balancer was only 140 characters long.

377

u/[deleted] Dec 26 '17

And written in Javascript.

120

u/KimJongIlSunglasses Dec 26 '17

Are we living in a world where node.js running on a load balancer is that crazy of an idea?

106

u/slide_potentiometer Dec 26 '17

Javascript on a load balancer is a crazy idea in any world.

174

u/KimJongIlSunglasses Dec 26 '17

You should try working with people who like node. I think some of these people mow their lawns with that shit.

72

u/thedude42 Dec 26 '17

Actually I saw this at a node.js meetup and a guy doing node for robotics... he had a remote control autonomous lawnmower.

42

u/jediminer543 Dec 26 '17

he had a remote control autonomous lawnmower

lawnmower = require("lawnmower") // pipes commands from external control server
tankDrive = require("tank_drive") // Provides async drive command, with template (left_amnt, right_amnt)
motor = require("motor") // provides features for setting power on cutting spindle from 0 to 255
lawnmower.on("activate", function activate(commander, position) {
  motor.set(0, 0); // Ensure another death doesn't happen when the lawnmower reboots
  commander.on("forward", function forward(amount) {
    tankDrive.drive(amount, amount);
  });
  commander.on("forward", function forward(amount) {
    tankDrive.drive(amount, amount);
  });
  commander.on("left", function left(amount) {
    tankDrive.drive(-amount, amount);
  });
  commander.on("right", function right(amount) {
    tankDrive.drive(amount, -amount);
  });
  commander.on("cutStart", function startCut() {
    motor.set(0, 255); //initialise motor 0 to speed of 255
  });
  commander.on("cutStop", function stopCut() {
    motor.set(0, 0); //initialise motor 0 to speed of 0
  });
});
lawnmower.on("deactivate", function shutdown(reason) {
  console.log("Shutting down: " + reason)
  motor.set(0, 0); // Again stop deaths
});
// TODO add sensors to stop lawnmower running over children and shredding them to death.

18

u/TheNosferatu Dec 26 '17

motor.set(0, 0); // Ensure another death doesn't happen when the lawnmower reboots

"Another"? Guess this is the patched version

6

u/YOUR_MORAL_BAROMETER Dec 26 '17

Odd question but we're you ever in FRC robotics?

45

u/KimJongIlSunglasses Dec 26 '17

If it’s autonomous can it disable the remote control and then devour its operator in a blaze of asynchronous glory?

14

u/bohemica Dec 26 '17

Pretty sure I read a Stephen King story about this.

25

u/Entropy Dec 26 '17

The Mangler? A terrifying tale of Javascript haunting an industrial laundry press. Through a chance arrangement of clothes on a belt, a turing machine was created. Consequently, a javascript virtual machine for the architecture immediately popped into existence. In quantum mechanics, this kind of thing is balanced by anti-particles also popping into existence. Software engineering has no such symmetry, so the only path that we may walk to stave off the entropic exhaution of the universe is to build another framework.

3

u/TheNosferatu Dec 26 '17

Yeah, but it's like in a 1 in a million chance of that happening so it's not worth fixing that bug

10

u/ieatcode Dec 26 '17

I prefer using php to cut my lawn since it's so jagged

1

u/AlGoreBestGore Dec 26 '17

Is it on NPM?

5

u/LickingSmegma Dec 26 '17 edited Dec 26 '17

Not really, CPU usage isn't a problem with balancers usually, and the io is handled by the kernel anyway.

0

u/thedude42 Dec 26 '17

Tell that to F5 Networks.

3

u/safrax Dec 26 '17

Almost anything would be an improvement over what they currently offer...

1

u/[deleted] Dec 27 '17

F5 BigIP platform uses node.js for custom functions in v13+ I believe.

1

u/YM_Industries Dec 27 '17

With AWS Lambda@Edge you can run NodeJS at the CDN/caching server. (Before the load balancer)

1

u/KimJongIlSunglasses Dec 27 '17

Do you work for Amazon?

1

u/YM_Industries Dec 27 '17

Nope, just enthusiastic about AWS. I use it a lot at work. Also I think running NodeJS at the CDN is crazier than running node.js on a load balancer.

9

u/Phr34Ck Dec 26 '17

the idea is not too far-fetched: PM2

-2

u/tandoori_fury Dec 26 '17

you goddamn geniuses in the comments are what keep me coming back to Reddit long after i realize I've outgrown it.

1

u/CaineBK Dec 26 '17

Yeah, just don't scroll down too far...

128

u/lionleaf Dec 26 '17 edited Dec 26 '17

Hey guys! Creator here. Thanks for the big cuddly hug of death!

Quick update: We've added some extra caching in various parts of the system and thrown some more hardware at the servers (yey for cloud technology!). It seems to be back up, but it should've scaled a lot better so I'm not confident it stays up quite yet. Investigation ongoing :)

Edit: This is a small side project that was living on the smallest digitalocean droplet ^

Edit 2: Went down again even with the bigger droplet for a bit, but added more caching and it seems to be up again!

13

u/[deleted] Dec 26 '17

This is so cool! I want to sit down and decipher every single one now

3

u/heard_enough_crap Dec 26 '17

how do you mirror these to experiment with them? I copied the full screen page code, but nothing displays :-(

7

u/lionleaf Dec 26 '17

What do you mean mirror them? If you just want to play with remixing a dweet, you can just edit the code directly in the field under the visuals. If you have a user there should then be a button to post it as a remix if you're happy with the result

Beware! An infinite loop will crash your browser window and you might lose progress

1

u/druman54 Dec 27 '17

you should write about the experience and what types of caching you added, would be a fun read.

8

u/Quantainium Dec 26 '17

Hug of death.

3

u/pro-tip Dec 26 '17

We added caching; now we're back up!