Skip to content

Instantly share code, notes, and snippets.

View robertpenner's full-sized avatar

Robert Penner robertpenner

View GitHub Profile
@robertpenner
robertpenner / .block
Created June 6, 2021 18:42 — forked from d3noob/.block
Basic Directional Force Layout Diagram
license: mit
@robertpenner
robertpenner / XStateViz.tsx
Created May 31, 2021 01:57 — forked from drbr/XStateViz.tsx
XState Visualizer (XState Inspector) as a React component with a standalone state machine
import { useEffect, useState } from 'react';
import { StateMachine } from 'xstate';
import { useMachine } from '@xstate/react';
import { inspect } from '@xstate/inspect';
let iFrameElement: HTMLIFrameElement | null = null;
function createIFrame() {
if (!iFrameElement) {
const iframe = document.createElement('iframe');
@robertpenner
robertpenner / *valoo.md
Created July 7, 2018 02:55 — forked from developit/*valoo.md
🐻 Valoo: just the bare necessities of state management. 150b / 120b. https://npm.im/valoo

🐻 valoo

just the bare necessities of state management.

Usage

Hotlink it from https://unpkg.com/valoo.

See Interactive Codepen Demo.

@robertpenner
robertpenner / functional-utils.js
Created March 15, 2017 02:01 — forked from bendc/functional-utils.js
A set of pure ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
[] + []; // JavaScript will give you "" (which makes little sense), TypeScript will error
//
// other things that are nonsensical in JavaScript
// - don't give a runtime error (making debugging hard)
// - but TypeScript will give a compile time error (making debugging unnecessary)
//
{} + []; // JS : 0, TS Error
[] + {}; // JS : "[object Object]", TS Error
{} + {}; // JS : NaN, TS Error
SystemJS.config({
transpiler: "typescript",
typescriptOptions: {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
},
map: {
"rxjs": "https://npmcdn.com/rxjs",
"angular2": "https://npmcdn.com/angular2",
"@ngrx": "https://npmcdn.com/@ngrx",
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>RxJSCraft</title>
<script src="https://npmcdn.com/systemjs@0.19.24/dist/system.js"></script>
<script src="https://npmcdn.com/typescript@1.8.9/lib/typescript.js"></script>
</head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>RxJSCraft</title>
<script src="https://npmcdn.com/systemjs@0.19.24/dist/system.js"></script>
<script src="https://npmcdn.com/typescript@1.8.9/lib/typescript.js"></script>
<script src="https://npmcdn.com/rxjs@5.0.0-beta.4/bundles/Rx.js"></script>
<style>
@robertpenner
robertpenner / config.js
Created March 17, 2016 04:32 — forked from johnlindquist/config.js
angular 2 with sagas and reducers
System.config({
//use typescript for compilation
transpiler: 'typescript',
//typescript compiler options
typescriptOptions: {
emitDecoratorMetadata: true
},
//map tells the System loader where to look for things
map: {
app: "./src",
@robertpenner
robertpenner / config.js
Last active March 17, 2016 04:29 — forked from johnlindquist/config.js
Angular 2 RxJS TypeWriter
System.config({
//use typescript for compilation
transpiler: 'typescript',
//typescript compiler options
typescriptOptions: {
emitDecoratorMetadata: true
},
//map tells the System loader where to look for things
map: {
app: "./src",