This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var path = require('path'); | |
| var webpack = require('webpack'); | |
| module.exports = { | |
| devtool: 'source-map', | |
| entry: { | |
| app: ['babel-polyfill', 'whatwg-fetch', './client/App'] | |
| }, | |
| output: { | |
| path: path.join(__dirname, '.', 'public', 'js'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function checkAction(action, allowedActions) { | |
| console.log('checkAction', ...arguments) | |
| var actionParts = action.split('/') | |
| return allowedActions.reduce((result, item) => { | |
| // Short circuit previous answer. | |
| if (result === true) return true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* parser generated by jison 0.4.13 */ | |
| /* | |
| Returns a Parser object of the following structure: | |
| Parser: { | |
| yy: {} | |
| } | |
| Parser.prototype: { | |
| yy: {}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* description: Parses end executes mathematical expressions. */ | |
| /* lexical grammar */ | |
| %lex | |
| %% | |
| \s+ /* skip whitespace */ | |
| [0-9]+("."[0-9]+)?\b return 'NUMBER' | |
| "true" return 'TRUE' | |
| "false" return 'FALSE' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let a = 1, b = 2, foo="foo", bar="bar", credentials: "insecure"; | |
| String.raw`http://foo.org/bar?a=${a}&b=${b} | |
| Content-Type: application/json | |
| X-Credentials: ${credentials} | |
| { "foo": ${foo}, | |
| "bar": ${bar}}`; | |
| /* The code above produces the result | |
| "http://foo.org/bar?a=1&b=2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %s/var \(.*\) = require('\(.*\)');/import \1 from '\2'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| []['map']['constructor']('s', 'alert(s); return true')('You don\'t know JavaScript') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [1,1,2,2,3,3,4,4,5].reduce( function(a, b, i) { | |
| if (i === 1) { | |
| return [[a, b]]; | |
| } else { | |
| if (i % 2 === 0) { | |
| return a.concat([[b]]); | |
| } else { | |
| return a.splice(0, a.length-1).concat([a[a.length-1].concat(b)]); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var time = 1000; | |
| function updateTimer() { | |
| document.body.innerHTML = ('<div style="font-size: 6em">' + Math.round(time/60) + ":" + (--time%60) + '</div><br/><div>' + time + ' total seconds</div>') | |
| } | |
| var timerId = setInterval( updateTimer, 1000) | |
| // reset with: | |
| // clearInterval(timerId); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <meta charset="utf-8"> | |
| <html> | |
| <head> | |
| <title>Minimal React Setup</title> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.min.js" type="text/javascript"></script> | |
| </head> | |
| <body> | |
| <script src="app.js" type="text/javascript"></script> | |
| </body> |