小编cyr*_*oxx的帖子

Node.js源代码构建在ARM上给出了分段错误

tl; dr:我试图在运行Ubuntu 12.10(量子)的基于ARMv7的Cubox上安装node.js. 从源代码编译node.js时(参见下面的"第二次尝试"),node会产生分段错误.我能在这做什么?

第一次尝试

首先,我尝试通过包管理器安装node.js,遵循这里给出的Ubuntu的说明:通过包管理器安装Node.js:Ubuntu,Mint

添加使用那里提到的存储库sudo add-apt-repository ppa:chris-lea/node.js似乎工作正常:

You are about to add the following PPA to your system:
 Evented I/O for V8 javascript. Node's goal is to provide an easy way to build scalable network programs
 More info: https://launchpad.net/~chris-lea/+archive/node.js
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keyring `/tmp/tmpp0owib/secring.gpg' created
gpg: keyring `/tmp/tmpp0owib/pubring.gpg' created
gpg: requesting key C7917B12 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpp0owib/trustdb.gpg: trustdb created
gpg: key …
Run Code Online (Sandbox Code Playgroud)

arm v8 segmentation-fault node.js ubuntu-12.10

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

将InputStream的Latin-1内容转换为UTF-8字符串

我需要将InputStream的内容转换为String.这里的难点是输入编码,即Latin-1.我尝试了几种方法和代码片段,包括String,getBytes,char []等,以便直接获得编码,但似乎没有任何效果.

最后,我想出了下面的工作解决方案.但是,这个代码对我来说似乎有点冗长,即使对于Java也是如此.所以这里的问题是:

有没有更简单,更优雅的方法来实现这里所做的事情?

private String convertStreamToStringLatin1(java.io.InputStream is)
        throws IOException {

    String text = "";

    // setup readers with Latin-1 (ISO 8859-1) encoding
    BufferedReader i = new BufferedReader(new InputStreamReader(is, "8859_1"));

    int numBytes;
    CharBuffer buf = CharBuffer.allocate(512);
    while ((numBytes = i.read(buf)) != -1) {
        text += String.copyValueOf(buf.array(), 0, numBytes);
        buf.clear();
    }

    return text;
}
Run Code Online (Sandbox Code Playgroud)

java string inputstream character-encoding

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

在Android应用程序包中包含OpenCV

我需要研究从Image中检测边缘,我正在使用Canny算法.因为OpenCV for android是2.4.2,而我正在尝试运行它的例子."未安装OpenCV Manager,请尝试安装它." 从市场安装后它工作正常.

但是,如果我希望用户安装我的应用程序,以便他们不必安装另一个.apk来使用我的应用程序.

- >如何在不要求其他应用程序的情况下使用openCV,即应预先安装manger.

- >有没有什么方法可以使用Canny算法进行边缘检测而不用OpenCV任何好的算法教程在android中实现.?

android opencv image image-processing

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

展平使用d3.js嵌套创建的对象层次结构

我试图以这样的方式可视化团队协作数据:

显示每个团队和周的不同协作工件类型的份额的图表

图表中的不同颜色是不同的协作工件类型.

来自源的数据如下所示:

var json = [
    {
        "teamLabel": "Team 1",
        "created_date": "2013-01-09",
        "typeLabel": "Email"
        "count": "5"
    },
    {
        "teamLabel": "Team 1",
        "created_date": "2013-01-10",
        "typeLabel": "Email"
        "count": "7"
    },
    /* and of course, a lot more data of this kind */
]
Run Code Online (Sandbox Code Playgroud)

请注意,数据是针对单日提供的.因此,对于上面的可视化,我需要根据一年中的一周来汇总数据.需要保留团队名称和工件类型,并将其用作分组属性.这是代码:

// "2013-01-09"
var dateFormat = d3.time.format.utc("%Y-%m-%d");

// "2013-02" for the 2nd week of the year
var yearWeek = d3.time.format.utc("%Y-%W");

