This file contains hidden or 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 encode = (str, debug) => str.split(' ').map((word) => { | |
| const cleanWord = word.replace(/^[^а-яa-z0-9]*|[^а-яa-z0-9]*$/uig, ''); | |
| if (cleanWord.length <= 3) { | |
| debug && console.log(`${word} → ${cleanWord}: skip`); | |
| return word; | |
| } | |
| const fixedChars = cleanWord.length > 12 ? 4 : (cleanWord.length > 9 ? 3 : (cleanWord.length > 6 ? 2 : 1)); | |
| const head = word.replace(new RegExp(`^([^а-яa-z0-9]*[а-яa-z0-9]{${fixedChars}}).+$`, 'ui'), '$1'); | |
| const tail = word.replace(new RegExp(`^.+([а-яa-z0-9]{${fixedChars}}[^а-яa-z0-9]*)$`, 'ui'), '$1'); | |
| const middle = word.slice(head.length, word.length - tail.length); |
- Если обрабатываем промис и возвращаем его, в
onRejectedвозвращаемPromise.reject(error)либо не используемonRejected, чтобы в любом случае была возможность обработать reject снаружи.const load = () => { return fetcher.get('/url') .then( (data) => { // Do something
return data;
This file contains hidden or 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
| # file comment | |
| invoice: 34843 | |
| date: 2001-01-23 | |
| # Русский коммент | |
| bill-to: &id001 | |
| given: Джон | |
| family: Коннор | |
| address: |
This file contains hidden or 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
| /* Запустить на странице https://www.instagram.com/%username%/ */ | |
| var promise = new Promise((resolve, reject) => { | |
| const DELAY = 1000; | |
| const DEVATION = 250; | |
| const limit = 50; | |
| // Сколько «страниц» скачать (на каждой по ${limit} фоток), 0 == без ограничений | |
| const totalPages = 0; | |
| // true если аккаунт друга (на кого подписан) или свой, иначе false | |
| const isMyFriendPage = true; |
This file contains hidden or 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 { useCallback, useState } from 'react'; | |
| /** | |
| * Хук для хранения уникального набора элементов в массиве. | |
| * Возвращает массив и функцию переключения элемента. | |
| */ | |
| export default (initialValue = []) => { | |
| const [items, setItems] = useState(initialValue); | |
| const toggle = useCallback( | |
| (item, force = null) => { |
This file contains hidden or 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
| // https://www.humanbenchmark.com/tests/reactiontime | |
| var timeout; | |
| var wait = false; | |
| var el = document.querySelector('.test-standard'); | |
| var check = function() { | |
| console.log('Working...'); | |
| if (wait && el.classList.contains('view-go')) { | |
| wait = false; | |
| console.log('Fire!!!'); |
This file contains hidden or 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
| www./a | |
| www./a/ | |
| www./a/go/to | |
| www./a/go/to/ | |
| www./a/джа/ва | |
| www./a/джа/ва/ | |
| www./aдж_а-ва | |
| www./a/%D0%B4%D0%B6%D0%B0/%D0%B2%D0%B0 | |
| www./a/go/to/index.html | |
| www./a/джа/ва/index.html |
This file contains hidden or 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
| size=50 | |
| mkdir converted | |
| find . -type f -maxdepth 1 -print0 | \ | |
| xargs -0 -n 1 -P 8 -I __FILE__ \ | |
| convert __FILE__ -resize $size -set filename:new '%d/%t' \ | |
| \( -clone 0 -tile overlay.png -draw "color 0,0 reset" \) \ | |
| # -compose blend -define compose:args=50 \ | |
| -compose overlay \ | |
| -composite "converted/%[filename:new]_${size}.png" |
NewerOlder