Skip to content

Instantly share code, notes, and snippets.

View hosembafer's full-sized avatar
💭
I may be slow to respond.

Rafayel Hovhannisyan hosembafer

💭
I may be slow to respond.
View GitHub Profile
@hosembafer
hosembafer / web-image-performance-optimization-guidelines.md
Last active July 27, 2023 06:47
Web Image Performance Optimization Guidelines

Web Image Performance Optimization Guidelines

Images make up 42% of an average web page's total weight.

Image format

Image files should be formatted as WebP (next-gen format) or PNG formats, don't use JPG/JPEG as it can't maintain quality properly.

Prefer WebP (next-gen format) over PNG, use PNG only in particular cases when size/quality is better with PNG.

@hosembafer
hosembafer / eq-test-cases.ts
Created June 13, 2022 15:11
EQ test cases
const case1 = [
{
type: "lowshelf",
frequency: 500,
gain: 18,
}
];
const case2 = [
{
enum OutageType {
INCIDENT,
MAINTENANCE,
}
type Outage = {
type: OutageType;
services?: string[];
resolved?: boolean;
force?: boolean;
...
import createStoreProvider from './store/createStoreProvider';
import { TodoListProvider } from './store/TodoListStore';
import { MessageProvider } from './store/MessageStore';
const StoreProvider = createStoreProvider([
TodoListProvider,
MessageProvider,
]);
import React from 'react';
const createStoreProvider = providers => ({ children }) => providers.reverse().reduce((tree, Provider) => <Provider>{tree}</Provider>, children);
export default createStoreProvider;
import React, { useState, useCallback } from 'react';
const Context = React.createContext();
let nextId = 0;
export const TodoListProvider = ({children}) => {
const [tasks, setTasks] = useState([]);
const addTask = useCallback(name => setTasks(tasks => ([...tasks, {id: ++nextId, name}])), [setTasks]);
import { useTodoListStore } from '../../store/TodoListStore';
const TodoList = () => {
const {
tasks,
addTask,
renameTask,
removeTask,
} = useTodoListStore();
@hosembafer
hosembafer / App.js
Last active April 25, 2019 14:25
react-swipe-to-dismiss: App.js
const MessageItem = ({message, onDismiss}) => {
const ref = useRef(null);
const swipeableMessageProps = useSwipeToDismiss(ref, onDismiss, false, 100, 'right');
return <div ref={ref} className={'Message'} {...swipeableMessageProps}>
{message}
</div>;
};
@hosembafer
hosembafer / SwipeToDismiss.js
Created April 25, 2019 14:23
react-swipe-to-dismiss: SwipeToDismiss.js
import React from 'react';
import PropTypes from 'prop-types';
import { findDOMNode } from 'react-dom';
class SwipeToDismiss extends React.Component {
constructor(props) {
super(props);
this.node = null;
@hosembafer
hosembafer / useSwipeToDismiss.js
Created April 25, 2019 14:22
react-swipe-to-dismiss: useSwipeToDismiss.js
import {useCallback, useEffect, useState} from 'react';
const useSwipeToDismiss = (ref, onDismiss, removeDOM = false, distanceBeforeDismiss = 100, direction = 'right') => {
const node = ref.current;
const [removing, setRemoving] = useState(false);
const [pressedPosition, setPressedPosition] = useState(false);
const [positionLeft, setPositionLeft] = useState(false);
const [animate, setAnimate] = useState(false);
const [opacity, setOpacity] = useState(1);