Skip to content

Instantly share code, notes, and snippets.

View mistadikay's full-sized avatar

Denis Koltsov mistadikay

View GitHub Profile
let mergeSort = (arr) => {
if (arr.length < 2) return arr;
let middle = parseInt(arr.length / 2),
left = arr.slice(0, middle),
right = arr.slice(middle);
return merge(mergeSort(left), mergeSort(right));
}
@mistadikay
mistadikay / index.scss
Created May 3, 2015 15:55
Fun with line-height
$lh: 1.4em;
body {
font-size: 1em;
line-height: $lh;
}
h1 {
background: #333;
margin: 0;
@mistadikay
mistadikay / index.js
Created May 13, 2015 09:36
flux in ES7 by @roman01la
function example(){
class Actions {
@Observable
static processSomething
}
class Store {
constructor(name){
this.name = name;
@mistadikay
mistadikay / product.es6
Last active August 29, 2015 14:25
Declarative data fetching in React components with Baobab
import { Component } from 'react';
import DataWatcher from 'components/@data-watcher';
// DataWatcher decorator watches data paths described below
// and updates local state whenever global state changes something in these paths
@DataWatcher
class Product extends Component {
static displayName = 'Product';
// data paths can be static or they can contain props and states
import { Component } from 'react';
// Flux action creators for products
import ProductsActions from 'actions/products';
// global state
import state from 'state';
// main wrapper component
class App extends Component {
import React, { Component } from 'react';
import DataWatcher from 'components/@data-watcher';
const sortTypes = [ 'asc', 'desc' ];
@DataWatcher
class ProductsList extends Component {
static displayName = 'ProductsList';
static data = (props, state) => ({
// in data dependency besides cursor path
import React from 'react';
class Popup extends React.Component {
render() {
return (
<div className={'popup' + (this.props.visible ? ' popup_visible' : '')}>
<div className="popup__overlay"></div>
<div className="popup__content">{this.props.children}</div>
</div>
);
import React from 'react';
import b from 'b_';
const block = b.with('popup');
class Popup extends React.Component {
render() {
return (
<div className={b({ visible: this.props.visible })}>
<div className={b('overlay')}></div>
import Yummies from '@yummies/yummies';
class Popup extends Yummies.Component {
render() {
return {
block: 'popup',
mods: {
visible: this.props.visible
},
content: [
import React from 'react';
import { BEM } from 'rebem';
class Popup extends React.Component {
render() {
return BEM(
{
block: 'popup',
mods: { visible: this.props.visible }
},