Skip to content

Instantly share code, notes, and snippets.

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

Dmytro Shchehlov DScheglov

🏠
Working from home
View GitHub Profile
@DScheglov
DScheglov / cloudSettings
Last active June 3, 2018 18:31
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-06-03T18:31:43.380Z","extensionVersion":"v2.9.2"}
@DScheglov
DScheglov / promises.js
Last active September 26, 2017 13:00
Promises
const push = results => res => {
results.push(res);
return results;
};
const chainPromises = results => (
(promise, func) => promise.then(func).then(push(results))
);
const series = (...promises) => promises.reduce(
export const shalowCompareArgs = (args, _args) => (
_args == null ||
args.length !== _args.length ||
args.some((a, index) => a !== _args[index])
);
export const memorize = (func, compare = shalowCompareArgs) => {
let _args;
let _res;
return (...args) => {
@DScheglov
DScheglov / thunk-async.js
Last active October 11, 2017 14:34
async/await vs promise as monad
import { api } from '../api';
import { regUser } from './creators';
export const loadProject = projectId => async dispatch => {
const user = await api.loadProject(projectId);
dispatch(
regUser(user)
);
};
@DScheglov
DScheglov / event-emitter.js
Last active November 13, 2017 08:59
EventEmitter - functional style
// --- EventEmitter Factory Implementation ---
const { call, numberCalls, removeItem, append } = require('./helpers');
const unsibsribe = (_handlers, event, handler) => {
_handlers[event] = removeItem(_handlers[event], handler);
};
const on = _handlers => (event, handler) => {
<script type="text/javascript">
if(window.performance && window.performance.timing) {
var dom_content_loaded = (
window.performance.timing.domContentLoadedEventEnd - window.performance.timing.navigationStart
);
var dom_complete = (
window.performance.timing.domComplete - window.performance.timing.navigationStart
);
var payload = {
url: '/api_v3/visit/track?appKey={/literal}{$smarty.const.PDFFILLER_API_KEY}{literal}',
@DScheglov
DScheglov / decorators.js
Created November 12, 2017 12:03
Fibonacci
const calls = func => {
const _F = (...args) => {
_F.calls.push(args);
return func(...args);
}
_F.calls = [];
return _F
}
const memorize = func => {
import { PropTypes } from 'prop-types';
export const SomeComponent = ({ title, onClick }) => (
<button onClick={onClick}>{title}</button>
);
SomeComponent.propTypes = {
title: PropTypes.string,
onClick: PropTypes.func,
};
import { post } from '../api';
import * as urls from '../api/end-points';
import { logger } from '../logger';
import AC from './actions-registry';
export const saveSchema = (schemaName, schema) => async dispatch => {
const { res, err } = await post(urls.addSchema(), schema);
if (err) {
logger.error(err);
throw err;
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.saveSchema = undefined;
var _api = require('../api');
var _endPoints = require('../api/end-points');