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
class Middleware { | |
constructor() { | |
this._middleware = [] | |
} | |
use(...fns) { | |
fns.forEach(fn => { | |
if (typeof fn !== 'function') { | |
throw new TypeError('Middleware must be 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
const tinyAjax = function tinyAjax(config) { | |
return new Promise((resolve, reject) => { | |
let request = new XMLHttpRequest() | |
request.open(config.method.toUpperCase(), config.url, true) | |
request.timeout = config.timeout || 60000 | |
// Listen for ready state | |
request.onreadystatechange = function handleLoad() { | |
if (!request || (request.readyState !== 4)) { | |
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
#!/bin/sh | |
# create self-signed server certificate: | |
read -p "Enter your domain [www.example.com]: " DOMAIN | |
echo "Create server key..." | |
openssl genrsa -des3 -out $DOMAIN.key 1024 |
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
/** | |
* @desc: Toast | |
* @authors: yongxiang.li | |
* @date: 2016-08-10 18:49:05 | |
* | |
* Toast('message') | |
*/ | |
// TODO 增加位置自定义 |
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
/** | |
* author: fa-ge | |
* github: https://github.com/fa-ge/LocalScrollFix | |
*/ | |
;(function() { | |
function createHeadTag() { | |
var styleNode = document.createElement('style') | |
styleNode.className = 'localscrollfix-head' | |
document.head.appendChild(styleNode) |
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
// include part of the element | |
// 包含元素的一部分区域在可以区域 | |
function isElementVisble(el) { | |
if(!el) { | |
return; | |
} | |
var viewportHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); | |
var elPos = el.getBoundingClientRect(); | |
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
//安卓不支持willShow方法,统一在didShow中处理 | |
RCTDeviceEventEmitter.addListener(Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow', evt=> { | |
if (!writeStore.isLoggingin) { | |
dispatcher.dispatch({ | |
namespace: 'write', | |
action: 'keyboardShow', | |
data: { | |
keyboardHeight: evt.endCoordinates.height |
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
/** @jsx React.DOM */ | |
var STATES = [ | |
'AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI', | |
'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', | |
'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', | |
'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY' | |
] | |
var Example = React.createClass({ |
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
/** @jsx React.DOM */ | |
define(['reactjs'], function(React){ | |
return React.createClass({ | |
getDefaultProps: function(){ | |
return { | |
multiple: false | |
/* | |
name: 'mySelect' |
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
Shell脚本编程30分钟入门 | |
==================== | |
## 什么是Shell脚本 | |
### 示例 | |
看个例子吧: | |
#!/bin/sh | |
cd ~ | |
mkdir shell_tut | |
cd shell_tut |
NewerOlder