Since Twitter doesn't have an edit button, it's a suitable host for JavaScript modules.
Source tweet: https://twitter.com/rauchg/status/712799807073419264
const leftPad = await requireFromTwitter('712799807073419264');Since Twitter doesn't have an edit button, it's a suitable host for JavaScript modules.
Source tweet: https://twitter.com/rauchg/status/712799807073419264
const leftPad = await requireFromTwitter('712799807073419264');| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Recursive Component in React</title> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.11.0/umd/react.development.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.11.0/umd/react-dom.development.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script> | |
| </head> |
| // A bot for this silly demo: http://www.webdeveloperjuice.com/demos/jquery/snake_jquery.html | |
| // Compile with http://closure-compiler.appspot.com/home set to Advanced Optimization | |
| // | |
| // Automatically runs when compiled statement is pasted into console. Type "win()" to run it again. | |
| (window['win'] = function () { | |
| // direction mappings | |
| var i, dirs = ['up', 'right', 'down', 'left'], | |
| diffs = [[-1, 0], [0, 1], [1, 0], [0, -1]]; // don't ask me why the coords are ordered [y,x] | |
| window['t'] = 1; // next Turn direction if we hit a wall (opposite of last turn direction) | |
| window['m'] = 0; // My internally tracked direction |
| // Rotation Around a Point | |
| // *********************** | |
| // To acheive rotation around a given point | |
| // - translate to that point | |
| // - rotate | |
| // - then translate back | |
| // (note: in Processing this last step is implicit | |
| // since draw() resets all transformations | |
| // each time it runs.) |