Skip to content

Instantly share code, notes, and snippets.

import path from 'path';
import webpack from 'webpack';
import autoprefixer from 'autoprefixer';
import CleanWebpackPlugin from 'clean-webpack-plugin';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import devPlugins from './devPlugins';
import prodPlugins from './prodPlugins';
const basePlugins = (isDev, projectRootDir, outPath, srcPath) => [
{
"name": "huntlyDashboard",
"private": true,
"version": "0.0.1",
"description": "",
"main": "",
"scripts": {
"_node": "./node_modules/.bin/babel-node --max-old-space-size=4096",
"_webpack": "npm run -s _node -- ./node_modules/.bin/webpack",
"_server": "npm run -s _node -- ./node_modules/.bin/webpack-dev-server",
import path from 'path';
import webpack from 'webpack';
import BowerWebpackPlugin from 'bower-webpack-plugin';
const isDevelopmentMode = true;
const isHot = false;
const srcPath = path.resolve(__dirname, 'src');
const outPath = path.resolve(__dirname, 'dist');
module.exports = function(self, Promise) { // (function(self) {
'use strict';
if (self.fetch) {
return
}
var support = {
searchParams: 'URLSearchParams' in self,
iterable: 'Symbol' in self && 'iterator' in Symbol,
@piecyk
piecyk / Enhance.js
Created March 29, 2016 11:42 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@piecyk
piecyk / arrayToObject.js
Created March 15, 2016 17:32
arrayToObject.js
function arrayToObject(a, key) {
const getKey = (key, v, k) => {
if (key === 'identity') {
return v;
} else if (key) {
return v[key] || k;
} else {
return k;
}
}
const DebounceRender = React.createClass({
mixins: [React.addons.PureRenderIgnoreFunctionsMixin],
isRender: false,
getDefaultProps() {
return {wait: 400, showLoading: true};
},
componentWillMount() {
this.forceRender = _.debounce(this.forceRender, this.props.wait);
},
forceRender() {
@piecyk
piecyk / magit-gh-comments.el
Last active April 22, 2018 19:31
Create github commit comments in magit-diff emacs!
;; api https://developer.github.com/v3/repos/comments/#create-a-commit-comment
;; aslo using https://github.com/sigma/gh.el and https://github.com/sigma/magit-gh-pulls
(defun magit-gh-current-revision (current)
(cond ((derived-mode-p 'magit-revision-mode)
(car magit-refresh-args))
((derived-mode-p 'magit-diff-mode)
(--when-let (car magit-refresh-args)
(and (string-match "\\.\\.\\([^.].*\\)?[ \t]*\\'" it)
(match-string 1 it))))))
@piecyk
piecyk / promise.js
Last active December 5, 2015 08:20
function resolvePending(arrayOfPromises) {
const d = $.Deferred();
let resolved = [];
let rejected = [];
const check = () => {
if (resolved.length + rejected.length === arrayOfPromises.length) {
rejected.length > 0 ? d.reject(rejected) : d.resolve(resolved);
}
};
@piecyk
piecyk / AsyncRender.js
Last active November 18, 2015 17:03
Render long list, that has a complex time consuming child elements in async why, break out of react render loop.
// <AsyncRender
// data={[{}, {}, {}]}
// name={'complex'}
// onRender={(el, i) => <TimeConsumingComponent {...el}/>)}
// />
// TODO: know issue, we need to restart the rendering if we got new data,
// when rendering old one still is happening...
// in proper place set pending: false, and bucket: []
const AsyncRender = React.createClass({