Skip to content

Instantly share code, notes, and snippets.

View iegik's full-sized avatar
🧾
Looking for work

Arturs Jansons iegik

🧾
Looking for work
View GitHub Profile
@iegik
iegik / code.html
Last active December 29, 2017 09:43
No code - no bugs

Design Patterns in JavaScript

Strategy

Observer

@iegik
iegik / README.md
Last active September 11, 2025 05:52

negate

const negate = fn => (...args) => !fn(...args);

claim

const claim = fn => (...args) => fn(...args);
@iegik
iegik / MAC.md
Last active January 30, 2021 21:29

  • === Option
  • === Command or CMD
  • === Escape or ESC
  • === Shift
  • === Caps Lock or CpsLck

+ ` - Switch between same app windows

:root {
--var1: 0;
}
.root {
/* .root-ZxY */
}
.module .btn {
/* .module-xYz .btn-Yzx */
}
.module :global .btn {
@iegik
iegik / FONTS.md
Last active January 27, 2021 08:28
Font loading technics

Loading fonts

font-display: optional;

DEPRICATED

if (getCookie('fonts') === 1) {
 printf('')
@iegik
iegik / FAST_REQUEST.md
Last active November 9, 2017 10:11
Fast Promise

Here is example of fast implimentation with requests:

import fast, request from './';
const {log} = console;

class API {}
API.json = (...args) => 
  // @fast request
 fast(request)(...args).then(data => data.json());
@iegik
iegik / Marionette 2 v.s. 3 diff
Last active January 27, 2021 07:35
Marionette and Backbone best practices
`childEvents` -> `childViewEvents`
`LayoutView` -> `View`
`ItemView` -> `View`
`onBeforeShow` -> `onRender`
`templateHelpers` -> `templateContext`
`(this|self)\.(\w+).show\(` -> `$1\.showChildView('$2', `
@iegik
iegik / Form.js
Last active December 5, 2017 09:53
Form validation
import React, { Component } from 'react';
import { reduce } from 'lodash';
export default View => class extends Component {
state = {
values: {},
errors: {},
isSubmitted: false,
isFresh: true,
onChangeField: (field, value, validation) => {
@iegik
iegik / ddata-api.js
Last active June 11, 2018 21:47
Place Predictions Interface
const DDATA_API_KEY = 'YOUR_API_KEY';
const ddataAPI = body => {
return new Promise((response, reject) => {
let xhr = new XMLHttpRequest();
xhr.open("POST", "https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/address?5");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Authorization", `Token ${DDATA_API_KEY}`);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = () => {