Skip to content

Instantly share code, notes, and snippets.

View Akiyamka's full-sized avatar
🏠
Working from home

Alexander CherryTea Akiyamka

🏠
Working from home
View GitHub Profile
@Akiyamka
Akiyamka / blend-mode-polyfill.js
Created November 9, 2018 10:13
blend-mode-polyfill
/**
* @author Boggddan <github.com/boggddan>
* Запускается в браузерах которые не поддерживают свойство background-blend-mode.
* Полифил применяется к тегам помеченым атрибутом `data-background-blend-mode` в свойтвах которого нужно передать режим смешивания.
* Поддерживается: normal, multiply, lighten, screen, darken. (протестировано в IE 11)
* @example: <div data-background-blend-mode="multiply"></div>
*/
/* Element.prepend polyfill for IE 11 */
function prependPolyfill() {
@Akiyamka
Akiyamka / apollo.js
Last active October 10, 2018 16:27
const { ApolloServer, gql } = require('apollo-server');
const { libraryAPI, bankAPI } = require('./mocks');
const typeDefs = gql`
type Book {
title: String
author: Author
}
@Akiyamka
Akiyamka / sign-in.md
Last active September 30, 2018 18:37
Firebase Authentification

Для того чтобы залогинить существующего пользователя воспользуйтесь методом signInWithEmailAndPassword

firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
  // Handle Errors here.
  var errorCode = error.code;
  var errorMessage = error.message;
  // ...
});
@Akiyamka
Akiyamka / migratiom.md
Last active September 13, 2018 12:48
D3 migration tips (3 -> 5)

Reducing Boilerplate

Упрощаем action creator:

Центральный элемент redux - action. Выглядит он примерно так:

{
 type: ADD_TODO,
<div id="cont" data-precent="100">
<svg id="svg" width="200" height="200" viewPort="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg">
<circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
<circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
</svg>
</div>
<label for="percent">Type a percent!</label>
<input id="percent" name="percent">
startQuery() {
return Promise.all([
this._createCampaign(this.$models),
this._createCreative(this.$models),
]).then(resps => {
this.setStore('campaign', resps[0]);
this.setStore('creative', resps[1]);
return this._createStrategy(this.$models, this.$store)
}).then(strategy => {
this.setStore('strategy', strategy);
function toBlob(func) {
const funcString = func.toString();
const code = funcString.substring(
funcString.indexOf('{') + 1,
funcString.lastIndexOf('}'),
);
const blob = new Blob([code], { type: 'application/javascript' });
return URL.createObjectURL(blob);
}
@Akiyamka
Akiyamka / test-url.js
Created July 7, 2018 15:18
test url for multiple protocols
const re = /^(?:(?:https?|[\w]*):((\/\/)[\w\d]|[\w\d+])).*/gm;
// VALID
tel:+12123123123123
http://asdasdasd.com
http://ru.asdasdasd.com
https://ru.asdasdasd.com
https://123sdasdasd.com
https://123sdasdasd.com/%D1%84%D1%8B%D0%B2%D1%84%D1%8B%D0%B2%D1%84%D1%8B%D0%B2
tg://asdasd
// Realization
function startPipeline(pipelineRequests, order) {
order = order || [
'before',
'requestModel',
'after',
'stateToModel',
'setValidations'