是否有可能确保使用node.js生成的进程child_process将在父级被杀死时被终止?
这是一个示例脚本
var spawn = require('child_process').spawn;
var log_tail = spawn("tail", ["-f", "/dev/null"]);
setInterval(function() {
console.log('just chilling');
}, 10000);
Run Code Online (Sandbox Code Playgroud)
如果我查看进程树,我会看到:
$ ps faux
ubuntu 9788 0.0 0.0 73352 1840 ? S 15:04 0:00 | \_ sshd: ubuntu@pts/7
ubuntu 9789 0.0 0.2 25400 6804 pts/7 Ss 15:04 0:00 | \_ -bash
ubuntu 10149 1.0 0.2 655636 8696 pts/7 Sl+ 15:07 0:00 | \_ node test.js
ubuntu 10151 0.0 0.0 7184 608 pts/7 S+ 15:07 0:00 | \_ tail -f /dev/null
Run Code Online (Sandbox Code Playgroud)
然后我需要停止该脚本,不能ctrl-c(说我的ssh连接丢失)
$ …Run Code Online (Sandbox Code Playgroud) 使用以下html,当我将鼠标悬停在子项上时,我获得了父项的绿色背景.我怎么能阻止这种情况发生?如果我在子元素之外盘旋,我确实想要绿色背景.
CSS3很好.
.parent {
padding: 100px;
width: 400px;
height: 400px;
}
.parent:hover {
background-color: green;
}
.child {
padding: 100px;
width: 200px;
height: 200px;
}
.child:hover {
background-color: blue;
}Run Code Online (Sandbox Code Playgroud) 可能重复:
在Vim中保留替代案例
是否可以在vim中进行搜索和替换以保留搜索词的大小写?这是我想念的一个有用的功能.
例如,类似于:
:s/[uU]ser/[pP]erson/ (obviously, this doesn't work)
Run Code Online (Sandbox Code Playgroud)
这样:
user->person
User->Person
Run Code Online (Sandbox Code Playgroud)
保留多个字符的另一个示例:
:s/[mM]y[uU]ser/[tT]his[pP]erson/g
Run Code Online (Sandbox Code Playgroud)
这样:
myuser->thisperson
myUser->thisPerson
MyUser->ThisPerson
Run Code Online (Sandbox Code Playgroud) 在PHP中,如果我有一个如下函数:
function test($b) {
var $a = 0;
while ($a < b) {
$a += 3;
}
return $a;
}
Run Code Online (Sandbox Code Playgroud)
并且光标$a += 3在线上,是否可以快速选择整个功能?
"v2aB"将选择包括函数括号在内的所有内容,但不会选择声明 function test($b)
在处理了几个大型Web应用程序,并看到没有清晰结构的巨大样式表之后,我真的很想知道人们是否已经找到了保持css清理大型复杂Web应用程序的方法.
你如何从遗留的,混乱的CSS转移到清理,漂亮的级联,DRY样式表?
我目前正在开发的应用程序有12000行css.它早在没有标准或评论css的情况下就有机地增长到这个尺寸,唯一的规则就是让应用程序与设计相匹配.我们经常遇到的一些问题:
冲突的样式:一个开发人员添加.header {font-weight:bold;}但是.header已经在其他模块中使用,并且不应该是那些粗体.
级联问题:Foo小部件有一个.header但它还包含一个带有.header类的Bar小部件列表.
继承问题,我们不断将小部件字体重新定义为11px/normal,因为一些顶级容器使用12px/18 px行高.
使用诸如dojo/dijit或jquery ui之类的库来对抗小部件库,这些库可以添加大量样式以实现功能,这意味着我们的代码充斥着我们必须覆盖库样式以使事物看起来恰到好处的地方.有大约2000行css只是为了调整内置dijit样式
我们正在考虑实施以下规则:
命名空间所有新的窗口小部件类 - 如果你有一个窗口小部件foo,所有的子类名将是.foo_,所以我们得到:.foo,.foo_header,.foo_content,.foo_footer.这使得我们的CSS基本上是FLAT,但我们看不到其他方法来组织我们的代码,而不会遇到上面提到的遗留样式或级联问题.
警察通用样式 - 有一小部分通用类,只适用于非常特殊的情况.例如.editable - 适用于应该调用编辑器的句子部分 - 应该只包含文本节点.
利用css编译器mixins要避免在不同的小部件中重复定义相同的样式,请定义并使用mixins.虽然我们担心mixins也会失控.
我们还能如何摆脱不断将回归引入可持续发展的css混乱.
在一个非常大的遗留应用程序中,我有没有实现这些接口的接口和类.
接口是基于类生成的,因此签名是相同的(除了接口在顶部添加另一个异常)并且名称相似(因此很容易从接口名称中找到类名).
为了获得接口的实现,我们做了一堆处理和记录调用,但基本上用于java.lang.reflect.Proxy委托给类.简化它看起来像这样:
// This will create a proxy and invoke handler that calls HelloWorld.doSomething
HelloWorldInterface i = MyProxyUtil.getInstance(HelloWorldInterface.class);
i.doSomething();
public interface HelloWorldInterface {
public void doSomething() throws Exception;
}
public class HelloWorld {
public void doSomething() {
//something
}
}
Run Code Online (Sandbox Code Playgroud)
是否有可能使用Spring注释处理,一般来说@Autowire所有类型的字段*Interface都有弹簧用于MyProxyUtil.getInstance(*Interface.class)注入实现?
这样
@Autowire HelloWorldInterface a;
HelloWorldInterface b = MyProxyUtil.getInstance(HelloWorldInterface.class);
@Autowire AnotherInterface c;
AnotherInterface d = MyProxyUtil.getInstance(AnotherInterface.class);
a == b
c == d
Run Code Online (Sandbox Code Playgroud) 我希望开始在服务器上使用 javascript,最有可能使用 node.js,以及使用 websockets 与客户端进行通信。然而,关于使用 TLS 和 wss:// 处理程序进行加密 Websocket 通信的信息似乎并不多。事实上,我见过的唯一明确支持 wss:// 的服务器是 Kaazing。
此TODO 是我在各种节点实现中找到的唯一参考。我是否遗漏了某些内容,或者 websocket js 服务器尚未准备好进行加密通信?
类似于这个问题。
我想在 Oracle (10g) 中获得类似于 PostgreSQL 中的 EXPLAIN ANALYZE 的详细查询计划和实际执行。有等价物吗?
在jQuery中,如果你在ajax回调方法中出错,你将得到一个正确的控制台错误信息和stacktrace.
$.get("https://api.github.com/users/octocat/orgs", function() {
var a = FAIL;
});
Run Code Online (Sandbox Code Playgroud)
然而,在使用道场/请求/ XHR道场似乎这些愚蠢的错误被完全吞噬.我运行它时控制台中唯一的东西是"然后"和"总是".
require(["dojo/request/xhr" ], function(xhr) {
var promise = xhr.get("https://api.github.com/users/octocat/orgs");
promise.then(function(data) {
console.log('then');
var a = FAIL;
console.log('goodbye');
}, function() {
console.log('error');
});
promise.otherwise(function() {
console.log('otherwise');
});
promise.always(function() {
console.log('always');
});
});
Run Code Online (Sandbox Code Playgroud)
使用已弃用的dojo.xhrGet,问题略有改善.我收到一个控制台错误消息,我的错误处理程序被调用,但它只是说"ReferenceError {}"并为我提供了一个永远不会指向我拥有的函数的堆栈跟踪:
dojo.xhrGet({
url: "https://api.github.com/users/octocat/orgs",
load: function() {
console.log('dojo.xhrGet.load');
var a = FAIL;
console.log('goodbye dojo.xhrGet.load');
},
error: function() {
console.log('dojo.xhrGet.error');
},
handle: function() {
console.log('dojo.xhrGet.handle');
}
});
Run Code Online (Sandbox Code Playgroud)
当编写一个程序,我们会犯错误,这是不错的,我们有一个像Chrome开发者工具的工具给我们指出这些错误.当您可以看到堆栈跟踪和错误消息时,找到错误所需的时间显然比没有反馈时快得多.我得到了道场没有反馈,我不能相信这样的通俗图书馆可以以这种方式操作.我究竟做错了什么?