当我减少数组时,我试图将数字设为零,但我不清楚这个函数的行为
[].reduce(function(previousValue, currentValue){
return Number(previousValue) + Number(currentValue);
});
Run Code Online (Sandbox Code Playgroud)
结果
TypeError: Reduce of empty array with no initial value
Run Code Online (Sandbox Code Playgroud)
似乎如果数组是空的我无法减少它
[""].reduce(function(previousValue, currentValue){
return Number(previousValue) + Number(currentValue);
});
Run Code Online (Sandbox Code Playgroud)
结果
""
Run Code Online (Sandbox Code Playgroud)
如果数组中唯一的元素是空字符串,则检索空字符串
我创建了一个Maven项目.这是结构:
-parent
-core
-web
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用该命令进行部署时mvn tomcat7:deploy
,我收到以下错误:
No plugin found for prefix 'tomcat7' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo]
Run Code Online (Sandbox Code Playgroud)
我把这个配置放在pom.xml(web项目)中:
<build>
<finalName>MavenWeb</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud) 我试图在这个堆栈上完成Docker shell的完成(OSX iTerm2 oh-my-zsh)
我按照本指南 - > https://docs.docker.com/compose/completion/
首先我执行了这个
$ mkdir -p ~/.zsh/completion
$ curl -L https://raw.githubusercontent.com/docker/compose/master/contrib/completion/zsh/_docker-compose > ~/.zsh/completion/_docker-compose
Run Code Online (Sandbox Code Playgroud)
然后我几乎在结束~/.zshrc
文件中添加了这两行
fpath=(~/.zsh/completion $fpath)
autoload -Uz compinit && compinit -i
Run Code Online (Sandbox Code Playgroud)
然后在终端我跑
source ~/.zshrc
exec $SHELL -l
Run Code Online (Sandbox Code Playgroud)
但是,当我按下tab
它时,建议路径上的文件和文件夹
我正在尝试安装类型安全激活器(scala,AKKA,播放框架,激活器)
我有Yosemite OSX
我的bash是哦我的ZSH
我已经安装并导出了JDK 1.7
我下载并解压缩了"typesafe-activator-1.2.10-minimal"文件.最后我将导出路径放在〜/ .zshrc上
但是当我在终端上键入激活器时,它打印出无法找到该文件
谢谢
Android画布改变颜色
我有一个有两个视图的应用程序
<com.myexample.ui.view.BackgroundView
android:id="@+id/id_draw_canvas_classroom"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="3dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="3dp"
android:layout_weight="1"
android:background="#FFFFFFFF" />
<com.myexample.ui.view.FrontView
android:id="@+id/id_draw_canvas_user"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="3dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="3dp"
android:layout_weight="1"
android:background="#00000000" />
Run Code Online (Sandbox Code Playgroud)
这些视图是重叠的,并且在一段时间内我在背景视图中加载信息.在此期间,我想将FrontView设置为白色,然后(当背景完成加载时)变为透明.
在FrontView中,我有一个带位图的Canvas.正在工作,如果我想将背景设置为透明,我可以这样做
canvas.drawColor(0);
Run Code Online (Sandbox Code Playgroud)
将背景设置为白色
canvas.drawColor(-1);
Run Code Online (Sandbox Code Playgroud)
但我无法改变透明白色.
谢谢
我正在使用Spring启动,这里是maven依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
对于网页,我将文件放在src/main/resources/static中.我有我的html文件,js库(angular,jquery)和css文件.
我正在尝试使用Angular进行HTTP请求POST(我也有一个正常工作的GET请求),但我得到了这个
POST http://localhost:8080/xxxx/12/addEntry 405 (Method Not Allowed)
Run Code Online (Sandbox Code Playgroud)
在响应标题中
HTTP/1.1 405 Method Not Allowed
Server: Apache-Coyote/1.1
X-Application-Context: application
Allow: HEAD, GET
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Wed, 09 Jul 2014 13:04:05 GMT
Run Code Online (Sandbox Code Playgroud)
我意识到在响应中,allow没有POST方法.
控制器中的方法
@RequestMapping(value = "/xxxx/{uid}/addEntry", method = RequestMethod.POST)
@ResponseBody
public String createEntry(@PathVariable String uid, @RequestBody String form) {
System.out.println(form);
return "index.html";
}
Run Code Online (Sandbox Code Playgroud) 我想在millis中获取当前时间
DateTime.now.millis
Run Code Online (Sandbox Code Playgroud)
但我明白了
Property[millisOfSecond]
Run Code Online (Sandbox Code Playgroud)
使用nscala-time以毫秒获得当前时间的方法是什么?
我想这样做,使用相同的库
我使用MySQL作为我的数据库,使用H2进行测试.我也在使用playframework 2.3.x和Scala,但我认为这与问题目的无关.
H2与我在查询中使用的某些函数存在冲突
SELECT *
FROM subscriptions
WHERE active_until >= (DATE_SUB(CURDATE(), INTERVAL 3 DAY))
AND active_until <= (DATE_ADD(CURDATE(), INTERVAL 1 DAY))
AND status = "ACTIVE"
Run Code Online (Sandbox Code Playgroud)
导致问题的函数是DATE_SUB和DATE_ADD.
是否有一个解决方法,我可以使这项工作或更改查询而不破坏它的mysql?
我有一个可以在容器内的虚拟机中远程工作的设置,并且我已经使用这些设置几个月了。我按照本指南设置了我的客户端环境。
今天,当我移除容器时,它断开了连接(因为我正在构建一个新容器),从那一刻起我就无法连接到工作。我接通后立即断开连接。我尝试了几件事
docker system prune
(客户端和服务器)容器正在工作,问题是我经常与容器断开与 VSCode 的连接
在日志中我可以读到
[23918 ms] Start: Run in container: set -o noclobber ; mkdir -p '/home/root/.vscode-server/data/Machine' && { > '/home/root/.vscode-server/data/Machine/.installExtensionsMarker' ; } 2> /dev/null
[24517 ms]
[24517 ms]
[24517 ms] Exit code 1
[24518 ms] Start: Run in container: for pid in `cd /proc && ls -d [0-9]*`; do { echo $pid ; readlink -f /proc/$pid/cwd ; xargs -0 < /proc/$pid/environ …
Run Code Online (Sandbox Code Playgroud) docker ×2
oh-my-zsh ×2
scala ×2
android ×1
arrays ×1
ecmascript-5 ×1
h2 ×1
iterm2 ×1
java ×1
javascript ×1
macos ×1
maven ×1
mysql ×1
nscala-time ×1
path ×1
spring ×1
spring-boot ×1
spring-mvc ×1
tomcat ×1
xcode ×1
xcode8 ×1