小编phs*_*phs的帖子

创建后查找HTML 5 Web sql数据库大小的大小

我在Safari中使用HTML 5 Web SQL数据库.我将数据库大小设置为5 MB.创建数据库后,大小增加了,但我找不到数据库的新大小.创建后我在哪里可以找到数据库的大小?

html5 web-sql

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

鼠标悬停在覆盖的 DIV 上

div有一个图像,其中覆盖了许多其他divs。像这样的东西:

<div style='width:100%;height:100%'><img src='someImage.png'></div>
<div id='covered'>I'm covered by the div above me, but still visible</div>
Run Code Online (Sandbox Code Playgroud)

我想像这样定义一个 jQuery 事件处理程序:

$('#covered').live('mouseover',function(){ do stuff });
Run Code Online (Sandbox Code Playgroud)

但是该mouseover事件不起作用,因为div它覆盖了它。有什么办法可以让它发挥作用吗?

(注意...div覆盖它确实具有更高的 z-index,因为它需要始终在顶部分层。我使用“live”是因为#covered它是动态生成的。)

css jquery

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

从一个巨大的文本文件中提取许多前导行

我有一个巨大的文本文件.我想提取它的前532541行并将它们存储在另一个文件中.用鼠标选择文本并执行ctrl + c显然不是一个可行的解决方案.

我该怎么做?

emacs bash terminal text

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

如何获取目录中文件的绝对路径?

我有一个包含文件,目录,子目录等的目录.如何使用Apache Hadoop API获取所有文件和目录的绝对路径列表?

java hadoop bigdata

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

基于多个条件设置numpy数组的值

我试图将numpy数组中的值设置为零,如果它等于列表中的任何数字.

让我们考虑以下数组

  a = numpy.array([[1, 2, 3], [4, 8, 6], [7, 8, 9]])
Run Code Online (Sandbox Code Playgroud)

我想设置多个元素的a它在列表[1, 2, 8]0.

结果应该是

   [[0, 0, 3],
    [4, 0, 6],
    [7, 0, 9]]
Run Code Online (Sandbox Code Playgroud)

对于单个元素,它很简单

   a[a == 1] = 0
Run Code Online (Sandbox Code Playgroud)

以上仅适用于单个整数.它如何适用于列表?

python arrays numpy

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

ostringstream运算符<< for long?

$ uname -a
Darwin Wheelie-Cyberman 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386

$ g++ --version
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cat nolove.cc
#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char ** argv) {
  unsigned long …
Run Code Online (Sandbox Code Playgroud)

c++ cout ostringstream long-integer

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

用算法计算

对不起,我想不出一个好头衔.

我正在进行与信息通信技术相关的练习并遇到这样的问题:

计算alg a(n)并且alg b(n)对于n = 1,2,3,4和5

(a)
    alg_a(n):result
    if n > 1 then
    return(alg_a(n?1)+alg_a(n?1))
    else return(1)

(b)
    alg_b(n):result
    if n > 1 then
    return(2 · alg_b(n?1))
    else return(1)
Run Code Online (Sandbox Code Playgroud)

首先,第1行的代码是什么(alg_a(n):result)?

答:问题要求我计算alg a(n),所以我说插入1 , if n > 1 --> no --> return 1. 但是当我插入n = 2时会发生什么.

任何帮助表示赞赏,

谢谢!

algorithm math

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

在第二个列表中混合两个列表而不重复

我有2个字符串向量(一个大约是另一个的1/3).我试图实现一个算法,将两个向量随机混合在一起.在结果矢量中,先前在矢量A中的项目可以相互跟随,但是矢量B中的项目不能.

例如,如果向量A中的每个元素都是"FOO"并且向量B中的每个元素都是"BAR",那么得到的向量可能是{"FOO","FOO","BAR","FOO","BAR", "富", "富", "BAR"}

你可以看到"FOO"可能会重复,但"BAR"一定不能重复

这大致是我到目前为止:

#include <string>
#include <chrono>
#include <algorithm>
#include <random>
#include <vector>

std::vector<std::string> a(1000, "FOO");
std::vector<std::string> b(300, "BAR");
std::vector<std::string> result;

bool resultIsValid();

void mergeVectors()
{
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    std::mt19937 generator(seed);

    result = a;
    result.insert(result.end(), b.begin(), b.end());
    while (!resultIsValid())
    {
        std::shuffle(a.begin(), a.end(), generator);
    }
}

bool resultIsValid()
{
    for(int i=0; i<result.size()-2; ++i)
        if (result[i] == "BAR" && result[i+1] == "BAR")
            return false;
    return true;
}
Run Code Online (Sandbox Code Playgroud)

这不是实际的代码,但这应该给出一个想法.当我运行它时,程序进入无限循环,因为字符串的实际数量要高得多(在10000范围内),它永远不会得到有效的向量.总是存在至少一个"BAR"顺序重复.有人能够建议一个更好的选择,然后只是继续重新检查创建的矢量为重复的"BAR"?我是否比这更复杂?

c++ algorithm c++11

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

Applescript,读取行作为变量

我希望Applescript能够从txt文件中设置变量,逐行读取或逐个字符地读取.也许像php函数:get_file_contents.有没有类似的东西或者你可以请我提供方式吗?

我知道如何设置文件路径.就像是

    set myfile to "/Users/Username/Desktop/test.txt"
    set theText to read myfile
Run Code Online (Sandbox Code Playgroud)

在txt文件中,它只是一行中的一个整数,比如

    1
    2
    3
    4
    5
Run Code Online (Sandbox Code Playgroud)

如果我使用

    set theTextList to paragraphs of theText
Run Code Online (Sandbox Code Playgroud)

结果将带有引号"".

我只想将这些整数设置为变量.所以以后我可以使用,比如

   set variable to 5  --here I would like to replace the real number 5 to the number I read from the txt file(just one line)

   start slideshow
   show slide variable
Run Code Online (Sandbox Code Playgroud)

在此先感谢您的帮助.

applescript text

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

无法在Linux服务器上安装node.js.

我按照一些说明在Linux服务器上安装node.js并运行到以下块.我开始做的事情sudo apt-get install python-software-properties很好.然后,我做到了sudo add-apt-repository ppa:chris-lea/node.js.但是,等等 - 没有命令add-apt-repository.好的,所以我查了一下,它告诉我这样做 apt-get install software-properties-common,这本来没问题,除了它给了我这个错误:

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package software-properties-common
Run Code Online (Sandbox Code Playgroud)

那么,我该怎么做才能在我的服务器上获取node.js?显然,如果你想知道的话,这一切都不起作用,它是Debian.我真的需要帮助.基本上,software-properties-common如果它不存在,我该如何安装?它只是不会出现.

linux debian node.js

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