Skip to content

Instantly share code, notes, and snippets.

View iosorin's full-sized avatar
🚀

Mir Osorin iosorin

🚀
View GitHub Profile
@iosorin
iosorin / blabla
Last active November 11, 2020 20:55
blabla
modules:
--api
--store
-- actions.ts
-- reducer.ts
-- selectors.ts
-- slice.ts
-- sagas.ts
@iosorin
iosorin / range.scss
Created November 8, 2020 02:44
range.scss
$color: #f2f5f9;
$activeColor: #6666fe;
$thumbColor: #6666fe;
$trackHeight: 5px;
$thumbHeight: 12px;
$progressPercent: 50%;
@mixin thumb {
appearance: none;
width: $thumbHeight;
1.init: npm init -y
2. react: yarn add react react-dom
3. babel: yarn add --dev @babel/preset-react (jsx support) @babel/core @babel/preset-env
4. babel: yarn add --dev babel-loader (transpile modern syntax to browser supportable)
4.1 babel: yarn add --dev @babel/plugin-proposal-class-properties
5. babel: .babelrc with installed presets and plugins
function* rootSaga() {
yield all([
takeLatest(login.type, loginUser),
takeLatest(logout.type, logoutUser),
takeLatest(loadNotes.type, fetchNotes),
takeLatest(loadCategories.type, fetchCategories),
takeLatest(loadSettings.type, fetchSettings),
takeLatest(sync.type, syncData),
takeLatest(
[
@iosorin
iosorin / GuardedRoute.tsx
Created October 20, 2020 20:14
GuardedRoute.tsx
import React, { ComponentType, FC } from 'react';
import { Redirect, Route, RouteProps } from 'react-router-dom';
type Props = RouteProps & {
component: ComponentType;
redirect?: string;
show?: boolean;
};
const GuardedRoute: FC<Props> = ({ component: Component, redirect = '/', show = false, ...rest }) => {
@iosorin
iosorin / PrivateRoute, react-ts
Created October 20, 2020 20:00
PrivateRoute, react-ts
import React, { ComponentType, FC } from 'react';
import { useSelector } from 'react-redux';
import { Redirect, Route, RouteProps } from 'react-router-dom';
import { getAuthenticated } from '@/store/selectors';
type PrivateRouteProps = RouteProps & {
component: ComponentType;
};
@iosorin
iosorin / eslint config react+ts
Created October 18, 2020 08:59
eslint config react+ts
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
ecmaFeatures: {
jsx: true
}
},
@iosorin
iosorin / generate alphabet string.js
Created October 5, 2020 05:21
generate alphabet string.js
[...Array(26)].map((_, y) => String.fromCharCode(y + 65)).join('')
@iosorin
iosorin / partial arguments (no bind)
Created October 5, 2020 05:04
partial arguments (no bind)
/* == Частичное применение (partial application)
Напиши функцию partial(fn, a1, a2, ....), которая позволяет зафиксировать один или несколько аргументов функции. Пример:
Есть функция с аргументами:
f1(a, d, c, d)
Мы можем с помощью partial сделать из нее функцию с меньшим числом аргументов, заранее задав значения для нескольких из них, например:
var f2 = partial(f1, 1, 2); // фиксируем a = 1, b = 2
И вызов: f2(x, y)
@iosorin
iosorin / greatest common devision
Created October 4, 2020 12:56
greatest common devision
function gcd(a = 10, b = 20) {
if (b === 0) return a;
return gcd(b, a % b);
}