Skip to content

Instantly share code, notes, and snippets.

@lmatteis
lmatteis / index.html
Created January 19, 2021 14:04
Test for blocks
<b>Foo Bar</b>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lmatteis
lmatteis / file.js
Last active December 10, 2019 20:15
const x = readInput();
if (isMultipleOfThree(x) && endsWithDigitFive(x)) {
return true;
} else {
return false;
}
function getPromotionalCode() {
...
if (!promotionalCode) {
emit('NoPromotionalCode')
}
...
}
diff --git a/test/package-lock.json b/test/package-lock.json
index db14f329..31122d5b 100644
--- a/test/package-lock.json
+++ b/test/package-lock.json
@@ -9,7 +9,7 @@
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz",
"integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==",
"requires": {
- "@babel/highlight": "^7.0.0"
+ "@babel/highlight": "7.5.0"
const card = yield { wait: cardInserted }
yield { request: { type: loadAccount, card } }
(isEnterpriseUser
? Promise.resolve()
: showAdvertisement()
)
.then(() => loadAccount(card))
.then(...)
@lmatteis
lmatteis / gist:959128492e02b0c54ab97ea2d4fd12f0
Created December 3, 2018 15:28
createBehavioralMiddleware
import BProgram from "./bp.js";
function createBehavioralMiddleware(threads) {
return ({ dispatch, getState }) => {
const bp = new BProgram();
let pr = 1;
bp.run();
threads.forEach(thread => bp.addBThread(``, pr++, thread));
bp.addBThread("dispatch", pr++, function*() {
import React from 'react';
import Coroutine from 'react-coroutine';
import Deferred from './Deferred.js';
export default Coroutine.create(Counter);
async function* Counter() {
let counter = 0;
while (true) {
yield (
@lmatteis
lmatteis / bp.js
Created July 22, 2018 10:53
Bikeshedding some behavioral programming into React
<Behavior
threads={[
function* ({ fetchSavedAudiences, onSelectSearch }) {
const value = yield { wait: onSelectSearch }
const audiences = yield { request: fetchSavedAudiences(value) }
this.setState({ audiences })
},
function* ({ onSelectChange }) {
const selectedAudience = yield { wait: onSelectChange }
this.setState({ selectedAudience })