我通常通过ssh(screen和vim)在远程服务器上工作,我有一个Git存储库.有时我不上网,所以我的笔记本电脑上有一个单独的存储库(从我的遥控器克隆).
但是,我无法从远程端的这个存储库中取出,因为我通常在防火墙后面,或者我没有公共IP.
我已经读过,我应该只是推到一个裸存储库.我应该如何将更改推送到远程存储库?
我在Eclipse中遗漏的一件事是,如果项目中一些完全不相关的文件包含错误,我就无法运行代码来测试各种事物(想想简短的main()).我在FAQ中读到我可以使用带有-proceedOnErrors参数的Eclipse编译器,但它仍然不起作用.暂时修复未完成的代码进行编译并不是我想要的.
我应该注意,我也使用Scala插件,但我的大部分代码仍然是Java文件.
编辑:我一直在这里投票.仅仅为了记录,我不再认为这很重要.自从我发布之后我就不需要了.
我想在Scala中做以下...
def save(srcPath: String, destPath: String) {
if (!destPath.endsWith('/'))
destPath += '/'
// do something
}
Run Code Online (Sandbox Code Playgroud)
......但我不能说destPath是val.有没有办法声明destPath为var?
注意:有类似的问题,但在所有这些问题中OP只是想修改数组.
请不要建议以下内容:
改变输入参数通常被认为是糟糕的风格,并且使得更难以推理代码.
我认为它在命令式编程中是有效的(Scala允许两者,对吗?)并添加类似tmpDestPath添加杂乱的东西.
编辑:不要误解.我知道字符串不可变,我不想引用引用,因为我不想修改调用者的数据.我只想修改调用者给我的字符串的本地引用(例如,orig +'/').我想仅在当前方法的范围内修改该值.看,这在Java中是完全有效的:
void printPlusOne(int i) {
i++;
System.out.println("i is: " + i);
System.out.println("and now it's same: " + i);
}
Run Code Online (Sandbox Code Playgroud)
我不必创建新变量,我不必两次计算i + 1.
我正在尝试根据我的XML模式验证我的XML文档.
这是我的架构:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://cars.example.org/">
<element name="cars">
<complexType>
<sequence minOccurs="0" maxOccurs="unbounded">
<element name="brand" type="string"/>
</sequence>
</complexType>
</element>
</schema>
Run Code Online (Sandbox Code Playgroud)
这是我的XML文档:
<?xml version="1.0" encoding="UTF-8"?>
<cars xmlns="http://cars.example.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://cars.example.org/ cars.xsd">
<brand>x</brand>
</cars>
Run Code Online (Sandbox Code Playgroud)
现在,当我验证文档时(通过Eclipse),我在第4行得到以下消息:
cvc-complex-type.2.4.a: Invalid content was found starting with element 'brand'. One of '{"":brand}' is expected.
Run Code Online (Sandbox Code Playgroud)
这条消息没有任何意义:(.谷歌解决方案很难(不可能?).
谢谢您的帮助.
我正在为Cortex-M0 CPU和gcc编写代码.我有以下结构:
struct {
volatile unsigned flag1: 1;
unsigned flag2: 1;
unsigned foo; // something else accessed in main loop
} flags;
Run Code Online (Sandbox Code Playgroud)
flag1从GPIO中断处理程序和主循环读取和写入.flag2只在主循环中读写.
ISR看起来像这样:
void handleIRQ(void) {
if (!flags.flag1) {
flags.flag1 = 1;
// enable some hw timer
}
}
Run Code Online (Sandbox Code Playgroud)
主循环看起来像这样:
for (;;) {
// disable IRQ
if (flags.flag1) {
// handle IRQ
flags.flag1 = 0;
// access (rw) flag2 many times
}
// wait for interrupt, enable IRQ
}
Run Code Online (Sandbox Code Playgroud)
flag2在主循环中访问时,编译器是否会优化对它的访问,以便每次在代码中读取或写入时都不会将其提取或存储到内存中?
我不清楚因为要设置flag1ISR,它需要加载整数char,设置一下并存储回来.
我有一个带有文件src/main/webapp/META-INF/context.xml的Web应用程序,其中包含一些用于测试数据库的配置.在生产服务器上,此文件位于$ TOMCAT_HOME/conf/Catalina/localhost/ROOT.xml中,我正在使用嵌入式tomcat进行测试,因此我不想打包此文件.我想从maven build中排除这个文件.我试过以下:
<build>
...
<resources>
<resource>
<directory>src/main/webapp/META-INF</directory>
<filtering>true</filtering>
<excludes>
<exclude>context.xml</exclude>
</excludes>
</resource>
</resources>
</build>
Run Code Online (Sandbox Code Playgroud)
以及:
<build>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<resources>
<resource>
<directory>src/main/webapp/META-INF</directory>
<filtering>true</filtering>
<excludes>
<exclude>context.xml</exclude>
</excludes>
</resource>
</resources>
</configuration>
</plugin>
</build>
Run Code Online (Sandbox Code Playgroud)
但是文件仍然在war和build目录中打包(例如target/myapp-1.0-SNAPSHOT/META-INF/context.xml).我究竟做错了什么?
如何实现整个SplitPane的比例调整?
public class JfxSplitPaneTest extends Application {
@Override
public void start(Stage stage) throws Exception {
SplitPane split = new SplitPane();
StackPane child1 = new StackPane();
child1.setStyle("-fx-background-color: #0000AA;");
StackPane child2 = new StackPane();
child2.setStyle("-fx-background-color: #00AA00;");
StackPane child3 = new StackPane();
child3.setStyle("-fx-background-color: #AA0000;");
split.getItems().addAll(child1, child2, child3);
//split.setDividerPositions(0.1f, 0.6f, 0.9f)
stage.setScene(new Scene(split, 400, 300));
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Run Code Online (Sandbox Code Playgroud)
启动程序:

设置分隔符我喜欢它们:

使窗口宽度非常小(我继续使它变得更小,没有图片):

调整大小并观察分频器既不是我设置它们也不是它们在程序启动时的方式.

这样做会使它更接近我的期望:
child1.setMinWidth(Region.USE_PREF_SIZE)
child1.setPrefWidth(100)
child2.setMinWidth(Region.USE_PREF_SIZE)
child2.setPrefWidth(200)
child3.setMinWidth(Region.USE_PREF_SIZE)
child3.setPrefWidth(300)
Run Code Online (Sandbox Code Playgroud)
除了分频器最初处于错误的位置(直到我调整SplitPane的大小,1px足够)并且当缩小窗口宽度时,分频器在组件内部.
我怎么能让这个工作好吗?
我想将这篇文章命名为“让 SQLite 在第一次错误时中止”,但 StackOverflow 的人工智能霸主认为这不符合他们对智能人类行为的概念。根据记录,我正在谷歌上搜索这一点,但也许谷歌人工智能也认为我的问题不值得,并且懒得帮助我。模组们,请随意根据您的人工智能老板的愿望更改标题(如果您能弄清楚的话)。
我有这个脚本
create if not exists table entries (
id integer primary key,
start datetime not null,
end datetime not null
);
delete from entries;
insert into entries values (1, '2018-08-01 10:00', '2018-08-01 15:00');
insert into entries values (2, '2018-08-01 17:00', '2018-08-01 20:00');
insert into entries values (1, '2018-08-02 19:00', '2018-08-02 00:00');
insert into entries values (1, '2018-08-03 00:00', '2018-08-03 04:00');
insert into entries values (1, '2018-08-03 14:00', '2018-08-03 18:00');
Run Code Online (Sandbox Code Playgroud)
表述有错误create。当我运行脚本时我得到
% …Run Code Online (Sandbox Code Playgroud) 我想在Scala中做一些我会用Java做的事情:
public void recv(String from) {
recv(from, null);
}
public void recv(String from, Integer key) {
/* if key defined do some preliminary work */
/* do real work */
}
// case 1
recv("/x/y/z");
// case 2
recv("/x/y/z", 1);
Run Code Online (Sandbox Code Playgroud)
在Scala我能做到:
def recv(from: String,
key: Int = null.asInstanceOf[Int]) {
/* ... */
}
Run Code Online (Sandbox Code Playgroud)
但它看起来很难看.或者我可以这样做:
def recv(from: String,
key: Option[Int] = None) {
/* ... */
}
Run Code Online (Sandbox Code Playgroud)
但现在用钥匙看起来很难看:
// case 2
recv("/x/y/z", Some(1));
Run Code Online (Sandbox Code Playgroud)
什么是正确的Scala方式?谢谢.
嗨.我想将初始化环境中的 Scala REPL嵌入到我的应用程序中.我看过IMain课,似乎我可以通过它的实例来做.实例被创建,然后存储到intp在公共变种process()的ILoop.
如何绑定某些名称和/或添加一些导入process()(例如在REPL之前)?
以下代码在第3行失败,因为intp尚未创建(=> NPE):
val x = 3
val interp = new ILoop
interp.bind("x", x) // -> interp.intp.bind("x", x)
val settings = new Settings
settings.usejavacp.value = true
interp.process(settings)
Run Code Online (Sandbox Code Playgroud)
谢谢-.
更新:createInterpreter()不幸的是,覆盖不起作用:
val x = 3
val interp = new ILoop {
override def createInterpreter() {
super.createInterpreter()
intp.bind("x", x) // -> interp.intp.bind("x", x)
}
}
val settings = new Settings
settings.usejavacp.value = true
interp.process(settings)
Run Code Online (Sandbox Code Playgroud)
解释器停留在输入上(看起来像死锁,仅在上面的代码中发生): …