Skip to content

Instantly share code, notes, and snippets.

View nezort11's full-sized avatar

Yegor Zorin nezort11

View GitHub Profile
@nezort11
nezort11 / lamoda-render-review-rating.js
Last active April 29, 2024 22:15
Render rating value and review count near every product in results on Lamoda
var REVIEW_RATING_REGEX = /"ratingValue": "([^"]+)",\s*"reviewCount": "([^"]+)"/;
var main = async () => {
const productCards = document.querySelectorAll(".x-product-card__card");
Array.from(productCards).forEach(async (productCard) => {
// console.log('productCard.id', productCard.id);
const productUrl = `https://www.lamoda.ru/p/${productCard.id}`;
// console.log('productUrl', productUrl);
@nezort11
nezort11 / yandex-market-rating-count-sort.js
Last active April 17, 2024 23:06
Sort products in Yandex Market search results based on rating count (sales)
var productCardList = document.querySelector('.SerpLayout');
var productCards = Array.from(productCardList.querySelectorAll('[data-apiary-widget-name="@light/Organic"]'));
var gerProductCardRatingCount = (productCard) => {
const productCardRatingCountDigits = productCard.querySelector('[data-baobab-name="rating"] > div:last-of-type > div:last-of-type')?.innerText.match(/\d/g) || ['0'];
return Number(productCardRatingCountDigits.join(''));
}
productCards.sort((productCard1, productCard2) => {
@nezort11
nezort11 / ozon-rating-count-sort.js
Last active April 26, 2024 21:04
Sort products in Ozon search results based on rating count (sales)
var productCardListList = document.querySelectorAll('.widget-search-result-container > div');
var productCards = [];
productCardListList.forEach((productCardList) => {
const productCardListCards = Array.from(productCardList.querySelectorAll('.widget-search-result-container > div > div'));
productCards = [...productCards, ...productCardListCards];
});
var gerProductCardRatingCount = (productCard) => {
const productCardRatingCountDigits = productCard.querySelector('.tsBodyMBold > span:last-of-type')?.innerText.match(/\d/g) || ['0'];
@nezort11
nezort11 / wb-rating-count-sort.js
Last active April 20, 2024 07:02
Wildberries sort by product rating count
var productCardList = document.querySelector('.product-card-list');
var productCards = Array.from(productCardList.querySelectorAll('.product-card'));
var gerProductCardRatingCount = (productCard) => {
const productCardRatingCountDigits = productCard.querySelector('.product-card__count')?.innerText.match(/\d/g) || ['0'];
return Number(productCardRatingCountDigits.join(''));
}
productCards.sort((productCard1, productCard2) => {
import { S as P, i as V, s as R, C as K, a as U, c as M, b as k, G, H as x, I as j, g as Y, d as z, h as H, K as X, o as Q, P as Z, $ as p, Z as q, _ as J } from "./index.ff0009f4.js";
import { l as T, L as W, b as o, Q as N, S as d } from "./common-text.425980d7.js";
import { w as B, j as $ } from "./singletons.725ad3fb.js";
import { H as ee } from "./control.f5b05b5f.js";
function te(e) {
let t, r;
const a = e[4].default,
i = K(a, e, e[3], null);
return {
c() {
@nezort11
nezort11 / run.sh
Last active January 9, 2024 08:52
Bash script to execute script from package.json without package manager (npm run, yarn, pnpm) or node_modules installed.
#!/usr/bin/env bash
PACKAGE_FILE="package.json"
PACKAGE_RUN_COMMAND="npm"
RUN_COMMAND="bash ${0}"
SCRIPT="$1"
# Check package manager
if [ -f "package-lock.json" ]; then
PACKAGE_RUN_COMMAND="npm"
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useDispatch } from 'react-redux';
import cn from 'clsx';
import { CrossIcon, ZeroGasIcon } from '@/assets/img';
import { Button, Loader, Typography } from '@/components';
import { useShallowSelector } from '@/hooks';
import { useTimeLeft } from '@/hooks/useTimeLeft';
import crowdSaleActionType from '@/store/crowdsale/actionTypes';
import { updateCrowdSaleOpenState } from '@/store/crowdsale/reducer';
""" Custom serializer related field filtering based on request user.
"""
class Model1RelatedField(serializers.PrimaryKeyRelatedField):
"""Custom Model1 related field that filters queryset based on requesting user.
It is REQUIRED for filter-based permission on related object.
On needed for create and update actions bacause they choose form serializer related field..
"""
def get_queryset(self):
@nezort11
nezort11 / webapp-archecture.md
Last active September 18, 2021 19:59
Web app architecture

How to connect back-end and front-end

Differ my data:

  1. When data will come?
  2. When data will be rendered?

Differ by purposes:

  1. For development
@nezort11
nezort11 / django-project-patterns.md
Created September 14, 2021 15:21
Django Project Patterns

Django Project Patterns

Project development:

  1. Describe
  2. Design
  3. Implement

What should be done for every Django/SPA project?