我使用的是旧版本(1.5)的com.sun.jersey-server/json/client,它必须是这个版本所以请不要建议使用更新的版本.
在我的pom.xml中,我通过它引用它
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey.version}</version>
<type>jar</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<!-- version conflicts with explicit direct dependency -->
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
</exclusion>
</exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud)
$ {jersey.version}为1.5
如果我不想编译它我得到这些错误:
[INFO] Scanning for projects...
[INFO]------------------------------------------------------------------------
[INFO] Building MediaAssistantWebService
[INFO] task-segment: [clean, install]
[INFO]------------------------------------------------------------------------
[...]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
Downloading: http://repositories.dai-labor.de/extern/content/repositories/dai-open/com/sun/jersey/jersey-server/1.5/jersey-server-1.5.pom
[INFO] Unable to find resource 'com.sun.jersey:jersey-server:pom:1.5' in repository dai-open (http://repositories.dai-labor.de/extern/content/repositories/dai-open)
Downloading: http://download.java.net/maven/2//com/sun/jersey/jersey-server/1.5/jersey-server-1.5.pom 10K downloaded (jersey-server-1.5.pom)
Downloading: http://maven.glassfish.org/content/groups/glassfish/com/sun/jersey/jersey-project/1.5/jersey-project-1.5.pom 185b downloaded (jersey-project-1.5.pom)
[WARNING] *** CHECKSUM FAILED - Checksum …Run Code Online (Sandbox Code Playgroud) 我试图解析一些日期,但DateTimeParser似乎不同意我的有效期
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
import java.util.Locale
ZonedDateTime.parse("Wed Jul 16, 2016 4:38pm EDT", DateTimeFormatter.ofPattern("EEE MMM dd, yyyy hh:mma z", Locale.US))
Run Code Online (Sandbox Code Playgroud)
当我试着这样说时
java.time.format.DateTimeParseException: Text 'Wed Jul 16, 2016 4:38pm EDT' could not be parsed at index 17
Run Code Online (Sandbox Code Playgroud)
那么小时有问题吗?当我放下其中一个'h'时它会进一步增加(尽管它应该只用0-pad我的小时),但是它不喜欢pm-stuff
ZonedDateTime.parse("Wed Jul 16, 2016 4:38pm EDT", DateTimeFormatter.ofPattern("EEE MMM dd, yyyy h:mma z", Locale.US))
java.time.format.DateTimeParseException: Text 'Wed Jul 16, 2016 4:38pm EDT' could not be parsed at index 21
Run Code Online (Sandbox Code Playgroud)
我不知道他的确切问题是什么.当我尝试'hh:mmaa'作为模式时它表示它不喜欢两个a而现在我被卡住了,因为错误消息没有帮助.
所以我第一次尝试使用隐式参数和变量,这非常合适
class Test(implicit val a: Int) {
bar(5)
def bar(c: Int)(implicit d: Int): Unit = {
println(d)
}
}
Run Code Online (Sandbox Code Playgroud)
然后我在一些更复杂的代码中尝试了它
class GameScreen(val game : Game)(implicit val batch: SpriteBatch, implicit val world: World, implicit val manager: AssetManager) extends Screen {
val camera : OrthographicCamera = new OrthographicCamera
createOpenGLStuff()
createMap()
def createMap(implicit w : World) : Unit =
{
}
Run Code Online (Sandbox Code Playgroud)
但现在我得到了错误
- not enough arguments for method createMap: (implicit w:
com.badlogic.gdx.physics.box2d.World)Unit. Unspecified value parameter w.
Run Code Online (Sandbox Code Playgroud)
我不知道为什么这不起作用,我可以写
createMap(this.world)
Run Code Online (Sandbox Code Playgroud)
一切都很好,但是因为this.world是隐含的(我认为?)我不应该在那里指定它.我在做什么/理解错了?
在我的conf.py中它说我应该看到内置主题列表的文档.现在我的第一个谷歌热门引导我到http://www.sphinx-doc.org/en/stable/theming.html#builtin-themes.那里有一堆主题,我的狮身人面像不知道.例如'经典'.
在conf.py
html_theme = 'classic'
在我的shell上我做: sphinx-build -b html source build
writing output... [100%] index
Exception occurred:
File "~\appdata\local\programs\python\python35\lib\site-packages\sphinx\jinja2glue.py", line 200, in get_source
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: about.html
Run Code Online (Sandbox Code Playgroud)
sphinx版本:1.6.3.
我正在开发一个chrome扩展,我想用chrome.runtime.sendMessage发送一个对象(带有一些函数).
现在做这样的事情
chrome.runtime.sendMessage({something: "Funny"});
Run Code Online (Sandbox Code Playgroud)
工作得很好.但是,只要我想创建更复杂的东西,我的消息似乎就是一个空对象.
function FunnyFunction() {
return 42;
}
var exampleObject = new Object();
exampleObject.FunnyFunction = FunnyFunction;
chrome.runtime.sendMessage({something: exampleObject });
Run Code Online (Sandbox Code Playgroud)
现在在接收端,它成功地注册了一条消息,并检测到它有一个键"某事".但是exampleObject总是空的.里面没有功能.
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
console.log("got message: ");
console.log(request);
if ('something' in request) {
exampleObject = request.exampleObject;
console.log(exampleObject);
}
}
);
Run Code Online (Sandbox Code Playgroud)
请求始终是一个对象
Object {something: Object}
Run Code Online (Sandbox Code Playgroud)
但是'something'背后的对象,应该是exampleObject - 我之前用2个函数定义的对象 - 总是空的.
Object {}
Run Code Online (Sandbox Code Playgroud)
当我尝试做exampleObject.FunnyFunction(); 它显然崩溃了,因为它没有这样的成员.
我在这做错了什么?
我想知道如何在numpy中生成与MATLAB中相同的随机(正态分布)数字.
作为一个例子,我在MATLAB中这样做
RandStream.setGlobalStream(RandStream('mt19937ar','seed',1));
rand
ans =
0.417022004702574
Run Code Online (Sandbox Code Playgroud)
现在我可以用numpy重现这个:
import numpy as np
np.random.seed(1)
np.random.rand()
0.417022004702574
Run Code Online (Sandbox Code Playgroud)
哪个好,但是当我使用正态分布执行此操作时,我会得到不同的数字.
RandStream.setGlobalStream(RandStream('mt19937ar','seed',1));
randn
ans =
-0.649013765191241
Run Code Online (Sandbox Code Playgroud)
和numpy
import numpy as np
np.random.seed(1)
np.random.randn()
1.6243453636632417
Run Code Online (Sandbox Code Playgroud)
两个函数在他们的文档中都说他们从标准的正态分布中得出,但给出了不同的结果.知道如何调整我的python/numpy以获得与MATLAB相同的数字.
因为有人将此标记为重复:这是关于正常分布,正如我在开头和结尾所写的那样.因为我写的统一分布工作正常,这是关于正态分布.链接线程中的所有答案都不能帮助正常分发.
基本上我想要一个可以使用超出其范围的函数的模块.我需要这个,因为我的工作只会提供一个框架,用户可以在其中放入自己的代码.这样的事情
Simulation.jl
abstract AbstractType
function startSimulation(unknown::AbstractType)
doStuff(unknown)
end
Run Code Online (Sandbox Code Playgroud)
MyModule.jl
module MyModule
include("Simulation.jl")
export AbstractType, startSimulation
end
Run Code Online (Sandbox Code Playgroud)
SomeImplementation.jl
type ConcreteType <: AbstractType
variable::Int64
end
doStuff(me::ConcreteType)
me.variable
end
Run Code Online (Sandbox Code Playgroud)
最后是Main.jl
# push!(LOAD_PATH, pwd()) # for local usage
using MyModule
include("SomeImplementation.jl")
startSimulation(ConcreteType(5))
Run Code Online (Sandbox Code Playgroud)
其中Simulation.jl和MyModule.jl由我编写,SomeImplementation.jl和Main.jl由用户编写.
现在上面的例子不起作用,因为模块有自己的命名空间,甚至在第3行的main中导入SomeImplementation.jl,解释器也不会在Simulation.jl的第4行中看到它.
我无法在MyModule.jl中导入任何内容,因为我无法知道用户将如何命名他的内容或者他甚至可能需要哪些额外的库.
有没有办法用模块做到这一点?否则我就不会使用模块.
我想为我的程序创建UserCredentials,这个任务的签名似乎是
Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.AuthorizeAsync(
(Uri clientSecretsUri, IEnumerable<string> scopes, string user, CancellationToken taskCancellationToken);
Run Code Online (Sandbox Code Playgroud)
我发现的所有教程只是创建一个ClientSecrets类并将其作为参数传递,遗憾的是这个类没有.ToUri()方法.我也找不到关于如何构建这个uri的任何文档.因此,鉴于我明显拥有我的客户端ID和秘密(如果需要,还可以重定向uri),如何创建此授权所需的uri?
这对我来说很重要.
foo =
bar
Run Code Online (Sandbox Code Playgroud)
我想轻松地移动等号后面的条形线的内容.我知道如果我在条形线上我可以这样做:
^^dEk$p
Run Code Online (Sandbox Code Playgroud)
但这感觉很笨拙,有更短/更优雅的方式吗?
朱莉娅0.5.1
我想在引用中创建一个函数,可以在使用指定的宏之后使用.这是我的意思的一个例子
macro wat()
quote
type Foo end
global bar() = begin end
global function bar2()
end
type Baaz end
end
end
@wat
Foo()
Baaz()
bar()
bar2()
Run Code Online (Sandbox Code Playgroud)
现在当我运行它时,最后一行崩溃,因为bar2未定义.我不明白为什么因为在我的理解中bar()和bar2()应该相等而bar只是bar2的语法糖.但他们显然不平等,我不明白为什么一个有效,另一个无效.
其次有没有一种方法可以在没有global-keyword的情况下在引号内定义bar和bar2,并且在执行宏之后仍然可用?
我想要bar2表示法的动机是我可以用这种语法指定一个返回类型.
global bar3()::Void = begin end
Run Code Online (Sandbox Code Playgroud)
不允许使用语法.