小编Joe*_*oel的帖子

Applescript(osascript):在iTerm 2中打开分割窗格并执行命令

以下工作在iTerm 2中打开两个选项卡.

我似乎无法弄清楚如何使用拆分窗格来改变它.

我试过应用我在几个论坛上看到的东西,但它永远不会奏效.有人能指出我正确的方向吗?

osascript <<-eof
        tell application "iterm"
                set myterm to (make new terminal)
                tell myterm
                        launch session "Default session"
                        tell the last session
                                set name to "Server"
                                write text "cd $projectsFolder"
                        end tell
                        launch session "Default session"
                        tell the last session
                                set name to "Console"
                                write text "cd $projectsFolder"
                        end tell
                end tell
        end tell
eof
Run Code Online (Sandbox Code Playgroud)

terminal applescript osascript iterm

9
推荐指数
4
解决办法
1万
查看次数

Passport-local返回400错误,从不查询数据库

我正在尝试在我的node.js应用程序中使用passport.js来验证使用MongoDB的用户.我从来没有成功过.

在帖子中,我发送"email":"email@gmail.com","密码":"测试"

var passport = require('passport')
   , LocalStrategy = require('passport-local').Strategy;


app.post('/login',
  passport.authenticate('local', { successRedirect: '/',
                               failureRedirect: '/fail' })
);

passport.use(new LocalStrategy({
      emailField: 'email',
      passwordField: 'passw',
   },
function (emailField, passwordField, done) {
   process.nextTick(function () {
      db.collection(users, function (error, collection) {
         if (!error) {
            collection.findOne({
               'email': emailField,
               'password': passwordField
            }, function (err, user) {
               if (err) {
                  return done(err);
               }
               if (!user) {
                  console.log('this email does not exist');
                  return done(null, false);
               }
                  return done(null, user);
            });
         } else {
            console.log(5, …
Run Code Online (Sandbox Code Playgroud)

node.js passport-local passport.js

5
推荐指数
2
解决办法
4093
查看次数

打破javascript嵌套的async.each循环,但继续主循环

我有一个名为recipesArray的对象数组.

recipesArray = [  [{name = "the recipe name", url = "http://recipeurl.com"},
                   {name = "the other neame", url = "http://adifferenturl.com"},
                   {name = "another recipe", url = "http://anotherurl.com"}],

                   [{name = "the recipe name", url = "http://recipeurl.com"},
                   {name = "the other neame", url = "http://adifferenturl.com"},
                   {name = "another recipe", url = "http://anotherurl.com"}],

                   [{name = "the recipe name", url = "http://recipeurl.com"},
                   {name = "the other neame", url = "http://adifferenturl.com"},
                   {name = "another recipe", url = "http://anotherurl.com"}] ]
Run Code Online (Sandbox Code Playgroud)

我想打破这个嵌套的async.each循环,但继续主async.each循环.

// main async.each
async.each(recipes, function(subArray, …
Run Code Online (Sandbox Code Playgroud)

javascript loops asynchronous node.js async.js

3
推荐指数
1
解决办法
7244
查看次数

MongoDB插入多个文件,其中可以复制_id

我正在使用以下内容将一个对象数组插入MongoDB(我正在分配一个唯一的_id),这是有效的:

collection.insert(records, {w:1}, function(err, result) 
Run Code Online (Sandbox Code Playgroud)

某些记录可能有重复的_id(意味着记录已经在数据库中).这是我得到的错误:

MongoError: E11000 duplicate key error index: heroku_app23495772.records.$_id_  dup key: { : "2b09aadb900f0e5112b6d03f665fb946" }
Run Code Online (Sandbox Code Playgroud)

即使遇到第一个对象(重复)上的错误,mongoDB仍会在此数组中插入剩余的对象吗?我真的不介意错误,如果它不会阻止插入不重复的剩余文件或对其他任何负面影响.

或者,我应该在发送对象数组之前逐字查询每个对象的数据库以查看它是否存在?我认为这样做对性能来说不是最好的.

我只想弄清楚处理这些重复项的最有效方法.

javascript error-handling performance mongodb

2
推荐指数
1
解决办法
2719
查看次数