Skip to content

Instantly share code, notes, and snippets.

View SirSerje's full-sized avatar
🏠
Working from home

Serhii Viazkov SirSerje

🏠
Working from home
View GitHub Profile
@SirSerje
SirSerje / index.js
Last active July 5, 2018 20:20
@roman_mtb calendar example
const POSTS = [
{ id:1,
name: 'post dog',
date: {
time: [6, 3, 2018],
}
},
{ id:12,
name: 'post dog',
date: {
@treyhuffine
treyhuffine / withStorage.js
Last active March 4, 2024 21:01
A higher-order component to access localStorage
import React from 'react';
const withStorage = (WrappedComponent) => {
class HOC extends React.Component {
state = {
localStorageAvailable: false,
};
componentDidMount() {
this.checkLocalStorageExists();
@Splaktar
Splaktar / unsaved-changes-guard.ts
Last active March 13, 2023 18:23
Guard against navigating away when there are unsaved changes
import {CanDeactivate, Router} from '@angular/router';
import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observer} from 'rxjs/Observer';
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material';
export interface CanComponentDeactivate {
canDeactivate: () => Observable<boolean> | Promise<boolean> | boolean;
}
@faressoft
faressoft / dom_performance_reflow_repaint.md
Last active May 6, 2024 06:11
DOM Performance (Reflow & Repaint) (Summary)

DOM Performance

Rendering

  • How the browser renders the document
    • Receives the data (bytes) from the server.
    • Parses and converts into tokens (<, TagName, Attribute, AttributeValue, >).
    • Turns tokens into nodes.
    • Turns nodes into the DOM tree.
  • Builds CSSOM tree from the css rules.
@mburakerman
mburakerman / package.json
Last active September 26, 2022 17:32
Webpack 4 config.js (SCSS to CSS and Babel) 👌 The Simplest Usage 👌
{
"name": "webpack-sass",
"version": "1.0.0",
"scripts": {
"start": "webpack-dev-server --open --mode development",
"build": "webpack -p"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
@zmts
zmts / tokens.md
Last active May 4, 2024 17:22
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@singhshivam
singhshivam / Immutable JS Examples
Last active August 5, 2023 19:16
Immutable JS Examples
List()
var list = Immutable.List([1,2,3])
// [1, 2, 3]
List.isList()
Immutable.List.isList(list)
// true
List.of()
var list = Immutable.List.of(1,2,3);
@weblancaster
weblancaster / gist:6e7f43fc02725ce747e224b0c4290906
Last active May 25, 2020 12:53
Kill all container, remove all images and stop all containers
#stop all containers:
docker kill $(docker ps -q)
#remove all containers
docker rm $(docker ps -a -q)
#remove all docker images
docker rmi $(docker images -q)
@bwangelme
bwangelme / server.py
Last active June 23, 2018 14:04
Python Hello,World Web Server
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from http.server import HTTPServer
from http.server import BaseHTTPRequestHandler
from http import HTTPStatus
class MyHandler(BaseHTTPRequestHandler):
def do_GET(self):
@bendc
bendc / supportsES6.js
Created August 25, 2016 08:05
Test if ES6 is ~fully supported
var supportsES6 = function() {
try {
new Function("(a = 0) => a");
return true;
}
catch (err) {
return false;
}
}();