Dwitter – A social network for short JavaScript demos
dwitter.net
dwitter.net
A few of my personal favorites:
Chrome 56, Windows 10.
Edit: Link to the issue https://github.com/lionleaf/dwitter/issues/66
maybe the script tag should support that one day
It's fun to optimize the code under 140 bytes. https://www.dwitter.net/d/832
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.)
Incidentally, this is where the "dwitter" name came from: "demos" as in the demoscene (https://en.wikipedia.org/wiki/Demoscene) and twitter.
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.
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.
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 ;)
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.
* scroll scroll scroll *
Nice work.
if (!this.mySettings) {
this.mySettings = { value: 1 }
}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?The direct link to the Sierpinski triangle inspired animation you're noting is below:
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...
Edit: In case you were stuck in a 500-loop I quickly changed your username to H2O, hopefully it works now
Are they all in iframes?
[0] https://news.ycombinator.com/item?id=13702021
[1] https://github.com/lionleaf/dwitter/blob/master/dwitter/temp...
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)