Skip to content

Instantly share code, notes, and snippets.

View mistical2008's full-sized avatar

Evgeniy Talko mistical2008

  • Russia
View GitHub Profile
import { createEffect, createEvent, createStore, restore } from "effector";
export const createWebSocketConnection = (url: string, retries = 5) => {
const onEvent = createEvent<Event>();
const statusChanged = onEvent.map(({ type }) => type);
const message = createEvent<MessageEvent>();
const send = createEffect();
const $status = restore(statusChanged.filter({ fn: (status) => status === "close" || status === "open" }), "close");
const error = onEvent.filter({fn: ({type}) => type === "error"})
const retry = createEffect();
// an option to create bindings to history
// usage is like
//
// export const historyUpdated = createEvent<HistoryUpdate>();
// export const clocks = createHistoryClocks();
//
// clocks have fields like `push, replace, go` and so on
// can be used like clocks.push({ to: "path" })
//
// wrapHistory({
@mistical2008
mistical2008 / factory.ts
Created April 18, 2023 04:23 — forked from 7iomka/factory.ts
Factory example
import { createLib, ValidationVisibilityCondition } from '@filledout/core';
import { createLib as createReactLib } from '@filledout/react';
import type { ApplyYupParams } from '@filledout/yup';
import { applyYup } from '@filledout/yup';
import type { FormModel, CreateFormParams } from '@filledout/core';
import type { AxiosError } from 'axios';
import { isAxiosError } from 'axios';
import type { EffectParams, Effect } from 'effector';
import { createEffect, is, sample } from 'effector';
import { getErrorsMap, isCustomAxiosError } from '../api';
@mistical2008
mistical2008 / README.md
Created March 27, 2022 08:20 — forked from matusnovak/README.md
Matrix (Synapse + Riot) in Docker with Traefik and federation

Matrix

matrix.org chat is split into two parts, the server and the client. The server we are going to use is called Synapse and the client is Riot.im. The Synapse will also need Postgres database and Redis for caching.

0. Folders

Make sure your folder structure looks like this.

example/
@mistical2008
mistical2008 / README.md
Created March 27, 2022 08:19 — forked from russelldavies/README.md
Matrix homeserver setup with Docker and Traefik

This guide assumes that example.com is your server name, so user IDs will in the format @user:example.com, and that matrix.example.com is the domain name of your actual server.

Requirements

At least 512 MB memory. Approximate memory usage of services:

  • Traefik: 20 MB
  • Postgres: 70 MB
  • Synapse: 150 MB
@mistical2008
mistical2008 / docker-compose.yaml
Created March 26, 2022 14:14 — forked from joenas/docker-compose.yaml
Matrix docker-compose with Postgres and docker network
### To use this file you need to run
### $ docker network create matrix-network
version: "2"
services:
postgres:
image: postgres:9.6.4
restart: always
# I like to be able to use psql on the host to connect to the database
@mistical2008
mistical2008 / install.md
Created March 12, 2022 18:56 — forked from AndersonIncorp/install.md
Install any linux distro on VPS with low RAM, locked ISO boot

Overview

Scenario

  • Your VPS provider doesn't support ISO mount
  • Your VPS has low RAM and cannot load whole ISO image
  • Your current /boot is to small to contain ISO file

Workaround

  • Boot low memory ISO (CorePure64.iso ~ 14MB)
  • Create new partition ~1GB / size of your ISO
  • dd your ISO into that partition
@mistical2008
mistical2008 / init-ts-package.sh
Created February 21, 2022 10:17 — forked from mcasimir/init-ts-package.sh
init-ts-package.sh
#!/usr/bin/env bash
generate_file() {
if [ ! -f "$1" ]; then
echo "$2" > "$1"
fi
}
# ---
# package.json
@mistical2008
mistical2008 / .eslintrc.js
Created February 21, 2022 10:14 — forked from Tim-W-James/.eslintrc.js
TypeScript w/ FP: ESLint
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
ecmaVersion: 2018,
sourceType: "module",
},
extends: [
"typed-fp",
"plugin:sonarjs/recommended",
@mistical2008
mistical2008 / .eslintignore
Created February 21, 2022 10:01 — forked from RyanHirsch/.eslintignore
Typescript + Jest + ESLint + Tailwind
.next
__generated__