Skip to content

Instantly share code, notes, and snippets.

import { Action, Causes, Fn, Patch, Rec, StoreOnPatch, TransactionResult } from '@reatom/core'
function getActionsType(actions: ReadonlyArray<Action>) {
return actions.length === 1
? actions[0].type
: actions.map(({ type }) => type).join(', ')
}
function parsePatch(patch: Patch) {
version: '3.6'
services:
postgres:
image: postgres:12
restart: always
volumes:
- db_data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: postgrespassword
hasura:

‎‎​

@artalar
artalar / hello-form.html
Last active January 26, 2021 18:23
typed-html
<form>
<label>
Enter your name
<input />
</label>
<button type="submit">Submit</button>
</form>
<p></p>
import { performance } from 'perf_hooks'
import * as effector from 'effector'
import w from 'wonka'
import { Action, Atom, createStore } from '../build'
const w_combine = <A, B>(
sourceA: w.Source<A>,
sourceB: w.Source<B>,
): w.Source<[A, B]> => {
const source = w.combine(sourceA, sourceB)
@artalar
artalar / EHBmVU0WoAYIxME.png
Last active November 19, 2022 14:37
sm-spec
EHBmVU0WoAYIxME.png
/**
* Queue for dynamic topological sorting.
* Paste a node and it kind, where
* `one` - is node with one up,
* `few` - is node with few up.
* After each `add` you must to extract next node by `get` method,
* process it, add it children, and so on.
*/
export class Queue<T> {
one = new Array<T>();
class Edge {
deps: Array<Edge> = [];
constructor(public name: string) {}
}
type Links = Array<Edge>;
// EXAMPLE
const e_1_1 = new Edge("e_1_1");
const e_1_2 = new Edge("e_1_2");
const e_1_3 = new Edge("e_1_3");
@artalar
artalar / hooks.js
Created July 24, 2020 14:14
minimal example react hooks implementation
let currentHookIndex = 0;
let currentHooks = [];
function useState(initValue) {
const myIndex = currentHookIndex++;
const myHooks = currentHooks;
let state = myHooks[myIndex];
if (state === undefined) {
state = initValue;