This file contains hidden or 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
| var crypto = require('crypto'); | |
| var moment = require('moment'); | |
| var xml2js = require('xml2js'); | |
| module.exports = { | |
| //生成随机字符串 | |
| createNonceStr: function(){ | |
| return Math.random().toString(36).substr(2, 15); | |
| }, | |
| //生成时间戳 |
This file contains hidden or 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
| 'use strict' | |
| var r1,r2,s=null; | |
| try{ | |
| r1=s.length; //产生错误 | |
| r2=100; //此语句不会执行 | |
| } catch(e){ | |
| console.log('error'+e); | |
| } finally{ | |
| console.log('finally'); | |
| } |
This file contains hidden or 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
| var express = require('express'); | |
| var session = require('express-session'); | |
| var app = express(); | |
| app.use(session({ | |
| secret:'dsafdsa', | |
| cookie:{maxAge:60*1000*30} | |
| })); | |
| app.get('/', function(req, res){ | |
| if(req.session.sign){ //检查用户是否已登录 |
This file contains hidden or 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
| var express = require('express'); | |
| var cookieParser = require('cookie-parser'); | |
| var app = express(); | |
| app.use(cookieParser); | |
| app.get('/', function(req, res){ | |
| // 如果请求中的 cookie 存在 isVisit, 则输出 cookie | |
| // 否则,设置 cookie 字段 isVisit, 并设置过期时间为1分钟 | |
| if(req.cookies.isVisit){ | |
| console.log(req.cookies); | |
| res.send('hello'); |
This file contains hidden or 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
| var WechatAPI = require('wechat-api'); | |
| var appid = 'xxx'; | |
| var appsecret = 'xxxxx'; | |
| var api = new WechatAPI(appid, appsecret); | |
| api.createLimitQRCode(10000, function(err, result){ | |
| if(err){ | |
| console.log('createLimitQRCode failed') | |
| } |
This file contains hidden or 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
| var WechatAPI = require('wechat-api'); | |
| var appid = 'xxx'; | |
| var appsecret = 'xxxxx'; | |
| var api = new WechatAPI(appid, appsecret); | |
| var me4_id; | |
| var openid_list; | |
| api.getMaterials('image', 0, 200, function(err, result, res){ | |
| if(err){console.log(err)} |
This file contains hidden or 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
| function createObj(nick,age){ | |
| var obj = { | |
| nick:nick, | |
| age:age, | |
| printName:function(){ | |
| console.log(this.nick); | |
| } | |
| } | |
| return obj; | |
| } |
This file contains hidden or 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
| var co = require('co'); | |
| var thunkify = require('thunkify'); | |
| function f1(callback){ | |
| callback(0, 1); | |
| } | |
| var n = thunkify(f1); | |
| co(function* (){ | |
| var out = yield n(); |
This file contains hidden or 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
| var thunkify = require('thunkify'); | |
| var co = require('co'); | |
| function myThunk(userName,callback){ | |
| callback(null , 'hello'+' '+ userName); | |
| } | |
| var myR = thunkify(myThunk); | |
| function* fn(){ | |
| var a = yield myR('a'); |
This file contains hidden or 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
| cd c:\ | |
| unzip nginx-1.8.1.zip | |
| ren nginx-1.8.1 nginx | |
| cd nginx | |
| start nginx | |
| control: | |
| nginx -s [stop|quit|reopen|reload] |
NewerOlder