Skip to content

Instantly share code, notes, and snippets.

View Olegas's full-sized avatar

Oleg Elifantiev Olegas

  • Russia, Yaroslavl
View GitHub Profile
class My extends Control {
_state = 0;
_beforeMount(options) {
// первичная инициализация
this._state = options.value;
}
_beforeUpdate(newOptions) {
if (this._options !== newOptions) {
// Пришли новые опции - обновим стейт
this._state = newOptions.value;
@Olegas
Olegas / let-me-explain.md
Last active April 18, 2019 16:36
Объясню...

Комменатрий к ответу: "У нас есть серия выражений, сгруппированных и разделённых запятыми, они оцениваются слева направо, но сохраняется только результат последнего выражения."

Комментарий @Akiyamka: "Более того, выполняется только последнее"

Т.е. я трактовал это как: "У нас есть серия выражений, ..... они (выражения) оцениваются слева направо, ... Более того, выполняется только последнее (выражение)"

const [images, setImages] = useState([]);
function loadFileAsync(file) {
const reader = new FileReader();
return new Promise((resolve, reject) => {
reader.onloadend = (e) => {
resolve(e.target.result);
};
// TODO handle error
reader.readAsDataURL(file);
@Olegas
Olegas / questions-to-styled-components.md
Last active April 15, 2019 13:26
Вопросы к styled components

Вопросы к styled-components

Что с подсветкой синтаксиса?

Есть плагин styled-components для WebStorm, с ним работает подскветка и подсказки

Что с SSR? Он есть, но прилетает ли страница сразу со стилями или они попадают в DOM после оживления?

@Olegas
Olegas / Day17.js
Last active December 17, 2018 15:22
var input=`x=547, y=508..535
x=514, y=169..178
x=367, y=152..154
x=545, y=1483..1485
y=618, x=494..497
y=657, x=497..500
y=747, x=544..570
x=512, y=197..205
x=400, y=209..229
x=427, y=26..37
@Olegas
Olegas / deploy.sh
Last active December 1, 2020 21:14
Machine deployment
#!/bin/bash
# TODO Add GruvBox
# TODO Add oh-my-git
mkdir -p ~/work/no_backup
# /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install node
brew install python
brew install postgres
@Olegas
Olegas / files.js
Last active July 4, 2017 12:17 — forked from kvasdopil/files.js
const files = [/* file names here */];
const limit = 100;
async function main() {
var runningWorkers = 0;
function continuationHandler() {
runningWorkers--;
loadWorkers();
}
@Olegas
Olegas / additional-links.md
Last active April 9, 2017 10:33
Additional links for "Redux for state management" talk
@Olegas
Olegas / actions.js
Last active September 29, 2015 20:03
A story about pet store or Yet another stupid redux application
import decreaseFoodAction from 'FoodStoreActions';
import validationErrorAction from 'ValidationErrors';
function feedAnimalAction(animalName, amount) {
var animal = getAnimalByName(animalName);
// no write access here
var foodStore = State.get('store');
var preferredFood = Animal.getRequiredFoodType(animal);
if (Animal.isHungry(animal)) {
if (Store.hasSufficientFood(foodStore, preferredFood, amount)) {