小编Zel*_*lid的帖子

MongoKit"ImportError:没有名为objectid的模块"错误

我使用MongoKit得到一些非常奇怪的错误:

>>> from mongokit import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/mongokit/__init__.py", line 35, in <module>
    from document import Document, ObjectId
  File "/usr/local/lib/python2.7/dist-packages/mongokit/document.py", line 48, in <module>
    from pymongo.objectid import ObjectId
ImportError: No module named objectid
Run Code Online (Sandbox Code Playgroud)

我尽力找到原因,但没有任何帮助.实际上我用google搜索"ImportError:没有名为objectid的模块"错误,它根本没有结果.我试着按照简单的教程http://namlook.github.com/mongokit/introduction.html#a-quick-example使用MongoKit,本教程的第一行产生了这个奇怪的错误.以下是MongoKit安装的日志.

我做错了什么?

user@server:~$ sudo pip install mongokit
Downloading/unpacking mongokit
  Downloading mongokit-0.7.2.tar.gz (69Kb): 69Kb downloaded
  Running setup.py egg_info for package mongokit

Downloading/unpacking pymongo>=2.0.1 (from mongokit)
  Downloading pymongo-2.2.tar.gz (228Kb): 228Kb downloaded
  Running setup.py egg_info for package pymongo …
Run Code Online (Sandbox Code Playgroud)

python pymongo flask python-2.7 mongokit

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

如何避免C#字符串中的双引号转义?

在Ruby中,可以使用字符串而无需转义字符串中的双引号,例如Q/Some我的字符串带有"双引号"/

是否可以使用C#来使用字符串而无需转义双引号?有一个很好的理由我需要编写内联SQL,每次将SQL查询从数据库控制台放到C#代码时,都要放弃双引号非常烦人.

我知道可以使用\"或"作为一个双引号.但是有可能避免逃避双引号吗?

c# double-quotes c#-4.0

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

使用 ReactiveUI 中的代码隐藏在 ListBox 内绑定数据

我有 WPF 列表框:

<ListBox Name="FileDownloads" SelectionMode="Extended">
  <ListBox.ItemTemplate>
    <DataTemplate>
      <TextBlock Name="Url" Text="{Binding Url}" />
    </DataTemplate>
  </ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)

我喜欢使用后面的代码按名称绑定 ListBox 的能力:this.OneWayBind(ViewModel, vm => vm.DownloadManager.FileDownloads, v => v.FileDownloads.ItemsSource);在代码隐藏中进行 绑定有助于重构。

有没有办法使用代码隐藏在列表框内绑定 Url texbox?

reactiveui

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

使用 GDB 在 Linux 和 Wine 上交叉调试 Win32 Mingw32 C/C++ 程序

我使用以下命令在 Ubuntu 14.10 上安装了 mingw-w64 和 gdb-mingw-w64:

sudo apt-get install mingw-w64 sudo apt-get install gdb-mingw-w64

我能够编译 C/C++ 程序并从 Wine 或 Windows 机器上运行它们。

我安装了 mingw32 版本的 gdb,以便能够调试使用 Mingw 编译的 Windows 应用程序。

我尝试使用 Netbeans 8、Code::Blocks 13.12、Eclipse Luna 的最新版本,并且能够将 Mingw 工具链配置为与 IDE 一起使用以从 Linux 构建 win32 应用程序。

