Skip to content

Instantly share code, notes, and snippets.

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

Сергей Константинов deeamtee

🏠
Working from home
View GitHub Profile
@deeamtee
deeamtee / clearValidation.js
Created July 27, 2025 11:39
clearValidation
export const clearValidation = (formElement, config) => {
const inputList = Array.from(
formElement.querySelectorAll(config.inputSelector)
);
const buttonElement = formElement.querySelector(config.submitButtonSelector);
inputList.forEach((inputElement) => {
hideInputError(formElement, inputElement, config);
});
disableSubmitButton(buttonElement, config);
};
// const customers = new Map();
// data.customers.forEach((customer) => {
// customers.set(customer.id, customer);
// });
// const result = data.products.reduce((acc, product) => {
// const key = product.category; //
// if (!acc[key]) {
// acc[key] = [];
const values = [1, 270, 290, 290, 400, 455, 587, 650.5, 660, 735, 735, 735, 788, 808, 808, 808, 808.5, 817.10, 932, 892.5, 892.5, 1039.5, 1071, 997.5];
const target = 1592;
function findBestSubset(values, target) {
const n = values.length;
const dp = Array(target + 1).fill(0);
const choose = Array.from({ length: target + 1 }, () => Array(n).fill(false));
for (let i = 0; i < n; i++) {
for (let j = target; j >= Math.floor(values[i]); j--) {
import { useState, useEffect, Dispatch, SetStateAction } from 'react'
function isDefined (storedValue: string | null): boolean {
return storedValue !== null && storedValue !== 'undefined';
}
export function useLocalStorageState<T>(
key: string,
initialValue: T
): [T, Dispatch<SetStateAction<T>>] {