This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const extrinsicsAtEvent = ( | |
events: Vec<EventRecord>, | |
block: SignedBlock, | |
filter?: { | |
method?: string; | |
} | |
) => { | |
return block.block.extrinsics.filter((ex, index) => | |
Boolean( | |
events.find( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Normalized<T extends Record<string | number | symbol, any>, K extends keyof T> = { | |
ids: T[K][], | |
byId: Partial<Record<T[K], T>> | |
} | |
export const fromArray = <T extends Record<string, any>, K extends keyof T> (array: T[], key: K): Normalized<T, K> => { | |
const keys = array.map(item => item[key]) | |
const index = array.reduce<Normalized<T, K>['byId']>((index, item) => { | |
return { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface Resolve<T> { | |
(value: T | PromiseLike<T>): Resolvable<T>; | |
} | |
export interface Reject<T> { | |
(reason: T | PromiseLike<T>): Resolvable<T>; | |
} | |
export interface Resolvable<T> extends Promise<T> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Required Draf-js version: 0.10. | |
// Live example: https://jsfiddle.net/schabluk/gh2gt22n/ | |
import React from 'react' | |
import ReactDOM from 'react-dom' | |
import {Editor, EditorState, EditorBlock} from 'draft-js' | |
class Line extends React.Component { | |
render () { | |
const blockMap = this.props.contentState.getBlockMap().toArray() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copy this into the console of any web page that is interactive and doesn't | |
do hard reloads. You will hear your DOM changes as different pitches of | |
audio. | |
I have found this interesting for debugging, but also fun to hear web pages | |
render like UIs do in movies. | |
*/ | |
const audioCtx = new (window.AudioContext || window.webkitAudioContext)() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const enum Job { | |
FOO = "FOO", | |
BAR = "BAR" | |
} | |
export const doJob = (job: Job) => { | |
if(job == Job.FOO) { | |
foo() | |
} | |
if(job == Job.BAR) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {periodic, map, filter, tap, combine, runEffects, multicast, merge} from "@most/core"; | |
import { newDefaultScheduler, asap } from "@most/scheduler"; | |
const scheduler = newDefaultScheduler(); | |
const everySecond$ = periodic(333); | |
let i = 0; | |
const increments$ = multicast(map(_ => i++, everySecond$)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WrittenText extends React.PureComponent { | |
constructor(props) { | |
super(props) | |
this.state = { | |
i: 0, | |
output: "" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Only accept cross origin from certain domains. | |
* Netlify browser app and localhost for development. | |
*/ | |
add_action( 'rest_api_init', function() { | |
remove_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Defines selectors using 'reselect' | |
import * as breedsSelectors from '../../core/domain/breeds/selectors' | |
function createSelectorMap(selectors, state) { | |
return Object.keys(selectors).reduce((selectorMap, selectorName) => { | |
selectorMap[selectorName] = (...args) => selectors[selectorName](state, ...args) | |
return selectorMap | |
}, {}) | |
} |