Skip to content

Instantly share code, notes, and snippets.

View DmitriyWebDev's full-sized avatar

Dmitriy Gavrilov DmitriyWebDev

View GitHub Profile
@vezaynk
vezaynk / HOC.ts
Created February 1, 2023 23:35
HOC helpers. reduceHOCs and applyHOCs.
interface HOC<T> {
(Component: React.ComponentType<T>): (props: T) => JSX.Element
}
const reduceHOCs = <T>(...hocs: HOC<T>[]): HOC<T> => hocs
.reduce((reduced, next) => (c) => next(reduced(c)));
const applyHOCs = <T>(...hocs: HOC<T>[]) {
const reducedHoc = reduceHOCs(...hocs);
import React, { useReducer } from 'react';
import { BrowserHistory, Update, History } from 'history';
import { Router } from 'react-router-dom';
import {
Middleware, createSlice,
} from '@reduxjs/toolkit';
type ReduxAction<T = any> = {
type: string,
payload?: T,
@natterstefan
natterstefan / README.md
Created February 18, 2020 14:47
Jest | Mock useState

Jest - mock useState

When using import React, { useState } from 'react' in your components, this is how you can mock useState with jest.

@acutmore
acutmore / README.md
Last active January 21, 2024 20:30
Emulating a 4-Bit Virtual Machine in (TypeScript\JavaScript) (just Types no Script)

A compile-time 4-Bit Virtual Machine implemented in TypeScript's type system. Capable of running a sample 'FizzBuzz' program.

Syntax emits zero JavaScript.

type RESULT = VM<
  [
    ["push", N_1],         // 1
    ["push", False],       // 2
 ["peek", _], // 3

Принципы разработки Амплифера

Тут перечислены не законы, последние слово всегда за здравым смыслом. Тут перечислены лишь направление, куда надо стремиться. Принципы, которые должны помочь, когда не знаешь, что выбрать.

Ценности

  1. Пользователь. Если что-то сильно мешает UX или есть критическая ошибка, то в первую очередь мы спасаем пользователей. Для этого иногда надо взять ответственность на себя, переубедить толпу, написать плохой код.
@ai
ai / requirements.md
Last active December 19, 2023 14:19
Website requirements

Amplifr logo

Amplifr Landings Rules

Amplifr’s rules for landing pages created by outsource.

Requirements

@hackingbeauty
hackingbeauty / ModalFooter.js
Created May 20, 2018 19:18
ModalFooter component for a large-scale React application as taught in the course "How To Write A Single Page Application" - www.singlepageapplication.com
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { modalFooterStyles } from './styles.scss'
import { Modal as ReactBootstrapModal } from 'react-bootstrap'
class ModalFooter extends Component {
constructor(props) {
super(props)
}
@AlexEscalante
AlexEscalante / ReactSelectWithAllOption.js
Last active May 7, 2021 13:26
Gives users of the fine component react-select the ability to select all options with a single click.
/**
* react-select + allOption
*
* author: alex.escalante@gmail.com, @alex_escalante
*
* Gives users of the fine component react-select the ability to select
* all options with a single click.
*
* We're basically wrapping react-select but using a special option,
* the "allOption". This option is exclusive of any other option
@javierarques
javierarques / jsdom-helper.js
Last active January 12, 2022 00:51
Simulate window resize event in jsdom
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const dom = new JSDOM('<!DOCTYPE html><html><head></head><body></body></html>');
global.window = dom.window;
global.document = dom.window.document;
// Simulate window resize event
const resizeEvent = document.createEvent('Event');
@MarkoCen
MarkoCen / isPromise.js
Created April 24, 2017 19:27
Check if an object is a Promise
function isPromise(object){
if(Promise && Promise.resolve){
return Promise.resolve(object) == object;
}else{
throw "Promise not supported in your environment"
}
}
var i = 1;
var p = new Promise(function(resolve,reject){