Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Brewer spaceribs

View GitHub Profile
View proposal.md

I've been exploring combining the concept of "Behavior Trees" (https://en.wikipedia.org/wiki/Behavior_Trees) with RxJS, and this revealed to me a combiner that I don't think currently exists, so I wanted to discuss if that's the case and if I should put up a PR to add such a combiner.

The most basic behavior tree at minimum contains an AND (sequence) combiner and an OR (selector) combiner. AND combiners run their children in sequence, and stop running if there are any failures. An AND combiner is actually very easy to translate to RxJS, it's literally just a concat.

An OR combiner instead runs it's children until success, and only fails if all it's children fail to return success. This is actually very similar to onErrorResumeNext except for the following attributes:

  • When all selectors are exhausted, throw an error.
  • Stop executing when any observable completes.

The code for the combiner in typescript/rxjs is below:

@spaceribs
spaceribs / index.html
Last active Jun 13, 2018
Object Literal versus Map Access (http://jsbench.github.io/#097e8087a12afe833f93d57cc055475e) #jsbench #jsperf
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Object Literal versus Map Access</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@spaceribs
spaceribs / double-shift-atom.coffee
Created Sep 3, 2017
Get double-shift behavior in Atom
View double-shift-atom.coffee
keyPressed = false;
atom.keymaps.addKeystrokeResolver ({event}) ->
if event.key == "Shift" && event.type == "keydown"
if keyPressed
keyPressed = false;
console.log('keyPressed');
return 'shift-double';
else
keyPressed = true;
View keybase.md

Keybase proof

I hereby claim:

  • I am spaceribs on github.
  • I am spaceribs (https://keybase.io/spaceribs) on keybase.
  • I have a public key ASDM8NFEUk77TaXH8snYeam9yqWKueACekMWuf7BUEeqpAo

To claim this, I am signing this object:

View gist:f59c4cb096cad848474b
/**
* @license
* lodash 3.10.0 (Custom Build) <https://lodash.com/>
* Build: `lodash modern -o ./lodash.js`
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license>
*/
;(function() {
@spaceribs
spaceribs / gist:7694120
Last active Mar 17, 2016
paper.js angular directive using $http.get You can use this via: <paper src="scripts/papers/test.js" width="600" height="600"></paper>
View gist:7694120
'use strict';
angular.module('myApp')
.directive('paper', ['$http', function ($http) {
return {
replace: true,
template: '<canvas></canvas>',
restrict: 'E',
link: function postLink(scope, element, attrs) {
You can’t perform that action at this time.