Skip to content

Instantly share code, notes, and snippets.

View SmolinPavel's full-sized avatar
:octocat:
Playing with octocat

Pavel Smolin SmolinPavel

:octocat:
Playing with octocat
View GitHub Profile
@SmolinPavel
SmolinPavel / Select
Created December 2, 2021 17:19
Select
// &:invalid {}
<div>
<select required>
<option value="" disabled selected>
Select items...
</option>
{options.map(({ value, label }) => (
<option key={value} value={value}>
{label}
@SmolinPavel
SmolinPavel / .stylelintrc.json
Created December 2, 2021 17:16
.stylelintrc.json example
// yarn add -D stylelint stylelint-config-standard stylelint-order-config-standard stylelint-order
// "stylelint": "stylelint \"**/*.(s)css\" --fix",
{
"extends": [
"stylelint-config-standard",
"stylelint-order-config-standard"
],
"plugins": [
var fullname = 'John Doe';
var obj = {
fullname: 'Colin Ihrig',
prop: {
fullname: 'Aurelio De Rosa',
getFullname: function () {
return this.fullname;
},
},
};
this.value = 'D';
const object = {
value: 'A',
methodA: () => {
console.log(this.value);
},
methodB: function () {
console.log(this.value);
},
@SmolinPavel
SmolinPavel / async-await.js
Created May 28, 2021 18:38
Compare Promise.all calls with .then vs async/await
/*
PROMISE/THEN approach
*/
const userIds = [1, 2, 3];
const requests = userIds.map((userId) =>
fetch(`https://jsonplaceholder.typicode.com/users/${userId}`),
);
Promise.all(requests)
@SmolinPavel
SmolinPavel / closure.js
Created May 21, 2021 16:25
Closure task. What will be the output?
var length = 10;
function fn() {
console.log(this.length);
}
var obj = {
length: 5,
method: function (fn) {
fn();
arguments[0]();
},
@SmolinPavel
SmolinPavel / queue.js
Created May 19, 2021 15:52
JS console.log quest (micro/macro task queues)
// what will be the output to the console?
console.log(1);
setTimeout(() => {
console.log(2);
setTimeout(() => console.log(3), 200);
}, 200);
new Promise(() => console.log(4));
import axios from 'axios';
import { LANGUAGE_NAME, REFRESH_TOKEN_IN_STORE, TOKEN_NAME_IN_STORE } from '../constants/api';
import { getBrowserLang, setTokens } from './GlobalHelper';
import { logoutDispatch } from './StoreHelper';
import LocalStorageHelper from './LocalStorageHelper';
import { BACKEND_ROUTES } from '../constants/routes';
export const API_REQUEST_AUTH_USER_LOGIN_URL = '/users/login';
export const API_REQUEST_AUTH_USER_LOGIN_SOCIAL_URL = '/login/social';
<html>
<head>
<style>
body style {
display: block;
}
</style>
</head>
<body>
<style contenteditable>
@SmolinPavel
SmolinPavel / Solution.js
Last active April 2, 2019 19:21
Mix of the legacy and new context API
import React, { Component, createContext } from 'react';
import PropTypes from 'prop-types';
const ExampleContext = createContext({ api: 'lorem ipsum' });
class New extends Component {
static contextType = ExampleContext;
render() {
const { name } = this.props;
const { api } = this.context;