Skip to content

Instantly share code, notes, and snippets.

View a-vershinin's full-sized avatar

Anatoliy Vershinin a-vershinin

View GitHub Profile
// getCookie(), setCookie(), deleteCookie()
// возвращает cookie если есть или undefined
function getCookie(name) {
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
))
return matches ? decodeURIComponent(matches[1]) : undefined
@a-vershinin
a-vershinin / iterm2-solarized.md
Created June 18, 2024 20:30 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@a-vershinin
a-vershinin / README.org
Created September 7, 2022 09:57 — forked from jcouyang/README.org
Promise All with Limit of Concurrent N

The Promise All Problem

in case of processing a very large array e.g. Promise.all(A_VERY_LARGE_ARRAY_OF_XHR_PROMISE)

which would probably blow you browser memory by trying to send all requests at the same time

solution is limit the concurrent of requests, and wrap promise in thunk

Promise.allConcurrent(2)([()=>fetch('BLAH1'), ()=>fetch('BLAH2'),...()=>fetch('BLAHN')])

@a-vershinin
a-vershinin / .eslintignore
Created June 3, 2021 19:52 — forked from RyanHirsch/.eslintignore
Typescript + Jest + ESLint + Tailwind
.next
__generated__
@a-vershinin
a-vershinin / movie_challenge.js
Created April 19, 2021 23:45 — forked from LevPewPew/movie_challenge.js
good challenge for javascript array methods
// 1. Implement topWatchlistedMoviesAmongFriends method that will return an array of top four movie titles,
// that have been most watchlisted by friends of a given user.
// 2. If there are no such movies, then an empty list should be returned or as many movies as possible.
// 3. Movies that have equal watchlist count, should be ordered alphabetically.
let movies = [{
"title": "The Shawshank Redemption",
"duration": "PT142M",
@a-vershinin
a-vershinin / tsconfig.json
Created April 2, 2021 22:28 — forked from KRostyslav/tsconfig.json
tsconfig.json с комментариями.
// Файл "tsconfig.json":
// - устанавливает корневой каталог проекта TypeScript;
// - выполняет настройку параметров компиляции;
// - устанавливает файлы проекта.
// Присутствие файла "tsconfig.json" в папке указывает TypeScript, что это корневая папка проекта.
// Внутри "tsconfig.json" указываются настройки компилятора TypeScript и корневые файлы проекта.
// Программа компилятора "tsc" ищет файл "tsconfig.json" сначала в папке, где она расположена, затем поднимается выше и ищет в родительских папках согласно их вложенности друг в друга.
// Команда "tsc --project C:\path\to\my\project\folder" берет файл "tsconfig.json" из папки, расположенной по данному пути.
// Файл "tsconfig.json" может быть полностью пустым, тогда компилятор скомпилирует все файлы с настройками заданными по умолчанию.
// Опции компилятора, перечисленные в командной строке перезаписывают собой опции, заданные в файле "tsconfig.json".
@a-vershinin
a-vershinin / indexInForOf.md
Created June 12, 2020 11:03 — forked from zmts/indexInForOf.md
Get index in for of

Get index in for of

for (const [index, value] of ['a', 'b', 'c'].entries()) {
  console.log(index, value)
}

/*
0 "a"
1 "b"

Debounce with promises

// https://stackoverflow.com/questions/35228052/debounce-function-implemented-with-promises

function debounce (inner, ms = 0) {
  let timer = null
  let resolves = []

 return function (...args) {
@a-vershinin
a-vershinin / update-build.md
Created June 12, 2020 11:00 — forked from zmts/update-build.md
Auto update application build version. Husky pre-commit hook.

Auto update application build version. Husky pre-commit hook.

package.json

"husky": {
    "hooks": {
      "pre-commit": "npm run build && node ./update-build.js"
    }
  }
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: "canary",