Skip to content

Instantly share code, notes, and snippets.

View KRostyslav's full-sized avatar
🇺🇦
Ukraine

Ros K. KRostyslav

🇺🇦
Ukraine
View GitHub Profile
@KRostyslav
KRostyslav / Clear localStorage on close tabs or browser
Last active June 16, 2020 10:04
Clear localStorage on close tabs/browser
((nm, tm) => {
const lStorage = localStorage;
const sStorage = sessionStorage;
const tabId = sStorage.getItem(tm)
|| ((newId) => {
sStorage.setItem(tm, newId);
return newId;
})((Math.random() * 1e8).toFixed());
const update = (setTabValue) => {
let currentValue = JSON.parse(lStorage.getItem(nm) || '{}');
# Prune images
$ docker image prune
or
$ docker image prune -a
# Prune containers
$ docker container prune
# Prune volumes
$ docker volume prune
# =================================
# List all node_modules
# Linux.
$ cd documents
$ find . -name "node_modules" -type d -prune -print | xargs du -chs
# Windows
$ cd documents
$ FOR /d /r . %d in (node_modules) DO @IF EXIST "%d" echo %d"
@KRostyslav
KRostyslav / script to run localTunnel
Last active April 10, 2021 16:23
Run localtunnel
#!/bin/bash
# Script for run localtunnel
# https://github.com/localtunnel/localtunnel
##### Constants
SUBDOMAIN='name'
PORT=8080
@KRostyslav
KRostyslav / PUTvsPOSTvsPATCH.md
Created January 30, 2018 19:10 — forked from zmts/PUTvsPOSTvsPATCH.md
PUT or POST or PATCH?

PUT or POST or PATCH? PATCH!

TL;DR

POST для создания новых ресурсов
POST для остальных кастомных глаголов
PATCH для обновления ресурсов. В 99,99% на обновление уходят не все поля ('created_at' и 'updated_at' так точно)
На PUT можно забить =)
# Password (min 8 symbols, with spec symbols)
/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})/
# Password (8-12 symbols, without spec symbols)
/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,12})/
# Percent (0 .. 100)
/^([0-9]{1,2}){1}(\.[0-9]*)?$|^(100)$/
@KRostyslav
KRostyslav / Environments.md
Last active July 8, 2022 19:56
Environments in React App

Environments in React App

// src/config.js

export default {
  s3: {
    BUCKET: "YOUR_S3_BUCKET_NAME",
  },
 api: {
# First, remove the old version:
# If installed via apt-get
sudo apt-get remove docker-compose
# If installed via curl
sudo rm /usr/local/bin/docker-compose
# If installed via pip
pip uninstall docker-compose
gource --seconds-per-day 1  -1280x720 -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset veryslow  -pix_fmt yuv420p -crf 22 -threads 0 -bf 0 video.mp4
@KRostyslav
KRostyslav / intro.md
Last active September 12, 2022 07:13
React Hooks

React Hooks

from React v.16.8

  • useState
  • useReducer
  • useEffect
  • useLayoutEffect
  • useContext
  • useMemo