哪个选择器更强?
#nav li.current
Run Code Online (Sandbox Code Playgroud)
要么
div #nav li
Run Code Online (Sandbox Code Playgroud)
第二个
a.test
Run Code Online (Sandbox Code Playgroud)
要么
.test .test
Run Code Online (Sandbox Code Playgroud)
答案是什么?
我有这个代码:
window.onload = function() {
document.cookie = 'foo=bar; expires=Sun, 01 Jan 2012 00:00:00 +0100; path=/';
var xhr = new XMLHttpRequest();
xhr.open("GET", "/showcookie.php",true);
xhr.setRequestHeader("Cookie", "foo=quux");
xhr.setRequestHeader("Foo", "Bar");
xhr.setRequestHeader("Foo", "Baz");
xhr.withCredentials = true;
var pre = document.getElementById('output');
xhr.onreadystatechange = function() {
if (4 == xhr.readyState) {
pre.innerHTML += xhr.responseText + "\n";
}
};
xhr.send(null);
};
Run Code Online (Sandbox Code Playgroud)
这个/showcookie.php
<?php
print_r($_COOKIE);
?>
Run Code Online (Sandbox Code Playgroud)
它总是显示出来
Array
(
[Host] => localhost
[User-Agent] =>
[Accept] =>
[Accept-Language] => pl,en-us;q=0.7,en;q=0.3
[Accept-Encoding] => gzip,deflate
[Accept-Charset] => ISO-8859-2,utf-8;q=0.7,*;q=0.7
[Keep-Alive] => 115
[Connection] …Run Code Online (Sandbox Code Playgroud) 我有返回数千个结果的查询,是否可以只在MySQL控制台或命令行中显示查询时间而没有实际结果?
如何选择li没有.hidden课程的最后一个?
我有像这样的HTML和CSS:
ul li:last-child:not(:first-child):not(.hidden) button {
background-color: red;
}Run Code Online (Sandbox Code Playgroud)
<ul>
<li>
<button>1</button>
</li>
<li>
<button>2</button>
</li>
<li class="hidden">
<button>3</button>
</li>
</ul>Run Code Online (Sandbox Code Playgroud)
我正在尝试调试claws-mail通知插件,我有这样的代码:
#include "notification_indicator.h"
#include "notification_prefs.h"
#include "notification_core.h"
#include "folder.h"
#include "common/utils.h"
#include <messaging-menu.h>
#include <unity.h>
#define CLAWS_DESKTOP_FILE "claws-mail.desktop"
#include <stdio.h>
void main(void)
{
GList *cur_mb;
gint total_message_count;
total_message_count = 0;
/* check accounts for new/unread counts */
for(cur_mb = folder_get_list(); cur_mb; cur_mb = cur_mb->next) {
Folder *folder = cur_mb->data;
NotificationMsgCount count;
if(!folder->name) {
printf("Notification plugin: Warning: Ignoring unnamed mailbox in indicator applet\n");
continue;
}
gchar *id = folder->name;
notification_core_get_msg_count_of_foldername(folder->name, &count);
printf("%s: %d\n", folder->name, count.unread_msgs);
}
}
Run Code Online (Sandbox Code Playgroud)
我用这个命令编译它:
gcc -I/home/kuba/Pobrane/claws-mail-3.13.2/src/
-I/usr/include/gtk-2.0/ …Run Code Online (Sandbox Code Playgroud) 我试图理解monads的概念,我想知道这个代码是否是这个概念的实现(在JavaScript中).
我有函数M返回具有set方法的新对象,该方法创建包装器方法
var foo = M().set('getX', function() {
return this.x;
}).set('setX', function(x) {
this.x = x;
}).set('addX', function(x) {
this.x += x;
});
Run Code Online (Sandbox Code Playgroud)
然后我可以链接foo的方法
foo.setX(10).addX(20).addX(30).getX()
Run Code Online (Sandbox Code Playgroud)
将返回60
如果我有方法对象并使用此对象调用M,则相同.
var foo = {
x: 10,
add: function(x) {
this.x += x;
}
};
M(foo).add(10).add(20).add(30).x
Run Code Online (Sandbox Code Playgroud)
将返回70
函数包含在M对象中,因此方法内的this context始终是M对象.
f = M({x: 20}).set('getX', function() {
return this.x;
}).set('addX', function(x) {
this.x += x;
}).addX(10).getX
Run Code Online (Sandbox Code Playgroud)
所以f是由M包裹的对象的上下文的函数 - 如果我调用f()它将返回30.
我理解正确吗?M是monad吗?
编辑修改后的代码在github上https://github.com/jcubic/monadic
我需要使用拉格朗日插值多项式计算多项式的系数,作为我的作业,我决定在Javascript中执行此操作.
这里是拉格朗日多项式(L(x))的定义

拉格朗日基多项式定义如下

计算特定X(W(x)函数)的y值很简单,但我需要计算多项式的系数([a0,a1,...,an]的数组)我需要这样做n <= 10但它将有任意n很好,然后我可以将该函数放入horner函数并绘制该多项式.

我有在第一个等式中计算分母的函数
function denominator(i, points) {
var result = 1;
var x_i = points[i].x;
for (var j=points.length; j--;) {
if (i != j) {
result *= x_i - points[j].x;
}
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
和使用horner方法返回y的函数(我也有使用canvas的绘图功能)
function horner(array, x_scale, y_scale) {
function recur(x, i, array) {
if (i == 0) {
return x*array[0];
} else {
return array[i] + x*recur(x, --i, array);
}
}
return function(x) {
return recur(x*x_scale, array.length-1, array)*y_scale;
}; …Run Code Online (Sandbox Code Playgroud) 如何使Emacs缩进这样的情况
switch ($foo) {
case "foo":
$foo .= " bar";
break
case "bar":
$foo .= " baz";
break
default:
$foo .= " undefined";
}
Run Code Online (Sandbox Code Playgroud)
代替
switch ($foo) {
case "foo":
$foo .= " bar";
break
case "bar":
$foo .= " baz";
break
default:
$foo .= " undefined";
}
Run Code Online (Sandbox Code Playgroud) 我正在使用本教程构建ios工具链.当我运行命令make ENABLE_OPTIMIZED = 1时,我得到了这个输出.
llvm[0]: Reconfiguring with /home/connor/llvm-svn/configure
config.status: creating Makefile.config
config.status: creating llvm.spec
config.status: creating docs/doxygen.cfg
config.status: creating tools/llvm-config/llvm-config.in
config.status: creating include/llvm/Config/config.h
config.status: creating include/llvm/Support/DataTypes.h
config.status: include/llvm/Support/DataTypes.h is unchanged
config.status: creating include/llvm/ADT/hash_map
config.status: include/llvm/ADT/hash_map is unchanged
config.status: creating include/llvm/ADT/hash_set
config.status: include/llvm/ADT/hash_set is unchanged
config.status: creating include/llvm/ADT/iterator
config.status: include/llvm/ADT/iterator is unchanged
config.status: executing setup commands
config.status: executing Makefile commands
config.status: executing Makefile.common commands
config.status: executing examples/Makefile commands
config.status: executing lib/Makefile commands
config.status: executing runtime/Makefile commands
config.status: executing test/Makefile …Run Code Online (Sandbox Code Playgroud) 我有几个主要模式(比如:Yaml和NXML),我不想要电动缩进模式(我希望它用于C语言),但如果关闭我就无法转动.为了让我有:
(electric-indent-mode 1)
Run Code Online (Sandbox Code Playgroud)
来自文档(用于可变电动缩进模式)
如果启用电气缩进模式,则为非零.请参阅
electric-indent-mode' for a description of this minor mode. Setting this variable directly does not take effect; either customize it (see the info nodeEasy Customization 命令')或调用函数`electric-indent-mode'.
并为一个功能
切换动态重新注册(电动缩进模式).使用前缀参数ARG,如果ARG为正,则启用Electric Indent模式,否则禁用它.如果从Lisp调用,则在省略ARG或nil时启用该模式.
所以我试着把它关掉:
(add-hook 'yaml-mode-hook (lambda ()
(electric-indent-mode -1)))
Run Code Online (Sandbox Code Playgroud)
(Actualy我使用after-change-major-mode-hook并检查(memql major-mode '(yaml-mode python-mode nxml-mode))我可以在列表中添加更多模式的位置).
但它不起作用,我也尝试:
(set (make-local-variable 'electric-indent-mode) nil)
Run Code Online (Sandbox Code Playgroud)
没有快乐.但是当我(electric-indent-mode -1)从.emacs文件中评估它时它可以工作.