Hacker News new | past | comments | ask | show | jobs | submit login
Dwitter – A social network for short JavaScript demos (dwitter.net)
361 points by 5960312 on Feb 21, 2017 | hide | past | favorite | 71 comments



Oh fun, didn't expect to see my side-project here :) A few of my personal favorites:

https://www.dwitter.net/d/90 https://www.dwitter.net/d/406 https://www.dwitter.net/d/433 https://www.dwitter.net/d/617


Didn't mean to post with that account. Oh well.


Awesome project, love the idea!

It's fun to optimize the code under 140 bytes. https://www.dwitter.net/d/832



A little feedback, the tab got helluva laggy after scrolling down a few pages. I assume that's because you aren't unloading dwitters when they scroll past the top of the viewport - which you probably should.

Chrome 56, Windows 10.


The dweets are stopped but not unloaded as you scroll away. You're entirely right though, needs some proper unloading.

Edit: Link to the issue https://github.com/lionleaf/dwitter/issues/66


Infinite loops (accidental in my case) should probably be catched in some way.


Yeah, the halting problem has been around since 1936. You'd think someone would have solved it already!


if (time_elapsed > some_arbitrary_threshold) { interrupt_sandboxed_code(); }


maybe give the scripts a quota of cycles then can consume.

maybe the script tag should support that one day


So I whipped up a standalone HTML page to use to develop Dwitter scripts without having to use their interface (which seems prone to crashing). Here's the source: https://gist.github.com/russellbeattie/ef27709f7c916ea54454c... and you can see it live on my site: http://www.russellbeattie.com/dwitterish.html

Interestingly, I found that some scripts really don't like using eval(), so I modified the page to dynamically swap in new <script> elements with the code instead, and a flag to go back and forth.

Here's an example of a script which doesn't like eval() - it runs noticeably faster when embedded in a script: https://www.dwitter.net/d/697

Edit: Added the ability to just embed the code in the URL: http://www.russellbeattie.com/dwitterish.html#c.width%7C%3D0...

(Note that I only tested this on Chrome, so feel free to modify if there's issues.)


We've gone full circle! This thing started as a stand-alone HTML page for dweets with ability to embed the code in the URL: http://arkt.is/t (hover to show editor). GitHub: https://github.com/sigvef/arktis-tweet-demo . Here it is with the same dweet embedded: http://arkt.is/t/Yy53aWR0aHw9MDtmb3Iobj0yMDA7bi09MS82NDt4LmZ... .

Incidentally, this is where the "dwitter" name came from: "demos" as in the demoscene (https://en.wikipedia.org/wiki/Demoscene) and twitter.


This is cool! You should consider submitting a patch back upstream with that script embedding improvement.


This is the coolest website I've seen in a long time. Awesome idea.

EDIT: one issue I'm running into is it's easy to accidentally write half-finished code that freezes my browser. It would be nice to have an option to only refresh the preview upon clicking some kind of button.


One trick you learn as a dweeter is to write all for-loops as "fr" instead of "for", and then only adding the last "o" when you feel confident that the loop won't accidentally go on forever!


or the source box could replace 'for' with a loop thats designed to run a few seconds.


Sorry about your lost dweet :( Accidental infinite loops while editing can be a pain. A "reload" button isn't a bad idea, or a "recover dweet draft" functionality.


I managed to finish one! https://www.dwitter.net/d/714

More suggestions:

- in-browser minification tool

- character counter would count using this output

- larger textarea

That way, I can compose without relying on vim + yui-compressor.

Awesome little site.


Brilliant dweet! Part of the challenge is the manual minification. A larger textarea might be worth it especially as you can use linebreaks instead of ; for better readability


Aye, then I cheated. :0 I'll try doing it manually next time.


Why not auto-save to local storage? That's something that's easily added.


Use Firefox, it doesn't hang on infinite loops.


that is the fun. reminds me of programming on MSDOS.


The source is on GitHub: https://github.com/lionleaf/dwitter \o/


This is really cool, but executing other people's javascript in a page makes me nervous. What sort of restrictions are in place to prevent malicious exploits?


Makes me quite nervous too. So far each dweet is run in a sandboxed iframe loaded from a separate subdomain.

There are definitely things you can do, and I'm aware of some annoying ones. I'll just manually delete them at this point. Any security conscious person would view it with noscript and just read the javascript ;)


While you're deleting stuff, I noticed someone on the new page has posted pornographic images. Alas, I'm not terribly surprised since this is the internet after all, but I'll +1 a feature to report dweets as being inappropriate.

A system to automatically hide dweets (for later manual review) after receiving a certain number of reports would likely solve the problem in the short term.


While you're manually deleting things... there are currently way too many that are just exact reposts of the default swaying black bars. Probably accidents rather than people being deliberately lame, but low-hanging fruit for any kind of automatic cleanup.


Why not make their javascript run in WebWorkers and provide a DOM-like interface for all the things? That way you can kill infinite loops etc.


That's something I've been thinking about. Webworkers don't have direct access to the Canvas though, but it seems like you can work around that by passing image data. Killing infinite loops would be great


how do you sandbox the iframe/code?


Using the <iframe> "sandbox" property. At least stops things like alert('hey') and a full-page redirect


This is awesome! During one of the last hackathons I participated while at Tumblr, I made a Processing post type, that allowed people to have interactive posts using Processing code, and could be reblogged with edits - very much like this. Love seeing something similar to this idea!


Woah, this is awesome but a bit misleading in the beginning. I spend my last 15 min trying it out: https://www.dwitter.net/d/702


Ended up with something totally different than what I was going for. This is fun.

https://www.dwitter.net/d/778


Check out my dweet :) https://www.dwitter.net/d/734



Oh, that's cool! I like the integration with twitter


The idea is much, much better than the name :)


