git clone https://gist.github.com/6780d7cc0cabb1b4d6c8.git
$ npm install # maybe npm start will take care of it but just in case
$ npm start && open out.png
> [email protected] start /Users/bsergean/src/offscreen_sample
| # !/usr/bin/env python | |
| import os, re, argparse, json | |
| parser = argparse.ArgumentParser( | |
| description='Extract code from ShaderToy json.') | |
| parser.add_argument('input') | |
| parser.add_argument('output') | |
| args = parser.parse_args() |
| var budo = require('budo') | |
| var server = budo('src/client.js') | |
| .on('connect', function (ev) { | |
| mainWindow.loadUrl(ev.uri) | |
| mainWindow.once('close', function () { | |
| server.close() | |
| }) | |
| }) | |
| .on('update', function(file, contents) { |
git clone https://gist.github.com/6780d7cc0cabb1b4d6c8.git
$ npm install # maybe npm start will take care of it but just in case
$ npm start && open out.png
> [email protected] start /Users/bsergean/src/offscreen_sample
| var Rx = require('rx'); | |
| var readline = require('readline'); | |
| var fs = require('fs'); | |
| var rl = readline.createInterface({ | |
| input: fs.createReadStream('lines.txt') | |
| }); | |
| var lines = Rx.Observable.fromEvent(rl, 'line') | |
| .takeUntil(Rx.Observable.fromEvent(rl, 'close')) |
Doing require extensions correctly is essential, because:
nyc need it to reliably supply coverage information that takes into account sourcemaps from upstream transforms.I was playing around with functional and reactive programming in Javascript, and the UI framework Cycle.js. In order to better understand how that framework works, I pared down the core functionality to a single concept: given a function that takes in an input stream and returns an output stream, resolve the circular dependency of feeding its output back into itself as input. I also built a naive re-implementation of the core Cycle.run command on top of that.
| /* jshint esnext:true */ | |
| function get( target, prop, receiver ) { | |
| console.log( 'target: ' + target ); | |
| console.log( 'property: ' + prop ); | |
| // console.log( 'Receiver: ' + receiver ); | |
| return Reflect.get( target, prop, receiver ); | |
| } | |
| var handler = { |
| var _ = require('lodash'); | |
| var Success = function(success) { this.success = success; }; | |
| var Failure = function(failure) { this.failure = failure; }; | |
| var bindAll = function(fs) { | |
| var bind = function(res, f) { | |
| return res instanceof Success ? f(res.success) : res; | |
| }; | |
| var bindF = function(f) { return _.partial(bind, _, f); }; |
| let regex = `import | |
| (?: | |
| ["'\s]* | |
| ([\w*{}\n, ]+) | |
| from\s* | |
| )? | |
| ["'\s]* | |
| ([@\w/_-]+) | |
| ["'\s]* | |
| ;? |