我有一个简单的"用户"集合,其中我现在只有2个文档.
{
"_id": ObjectId("4ef8e1e41d41c87069000074"),
"email_id": {
"0": 109,
"1": 101,
"2": 64,
"3": 97,
{
"_id": ObjectId("4ef6d2641d41c83bdd000001"),
"email_id": {
"0": 109,
"1": 97,
"2": 105,
"3": 108,
Run Code Online (Sandbox Code Playgroud)
现在,如果我尝试在email_id字段上使用{unique:true}创建一个新索引,mongodb会向我抱怨"E11000重复键错误索引:db.users.$ email_id dup key:{:46}".即使在指定{dropDups:true}之后我也会得到相同的错误,但我不认为这是这种情况,因为两个文档都存储了不同的电子邮件ID.
我不确定这里发生了什么,任何指针都会非常感激.
编辑:文档的完整视图:
{
"_id": ObjectId("4ef8e1e41d41c87069000074"),
"email_id": {
"0": 109,
"1": 101,
"2": 64,
"3": 97,
"4": 98,
"5": 104,
"6": 105,
"7": 110,
"8": 97,
"9": 118,
"10": 115,
"11": 105,
"12": 110,
"13": 103,
"14": 104,
"15": 46,
"16": 99,
"17": 111,
"18": 109
}
}
Run Code Online (Sandbox Code Playgroud)
和
{ …Run Code Online (Sandbox Code Playgroud) 我希望使用adb screencap没有-p标志的实用程序.我想象输出将以原始格式转储,但看起来不像.我尝试用Pillow(python)库打开原始图像文件导致:
$ adb pull /sdcard/screenshot.raw screenshot.raw
$ python
>>> from PIL import Image
>>> Image.open('screenshot.raw')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/....../lib/python2.7/site-packages/PIL/Image.py", line 2025, in open
raise IOError("cannot identify image file")
IOError: cannot identify image file
Run Code Online (Sandbox Code Playgroud)
发现不是这样读取原始图像的正确方法,我甚至给了以下镜头:如何使用PIL读取原始图像?
>>> with open('screenshot.raw', 'rb') as f:
... d = f.read()
...
>>> from PIL import Image
>>> Image.frombuffer('RGB', len(d), d)
__main__:1: RuntimeWarning: the frombuffer defaults may change in a …Run Code Online (Sandbox Code Playgroud) 我有一个应用程序,其中每个websocket连接(在tornado打开回调内)创建一个zmq.SUB现有zmq.FORWARDER设备的套接字.想法是从zmq接收数据作为回调,然后可以通过websocket连接将其转发到前端客户端.
https://gist.github.com/abhinavsingh/6378134
ws.py
import zmq
from zmq.eventloop import ioloop
from zmq.eventloop.zmqstream import ZMQStream
ioloop.install()
from tornado.websocket import WebSocketHandler
from tornado.web import Application
from tornado.ioloop import IOLoop
ioloop = IOLoop.instance()
class ZMQPubSub(object):
def __init__(self, callback):
self.callback = callback
def connect(self):
self.context = zmq.Context()
self.socket = self.context.socket(zmq.SUB)
self.socket.connect('tcp://127.0.0.1:5560')
self.stream = ZMQStream(self.socket)
self.stream.on_recv(self.callback)
def subscribe(self, channel_id):
self.socket.setsockopt(zmq.SUBSCRIBE, channel_id)
class MyWebSocket(WebSocketHandler):
def open(self):
self.pubsub = ZMQPubSub(self.on_data)
self.pubsub.connect()
self.pubsub.subscribe("session_id")
print 'ws opened'
def on_message(self, message):
print message
def on_close(self):
print 'ws …Run Code Online (Sandbox Code Playgroud) 我不久前在某处读过,可以配置外部jabber组件(XEP-0114)代表任何用户发送XMPP节.例如,假设我有一个组件绑定到(component.localhost),我希望它发送一个带有"from"属性设置为"user @ localhost"的消息节.
我试图用ejabberd实现这一目标.如果我不得不破解ejabberd src以使其工作(如果可能的话),那就不会感到惊讶了.