This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple express server with a dynamic gz compression enabled. | |
*/ | |
"use strict"; | |
const express = require("express"); | |
const cors = require("cors"); | |
const compression = require('compression'); | |
const morgan = require('morgan'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component, PropTypes } from 'react'; | |
import { render } from 'react-dom'; | |
import { createStore, combineReducers, bindActionCreators } from 'redux' | |
import { Provider, connect } from 'react-redux' | |
// ## Simple component | |
// =================== | |
class Root extends Component { | |
constructor(props) { | |
super(props); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component, PropTypes } from 'react'; | |
import { render } from 'react-dom'; | |
import { createStore, combineReducers, bindActionCreators } from 'redux' | |
import { Provider, connect } from 'react-redux'; | |
import { | |
FormattedDate, | |
FormattedTime, | |
FormattedRelative, | |
FormattedNumber, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component, PropTypes } from 'react'; | |
import { render } from 'react-dom'; | |
import { createStore, combineReducers, bindActionCreators, applyMiddleware } from 'redux' | |
import { Provider, connect } from 'react-redux' | |
import thunkMiddleware from 'redux-thunk' | |
// We need only two things: add 'thunk' and create async action (see bellow) | |
// "External" async function | |
// ========================= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The idea is taken from: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html | |
const makeCancelable = (promise) => { | |
let hasCanceled_ = false; | |
const wrappedPromise = new Promise((resolve, reject) => { | |
promise.then((val) => | |
hasCanceled_ ? reject({isCanceled: true}) : resolve(val) | |
); | |
promise.catch((error) => | |
hasCanceled_ ? reject({isCanceled: true}) : reject(error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this filter suppress react-intl's redundant console output while not in production | |
class ErrorConsoleFilter { | |
constructor(disabledValue) { | |
this.disabledValue = disabledValue; | |
this.originalConsoleError = console.error; // eslint-disable-line no-console | |
this.outputHandler = this.outputHandler.bind(this); | |
console.error = this.outputHandler; // eslint-disable-line no-console | |
} | |
outputHandler(...args) { | |
if (args[0].indexOf(this.disabledValue) === 0) return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { jsdom } from 'jsdom'; | |
const document = jsdom('<!DOCTYPE html><head></head><body></body></html>'); | |
const exposedProperties = ['window', 'navigator', 'document']; | |
global.document = document; | |
global.window = document.defaultView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# EditorConfig is awesome: http://EditorConfig.org | |
# top-most EditorConfig file | |
root = true | |
# Unix-style newlines with a newline ending every file | |
[*] | |
end_of_line = lf | |
charset = utf-8 | |
indent_style = space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# ================================= | |
# Android SDK & Emulator installer | |
# For React Native development | |
# Platform: OSX, WIN | |
# Ver: 20171128 | |
# dmitriy.karmalita@gmail.com | |
# Original gist: https://git.io/vbLFg | |
# ================================= | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint no-console: 0 */ | |
'use strict' | |
const shellExec = ( | |
cmd, // shell command to execute | |
suppressErr=false, // drop errors if any | |
suppressOutput=false // execute silent | |
) => new Promise((resolve,reject)=>{ | |
const { spawn } = require('child_process'); | |
const worker = spawn(cmd, { shell: true }) |
OlderNewer