Fork me on GitHub
Blog


  • Home

  • Tags

  • Categories

  • Archives

  • About

  • BlogDIY

About Open Source And Copyright

Posted on 2019-01-30

1.开源软件协议

GitHub 用了很长时间了,open source也fork了不少,但是对于开源软件协议不甚了解,于是就学习一下,加深印象,感谢强大的互联网和各位大神。
借用阮一峰老师的图Mark一下,以备参考:六种流行开源协议的使用区分

六种流行开源协议的使用区分
三种简明

选择一个开源软件协议-中文(感谢GcsSloop)

Choose an open source license

2.知识共享

Creative Commons,简称CC。 是一个非营利组织,也是一种创作的授权方式。

传统的著作权通常为两种极端,一端是“保留所有权利”,另一端则是“不保留任何权利”(即公有领域,public domain)。
知识共享则试图在两者中间广大的灰色地带保有弹性,使得创作者可以“保留部分权利”。知识共享提供多种可供选择的授权形式及条款组合,
创作者可与大众分享创作,授予其他人再散布的权利,却又能保留其他某些权利。知识共享的诞生是为了避免现代知识产权以及版权法在信息共享方面的问题。

一般用于设计,摄影,图片作品的开放式分享。

作为作者,你可以选择以下1~4种权利组合:

  1. 署名(Attribution,简写为BY):必须提到原作者。
  2. 非商业用途(Noncommercial,简写为NC):不得用于盈利性目的。
  3. 禁止演绎(No Derivative Works,简写为ND):不得修改原作品, 不得再创作。
  4. 相同方式共享(Share Alike,简写为SA):允许修改原作品,但必须使用相同的许可证发布。
    权利组合 来自百度百科

简化6种协议组合

  1. 署名(BY)
  2. 署名(BY)-相同方式共享(SA)
  3. 署名(BY)-禁止演绎(ND)
  4. 署名(BY)-非商业性使用(NC)
  5. 署名(BY)-非商业性使用(NC)-相同方式共享(SA)
  6. 署名(BY)-非商业性使用(NC)-禁止演绎(ND)
    在最新Creative Commons(知识共享)3.0协议中,署名(BY)权利成为必选项。
    6种协议组合 来自百度百科

CreativeCommons
署名 3.0 中国大陆 (CC BY 3.0 CN)

Windows下安装pip,通过pip安装aws-cli

Posted on 2018-12-14

Python环境

pip依赖于Python,我机器Win7 64位已经安装了Python3,并添加了环境变量:

PYTHON_HOME : E:\temp\Python36
Path : %PYTHON_HOME%;%PYTHON_HOME%\Tools\Scripts;%PYTHON_HOME%\Scripts;

Python Downloads cmd-markdown-logo

Python 2 >=2.7.9 Python3 >=3.4 版本安装好以后根目录下Scripts文件夹里有pip,只需升级一下即可,其他版本则需要安装pip。

升级Pip包

python -m pip install -U pip

如图:update

安装PIP包

到Python Package Index 搜索 pip,下载最新版pip包
如图:dld

用常规的解压工具解压pip-18.1.tar.gz,进入到pip的解压目录,CMD执行python setup.py install进行安装
如图:ok

因为pip命令被安装到Python根目录的Scripts文件夹下,如果没有添加环境变量的则需要添加Path : %PYTHON_HOME%\Scripts; ,CMD执行pip list
如图:pip list

安装pip成功,则可以通过pip命令安装其他的python模块了。

安装AWS CLI

CMD执行pip install awscli
如图:awscli

CMD执行pip list
如图:pip l

CMD执行aws --version
如图:aws v

这样aws-cli就装好了.

更新到最新版本的 AWS CLI

pip install awscli --upgrade --user
如图:upd ac

卸载 AWS CLI

pip uninstall awscli

AWS CLI Github

React Practice Deposit

Posted on 2018-12-12

React.createClass与React.Component区别

this自绑定

