This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Очередь синхронного кода (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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
&::after { | |
content: ""; | |
position: absolute; | |
width: 0; | |
height: 0; | |
top: 0; | |
left: 50%; | |
margin-left: 12px; | |
box-sizing: border-box; | |
border: 10px solid black; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Promise((resolve, reject) => { | |
throw new Error('err'); | |
}) | |
.then(() => { | |
console.log('then'); | |
}) | |
.catch(() => { | |
console.log('catch'); | |
}) | |
.catch(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import './styles/Radio.less'; | |
const Radio = (props) => { | |
const { | |
label, | |
value, | |
checked = false, | |
disabled = false, | |
name = 'name', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const array1 = [{ | |
"id": 1, | |
"name": "apple", | |
}, { | |
"id": 2, | |
"name": "orange" | |
}]; | |
const array2 = [{ | |
"id": 1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.loading { | |
&:before { | |
background: rgba(255, 255, 255, 0.8); | |
content: ''; | |
height: 100%; | |
left: 0; | |
position: absolute; | |
top: 0; | |
width: 100%; | |
z-index: 1; |
NewerOlder