I enjoy the matrix theme falling letters (4th on the top-sorted list). Thanks!


Opened page: this is kinda lam....oooh that's neat.

* scroll scroll scroll *

Nice work.


In a similar style, but with WebGL: https://www.shadertoy.com


Yup, pretty similar but the limitation to plain JS and to 140 chars makes the code more fun :)


This is definitely fun... It'd be nice if it used Github to login and save to Gists. Also, I think it'd be better if the developer called u(t){}, rather than it being the content of the entire post, so it could set up variables, etc., and since it already has a few shortcuts like c,x,C,S,T,R, might as well add in a more complete API.


Just set something on `this`:

    if (!this.mySettings) {
      this.mySettings = { value: 1 }
    }


140 character limit, so that wastes like 60 of it. :-)


Ah, didn't realize, my bad! It's doable in fewer characters of course, but still a waste. Funny, I thought it was just a bit odd how terse some of these demos were, but given the 140 char limit that I somehow didn't notice at all it makes more sense.


I thought the same until I tried it and realized of the 140char limitation, which really limits what you can do


Neat concept. It reminds me of the Wolfram One-Liner competition http://blog.wolfram.com/2016/11/09/the-2016-wolfram-one-line...


How do I link to a specific post?

This one by mxfh looks very cool:

    d=x.getImageData(0,0,w=c.width=256,h=144);for(i=0;i<h;i++)for(j=0;j<w;j++)d.data[(i*w+j)*4+3]=(i-j&j+i)*t%w;x.putImageData(d,0,0)
Does anyone know how it works?


There's a share button on each of the "tweets" at least on my screen.

The direct link to the Sierpinski triangle inspired animation you're noting is below:

https://www.dwitter.net/d/676


I don't know either, was more of an accident and I ran for it. But I'll try:

Manipulating the canvas Imagedata TypedArray is usually faster than draw calls like fillRect; yet the getImagadata-setImagedata and 2D-Y-X-iteration (here ij) fluff doesn't leave much bytes for actual per pixel operations.

    (i*w+j)*4+3 // is the alpha channel (offset of 3) index of the pixel in the Imagedata
The actual payload:

    (i-j&j+i)*t%w
Translates to

    (y - x & x + y) * time % 256
With 255 resulting in Black rgba(0,0,0,1) to transparent black rgba(0,0,0,0), which is then effectively viewed as background color, in this case white.

see https://www.dwitter.net/d/661 for an earlier full RGBA example

Before WebGL this was the fastest way to get stuff done in the canvas: https://hacks.mozilla.org/2011/12/faster-canvas-pixel-manipu...


What resources to people recommend for learning about animating in canvas tags like on Dwitter? I'm already familiar with Javascript, but seeing what people are able to do here with 140 characters amazes me.


Thank you for this. It definitely stimulated my imagination and creativity.


I'm not understanding this. How is animation happening? What is S(t)? Can somebody please explain this project?


Scroll down:

  u(t) is called 60 times per second.
  t: elapsed time in seconds.
  c: A 1920x1080 canvas.
  x: A 2D context for that canvas.
  S: Math.sin
  C: Math.cos
  T: Math.tan
  R: Generates rgba-strings, ex.: R(255, 255, 255, 0.5)


I'd appreciate for not auto running the demos. The fractal animation lagged whole page down to 5FPS.


Just tried to register with username @H2O. Sent post request, after that got 500 error.


Oh, got the 500 error dump. It's the @ in your username, that'll teach me. For now avoid special characters in your username ;)

Edit: In case you were stuck in a 500-loop I quickly changed your username to H2O, hopefully it works now


I tried to register as "sfz-" and also got a 500. Is there a problem with a trailing dash? If so, can you fix my username as well to "sfz"? Thanks!


Changed to sfz :)



Thank you! :) Real time debugging is cool! :)


My MacBook Air is complaining after a few minutes of reading this site.


I kind of love it!

Are they all in iframes?


Yup, as confirmed by the author[0]. Also, it's opensource, 'dweet card' template shows that it uses iframes[1].

[0] https://news.ycombinator.com/item?id=13702021

[1] https://github.com/lionleaf/dwitter/blob/master/dwitter/temp...


This kills the Firefox.


This reminds me a bit of ShaderToy -- very cool :)


12 hours until twitter name infringement


Name does not pass bar test.


within a half hour of playing around on this site, someone posted goatse. and there is no way to report, hide, downvote, etc.




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

Search: