Skip to content

Instantly share code, notes, and snippets.

View 197291's full-sized avatar
:octocat:

Yuriy Provotorov 197291

:octocat:
  • Taganrog
View GitHub Profile
@197291
197291 / Helpers.js
Last active April 16, 2018 07:33
Helpers
export function empty(val) {
return (typeof val === 'undefined' || val === '' || val === 0 || val === '0' || val === null
|| val === false || (typeof val === 'object' && !Object.keys(val).length) || (Array.isArray(val) && !val.length )
);
}
export function apiUrl (path, params, absolut = false) {
return URL_BASE + path
}
@197291
197291 / PaymentContainer.js
Last active October 26, 2017 06:59
Payments container
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import config from 'config';
import Helmet from 'react-helmet';
import { connect } from 'react-redux';
import { injectIntl, intlShape } from 'react-intl';
@197291
197291 / reducer.js
Last active October 26, 2017 07:02
Reducers
export const plansName = [
{
id: 'standard',
nameId: 'billing.plan.name.standard'
},
{
id: 'plus',
nameId: 'billing.plan.name.plus'
},
];
@197291
197291 / SelectPlan.js
Last active October 26, 2017 07:04
Select Plan
import React from 'react';
import PropTypes from 'prop-types';
import SelectField from 'material-ui/SelectField';
import MenuItem from 'material-ui/MenuItem';
import { RadioButton, RadioButtonGroup } from 'material-ui/RadioButton';
import RaisedButton from 'material-ui/RaisedButton';
import Paper from 'material-ui/Paper';
@197291
197291 / api.js
Created October 26, 2017 06:52
Api client helper
import superagent from 'superagent';
import cookies from 'react-cookie';
import config from '../config';
import CryptoJS from 'crypto-js';
import _clone from 'lodash/clone';
import { normalizePayload } from 'utils/jwt';
const methods = ['get', 'post', 'put', 'patch', 'del'];
@197291
197291 / actions.js
Created October 26, 2017 07:03
Actions
export function loadPlans(etag) {
return {
types: [LOAD_PLANS, LOAD_PLANS_SUCCESS, LOAD_PLANS_FAIL],
promise: (client) => client.get('/plans', {
headers: {
'If-None-Match': etag
}
})
};
}
@197291
197291 / DynamicArc.js
Created October 26, 2017 13:19
Example_D3_part1
App.prototype.makeDynamicArc = function (data) {
var rowLen = data.rowLen;
var shape0_x,
shape0_y;
var shape0_w = data.tag.w,
shape0_h = data.tag.h;
var shapeType = data.shape.shapeType,
shapeW = data.shape.w,
shapeH = data.shape.h;
@197291
197291 / calculateCoords.js
Created October 26, 2017 13:19
Example_D3_part2
App.prototype.calculateCoords = function (rowNumber, currentShape) {
var max_y = 20;
d3.selectAll('g.group').each(function (d) {
var coords = d3.transform(d3.select(this).attr("transform"));
var grpX = coords.translate[0];
var grpY = coords.translate[1];
if (grpY > max_y) {
max_y = grpY;
}
});
@197291
197291 / editRow.js
Created October 26, 2017 13:20
Example_D3_part3
App.prototype.editRow = function (config) {
if(config.name) {
if(this._isUniqueTag(config.name, self.shapes['grouped'])) {
d3.select(self.currentGroupForEdit).select('text').text(config.name)
} else {
alert('Group tag have to be unique. ' + config.name + ' is already existing.')
}
}
if(config.numberOfSeats) {
var elements = d3.select(self.currentGroupForEdit).selectAll('g.point');
@197291
197291 / mongo-cli.js
Created November 5, 2017 12:38
Usage cli for setting queries to mongodb
var MongoClient = require('mongodb').MongoClient,
commandLineArgs = require('command-line-args'),
assert = require('assert');
var options = commandLineOptions();
MongoClient.connect('mongodb://localhost:27017/crunchbase', function(err, db) {