This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Canvas, CanvasKit as CKType, CanvasKitInit } from 'canvaskit-wasm'; | |
import { makeNoise2D } from 'fast-simplex-noise'; | |
import hexRgb from 'hex-rgb'; | |
((window as unknown as { CanvasKitInit: typeof CanvasKitInit }).CanvasKitInit as typeof CanvasKitInit)({ locateFile: (file) => `https://unpkg.com/canvaskit-wasm@0.19.0/bin/${file}` }).then(main); | |
function randomInteger(min: number, max: number) { | |
let rand = min - 0.5 + Math.random() * (max - min + 1); | |
return Math.round(rand); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Canvas, CanvasKit as CKType, CanvasKitInit } from 'canvaskit-wasm'; | |
import { makeNoise2D } from 'fast-simplex-noise'; | |
((window as unknown as { CanvasKitInit: typeof CanvasKitInit }).CanvasKitInit as typeof CanvasKitInit)({ locateFile: (file) => `https://unpkg.com/canvaskit-wasm@0.19.0/bin/${file}` }).then(main); | |
function randomInteger(min: number, max: number) { | |
let rand = min - 0.5 + Math.random() * (max - min + 1); | |
return Math.round(rand); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Canvas, CanvasKit as CKType, CanvasKitInit } from 'canvaskit-wasm'; | |
((window as unknown as { CanvasKitInit: typeof CanvasKitInit }).CanvasKitInit as typeof CanvasKitInit)({ locateFile: (file) => `https://unpkg.com/canvaskit-wasm@0.19.0/bin/${file}` }).then(main); | |
function main(CanvasKit: CKType): void { | |
const [ width, height ] = [640 * 2, 640 * 2]; | |
const surface = CanvasKit.MakeCanvasSurface('root'); | |
function grid(canvas: Canvas): void { | |
const [v, h] = [128 / 4, 128 / 4]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Canvas, CanvasKit as CKType, CanvasKitInit } from 'canvaskit-wasm'; | |
import './styles/style.css'; | |
((window as unknown as { CanvasKitInit: typeof CanvasKitInit }).CanvasKitInit as typeof CanvasKitInit)({ locateFile: (file) => `https://unpkg.com/canvaskit-wasm@0.19.0/bin/${file}` }).then(main); | |
function main(CanvasKit: CKType): void { | |
const [ width, height ] = [2000, 1400]; | |
const nodeSize = 100; | |
const nodes: Array<Array<[number, number, number]>> = []; | |
const surface = CanvasKit.MakeCanvasSurface('root'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Утилитарный тип, чтобы указать тип аргумента как конструктор класса, а не как инстанс класса | |
export interface Newable<T = any> extends Function { | |
new(...args: any[]): T; | |
} | |
// Это структура с бека допустим такая прилетает | |
type Product = { | |
id: string; | |
price2: number; | |
price3: number; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function recursivePow(x, n, I, mult) { | |
if (n == 0) { | |
return I; | |
} | |
if (n == 1) { | |
return x; | |
} | |
let y = recursivePow(x, Math.floor(n / 2), I, mult); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const csv = require('csv-parser') | |
const fs = require('fs') | |
const results = []; | |
const dates = {}; | |
fs.createReadStream('free_navalny.csv') | |
.pipe(csv({ separator: ';' })) | |
.on('data', (data) => { | |
if (!Boolean(data.ACCEPT_TIME)) { | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { readdirSync } = require('fs'); | |
const sharp = require('sharp'); | |
const path = './static/omages/services-page/'; | |
const uploadsList = readdirSync(path).filter(i => ['jpg', 'jpeg', 'png'].some(fmt => i.includes(fmt))); | |
const shouldCompress = uploadsList.filter(((value, index, obj) => { | |
const should = !obj.find(i => i.includes(`${value}_compressed.webp`)); | |
return should; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios, { AxiosError, AxiosInstance, AxiosResponse } from 'axios'; | |
import { API_BASENAME, ENDPOINTS } from '../constants/api'; | |
import interceptorInjector from './interceptor'; | |
import { AuthData, AuthStoreInstance } from '../stores/auth'; | |
import { LOCAL_STORAGE } from '../constants/hardcode'; | |
type RequestConfig = { | |
endpoint: string; | |
method: 'POST' | 'GET' | 'PUT' | 'PATCH' | 'DELETE'; | |
data: Record<string, string | number | null>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
class ApiRequest { | |
constructor() { | |
axios.interceptors.response.use((res) => { | |
console.log({ status: res.status }, res); | |
return res; | |
}, (err) => { | |
const { config, response } = err; | |
const { status } = response; |