Skip to content

Instantly share code, notes, and snippets.

View stepanmas's full-sized avatar
🙉
I am looking for a job!

StepanMas stepanmas

🙉
I am looking for a job!
View GitHub Profile
Очередь синхронного кода (callstack)
Очередь микрозадач (Promise)
Очередь макрозадач (setTimeout() и setInterval() или AJAX-запросы)
Отдельная очередь браузера для отрисовки содержимого (requestAnimationFrame)
requestAnimationFrame(() => console.log('1 animation frame'));
setTimeout(() => console.log('2 timeout'), 0);
Promise.resolve().then(() => console.log('3 promise'));
console.log('4 sync');
@stepanmas
stepanmas / Arrow with shadow
Created January 8, 2019 13:13
Arrow with shadow
&::after {
content: "";
position: absolute;
width: 0;
height: 0;
top: 0;
left: 50%;
margin-left: 12px;
box-sizing: border-box;
border: 10px solid black;
@stepanmas
stepanmas / Собеседование: промис 2
Last active December 27, 2018 12:22
Собеседование: промис 2
const url = 'http://lol';
function apiGet(url, attempts = 5) {
return new Promise(function core(resolve, reject) {
fetch(url)
.then((res) => {
resolve(res)
})
.catch(() => {
if (attempts) {
@stepanmas
stepanmas / Собеседование: промис 1
Last active December 26, 2018 08:43
Собеседование: промис 1
new Promise((resolve, reject) => {
throw new Error('err');
})
.then(() => {
console.log('then');
})
.catch(() => {
console.log('catch');
})
.catch(() => {
@stepanmas
stepanmas / Собеседование: use strict
Last active December 26, 2018 08:44
Собеседование: use strict
'use strict'
x = 5; // error! next examples with let x
console.log(++x); // 6
console.log(x++); // 6
function foo() {
console.log(x); // undefined, because there is x below
x += 5;
@stepanmas
stepanmas / radio-checkbox
Last active October 25, 2018 03:19
Radio or checkbox use CSS only (+React)
import React from 'react';
import './styles/Radio.less';
const Radio = (props) => {
const {
label,
value,
checked = false,
disabled = false,
name = 'name',
@stepanmas
stepanmas / uniqueObjInArray
Last active October 23, 2018 03:16
Собеседование: Отфильтровать объекты от повторяющихся значении.
const array1 = [{
"id": 1,
"name": "apple",
}, {
"id": 2,
"name": "orange"
}];
const array2 = [{
"id": 1,
fallocate -l 3G /swapfile
chmod 600 /swapfile
mkswap /swapfile
dd if=/dev/zero of=/swapfile bs=1G count=16
echo -e "/swapfile none swap sw 0 0 \n" >> /etc/fstab
swapon /swapfile
#!/usr/bin/env python3
# Author: Edoardo Paolo Scalafiotti <edoardo849@gmail.com>
import os
from time import sleep
import signal
import sys
import RPi.GPIO as GPIO
pin = 12 # The pin ID, edit here to change it
maxTMP = 55 # The maximum temperature in Celsius after which we trigger the fan
@stepanmas
stepanmas / loading.less
Last active February 18, 2020 13:56
Freeze a block use loader/loading animation.
.loading {
&:before {
background: rgba(255, 255, 255, 0.8);
content: '';
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
z-index: 1;