React.createClass创建的组件,其每一个成员函数的this都有React自动绑定,任何时候使用,直接使用this.method即可,函数中的this会被正确设置。

1
2
3
4
5
6
7
8
9
10
const Clazz = React.createClass({  
handleClick() {
console.log(this); // React Component instance
},
render() {
return (
<div onClick={this.handleClick}></div>
);
}
});

React.Component创建的组件,其成员函数不会自动绑定this,需要开发者手动绑定,否则this不能获取当前组件实例对象。

1
2
3
4
5
6
7
8
9
10
11
12
13
class Clazz extends React.Component {  
constructor(props) {
super(props);
}
handleClick() {
console.log(this); // null
}
render() {
return (
<div onClick={this.handleClick}></div>
);
}
}

React.Component有三种手动绑定方法:可以在构造函数中完成绑定,也可以在调用时使用method.bind(this)来完成绑定,还可以使用Arrow Function(箭头函数)来绑定。

1
2
3
4
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this); //构造函数中绑定
}

<div onClick={this.handleClick.bind(this)}></div> //使用bind来绑定

<div onClick={()=>this.handleClick()}></div> //使用Arrow Function来绑定

组件初始状态state的配置不同

React.createClass创建的组件,其状态state是通过getInitialState方法来配置组件相关的状态。

1
2
3
4
5
6
7
8
9
10
11
const Clazz = React.createClass({
// return an object
getInitialState(){
return {
isEditing: false
}
}
render(){
return <div></div>
}
})

React.Component创建的组件,其状态state是在constructor中像初始化组件属性一样声明的。

1
2
3
4
5
6
7
8
9
10
11
class Clazz extends React.Component{
constructor(props){
super(props);
this.state = { // define this.state in constructor
isEditing: false
}
}
render(){
return <div></div>
}
}

组件属性类型propTypes及其属性defaultProps配置不同

React.createClass在创建组件时,有关组件props的属性类型及组件默认的属性会作为组件实例的属性来配置,其中defaultProps是使用getDefaultProps的方法来获取默认组件属性的。

1
2
3
4
5
6
7
8
9
10
11
12
13
const Clazz = React.createClass({
propTypes: { // as an object
name: React.PropTypes.string
},
getDefaultProps(){ // return a object
return {
name: ''
}
}
render(){
return <div></div>
}
})

React.Component在创建组件时配置这两个对应信息时,他们是作为组件类的属性,不是组件实例的属性,也就是所谓的类的静态属性来配置的。

1
2
3
4
5
6
7
8
9
10
class TodoItem extends React.Component {
static propTypes = { //类的静态属性
name: React.PropTypes.string
};
static defaultProps = { //类的静态属性
name: ''
};

...
}

一个 Serverless offline + Aws Dynamodb local Demo

Posted on 2018-12-04

从无极而太极,无服务即是服务

  • Serverless是什么,国内外云计算大厂提供相关技术架构和服务,如 WS Lambda,Azure Functions,Google Cloud Functions,IBM Cloud Functions,阿里云的函数计算等,还有为特定用例提供服务的小型供应商, 例如 Twilio Functions、 PubNub Functions、 Auth0 Webtask。还有一些使用 Docker 和 Kubernetes 构建的 serverless 计算实现,例如 Kubeless 和 Fission。
  • Serverless官网
  • Serverless Framework Github

本地环境:Win7,Git,Nodejs(npm)

1.安装全局 serverless framework

npm install -g serverless

安装完验证一下

serverless -v

2.设置 aws 凭证

我这里没有aws账号,暂且用官方的示例:临时安全凭证
将其导入到本地

serverless config credentials --provider aws --key AKIAIOSFODNN7EXAMPLE --secret wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

将会自动生成配置到用户目录下 ~/.aws/credentials

下面先下载官方Demo在本地配置跑一下

3.下载aws-node-rest-api-with-dynamodb-and-offline

serverless install -u https://github.com/serverless/examples/tree/master/aws-node-rest-api-with-dynamodb-and-offline -n aws-node-rest-api-with-dynamodb-and-offline

