Skip to content

Instantly share code, notes, and snippets.

View pilwon's full-sized avatar

Pilwon Huh pilwon

View GitHub Profile
import startsWith from 'lodash/string/startsWith';
import React from 'react';
import Context from 'react-famous/core/Context';
import Surface from 'react-famous/core/Surface';
import Scrollview from 'react-famous/views/Scrollview';
const SURFACE_REF_PREFIX = 'surface_';
class Component extends React.Component {
componentDidMount() {
@pilwon
pilwon / code.js
Last active October 13, 2015 04:13
react-native DependencyResolver perf test (script & full result) https://github.com/facebook/react-native/issues/361#issuecomment-87829808
var path = require('path');
var async = require('async');
var mathjs = require('mathjs');
var ReactPackager = require('react-native/packager/react-packager');
var blacklist = require('react-native/packager/blacklist');
var reactNativePackage = require('react-native/package');
var NUM_TESTS = 100;
function test() {
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
@pilwon
pilwon / test-es6-imports.js
Created March 29, 2015 06:57
Tests if regex matches all valid ES6 import syntaxes. https://github.com/facebook/react-native/pull/386
//
// Tests if regular expression matches all valid ES6 import syntaxes.
//
// ES6 Language Specification Reference:
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-imports
//
const ES6_IMPORT_REGEX = /\bimport\s+(?:.+\s+from\s+)?[\'"]([^"\']+)["\']/g;
const VALID_ES6_IMPORT_SYNTAXES = [

Usage

  1. npm install babel-loader imports-loader webpack --save
  2. Create webpack.config.js
  3. Move index.ios.js to src/index.ios.jsx
  4. webpack --watch

Example

src/index.ios.jsx

var path = require('path');
function ReactNativeResolverPlugin(reactNativeRoot) {
if (!reactNativeRoot) {
reactNativeRoot = path.resolve(__dirname, 'node_modules/react-native');
}
this.reactNativeRoot = reactNativeRoot;
}
@pilwon
pilwon / README.sh
Last active August 29, 2015 14:01
Haproxy 1.5 deb package w/ FPM
# Run FPM in docker container.
docker run -it --rm dockerfile/fpm
# Install dependencies.
apt-get install -y libssl-dev
# Download & Build Haproxy.
cd /tmp
wget http://haproxy.1wt.eu/download/1.5/src/devel/haproxy-1.5-dev25.tar.gz
tar xvzf haproxy-1.5-dev25.tar.gz