Skip to content

Instantly share code, notes, and snippets.

View a-x-'s full-sized avatar
🛩️

Alexander a-x-

🛩️
View GitHub Profile
@a-x-
a-x- / example-page-container.jsx
Last active November 6, 2017 10:55
HO cantainer that works with HO reducer loadable (http://bit.ly/2zz8ZCB)
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import layout from '../containers/layout';
import * as selectors from '../selectors/operations';
import { getItems, changeOperationStatus, getHeaders, paginate } from '../actions/operations';
import isDefined from '../utils/is-defined';
import Content from '../components/operations/content';
@a-x-
a-x- / example-reducer.js
Last active November 6, 2017 10:56
High-Order reducer loadable — part of loadable HOX (HO x aka HO complex)
// Composed with loadableHOX(HOReducers: { replace, update, patch }, storeKeys: { error, loading, data })
import { Map, List } from 'immutable';
import * as loadable from './common/loadable';
const updatePage = loadable.createReducer();
const updateHeaders = loadable.createReducer();
const updateSelectedItems = loadable.createReducer();
/**
@a-x-
a-x- / promise-is-like-a-monad.js
Created October 28, 2017 00:33
Touch the monad everyday
async function foo () {
const response = await request(url)
/* not null or undefined */
if (!response) throw new Error(‘no_data’)
return response;
}
foo().then(just, nothing)
import { Iterable, Map, List } from 'immutable';
// add fast getter into immutable
const accesor = new Proxy(Object.prototype, {
get: (target, property, receiver) => target.get(property),
});
Object.setPrototypeOf(Iterable.prototype, accesor);
// now you can do:
const m = Map({ a: 1 });
@a-x-
a-x- / hoisting.es
Created October 27, 2017 21:24
#hoisting #iife
{
 console.log(a); // ReferenceError
 const a = 1;
}
{
 const f = () => console.log(a);
 const a = 1;
 f() // → 1
}
@a-x-
a-x- / mixin.js
Last active October 25, 2017 08:11 — forked from march213/mixin.js
(() => {
// todo: mixins collection
class Foo {
foo() {
console.log(this.bar());
}
bar() { console.log('bar'); return 42 }
}
const SomeMixin = {
// @props Array<T> list1, list2
// Assumptions: lists're sorted; T is primitive
// @returns { mergedItems, commonItems, list1Uniqs, list2Uniqs }
function mergeLists (list1, list2, options = {}) {
let {
compare = (a, b) => b - a, // todo: compare strings
mergedItems = [],
commonItems = [],
} = options;
{
// ...
output: {
path: path.resolve(__dirname, 'build'),
library: 'lib',
filename: 'main.js',
libraryTarget: 'commonjs',
}
externals: {
react: {
class Link extends PureComponent {
render () {
// Unusual useful omit application
const rest = omit(this.props, [
'url', 'basePath', 'RouterLink', 'method', 'currentTab', 'disabled', 'children', 'className',
'title', 'confirm', 'onClick', 'onSuccess', 'onFailure', 'axiosProps', 'noExternalIcon',
]);
return isExternalUrl(this.props.url)
? this.renderExternalLink({ rest })
: this.renderInternalLink({ rest });
я календарь переверну и снова
в действительности все не так как на самом деле
Т-0,66 5ВА КЛ.0,5 1000/5 М 3/В ЯЩ.
€40.35
жк
жк с парковкой для теслы
за что казнили изобретателя гильотины
за одно
вы стали тимлидом
жк солнечная система