4.安装必要依赖

cd aws-node-rest-api-with-dynamodb-and-offline
npm install

1

5.安装 aws dynamodb

serverless dynamodb install

6.启动本地离线服务

serverless offline start

2

7.另外打开一个GitBash,迁移数据,这一步不执行也行,因为会报 Serverless: DynamoDB - Warn - table aws-node-rest-api-with-dynamodb-and-offline-dev already exists

serverless dynamodb migrate

8.打开浏览器地址栏输入 http://localhost:8000/shell/ 就可以看到DynamoDB JavaScript Shell

3

在控制台输入 tutorial.start() 可以漫游Dynamodb基本操作
4

9.浏览器地址栏输入 http://localhost:3000/todos 请求到的是空json对象

5

控制台输出红圈响应:

6

10.下面通过 curl插入一条数据

7

控制台输出响应:

8

重复第9步,浏览器输出数据:

9

11.通过火狐插件 HttpRequester插件再插入一条数据

10

控制台输出响应:

11

重复第9步,浏览器输出数据:

12

设置Outlook邮件 自动转发

Posted on 2018-11-30

设置Outlook邮件 自动转发

  1. Tools —> Rules and Alerts
    Rules and Alerts

  2. NewRule
    NewRule

  3. Start from a blank rule —> Check the messages when they arrive
    Start from a blank rule

  4. Next
    Next

  5. from people or distribution list
    from people or distribution list

  6. Add From Address list
    Add From list

  7. Next
    Next

  8. Check the [forward it to people or distribution list]
    forward it to people or distribution list

  9. Set to Address
    Set to

  10. Set exceptions
    Set exceptions

  11. Finish set a name and turn on
    Finish

Markdown Info

Posted on 2018-11-23

Markdown 编辑器

MdEditor

cmd-markdown-logo

Cmd Markdown 编辑阅读器

cmd-markdown-logo
除了您现在看到的这个 Cmd Markdown 在线版本,您还可以前往以下网址下载:
Windows/Mac/Linux 全平台客户端

Typora

[下载](https://www.typora.io/#download)

小书匠编辑器

离线版下载地址
GitHub

Dillinger

马克飞象

cmd-markdown-logo

Editor

cmd-markdown-logo

数学公式

MathJax 中文文档
Latex 文档
IPython

  • 参考1
  • 参考2
  • 参考3

    Sample:

    LaTeX 公式

    可以创建行内公式,例如 $\Gamma(n) = (n-1)!\quad\forall n\in\mathbb N$。或者块级公式:

流程图

Hexo-filter-flowchart

  • 参考1

    Hexo-filter-mermaid-diagrams

  • 参考2
  • 参考3
  • 参考4

    Sample:

5. 高效绘制 序列图

Hexo-filter-sequence

  • 参考

    Sample:

7. 绘制表格

项目 价格 数量
计算机 $1600 5
手机 $12 12
管线 $1 234

代码高亮

参考1
参考2
参考3
参考4

1
2
3
4
5
6
7
@requires_authorization
class SomeClass:
pass

if __name__ == '__main__':
# A comment
print 'hello world'

我是分割线



Other

Hello World

Posted on 2018-11-22

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

the same cmd is:

1
$ hexo s

Change the port

1
hexo s -p 4001

More info: Server

Generate static files

1
$ hexo generate

the same cmd is:

1
$ hexo g

Watch for File Changes

Hexo can watch for file changes and regenerate files immediately. Hexo will compare the SHA1 checksum of your files and only write if file changes are detected.

1
$ hexo generate --watch

More info: Generating

Deploy to remote sites

1
$ hexo deploy

the same cmd is:

1
$ hexo d

More info: Deployment

Cleans the cache file (db.json) and generated files (public).

1
$ hexo clean

More info: Deployment

Hexo-Env
中文文档
cmd-markdown-logo

Roc

Roc

7 posts
GitHub
© 2019 Roc
Powered by Hexo
|
Theme — NexT.Muse v5.1.4
|