小编gab*_*eio的帖子

如何在RethinkDB中使用getall和orderby

我想列出两个时间戳之间id = 1的记录,最后根据时间戳排序.

Mysql查询的东西:

Select * from test 
where (timestamp between 100099323 AND 1423699323) AND id=1 
order by timestamp
Run Code Online (Sandbox Code Playgroud)

重新思考数据库中有超过500万个文档.

我尝试使用索引进行简单的mysql查询:

Select * from test where id=1 order by timestamp
Run Code Online (Sandbox Code Playgroud)

和Rethinkdb查询是:

r.table('test').getAll(1, {index: 'id'}).orderBy({index: 'timestamp'})
Run Code Online (Sandbox Code Playgroud)

但我得到错误:

RqlRuntimeError: Indexed order_by can only be performed on a TABLE or 
TABLE_SLICE in:
r.table("test").getAll(1, {index: "id"}).orderBy({index: "timestamp"})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Run Code Online (Sandbox Code Playgroud)

有什么建议吗?

rethinkdb

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

安装 GitWeb - 如何

我刚刚在我的生产服务器上安装了 Git,并希望 GitWeb 能够使用它。当我偶然发现一个教程展示如何使用 git web 工作时,我对让它工作非常感兴趣......

git instaweb -d webrick --start

它的工作原理与教程中描述的完全一样... http://lostechies.com/jasonmeridth/2009/09/27/git-instaweb/

然而,在阅读其他论坛后,似乎 instaweb 并不真正适合使用,相反,我应该设置 GitWeb 在 Apache 上运行。

我对 Apache 相当陌生,所以不太熟悉我应该做什么。我一直在关注http://unix-heaven.org/node/31上的教程。但我不认为我需要所有这些。我认为我唯一需要做的就是将以下内容放入我的 httpd.conf 文件中......

<VirtualHost *:80>
    ServerAdmin <a href="mailto:admin@example.org">admin@example.org</a>
    ServerName git.example.org
    ServerAlias git-pub.example.org
    RedirectMatch ^/$ /gitweb.cgi
    SetEnv GITWEB_PROJECTROOT /cvs/codeRepository/git

    Alias /gitweb.js                /srv/www/gitweb/static/gitweb.js
    Alias /gitweb.css               /srv/www/gitweb/static/gitweb.css
    Alias /git-logo.png             /srv/www/gitweb/static/git-logo.png
    Alias /git-favicon.png           /srv/www/gitweb/static/git-favicon.png

    ScriptAlias / "/srv/www/gitweb/"

    <Directory "/srv/www/gitweb/">
        AllowOverride None
        Options Indexes FollowSymLinks ExecCGI
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog "/var/log/apache2/httpd-git-pub.example.org-access.log"
    CustomLog "/var/log/apache2/httpd-git-pub.example.org-error.log" common
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

其中 /srv/www/gitweb/ …

git gitweb

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

Python将字符串解压缩到数组中

我每天都在使用Ruby,但我在Python中遇到了问题.我发现这种语言非常相似...但我从Ruby迁移有一些问题:)

请帮我在python中转换这个动作:

   string = "qwerty2012"
   (var, some_var, another_var)  = string.unpack("a1a4a*")
Run Code Online (Sandbox Code Playgroud)

这应该从string返回三个带有解压缩值的变量:

   var         = "q"      # a1
   some_var    = "wert"   # a4
   another_var = "y2012"  # a*
Run Code Online (Sandbox Code Playgroud)

帮我用Python代表它谢谢!

python arrays string

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

递归 Expressjs 路由

无论如何,在不使用正则表达式的情况下,expressjs 可以递归调用路由,即 url 示例:

/f:forum/s:section/t:thread/p:post  
/f:forum/s:section/s:section/t:thread/p:post  
/f:forum/s:section/s:section/s:section/t:thread/p:post  
...  
Run Code Online (Sandbox Code Playgroud)

因此,在技术上允许论坛中有无限数量的“部分/小节”。

我试图做:

应用程序.js:

var express = require('express');
app = express();
app.route('/').get(function(req, res, next){
    return res.send('hello');
});
app.use('/f:forum', require('./section'));
server = app.listen(process.env.http || process.env.PORT);
module.exports = app;
Run Code Online (Sandbox Code Playgroud)

部分.js:

var router = require('express').Router();
router = router;
router.route('/s:section').get(function(req, res, next){
  return res.send(req.params);
});
router.use('/s:section', require('./thread'));
module.exports = router;
Run Code Online (Sandbox Code Playgroud)

线程.js:

var router = require('express').Router();
router.use('/s:section', require('./section'));
router.route('/t:thread/p-:post').get(function(req, res, next){
  return res.send(req.params);
});
router.route('/t:thread').get(function(req, res, next){
  return res.send(req.params);
});
module.exports = router;
Run Code Online (Sandbox Code Playgroud)

