Skip to content

Instantly share code, notes, and snippets.

View egorguscha's full-sized avatar
🏠
Working from home

Egor egorguscha

🏠
Working from home
View GitHub Profile
@egorguscha
egorguscha / fo.js
Last active November 20, 2020 17:56
#!/usr/bin/env node
console.log(123)
import { I18nTypes } from './I18nTypes';
const lang = 'en';
interface Langs {
[key: string]: string | string[];
}
/*tslint:disable:no-var-requires*/
const langs: Langs = require(`./langs/${lang}.json`);
const setInitialState = (settings) => {
const {
itemHeight,
amount,
tolerance,
minIndex,
maxIndex,
startIndex
} = settings;
const viewportHeight = amount * itemHeight;
import React, {useEffect, useState} from 'react'
import {FixedSizeList} from 'react-window'
import {Table} from 'antd';
// https://jsonplaceholder.typicode.com/posts?_page=1&_limit=10
import 'antd/dist/antd.css'
const columns = [
{
title: 'User ID',
function css(tags, ...attrs) {
const value = style(tags, ...attrs)
const node = document.createElement('style')
node.id = 'insertedStyle'
node.appendChild(document.createTextNode(value))
const sheet = document.getElementById('insertedStyle')
if (sheet) {
sheet.disabled = true
sheet.parentNode.removeChild(sheet)
}
import {ChangeEvent, FocusEvent} from 'react'
import {
createEvent,
createEffect,
createStore,
forward,
combine,
guard,
sample,
Store,

Computation priority

For sure you've been noticed that function must be pure... or watch there is a place for side effect. Yes and we will tell about this in that section - Computation priority

A real example of queue priority - people awaiting medical treatment hospital, extreme emergency cases will have the highest priority and move on the start of the queue less significant at the end.

The main of the reason for creating Computation priority was that side effects:

  • Letting go first pure functions
  • Following consistent state of application
// @flow
import { $baseUri } from "../model/config.store"
import { $token } from "../model/token"
type Method = "GET" | "POST" | "PUT" | "DELETE"
type Options = {
headers?: { [key: string]: string },
parse?: "text" | "json" | "noparse",
baseUri?: string,
@egorguscha
egorguscha / env.js
Last active November 27, 2019 15:43
/* eslint-disable no-magic-numbers, unicorn/no-process-exit, no-console, prefer-template */
const fs = require('fs');
const path = require('path');
const dotenv = require('dotenv');
const dotenvExpand = require('dotenv-expand');
const paths = require('./paths');
// Make sure that including paths.js after env.js will read .env variables.
delete require.cache[require.resolve('./paths')];

+++ title = "Application structure" description = "Where to look for files and where to put new" date = 2019-08-20 rss = true +++

I split my source code on features/, ui/ and pages/.
Logic can be only in the pages/ and features/.