问题列表 - 第49470页


MySQL:不喜欢

我的数据库中有这些文字,

categories_posts
categories_news
posts_add
news_add
Run Code Online (Sandbox Code Playgroud)

我不想选择行categories,我使用这样的查询,

SELECT *
    FROM developer_configurations_cms

    WHERE developer_configurations_cms.cat_id = '1'
    AND developer_configurations_cms.cfg_variables LIKE '%parent_id=2%'
    AND developer_configurations_cms.cfg_name_unique NOT LIKE '%categories%'
Run Code Online (Sandbox Code Playgroud)

但它也会在输出中返回这两个......

categories_posts
categories_news
Run Code Online (Sandbox Code Playgroud)

如何在查询中忽略它们?

谢谢.

mysql sql-like

57
推荐指数
2
解决办法
27万
查看次数

使用reportlab构建由matplotlib生成的基于矢量的图形的PDF

我正在尝试使用reportlab在Django-Installation中在服务器端构建PDF文档.这些文档应该包含几个用matplotlib创建的图表.

我已经想出如何通过将PIL-Image对象直接传递给Image()-flowable 来使reportlab使用matplotlib的图像而不将它们临时转储到文件系统.这对于像PNG这样的光栅化图像格式非常有效.

现在,锦上添花就能嵌入基于矢量的图形(如SVG).

我使用svglib将matplotlib生成的SVG转换为reportlab图形对象,但不幸的是svglib确实省略了tickmarks和axis标签.在一些图表上,它总体上失败了.

你们有什么想法吗?

svg reportlab matplotlib

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

实体框架代码优先:如何在两个表之间创建一对多和一对一的关系?

这是我的模型:

public class Customer
{
    public int ID { get; set; }

    public int MailingAddressID { get; set; }
    public virtual Address MailingAddress { get; set; }

    public virtual ICollection<Address> Addresses { get; set; }
}

public class Address
{
    public int ID { get; set; }

    public int CustomerID { get; set; }
    public virtual Customer Customer { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

客户可以拥有任意数量的地址,但这些地址中只有一个可以是邮寄地址.

如果我只使用一个,我可以得到One to One关系,One to Many工作得很好,但是当我尝试介绍两者时,我在Addresses表上获得了多个CustomerID键(CustomerID1,CustomerID2,CustomerID3).我真的把头发撕成了这个.

为了映射一对一的关系,我使用这里描述的方法http://weblogs.asp.net/manavi/archive/2011/01/23/associations-in-ef-code-first-ctp5-part- 3,一到一个外键,associations.aspx

c# entity-framework entity-framework-ctp5

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

Pygame-使精灵沿其朝向移动

我正在制作一个自上而下的赛车游戏,我想在按向左和向右键时使汽车旋转(我已经做过那部分了),子画面的旋转存储在一个度数变量中。我希望能够使它根据其朝向的加速度进行移动。我可以自己弄清楚加速度部分,它只是弄清楚那个方向上到底是什么像素。谁能给我一些简单的代码来帮助这一点?

以下是相关的课程内容:

def __init__(self, groups):
    super(Car, self).__init__(groups)
    self.originalImage = pygame.image.load(os.path.join("Data", "Images", "Car.png")) #TODO Make dynamic
    self.originalImage.set_colorkey((0,255,0))
    self.image = self.originalImage.copy() # The variable that is changed whenever the car is rotated.

    self.originalRect = self.originalImage.get_rect() # This rect is ONLY for width and height, the x and y NEVER change from 0!
    self.rect = self.originalRect.copy() # This is the rect used to represent the actual rect of the image, it is used for the x and y of the image that is …
Run Code Online (Sandbox Code Playgroud)

python pygame rotation sprite

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

const_iterator和iterator有什么区别?

这两个关于STL内部实现的区别是什么.性能有什么不同?我想当我们在"只读明智"中遍历矢量时,我们更喜欢const_iterator,对吧?

谢谢.

c++ iterator stl const-iterator

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

HTML.Partial - MVC 3 Razor

我从使用与我的主视图不同的模型的控制器返回局部视图时遇到问题.例如:

    public ActionResult Index()
    {
        //myModel - get Some Types
        return View(mymodel);
    }

    public PartialViewResult Categories()
    {
        //my another Model - get different Types

        return PartialView(myanothermodel);
    }
Run Code Online (Sandbox Code Playgroud)

然后在索引视图中:

@Html.RenderPartial("Categories")

我得到一个例外,说它是错误的类型.它期望第一种类型(mymodel)而不是第二种类型.

是否可以为视图及其局部视图返回不同类型?谢谢你的回复.

asp.net razor asp.net-mvc-3

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

匹配后在线打印所有内容

我有一个大文本文件,中间包含一个唯一的字符串.我想要做的是使用grep打印字符串之后的所有内容.

cat textfile | grep "target_string"
This highlights target_string but prints the whole file

cat textfile | grep -o "target_string"
This prints only target_string

cat textfile | grep -o "target_string*"
This prints only target_string
Run Code Online (Sandbox Code Playgroud)

如何在target_string之后打印所有内容之前没有任何内容?

bash grep

28
推荐指数
4
解决办法
7万
查看次数

生成'Hello,World!' 使用Java ASM库的类

我已经开始乱用我正在研究的编译器项目的ASM API.但是,我发现文档对很多地方的新手来说并不清楚,我认为有一个很好的例子,可以生成一个只打印"Hello,World!"的类.这将是一个很好的例子.

目前,我可以使用main()(使用ClassWriter,ClassVisitor和MethodVisitor类)生成一个类,但我似乎无法弄清楚如何生成main的主体.任何人都可以给我一个在ASM中生成类文件的示例:

  • 包含一个main()
  • 在main()中创建一个本地String变量,其值为"Hello,World!"
  • 打印变量

java bytecode compilation jvm-languages java-bytecode-asm

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

在映射文件上调用VirtualProtect

我正在使用CreateFileMapping和MapViewOfFile函数将文件映射到内存中.在某一点之后,我调用VirtualProtect将其保护从只读更改为读写.此调用失败,GetLastError提供ERROR_INVALID_PARAMETER.

这是我的代码的简化版本,用于演示此问题.

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

int main() {
    HANDLE fd, md;
    char *addr;
    DWORD old;
    BOOL ok;

    fd = CreateFile("filename", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    md = CreateFileMapping(fd, NULL, PAGE_READWRITE, 0, 100, NULL);
    addr = MapViewOfFile(md, FILE_MAP_READ, 0, 0, 100);
    ok = VirtualProtect(addr, 100, PAGE_READWRITE, &old);
    if (!ok) {
        // we fall into this if block
        DWORD err = GetLastError();
        // this outputs "error protecting: 87"
        printf("error protecting: %u\n", err);
        return 1;
    }
    UnmapViewOfFile(addr);
    CloseHandle(md);
    CloseHandle(fd); …
Run Code Online (Sandbox Code Playgroud)

c windows winapi

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