我还尝试在这些 IDE 中以相同的方式配置以使用 Mingw 版本的 GDB (gdb-mingw-w64),就像标准 GDB 被起诉用于非 mingw GCC 工具链一样,但从未能够使其工作:(

如何从 Linux 调试使用 Mingw 编译的 C/C++ 程序?如何在上面列出的任何 IDE 中进行配置?

谢谢!

gcc gdb mingw cross-compiling mingw-w64

5
推荐指数
0
解决办法
998
查看次数

如何获得标准的 Mac OS X 图标以在您的应用程序中使用?

您如何在您的设计/应用程序中使用标准的 Mac OS X 图标?

我所说的标准图标是指此屏幕截图中的工具栏图标: 在此处输入图片说明 在此处输入图片说明

是否有存储这些文件的位置或有什么方法可以从 Mac OS X 应用程序中提取它们?

macos cocoa osx-yosemite

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

带有自定义视图小部件的 QItemDelegate

Qt 5.5 有一个虚拟方法来定义编辑模式的自定义小部件:

QWidget *createEditor(QWidget *parent,const QStyleOptionViewItem & option ,const QModelIndex & index ) const
Run Code Online (Sandbox Code Playgroud)

但是如何使用自定义小部件来覆盖“查看”模式呢?我看到了“星级评级”委托示例,其中paint使用了方法,但这不是我需要的。我需要显示一个自定义小部件,其中包含其他标准小部件,并在QTableView或 的视图模式下使用它QListView。无需搞乱绘制指针和数字 - 只需显示一个自定义小部件(具有 .ui 文件)并包含其他标准小部件及其行为。

例如:有一个下载管理器应用程序,可以将下载显示为表格或列表视图。QListView带有下载列表。每个下载都有 URL、标题、总大小、下载大小、进度栏、暂停按钮、删除按钮、恢复按钮。所有这些都可以是表格 ( QTableView) 中的列,也可以类似于 HTML 的 DIV 那样组合在一个单元格中(QListView小部件)

如何实现?有类似的东西QWidget *createViewer(...吗?

QtWidgets 不使用 QML。

qt qitemdelegate model-view qt5

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

站点根页面的 Django 和 Nginx try_files 403

我对域使用这样的 Nginx 配置:

server_name_in_redirect off; 
listen 80;
server_name  ~^(www\.)?(.+)$;
root /var/www/$2/htdocs;

location / {
    try_files  $uri  $uri/ $uri/index.htm  @django;
    index index.html index.htm;
}

location @django {
    fastcgi_pass 127.0.0.1:8801;
    fastcgi_param PATH_INFO $fastcgi_script_name;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param SERVER_NAME $server_name;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_pass_header Authorization;
    fastcgi_intercept_errors off;
    fastcgi_param REMOTE_ADDR $remote_addr;
}
Run Code Online (Sandbox Code Playgroud)

Django URL 配置:

urlpatterns = patterns('',   
    url(r'^$', home, name='home'),
    url(r'index.htm', home, name='home'),    
    url(r'^(?P<name>.*).htm$', plain_page, name="plain_page"),
}
Run Code Online (Sandbox Code Playgroud)

所有像http://domain.com/somepage.htm这样的 url …

django nginx django-urls

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

使用Elasticsearch C#Mpdreamz/NEST客户端在嵌套字段上进行构面

如何使用Mpdreamz/NEST Elasticsearch客户端基于嵌套字段的属性列出构面?

我查看了Nest文档,但目前尚不清楚如何操作.

这是我尝试的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using Nest;

namespace Demo
{
    class Program
    {
        public class Movie
        {
            public int Id { get; set; }
            public string Title { get; set; }
            public string Description { get; set; }
            [ElasticProperty(Index = FieldIndexOption.analyzed, Type = FieldType.nested)]
            public List<Genre> Genres { get; set; }
            public int Year { get; set; }
        }

        public class Genre
        {
            //        public int Id { get; set; }
            [ElasticProperty(Index = FieldIndexOption.analyzed)]
            public …
Run Code Online (Sandbox Code Playgroud)

elasticsearch nest

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

FFMpeg 无需转码即可复制流

我正在尝试将多个文件中的所有流复制到一个文件中,而无需对流进行转码。你通常用ffmpeg效用做的事情ffmpeg -i “file_with_audio.mp4” -i “file_with_video.mp4” -c copy -shortest file_with_audio_and_video.mp4

这是代码:

int ffmpegOpenInputFile(const char* filename, AVFormatContext **ic) {

    int ret;
    unsigned int i;

    *ic = avformat_alloc_context();
    if (!(*ic))
        return -1; // Couldn't allocate input context

    if((ret = avformat_open_input(ic, filename, NULL, NULL)) < 0)
        return ret; // Couldn't open file

    // Get format info (retrieve stream information)
    if ((ret = avformat_find_stream_info(*ic, NULL)) < 0)
        return ret; // Couldn't find stream information

    for (int i = 0; i < (*ic)->nb_streams; …
Run Code Online (Sandbox Code Playgroud)

c ffmpeg libavcodec libavformat

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

从Objective-C函数调用C ++函数不起作用

我无法弄清楚为什么从Objective-C文件进行此简单调用的C ++函数不起作用...如何解决该问题?

上下文菜单:

#import <Cocoa/Cocoa.h>

void showMyMenu() {
    NSMenu *theMenu = [[NSMenu alloc] initWithTitle:@"Contextual Menu"];
    [theMenu insertItemWithTitle:@"Beep" action:@selector(beep:) keyEquivalent:@"" atIndex:0];
    [theMenu insertItemWithTitle:@"Honk" action:@selector(honk:) keyEquivalent:@"" atIndex:1];
    [theMenu popUpMenuPositioningItem:nil atLocation:[NSEvent mouseLocation] inView:nil];
}
Run Code Online (Sandbox Code Playgroud)

app.h:

#ifdef __cplusplus
extern "C" {
#endif

    void showMyCppMenu();

#ifdef __cplusplus
}
#endif
Run Code Online (Sandbox Code Playgroud)

app.cpp:

#include "app.h"

void showMyMenu();

void showMyCppMenu() {
    showMyMenu();
}
Run Code Online (Sandbox Code Playgroud)

main.m:

#import <Cocoa/Cocoa.h>

#include "app.h"

// void showMyMenu();
// void showMyCppMenu();

int main(int argc, const char * argv[])
{
    NSApplication * application = [NSApplication sharedApplication];

    // …
Run Code Online (Sandbox Code Playgroud)

c c++ objective-c clang clang++

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