我想重新启动我在服务器上运行的许多Node.js进程之一.如果我运行,ps ax | grep node我会获得所有Node proccesses的列表,但它并没有告诉我他们在哪个端口.如何杀死在端口3000上运行的那个(例如).管理多个Node进程的好方法是什么?
我正在使用passport.js,如果我可以将facebook id链接到登录用户的帐户,我就会受伤.像这样的东西:
passport.use( new FacebookStrategy({
consumerKey: ---
consumerSecret: ---
callbackURL: "http://mycallback"
},
function(token, tokenSecret, profile, done) {
if (user is logged in)
user = User.addfacebookId(user, profile.id)
done(user);
}
}
));
Run Code Online (Sandbox Code Playgroud) 从单个链接传递大量数据的最佳方法是什么?这样的事情是个好主意还是有更好的方法?
<a href="{ 'id':'1', 'foo':'bar', 'something':'else' }" id="myLnk" > Click </a>
$('#myLnk).click( function(event){
event.preventDeafult();
var data = $(this).attr('href')
console.log( $.parseJSON( response ) );
})
Run Code Online (Sandbox Code Playgroud)
谢谢!
我正在使用dynamicHelpers在Express 2的每个页面上设置一些变量.现在它们已经消失,我不知道该怎么做.使用Express 3做这样的事情的最佳方法是什么?
app.js
app.dynamicHelpers( require('dynamicHelpers') )
Run Code Online (Sandbox Code Playgroud)
dynamicHelpers.js
exports.user = function(req, res) {
return req.user || {};
}
exports.message = function(req, res) {
return req.flash.message || {};
}
Run Code Online (Sandbox Code Playgroud)
在veiw.jade
h1= user.username
Run Code Online (Sandbox Code Playgroud) 我对 finfo_open() 做了一个简单的调用,我得到:
“调用未定义的函数 finfo_open()”
FileInfo 不是与 php 5.3.3 (Unix) 一起打包的。我需要在 php.ini 中打开它吗?
谢谢
我正在尝试更新Mongoose.js 3.1.2中的一些内容,我无法使这两个功能起作用.有什么想法吗?谢谢...
function(req, res) {
Content.findById(req.body.content_id, function(err, content) {
// add snippet to content.snippets
content.snippets[req.body.snippet_name] = req.body.snippet_value;
content.save(function(err) {
res.json(err || content.snippets);
});
}
}
function(req, res) {
Content.findById(req.body.content_id, function(err, content) {
// delete snippets
delete content.snippets[req.body.snippet_name];
//content.snippets[req.body.snippet_name] = undefined; <-- doesn't work either
content.save(function(err) {
res.json(err || "SUCCESS");
});
});
}
Run Code Online (Sandbox Code Playgroud)
我的架构看起来像这样:
contentSchema = new Schema(
title: String,
slug: String,
body: String,
snippets: Object
);
Run Code Online (Sandbox Code Playgroud) 我有一个简单的 Dockerfile,它创建了一个 zip 文件,我正在尝试在它准备好后检索 zip 文件。我的 Dockerfile 看起来像这样:
FROM ubuntu
RUN apt-get update && apt-get install -y build-essentials gcc
ENTRYPOINT ["zip","-r","-9"]
CMD ["/lib64.zip", "/lib64"]
Run Code Online (Sandbox Code Playgroud)
阅读完文档后,我觉得这样的事情应该可以做到,但我无法让它发挥作用。
docker build -t ubuntu-libs .
docker run -d --name ubuntu-libs --mount source=$(pwd)/,target=/lib64.zip ubuntu-libs
Run Code Online (Sandbox Code Playgroud)
另一个问题:是否可以从命令行重命名 zip 文件?
这与评论中提到的重复问题不同,因为当他们使用cp从正在运行的 Docker 容器复制文件时,我试图在实例化时挂载一个目录。
dataLayer我正在将一个简单的电子商务对象推送到客户端的Google 跟踪代码管理器。它工作正常,但我需要将其移至服务器。
我找到了Google API Node.js 客户端库,但它还很年轻,我找不到任何有效的示例。
有人设法做到这一点吗?如何使用 node.js 中的 google-api-nodejs-client 完成以下任务?
dataLayer.push({
event: 'purchase',
user: 'user_1234',
transactionId: 'trans_123',
transactionAffiliation: 'Acme Clothing',
transactionTotal: 11.99,
transactionProducts: [
{
id: '1234',
sku: 'SKU47',
name: 'Fluffy Pink Bunnies',
price: 11.99,
quantity: 1
}
]
});
Run Code Online (Sandbox Code Playgroud) google-analytics node.js google-api-nodejs-client google-apis-explorer
我正在尝试为 xml 站点地图生成“changefreq”。每次保存页面时,我都会向“save_history”数组添加一个日期,该数组为我提供了要使用的日期列表。最初我以为我只需将所有日期相加并除以长度即可,但这只是给出了自 1970 年 1 月 1 日以来的平均时间。如何修复此函数以获得日期之间的平均时间?
http://jsfiddle.net/jwerre/pAfdM/19/
或者
getChangeFequency = function(history) {
var sum = _.reduce(history, function(memo, num) {
return memo + num.getTime();
}, 0);
var average = sum / history.length;
var hours = average / 3600000;
console.log("totals:", sum, average, hours); // 20292433147523 1352828876501.5334 375785.7990282037
if (hours > 17532) {
return "never";
} else if ((8766 < hours && hours > 17531)) {
return "yearly";
} else if ((730 < hours && hours > 8765)) { …Run Code Online (Sandbox Code Playgroud)