Skip to content

Instantly share code, notes, and snippets.

@zinovyev
zinovyev / bootstrap
Last active April 29, 2018 16:14
Vagrant nginx & php-fpm bootstrap.sh
#!/usr/bin/env bash
#
# Vagrant nginx & php-fpm
# Vagrant basic bootstrap.sh file configuration for getting a ready to use dev solution
#
# Ivan Zinovyev <vanyazin@gmail.com>
#
# (The "ubuntu/trusty64" box was used and tested)
#
@jcouyang
jcouyang / react-tips.md
Last active October 24, 2015 13:33
some tips about React

React Tips

如果把每个Component想象成一个函数,那么props就是这个函数的参数。在有类型检查的语言中,很容易在编译期间就可以对参数类型检 查来避免一些不必要的错误。

javascript没有类型检查,但是我们仍然能筒高React的Prop Validation在运行期间检查props的类型。

只需要在Component声明里加上

propTypes: {
@hsnaydd
hsnaydd / es6-ajax-request.js
Created March 7, 2016 11:52
Es6 Ajax request
export default class Ajax {
get(url, callback) {
let xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
xhr.open('GET', url);
xhr.onreadystatechange = () => {
if (xhr.readyState > 3 && xhr.status === 200) {
callback(xhr.responseText);
}
};
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
var CryptoJS = require('crypto-js')
var request = require('request-promise')
/*
* npm install crypto-js request-promise request
* node wx_t1t_hack.js
*/
// export function testEncription(msg, fullKey) {
// var fullKey = fullKey.slice(0, 16)