Requires building the master branch of TypeScript, and the reflect-metadata polyfill.
Compile with
node built/local/tsc.js --target ES5 --experimentalDecorators --emitDecoratorMetadata --module commonjs inject.ts
import {inject} from 'aurelia-framework'; | |
import {HttpClient} from 'aurelia-http-client'; | |
@inject(HttpClient) | |
export class ClusterList { | |
heading = 'Clusters'; | |
url_base = 'https://foobar:443/v1'; | |
fabrics = []; | |
constructor(http){ |
module.exports = React.createClass({ | |
displayName : 'LazyRender', | |
getInitialState() { return { props : this.props } }, | |
componentWillReceiveProps(newProps) { setTimeout(() => this.setState(newProps), 10) }, | |
shouldComponentUpdate(newProps, newState) { return this.state !== newState; }, | |
render() { return React.cloneElement(React.Children.only(this.props.children), this.state); } | |
}); |
declare function require(module:string):any; | |
declare var process:any; | |
var readline = require('readline'); | |
var fs = require('fs'); | |
type brainfuckDone = (char : string) => void; | |
type brainfuckInput = (done : brainfuckDone) => void; | |
function brainfuck(tokens : string[], inp : brainfuckInput) { |
function curry(fn, ...args) { | |
if (args.length === fn.length) { | |
return fn(...args); | |
} | |
return curry.bind(this, fn, ...args); | |
} | |
function add(a, b) { | |
return a + b; |
Requires building the master branch of TypeScript, and the reflect-metadata polyfill.
Compile with
node built/local/tsc.js --target ES5 --experimentalDecorators --emitDecoratorMetadata --module commonjs inject.ts
function await(generatorFunction) { | |
let gen = generatorFunction(); | |
/** | |
* @param {any?} err The error to throw in the generator, where yield was last called. | |
* @param {any?} result The result to pass to the genarator for the last call to yield | |
*/ | |
function next(err, result) { | |
// If the last promise that was yielded was rejected, | |
// trigger an error inside the generator where yield was last called |
{ | |
"Aberavon": [ | |
{ | |
"name": "(LAB)", | |
"votes": 16073, | |
"share": 0.52 | |
}, | |
{ | |
"name": "(LD)", | |
"votes": 5034, |
require('babel/polyfill'); | |
/** | |
* Imagine this is some complex async process | |
*/ | |
async function random() { | |
return new Promise(r => r(Math.random())); | |
} | |
async function main() { |
<?php | |
$json = file_get_contents('https://gist.githubusercontent.com/nathggns/051203c3d7e72159de0d/raw/9e368d3a99a219a7fc487d327b86ebd4f6c8ed53/results.json') or die('Cannot fetch data'); | |
$consts = json_decode($json, true) or die('Cannot decode data'); | |
var_dump(array_reduce(array_map(function($const_name) use ($consts) { | |
return [$consts[$const_name][0]['name'], $const_name]; | |
}, array_filter(array_keys($consts), function($const_name) use($consts) { | |
return $consts[$const_name][0]['share'] >= 0.5; | |
})), function($data, $pair) { |
<?php | |
$json = file_get_contents('https://gist.githubusercontent.com/nathggns/051203c3d7e72159de0d/raw/9e368d3a99a219a7fc487d327b86ebd4f6c8ed53/results.json') or die('Cannot fetch data'); | |
$consts = json_decode($json, true) or die('Cannot decode data'); | |
echo array_reduce(array_values($consts), function($amount, $parties) { | |
return $amount + ($parties[0]['share'] < 0.5 ? 1 : 0); | |
}, 0); |