但有趣的是,它告诉我在 thread.jsrequire('./section') = {} …

recursion node.js express

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

为什么这段代码给我一个"IndentationError:意外的unindent"

下面的代码真的很烦我,我已经看了stackoverflow和谷歌但还没有找到任何东西,我是一个非常好的pyton程序员,还没有,至今,直到现在,发现一个我无法处理的错误.我已经尝试了所有的东西,但是代码的这种平和给了我IndentationError:意外的unindent这很奇怪,因为正常的错误是"不应该看到的缩进",这意味着多次发布它的间距以及我如何间隔它所以我经历了整个代码和nada相同的错误,我正确地放入四个空格,一切仍然......没有.救命?

from bottle import Bottle, run, route, static_file, debug
from mako.template import Template as temp
from mako.lookup import TemplateLookup

lookup = TemplateLookup(directories=[base+'/templates'])
application = Bottle()

if __name__ == '__main__':
    @route('/')
else:
    @application.route('/')
def index():
    index_temp = lookup.get_template('index.html')
    return index_temp.render(site=site, corperate=corperate, copyright=copyright)
Run Code Online (Sandbox Code Playgroud)

python

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

我应该使用Screen Scrapers或API来读取网站上的数据

我正在构建一个Web应用程序作为大学项目(使用Python),我需要从网站上阅读内容.它可能是互联网上的任何网站.

起初我想过使用像BeautifulSoup,lxml这样的Screen Scrapers来阅读内容(作者写的数据)但我无法根据一个逻辑搜索内容,因为每个网站都是根据不同的标准开发的.

因此我想到使用RSS/Atom(使用Universal Feed Parser),但我只能得到内容摘要!但我想要所有内容,而不仅仅是摘要.

那么,是否有一种方法可以使用一个逻辑,我们可以使用像BeautifulSoup,lxml等lib一样阅读网站的内容?

或者我应该使用网站提供的API.

如果我的博客作者博客可以使用谷歌数据API,我的工作变得容易,但麻烦的是,我是否需要为同一份工作为每个不同的API编写代码?

什么是最好的解决方案?

html python screen-scraping web-scraping

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

Python For循环列表有趣的结果

a = [0,1,2,3,4,5]
for b in a:
  print ":"+str(b)
  a.pop(0)
Run Code Online (Sandbox Code Playgroud)

认为这将按顺序遍历整个列表及其所有项目,我运行此代码并期望这一点.

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

相反,我得到了这个:

:0
0
:2
1
:4
2
Run Code Online (Sandbox Code Playgroud)

现在我明白为什么会发生这种情况,但这是python中的错误吗?它不应该仍然通过所有原始对象而不是当前列表的长度?为什么这不会抛出并超出界限错误?IE:它还不应该做到:

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

python python-2.7

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

如何通过自己的类删除对象?

我知道如何通过将其引用变量设置为null来为垃圾收集器留下信号以删除对象:

Player player_reference = new Player();
player_reference = null; 
// Now the Garbage collector knows to release all the memory related to this object.
Run Code Online (Sandbox Code Playgroud)

但是如何通过对象的类将引用变量设置为null?

class Player {
    public void doSomthing() {
        if(condition) {
            // some code which set the reference variable to null.
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

java null garbage

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

Python代码中的'r_ []'和"basename ='arc'"行是什么

有Python代码的例子在这里.我找不到以下几行的解释:

x = r_[36, 36, 19, 18, 33, 26]
y = r_[14, 10, 28, 31, 18, 26]
basename = 'arc'
Run Code Online (Sandbox Code Playgroud)

请告诉我它是如何工作的.或参考任何信息页面.谢谢.

python numpy

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

Java有一个最奇怪的错误

当我运行以下代码时:

class zTree<T>
{
    ArrayList<ArrayList<T>> table = new ArrayList<ArrayList<T>>();
    int height = 0;

    <T> void zTree(BinaryTree<T> tree)
    {
        recIt((BinaryTree<T>)tree, 1);
    }

    void recIt(BinaryTree<T> tree, int fromRoot)
    {
        if(!(tree.isEmpty()))
        {
            ArrayList<T> tempList = (ArrayList<T>)table.get(fromRoot);
            tempList.add((T)tree.getData()); // add data to table
            recIt(tree.left,fromRoot+1); // recursive left,
            recIt(tree.right,fromRoot+1); // right
        }
        else
        {
            height = fromRoot-1;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Javac返回此错误.

zTree.java:15: recIt(structures.tree.BinaryTree<T>,int) in zTree<T> cannot be applied to (structures.tree.BinaryTree<T>,int)
        recIt((BinaryTree<T>)tree, 1);
        ^
1 error
Run Code Online (Sandbox Code Playgroud)

我不关心他的代码效率.我想知道出了什么问题,但javac显然没有多少帮助,因为它告诉我(x,y)不能应用于(x,y)......但为什么呢?

java binary-tree arraylist

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