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
// index.js | |
dot.templateSettings.begin = '<?js'; | |
dot.templateSettings.end = '?>'; | |
// index.html | |
<p>hello <?js! word ?></p> |
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
/** | |
* 显示指定用户 profile 页面 | |
* | |
* 获取关注和被关注的数据 | |
* 获取此用户最近的活动数据 | |
* - 活动数据里面包含各种数据的聚合 | |
* 判断当前登录的用户与指定用户是否已经相互关注 | |
* | |
*/ |
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
------------- new Buffer 0 | |
free 139.82421875MB | |
------------- after new 1MB buffer | |
free 138.890625MB | |
------------- new Buffer 1 | |
free 138.890625MB | |
------------- after new 1MB buffer | |
free 138.890625MB |
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 db = require('mongoskin').db('localhost:27017/taohistorytest'); | |
db.bind('histories'); | |
db.histories.ensureIndex('num_iid', true, function() {console.log(arguments);}); | |
db.histories.find().toArray(function(err, items){ | |
console.log(arguments); | |
}); | |
db.histories.insert({num_iid: 1, title: 'test title'}, function() { | |
console.log(arguments); | |
}); |
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
{ | |
user: shiba, | |
item: { | |
2222 : "dfdfdfdf", | |
3333 : "dfdfdff", | |
1111 : "kdkdfdfdf" | |
}, | |
user: liulei, | |
item: { |
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 mongo = require('mongoskin'); | |
var db = mongo.db('127.0.0.1:27017/test'); | |
// create index: | |
// key, unique, callback | |
db.collection('user').ensureIndex([['name', 1]], true, function(err, replies){}); | |
// bind method: db.user ===> db.collection('user') | |
db.bind('user'); |
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 b = new Buffer(2) | |
> b | |
<Buffer 00 00> | |
> b[0] = 0xcb | |
203 | |
> b | |
<Buffer cb 00> | |
> b[1] = 0xd5 | |
213 | |
> b |
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
Foo.prototype.get = function(key, callback) { | |
db.get(key, function(err, data) { | |
if (err) return callback(err); | |
try { | |
callback(null, JSON.parse(data.toString()); | |
} catch(e) { | |
callback(e); | |
} | |
}); | |
}; |
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
Foo.prototype.get = function(key, callback) { | |
db.get(key, function(err, data) { | |
if (err) return callback(err); | |
try { | |
callback(null, JSON.parse(data.toString())); | |
} catch(e) { | |
callback(e); | |
} | |
}); | |
}; |
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 redis_host='10.1.152.61',redis_port='6379'; | |
var http=require('http'); | |
var url=require('url'); | |
var redis=require('redis'), | |
redisClient=redis.createClient(redis_port,redis_host); | |
redisClient.on("error",function(err){ | |
console.log('redis error:', err); | |
}); |
OlderNewer