小编Dav*_*ver的帖子

CouchDB:查询"用A或B标记的文档"?

没有做客户端过滤或POST一次性map/reduce(这会导致表扫描),有没有办法查询标记为tagA tagB

tagging couchdb

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

mod_rewrite:为什么不能使用环境变量来防止递归?

为什么我不能使用mod_rewrite与此类似的规则:

RewriteEngine On
RewriteCond %{ENV:did_rewrite} !=true
RewriteCond %{REQUEST_URI} ^(.*)/
RewriteRule (.*) %1/foo.php?original=$1 [E=did_rewrite:true]

为了防止递归?

当我转过身时RewriteLogLevel,我看到:

[.../initial] (3) [perdir /.../test/] strip per-dir prefix: /.../test/stuff -> stuff
[.../initial] (3) [perdir /.../test/] applying pattern '(.*)' to uri 'stuff'
[.../initial] (4) [perdir /.../test/] RewriteCond: input='' pattern='!=true' => matched
[.../initial] (4) [perdir /.../test/] RewriteCond: input='/test/stuff' pattern='(.*)/' => matched
[.../initial] (2) [perdir /.../test/] rewrite 'stuff' -> '/test/foo.php?original=stuff'
[.../initial] (5) setting env variable 'did_rewrite' to 'true'
[.../initial] (3) split uri=/test/foo.php?original=stuff -> uri=/test/foo.php, args=original=stuff …

mod-rewrite apache2

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

是否有可能改变IPython的漂亮打印机?

是否有可能改变IPython使用的漂亮的打印机?

我想切换默认的漂亮的打印机pprint++,我更喜欢嵌套结构之类的东西:

In [42]: {"foo": [{"bar": 42}, {"bar": 16}] * 3, "bar": [1,2,3,4,5]}
Out[42]: 
{'bar': [1, 2, 3, 4, 5],
 'foo': [{'bar': 42},
  {'bar': 16},
  {'bar': 42},
  {'bar': 16},
  {'bar': 42},
  {'bar': 16}]}

In [43]: pprintpp.pprint({"foo": [{"bar": 42}, {"bar": 16}] * 5, "bar": [1,2,3,4,5]})
{
    'bar': [1, 2, 3, 4, 5],
    'foo': [
        {'bar': 42},
        {'bar': 16},
        {'bar': 42},
        {'bar': 16},
        {'bar': 42},
        {'bar': 16},
        {'bar': 42},
        {'bar': 16},
        {'bar': 42},
        {'bar': 16},
    ],
}
Run Code Online (Sandbox Code Playgroud)

python ipython pprint

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

为什么numpy.polyfit大幅减少?

我正在尝试使用np.polyfit一个相当简单的数据集,但它的相关幅度相当大:

非常适合数据

和代码:

import numpy as np
import matplotlib as plt

fit = np.polyfit(xvals, yvals, 1)
f = np.poly1d(fit)
plt.scatter(xvals, yvals, color="blue", label="input")
plt.scatter(xvals, f(yvals), color="red", label="fit")
plt.legend()
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?我怎样才能提高合身度?

原始数据:

xvals = array([  0,   1,   2,   3,   4,   5,   7,   8,   9,  10,  11,  12,  14,
                15,  16,  17,  18,  20,  21,  22,  23,  24,  25,  27,  28,  29,
                30,  31,  32,  34,  35,  36,  37,  38,  40,  41,  42,  43,  44,
                45,  47,  48,  49,  50,  51,  52, …
Run Code Online (Sandbox Code Playgroud)

python numpy

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

Flash:什么是`BitmapData.ctor`?

我正在分析一些Flash代码,其中一种占用大量时间的方法是BitmapData.ctor.那是什么错误的?

flash profiling bitmapdata

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

使用Django对SQLite执行原始SQL会导致"DatabaseError:near"?":syntax error`

例如,当我cursor.execute() 按照记录使用时:

>>> from django.db import connection
>>> cur = connection.cursor()
>>> cur.execute("DROP TABLE %s", ["my_table"])
django.db.utils.DatabaseError: near "?": syntax error
Run Code Online (Sandbox Code Playgroud)

当不使用Django的参数替换时,查询按预期工作:

>>> cur.execute("DROP TABLE my_table")
django.db.utils.DatabaseError: no such table: my_table
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?如何使参数化查询起作用?

笔记:

  • 使用查询后缀;并没有帮助
  • 根据文档,%s应该使用,而不是SQLite ?(Django转换%s?)

python sqlite django django-1.3

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

使用NetBeans检查实时Java对象?

在Python中,我习惯于能够在代码中的任何位置启动调试器,然后在实时对象(调用方法,类似的东西)上查看.有没有办法,使用NetBeans来做到这一点?

例如,我希望能够突破foo = bar().baz().blamo()并运行bar(),bar().baz()bar().baz().blamo()看看他们做了什么.

在Python中,这就是我要做的:

...
import pdb; pdb.set_trace()
foo = bar().baz().blamo()
Run Code Online (Sandbox Code Playgroud)

然后它会给我一个提示,我可以输入内容:

(pdb) bar()
... some objet ...
(pdb) bar() + 42
...
Run Code Online (Sandbox Code Playgroud)

java debugging netbeans

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

Vim:在函数中定义语法规则?

我想在函数内动态创建语法规则.例如,类似于:

fun! DoStuff(word)
    syntax match Error '\<'.word.'\>' contained
    ... other stuff ...
endf
Run Code Online (Sandbox Code Playgroud)

但是,显然*不起作用.那么......我怎么能这样做?

*:据我所知,Vim脚本仍然是伏都教

vim

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