CommonJS和AMD和CMD
CommonJS根据JS的表现制定规范:
{模块引用(require)} {模块定义(exports)} {模块标识(module)}
NodeJS遵循了CommonJS规范,写法如下:
12345// foo.jsmodule.exports = function(x) { console.log(x);};
1234// index.jslet foo = require('./foo')foo(1);
CommonJS主要为了JS在后端制定的规范,但并不适用与前端,因为代码在是通过网络加载,所以AMD(异步模块定义)出现:
define([‘dep1’,’dep2’],function(dep1,dep2){…});
RequireJS实现了AMD规范,写法如下:
1234567// foo.jsdefine(function() { return function(x) { console.log(x); };});
12345// ind ...
JwtBearer
JWT Token由以下三部分组成:
HEADER:ALGORITHM & TOKEN TYPE
1234 { "alg": "HS256", "typ": "JWT"}
PAYLOAD:DATA
12345{ "sub": "1234567890", "name": "John Doe", "iat": 1516239022}
VERIFY SIGNATURE
12345HMACSHA256( base64UrlEncode(header) + "." + base64UrlEncode(payload), your-256-bit-secret)
cron-parser
Github: cron-parser
123456789* * * * * *┬ ┬ ┬ ┬ ┬ ┬│ │ │ │ │ |│ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun)│ │ │ │ └───── month (1 - 12)│ │ │ └────────── day of month (1 - 31)│ │ └─────────────── hour (0 - 23)│ └──────────────────── minute (0 - 59)└───────────────────────── second (0 - 59, optional)
每10秒执行: */10 * * * * *
每周一10点执行: 0 0 10 ? * 1
每月1号10点执行: 0 0 10 1 * ?
暂时不支持:L、W、#
TypeScript in 5 minutes
类型注解123456789// jsfunction greeter(person) {}// tsfunction greeter(person: string) {}
接口1234567891011121314interface Person{ firstName: string, lastName: string}function greeter(person: Person) {}let user = { firstName: 'J', lastName: 'N'};// 内部结构兼容则兼容greeter(user);
类12345678910// 使用public可以自动创建该名称的属性class Student { fullName: String, constructor(public firstName: string, public lastName: string) { ...
关于通过document.styleSheets修改样式规则
1234567891011121314151617181920212223242526272829var innerText = '';function changeTheme() { try { var colors = JSON.parse( window.localStorage.getItem(window.localStorage.getItem('ROLE_ID') + '__theme') ); } catch (error) { } if (!colors) { return; } var keys = ['background', 'background-color', 'color', 'border-color']; var styleSheet = ...
Mac修改屏幕快照保存的位置
12$ defaults write com.apple.screencapture location <path>$ killall SystemUIServer
GitBook的安装和使用
##GitBook官网
https://github.com/GitbookIO/gitbook
##Node.js安装Nodejs官网下载pkg安装文件,一键安装##Gitbook安装 ###终端命令:
$ npm install gitbook -g
###dmg编辑器下载连接 https://github.com/GitbookIO/editor/releases
##编写图书
##图书输出###静态网页
$ gitbook build ./图书目录 –output=./输出目录
###PDF 需要安装:gitbook-pdf npm方式安装失败可去官网http://phantomjs.org/下载安装。
终端命令:
$ gitbook pdf ./图书目录
###eBook需安装:ebook-convert
终端命令:
$ gitbook epub ./图书目录
参考: http://gitbook-zh.wanqingwong.com/howtouse/gitbookcli.html
http://www.linu ...
All about angularjs $formatters and $parsers
The original link
Hi folks, As a front end developers we need to deal with different data models which come from the server side. We have to format them , change them and yes! we need to validate them. Mainly JSON at these days. In most cases back end data not in the way it should be.(Back end developers doesn’t bother to format data that much).Hence we are in a dark when we are going to render that data in our view. If you are angularjs user, Hell! you are in the business. Fortunately angularjs ...
用Python写爬虫
##目标
爬取美图天空的图片,并自动下载至本地
##环境
Python3.4+BeautifulSoup
##步骤
首先打开http://www.tootk.net/tupian/bizhi/分析网页内容
class="w170img"为每一条内容
里面的img内的src、alt分别为图片链接和名字
有了这两样就可以把图片下载下来了
##代码
12345678910111213141516171819202122232425262728293031323334353637383940# 语言:Python 3.4import urllib.requestimport bs4,ospage_sum = 10 #设置下载页数path = os.getcwd()path = os.path.join(path,'images')if not os.path.exists(path): os.mkdir(path) #创建文件夹url = "ht ...
Mac上本地新建SVN步骤
启动SVN服务:svnserve -d -r /Users/pengfeishi/Desktop/svn特别注意,路径一定是SVN的目录,不是其中一个版本库的目录,不然,能正常启动,就是访问有问题没有任何输出,则启动成功
关闭: killall -9 svnserve
连接: `svn://127.0.0.1/res