Skip to content

Instantly share code, notes, and snippets.

View jinnyMcKindy's full-sized avatar
:octocat:
Working from home

Julia Kits jinnyMcKindy

:octocat:
Working from home
View GitHub Profile
@jinnyMcKindy
jinnyMcKindy / gist:1b815894d302513d3e4deb8047173475
Last active September 15, 2019 10:12
Различия Vue and React

Различия Vue/Vuex and React/Redux

  1. Во Vue данные легко мутировать из-за чего не произойдет апдейт элемента. 2 Virtual Dom сравнятся и не будет изменений. Example: Vue:
const words = this.state.words; //ссылка на массив
words.push('marklar’); //массив мутируется напрямую
this.words = words; //нет изменения
@jinnyMcKindy
jinnyMcKindy / lru.js
Last active June 28, 2020 21:16
Implement An LRU Cache algorithm JavaScript
const head = Symbol('head')
const tail = Symbol('tail')
class DoublyLinkedListNode {
constructor(value, index=0) {
this.value = value;
this.previous = null;
this.next = null;
this.index = index;
}
}
function bubbleSort(arr) {
arr.forEach((_, i) => {
if(arr[i] > arr[i + 1]) {
let a = arr[i];
let b = arr[i + 1];
arr[i] = b;
arr[i + 1] = a;
}
})
return arr;
function mergeSort(array, half = array.length/2) {
if(array.length < 2) { return array; }
const left = array.splice(0, half);
return merger(mergeSort(left), mergeSort(array));
}
function merger(left, right) {
const arr = [];
while(left.length && right.length) {
if(left[0] < right[0]) {
arr.push(left.shift());
@jinnyMcKindy
jinnyMcKindy / gist:fe35ef1eafd05a88141d170a2054481b
Created October 27, 2020 12:44
Frontend Interview questions
What are some ways you may improve your website's scrolling performance?
JS:
https://github.com/yangshun/front-end-interview-handbook/blob/master/questions/javascript-
questions.md
● Describe event bubbling, capturing. (-)
● Explain event delegation. (-)
● Two main paradigms: OOP & FP. What is, pluses/minuses? In two words. (-/+)
○ (He is confusing functional prog with procedural programming)
● Explain how this works in JavaScript.
○ Said content (in fact conteXt)
//называем класс согласно сущности, которую он представляет
class Fruit {
taste = «juicy»;
name;
constructor(name) {
this.name = name;
}
public getTaste() {
return `${this.name} is ${this.taste}`;
}
@jinnyMcKindy
jinnyMcKindy / users.js
Last active February 7, 2022 08:29
Пример компонента для таблиц
@Prop() type!
switch type {
case "users":
api.call("users")
break;
case "events":
api.call("events")
break;
}
@jinnyMcKindy
jinnyMcKindy / functional.js
Last active February 7, 2022 08:27
Функциональный пример
function delay(callback) {
setTimeout(() => callback(), 500)
}
function calc(a) {
return (b) => a + b;
}
calc(1)(2)
//3
class Context {
private strategy: Strategy;
constructor(strategy: Strategy) {
this.strategy = strategy;
}
public setStrategy(strategy: Strategy) {
this.strategy = strategy;
}
public doSomeBusinessLogic(): void {
const result = this.strategy.printText("test")
@jinnyMcKindy
jinnyMcKindy / ts-from-graphql.md
Created January 13, 2022 13:52 — forked from Vyachean/ts-from-graphql.md
Декларируем типы из graphql файлов

Декларируем типы из graphql файлов

Нужно быстро и не сильно вникая выжать всё самое полезное из graphql файлов. Нам поможет "graphql-codegen", он получит схему с сервера, и опишет типы для наших запросов.

настроим для него конфиг

# codegen.yml