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
createObjFromUrl(uriString){
if (uriString && typeof uriString === 'string' && uriString.includes('=')) {
uriString = uriString.split('&').map((item) => item.split('='));
let urlObject = {};
uriString.forEach((i) => { urlObject[i[0]] = i[1]; });
return urlObject;
} else {
console.warn('Cannot parse that string: ' + uriString);
return {};
}
const processors = {
paypal: {
checker: urlParams.PayerID && urlParams.paymentId && urlParams.token,
resolver: () => {
this.savePaypalPayment(urlParams).then(
() => this.toast.success('Payment is successfull'),
e => this.toast.error(e || 'Payment is not successfull'),
);
},
},
const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
/**
* NEAT FETCH
*
* In the process of communicating with the server,
* we have a lot of places where there will be an error.
*
* The main purpose of this code is to unify the response even in case of an error.
* If we know exactly what the object function will return,
* the code will be easier to debug and work more reliably.
*
{
"name": "door-code",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test": "vue-cli-service test",
"lint": "vue-cli-service lint"
},
@Akiyamka
Akiyamka / godeeper.js
Last active June 17, 2018 13:34
Create tree from flat array
const childs = [
{
id: 'foo|bar|baz|bug',
name: 'foo, bar, baz, bugger',
},
{
id: 'foo',
name: 'foorer'
},
{
activate() {
this.pipeline = {
A_requestModel: () => {
this.params.loading = true;
return this.get(newRequest(this.params));
},
B_requestDataOnce: () => {
const state = this.store.getState();
this.constants = state.constants;
this.currentUser = state.currentUser;
// Realization
function startPipeline(pipelineRequests, order) {
order = order || [
'before',
'requestModel',
'after',
'stateToModel',
'setValidations'
@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