我安装了最新版本的SDK (r21)和ADT 21.0.0。我尝试了简单的代码,它工作得很好,但现在我在LogCat中得到了一个警告,在以前的版本中没有出现:
nativeGetEnabledTags的意外值:0
我谷歌了一下,我发现问题39723:模拟器垃圾邮件LogCat与“意外值从nativeGetEnabledTags: 0”消息。
这是什么意思?
我安装了最新版本的SDK (r21)和ADT 21.0.0。我尝试了简单的代码,它工作得很好,但现在我在LogCat中得到了一个警告,在以前的版本中没有出现:
nativeGetEnabledTags的意外值:0
我谷歌了一下,我发现问题39723:模拟器垃圾邮件LogCat与“意外值从nativeGetEnabledTags: 0”消息。
这是什么意思?
这个问题几乎说明了一切。使用JPARepository我如何更新一个实体?
JPARepository只有一个save方法,它并没有告诉我它是创建还是更新。例如,我插入一个简单的对象到数据库User,它有三个字段:姓,名和年龄:
@Entity
public class User {
private String firstname;
private String lastname;
//Setters and getters for age omitted, but they are the same as with firstname and lastname.
private int age;
@Column
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
@Column
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
private long userId;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public long getUserId(){
return this.userId;
}
public void setUserId(long userId){
this.userId = userId;
}
}
然后我简单地调用save(),这在这一点上实际上是插入到数据库:
User user1 = new User();
user1.setFirstname("john"); user1.setLastname("dew");
user1.setAge(16);
userService.saveUser(user1);// This call is actually using the JPARepository: userRepository.save(user);
到目前为止一切顺利。现在我要更新这个用户,比如改变他的年龄。为此,我可以使用QueryDSL或NamedQuery之类的查询。但是,考虑到我只想使用spring-data-jpa和JPARepository,我如何告诉它我想做更新而不是插入呢?
具体来说,我如何告诉spring-data-jpa具有相同用户名和名字的用户实际上是EQUAL,并且现有实体应该被更新?重写等号并不能解决这个问题。
我想知道是否有一种技巧可以将当前日期放在.rmd文档的YAML前端,由knitr和rmarkdown包处理。我曾经在我的维基页面顶部有这样一行字,
_baptiste, `r format(Sys.time(), "%d %B, %Y")`_
并且它将在html输出中转换为baptiste, 03 May, 2014。现在,我想利用rmarkdown提供的高级pandoc包装器,但在YAML头中有r代码似乎不起作用:
---
title: "Sample Document"
output:
html_document:
toc: true
theme: united
date: `r format(Sys.time(), "%d %B, %Y")`
author: baptiste
---
Error in yaml::yaml.load(front_matter) :
Scanner error: while scanning for the next token at line 6, column 7
found character that cannot start any token at line 6, column 7
Calls: <Anonymous> ... output_format_from_yaml_front_matter ->
parse_yaml_front_matter -> <Anonymous> -> .Call
有解决方案吗?
对于使用roxygen(2)记录类,指定标题和描述/细节似乎与函数、方法、数据等相同。然而,槽和继承是它们自己的一种动物。在roxygen2中记录S4类的最佳实践(当前的或计划的)是什么?
尽职调查:
我发现在roxygen的早期描述中提到了@slot标签。 2008年R-forge邮件列表帖子 似乎表明这已经死了, 并且roxygen中不支持@slot:
roxygen2也是这样吗?前面提到的文章建议用户应该使用LaTeX标记创建自己的逐项列表。例如,扩展“character”类的新S4类将像这样编码和记录:
#' The title for my S4 class that extends \code{"character"} class.
#'
#' Some details about this class and my plans for it in the body.
#'
#' \describe{
#' \item{myslot1}{A logical keeping track of something.}
#'
#' \item{myslot2}{An integer specifying something else.}
#'
#' \item{myslot3}{A data.frame holding some data.}
#' }
#' @name mynewclass-class
#' @rdname mynewclass-class
#' @exportClass mynewclass
setClass("mynewclass",
representation(myslot1="logical",
myslot2="integer",
myslot3="data.frame"),
contains = "character"
)
然而,尽管这样做是有效的,但是这种用于记录槽的\describe, \item方法似乎与roxygen(2)的其余部分不一致,因为没有@-分隔的标记,并且槽可以在没有roxygenize()反对的情况下被记录。它也没有说明以一致的方式记录所定义类的继承。我认为使用@import标记依赖关系通常仍然可以正常工作(如果特定插槽需要来自另一个包的非基类)。
那么,总结一下,目前roxygen(2)插槽的最佳实践是什么?
目前似乎有三种选择可供考虑:
A——分项列表(如上面的例子)。 B——@槽…但是我错过了额外的标签/实现。我无法让@slot在版本中使用roxygen / roxygen2 它是作为示例中逐项列表的替换而包含的 以上。同样,上述例子也适用于roxygen(2)。 C——一些用于指定槽的替代标记,比如@param,可以完成同样的事情。
我从github上roxygen2开发页面上的一篇文章中借用/扩展了这个问题。
我不明白有什么区别,它们看起来是一样的,但我想它们不是。
任何关于何时使用其中一个或另一个的例子都将是非常感谢的。
这不是一个很简单的手术吗?但是,我看到既没有size()也没有length()方法。
这是运行脚本检查Tensorflow是否工作时收到的消息:
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcurand.so.8.0 locally
W tensorflow/core/platform/cpu_feature_guard.cc:95] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:95] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:910] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
我注意到它提到了SSE4.2和AVX,
什么是SSE4.2和AVX? 这些SSE4.2和AVX如何提高Tensorflow任务的CPU计算。 如何使用这两个库使Tensorflow编译?
如何在SQLAlchemy中执行原始SQL ?
我有一个python web应用程序,运行在flask和接口到数据库通过SQLAlchemy。
我需要一种方法来运行原始SQL。该查询涉及多个表连接和内联视图。
我试过了:
connection = db.session.connection()
connection.execute( <sql here> )
但是我总是得到网关错误。
如果您有子文档数组,Mongoose会自动为每个子文档数组创建id。例子:
{
_id: "mainId"
subDocArray: [
{
_id: "unwantedId",
field: "value"
},
{
_id: "unwantedId",
field: "value"
}
]
}
是否有一种方法告诉猫鼬不为数组中的对象创建id ?
我使用S3托管一个javascript应用程序,将使用HTML5 pushStates。问题是,如果用户书签了任何url,它将不会解析为任何东西。我需要的是能够接受所有url请求,并在我的S3桶中提供根index.html,而不仅仅是进行完全重定向。然后我的javascript应用程序可以解析URL并提供适当的页面。
有没有办法告诉S3为所有URL请求服务index.html,而不是做重定向?这类似于通过提供一个index.html来设置apache来处理所有传入的请求,如本例中的https://stackoverflow.com/a/10647521/1762614。我真的希望避免仅仅为了处理这些路由而运行web服务器。从S3执行所有操作非常有吸引力。