小编use*_*226的帖子

nodejs - 如何将状态保持在stdout之上

我正在尝试输出这样的东西:

counter is: 10            <= fixed line and auto updating
console.logs, etc...      <= other console.logs, errors, defaul outputs
console.logs, etc...
console.logs, etc...
console.logs, etc...
Run Code Online (Sandbox Code Playgroud)

这可能吗?

我已尝试使用process.stdout.write()但它无法正常工作.

var counter = 0;
setInterval(function(){
    counter++;
    process.stdout.write("counter is " + counter + " \r");
}, 500);

setInterval(function(){
    console.log('some output');
}, 1500);
Run Code Online (Sandbox Code Playgroud)

node.js

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

简单的字符串拆分返回对象而不是数组

我正在尝试在NodeJS中进行简单的字符串拆分,但它返回的是一个对象,而不是数组.

var mytext = "a,b,c,d,e,f,g,h,i,j,k";
var arr = mytext.split(",");
console.log(typeof mytext); <======= output string
console.log(typeof arr);    <======= output object
Run Code Online (Sandbox Code Playgroud)

jsfiddle:http://jsfiddle.net/f4NnQ/

为什么?

javascript node.js

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

尝试运行artisan dump-autoload时proc_open错误

当我尝试运行php artisan dump-autoload时,我收到此错误:

 root@server:/var/mysite# php artisan dump-autoload
 Generating optimized class loader

   [Symfony\Component\Process\Exception\RuntimeException]
   The Process class relies on proc_open, which is not available on your PHP installation.

 dump-autoload

 root@server:/var/mysite#
Run Code Online (Sandbox Code Playgroud)

我在DigitalOcean上使用Ubuntu 12.10 x64.

任何的想法?

php ubuntu laravel composer-php

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

循环10k数组表示错误超出最大调用堆栈大小

我正在尝试处理一个包含10k项目的数组,以便在每一行上设置一个新属性.

 _async.mapLimit(collection, 100, function (row, cb){
      row.type = "model";
      cb(null, row);
 }, function (err, collection){
      if(err) throw(err);
      console.log(collection);
 });
Run Code Online (Sandbox Code Playgroud)

然后我收到这个错误:

RangeError: Maximum call stack size exceeded
Run Code Online (Sandbox Code Playgroud)

这是什么?我尝试使用异步eachSeries,但同样的事情发生了.

javascript asynchronous node.js

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

rundeck - 配置失败:SSH 密钥文件不存在

当我在 Rundeck 中尝试命令时,它显示:

Failed: ConfigurationFailure: SSH Keyfile does not exist: ~/.ssh/id_rsa
Execution failed: 19: [Workflow step failures: {1=Dispatch failed on 1 nodes: [my.server.com: ConfigurationFailure: SSH Keyfile does not exist: ~/.ssh/id_rsa]}, Node failures: {my.server.com=[ConfigurationFailure: SSH Keyfile does not exist: ~/.ssh/id_rsa]}]
Run Code Online (Sandbox Code Playgroud)

我已经生成了 ssh-key,我可以使用它来连接 SSH,无需密码。

在rundeck机器中,密钥是在~/.ssh/id_rsa

在远程机器中,密钥被复制到~/.ssh/authorized_keys

难道我做错了什么?

linux ssh rundeck

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

我为什么要在每个文件上都要求所有模块?

我经常看到的默认方法是:

// repeat this in all files
var express  = require('express');
var mongoose = require('mongoose');
var async    = require('async');
...
Run Code Online (Sandbox Code Playgroud)

但在我的NodeJS应用程序中,我这样做:

// include this only on the server file
_express  = require('express');
_mongoose = require('mongoose');
_async    = require('async');
...
Run Code Online (Sandbox Code Playgroud)

我更喜欢使用_前缀来识别libs/modules而我不使用,var因为我不想在我的应用程序的每个文件上重复所有包的require/setup.

这样我require()只能在server.js文件上使用一次模块并在任何地方使用它.

这是一个坏主意吗?

javascript node.js

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

如何按列分组并返回其他列的SUM?

我按信息ID和ANCHOR选择值:

 SELECT 
      infoid, 
      anchor, 
      value 
 FROM 
      infodata 
 WHERE 
      (infoid = 1) 
      OR (infoid = 2)
      OR (infoid = 3)
 ORDER BY 
      anchor ASC
Run Code Online (Sandbox Code Playgroud)

此查询返回一个infoid,anchors和数字列表:

infoid      anchor     value
------      -----      -----
1           10         500
2           10         600
3           10         700

1           20         800
2           20         900
3           20         1000
Run Code Online (Sandbox Code Playgroud)

我如何通过ANCHOR GROUP并返回3个infos的SUM()值?返回这样的东西:

anchor     value
-----      -----
10         500+600+700
20         800+900+1000
Run Code Online (Sandbox Code Playgroud)

mysql sql

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

python - 如何在变量中设置多行json?

我正在尝试做这样的事情:

def myjson = '
    {
        "json":true
    }
'
Run Code Online (Sandbox Code Playgroud)

我怎么能在python中这样做?

python

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

sql - 如何在没有group_concat的情况下将不同的行合并为一个

在这个例子中,我对同一个用户有不同的值.所以我必须在单行中获得所有这些值.

user_id     key           value
-------     --------      -----------
123         name       thomps
123         url        thomps.com
123         email      thomps@me.com

456         name       hond
456         url        hond.com
456         email      hond@me.com
Run Code Online (Sandbox Code Playgroud)

如何获取合并这样的行的列表:

user_id    name       url           email
-------    ----       ----          ------
123        thomps     thomps.com    thomps@me.com
456        hond       hond.com      hond@me.com
Run Code Online (Sandbox Code Playgroud)

我尝试使用grop_concat并加入子查询但没有成功

mysql sql

0
推荐指数
1
解决办法
105
查看次数

总是使用255个字符来varchar字段降低性能?

我通常使用varchar字段的最大字符,所以在大多数情况下我设置255但在列中只使用16个字符...

这会降低我的数据库的性能吗?

mysql database-performance

0
推荐指数
1
解决办法
323
查看次数

ubuntu - 如何卸载deb包?

如何删除安装了debian软件包的程序?

我在我的Ubuntu 14.04中安装了Rundeck(http://rundeck.org/downloads.html).

ubuntu deb rundeck

0
推荐指数
1
解决办法
8380
查看次数