Skip to content

Instantly share code, notes, and snippets.

@spaceribs
spaceribs / gist:f59c4cb096cad848474b
Last active February 11, 2024 22:37
Lodash Exports
/**
* @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() {
WEBVTT
_id: 76a479f0-99f4-4e9c-b845-d691ffc89e6a
_rev: 76a479f0-99f4-4e9c-b845-d691ffc89e6a
type: plopdown_v2
title: Rifftrax - Stranger Things
for: Stranger Things
url: https://github.com/spaceribs/plopdown-video
license: CC0
language: en-US
thumbnail: StrangerThings_PosterA.jpg

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 June 13, 2018 20:11
Object Literal versus Map Access (http://jsbench.github.io/#097e8087a12afe833f93d57cc055475e) #jsbench #jsperf
<!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 September 3, 2017 14:37
Get double-shift behavior in Atom
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;

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:

@spaceribs
spaceribs / gist:7694120
Last active March 17, 2016 20:31
paper.js angular directive using $http.get You can use this via: <paper src="scripts/papers/test.js" width="600" height="600"></paper>
'use strict';
angular.module('myApp')
.directive('paper', ['$http', function ($http) {
return {
replace: true,
template: '<canvas></canvas>',
restrict: 'E',
link: function postLink(scope, element, attrs) {