var data = d3.nest().key(function(d) {
        return d.teamLabel;
    }).key(function(d) {
        var created_date = dateFormat.parse(d.created_date);
        return yearWeek(created_date);
    })
    .key(function(d) { …
Run Code Online (Sandbox Code Playgroud)

javascript d3.js

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

如何使用windows命令行将JSON文件解析为变量?

我有这个JSON文件叫做test.json:

{
    "test":true,
    "limit": 
    {
        "min":0.5,
        "max":1.5
    }
}
Run Code Online (Sandbox Code Playgroud)

我希望能够在Windows命令行中读取此文件,并将这些对象解析为变量.

我该怎么做?

windows command-line json

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

如何监控HttpURLConnection发送的数据大小?

我试图显示已经发送的数据的大小,OutputStreamWriter但似乎write方法有点像异步,这意味着如果文件是 60M 并且上传速率是 200K/s,输出只显示一行“数据发送:61210K "(或任何大数字)而不是应该是什么(每秒一个小数字)

我错过了什么?

代码段:

Writer writer = new OutputStreamWriter(out, POST_ENCODING);
char[] buf = new char[1024];
int read = 0;
long bytes = 0;
while ((read = reader.read(buf)) >= 0) {
    bytes += read;
    if (System.currentTimeMillis() - lastMsgTimeStamp > 1000) {
        lastMsgTimeStamp = System.currentTimeMillis();
        System.out.println("Data sent: " + (bytes / 1024) + " K");
    }
    writer.write(buf, 0, read);
}
writer.flush();
Run Code Online (Sandbox Code Playgroud)

java post httpurlconnection

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

在SPARQL中进行布尔检查,检查是否存在语句

假设我有一个充满视频元数据的三重存储.视频可以任意选择预定义的标签,如下所示:

v1 ex:hasTag A.
v2 ex:hasTag B.
v3 ex:hasTag A;
   ex:hasTag B.
Run Code Online (Sandbox Code Playgroud)

因此,为了这个例子,只有两个预定义的标签AB.

现在我想概述哪个视频附加了哪个标签,在这样的矩阵中(或者类似):

    A     B 

v1  true  false
v2  false true
v3  true  true
Run Code Online (Sandbox Code Playgroud)

但是,我不知道如何实现这一目标.首先,我需要一个布尔测试,例如类似isTrue(?video ex:hasTag A)或类似的东西.即便如此,我也不知道该把它放在哪里.如果我将前一个语句放在WHERE子句中,查询结果当然只包含带有标记的视频A.

来自SQL,我可以想象我需要以某种方式使用子查询,但这些似乎不是标准化的.我也看到了FILTER关键字,但我觉得这不是我想要的.

我现在不知所措,但总是愿意学习.任何帮助表示赞赏.

rdf boolean semantic-web sparql

4
推荐指数
2
解决办法
5314
查看次数

无法安装Python的包'请求'

我尝试使用以下命令在我的Ubuntu 10.04服务器上安装python请求包:

$ pip install requests
Run Code Online (Sandbox Code Playgroud)

但我一直得到回报:

下载/解压缩请求无法获取URL http://pypi.python.org/simple/requests:在查找请求的下载链接时将跳过URL(... url ...)无法获取URL(... url ...):在查找请求的下载链接时会跳过URL(... url ...)无法获取索引基URL(... url ...)无法找到需求请求,也无法获取索引URL(.. .url ...)存储完整的登录./pip-log.txt

请原谅我使用上面的"(... url ...)",因为StackOverflow不允许我发布超过2个链接.

这是pip-log.txt中的回溯:

Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/pip.py", line 252, in main
    self.run(options, args)
File "/usr/lib/python2.6/dist-packages/pip.py", line 08, in run
    requirement_set.install_files(finder, force_root_egg_info=self.bundle)
File "/usr/lib/python2.6/dist-packages/pip.py", line 1750, in install_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
File "/usr/lib/python2.6/dist-packages/pip.py", line 996, in find_requirement
    url_name = self._find_url_name(Link(self.index_urls[0]), url_name, req)
File "/usr/lib/python2.6/dist-packages/pip.py", line 1073, in _find_url_name
    raise DistributionNotFound('Cannot find requirement %s, nor fetch index …
Run Code Online (Sandbox Code Playgroud)

python django ubuntu pip python-requests

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

django auto_add_now无法正常工作

我有一个模型,在我使用时会抛出错误 python manage.py syncdb

在这一行createdAt = models.DateTimeField(auto_add_now=True),错误是

File "/home/vaibhav/TRAC/coupon-rest-api/couponRestApi/couponRestApiApp/models.py", line 18, in tags
  createdAt = models.DateTimeField(auto_add_now=True)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 660, in __init__
  Field.__init__(self, verbose_name, name, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'auto_add_now'
Run Code Online (Sandbox Code Playgroud)

我在这里做错了什么?

python django

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

Java接口可以有构造函数吗?

ActionListener是一个接口,但为什么我可以创建实例对象?

   JButton button = new JButton("Button1");

   ActionListener me = new ActionListener(){
        public void actionPerformed(ActionEvent ae){
            JOptionPane.showMessageDialog(null,ae.getActionCommand());  
        }
    };
    button.addActionListener(me);
Run Code Online (Sandbox Code Playgroud)

还有什么?我不确定.请帮我.

java interface

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