Skip to content

Instantly share code, notes, and snippets.

new method
https://facebook.github.io/react-native/docs/upgrading.html
// step 1
remove PROJECT/ios/build/
change package.json dependencies version
// step 2
@duncan60
duncan60 / docker restart
Created January 17, 2017 03:58
docker restart
sudo su -
service docker stop
ps aux | grep docker
#判断是否是Array
function isArray(data) {
return Array.isArray ? Array.isArray(data) : Object.prototype.toString.call(data) === '[object Array]';
}
#判断是否是 empty object {}
var isEmpty = function ua(data) {
if (Object.keys)
return Object.keys(data).length === 0;
for (var wa in data)
@duncan60
duncan60 / README.md
Created June 28, 2016 07:38 — forked from jonathantneal/README.md
createElement.js // a 300 byte DOM Element creator

createElement.js

createElement.js lets document.createElement use CSS selectors.

This is a pretty useful library for building out DOM elements. The whole thing runs on one regex and a for loop, so it’s plenty fast. The script is 300 bytes when compressed and gzipped. For 524 bytes (advanced), it includes nesting support and can generate entire DOM hierarchies, including text nodes.

Usage

document.createElement(); // generates <div />
@duncan60
duncan60 / Dockerfile
Last active May 22, 2016 15:06
docker run
# python 2
# Flask-RESTful & pymssql
FROM python:2-onbuild
MAINTAINER duncan60 <tmduncan60@gmail.com>
RUN apt-get update \
&& apt-get install freetds-dev \
&& pip install Flask \
&& pip install Flask-SQLAlchemy \
@duncan60
duncan60 / 0_reuse_code.js
Created April 27, 2016 02:54
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
var Webpack = require('webpack'),
path = require('path'),
util = require('util'),
pkg = require('./package.json'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
ExtractTextPlugin = require('extract-text-webpack-plugin');
var nodeModulesPath = path.resolve(__dirname, 'node_modules'),
buildPath = path.resolve(__dirname, 'dist'),
mainPath = path.resolve(__dirname, 'src', 'app', 'app.js'),
// createStore
const createStore = (reducer) => {
let state;
let listeners = [];
const getState = () => state;
const dispatch = (action) => {
state = reducer(state, action);
listeners.forEach(listener => listener());
};
@duncan60
duncan60 / example 1
Created January 2, 2016 10:28
pure function
let player = {
name : '',
state : '',
level : '',
height: 0,
age : 0,
point : 0
};
//impure
@duncan60
duncan60 / monad example
Last active June 12, 2017 10:20
functional programming
let add = (val, fun) => fun(val + 3);
let multiplication = (val) => val * 3;
console.log(add(2, multiplication));
//--------------------------------
let test = {
a: 10,
b: 20,
c: 30
};