Skip to content

Instantly share code, notes, and snippets.

View balkhaev's full-sized avatar
🏋️‍♀️
Buryat Developer

Mikhail balkhaev

🏋️‍♀️
Buryat Developer
View GitHub Profile
switch (Math.floor(HTTPStatus / 100)) {
case 1:
// Informational 1xx
console.log("Information code " + vMsg);
break;
case 2:
// Successful 2xx
console.log("Successful code " + vMsg);
break;
case 3:
const apiMachine = new Machine({
name: 'apiMachine',
type: 'general'
})
apiMachine.add({
details: [ lodashDetail, restDetail ],
components: [ apiComponent ]
})
const gameMachine = new StateMachine({
name: 'gameMachine',
type: 'specialized'
})
gameMachine.add({
details: [ renderDetail, controllerDetail, ],
components: [ playerComponent ]
})
@balkhaev
balkhaev / fabrica.js
Last active September 1, 2016 21:56
Fabrica for Machine,js
import Machine from 'machine.js'
import StateMachine from 'stateMachine.js'
import ViewStateMachine from 'viewStateMachine.js'
const fabrica = new Fabrica({
details: [ storeDetail, domDetail, lodashDetail, restDetail ],
components: [ flashbackComponent, spectatorComponent, apinatorComponent ],
mechanisms: [ ],
machnies: {
ViewStateMachine,
import ViewStateMachine from 'ViewStateMachine.js'
const frontendMachine = new ViewStateMachine({
name: 'frontendMachine',
type: 'specialized'
})
frontendMachine.add({
details: [ viewDetail, stateDetail ],
components: [ flashbackComponent, spectatorComponent ]
@balkhaev
balkhaev / es6-module.js
Created October 9, 2018 11:24
JS Module Examples
// Abstract
const privateSingletonVariable = {};
export const publicSingletonVariable = [];
export function publicPureFunction(arg1, arg2) {
return arg1 - arg2;
}
@balkhaev
balkhaev / encapsulation-vs-abstraction.js
Last active October 26, 2018 12:06
Инкапсуляция против абстракции
/**
* Кейс когда лучше инкапсуляция.
* Необходимо создать
*/
// Инкапсуляция
class Hero {
constructor(name, level) {
this.name = name;
@balkhaev
balkhaev / custom-select.html
Last active October 26, 2018 11:48
Кастомный селект с возможность подтягивания данных - https://jsfiddle.net/n7fp3Lv9/1/
<style>
.custom-select {
position: relative;
display: block;
max-width: 400px;
min-width: 180px;
margin: 0 auto;
background-color: #bf9622;
z-index: 10;
}
@balkhaev
balkhaev / algorithms.js
Last active October 29, 2018 15:29
Оценка сложности алгоритмов
/**
* Поиск дублирующихся символов.
*
* Сложность: f(n) = 4 + 4n + 8n² = O(n²)
*
* @param {string} str строка для поиска совпадений
* @returns {array} только дублирующиеся символы
*/
function duplicationSymbols(str = '') {
const dupSymbols = {};
@balkhaev
balkhaev / drag.js
Last active March 7, 2020 02:05
Vanilla js drag handlers
let dragStartX = null;
let dragStarted = false;
let currentPositionX = 0;
function dragStart(e) {
// Клик правой кнопкой
if (e.button === 2) {
return;
}