我有这个玉文件:
!!! 5
html
head
title test include
style(type='text/css')
//- DOES NOT WORK!
include test.css
body
//- works
include test.css
div
//- works
include test.css
Run Code Online (Sandbox Code Playgroud)
输出:
$ jade -P test.jade
rendered test.html
$ cat test.html
<!DOCTYPE html>
<html>
<head>
<title>test include</title>
<style type="text/css">
//- DOES NOT WORK!
include test.css
</style>
</head>
<body>body { color: peachpuff; }
<div> body { color: peachpuff; }
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当然,我可以简单地链接css文件,但我不想.
在页面上附加25个圆圈后,我运行以下功能:
var transitionPage = function () {
startThePage();
var height = $(document).height() - 20
, width = $(document).width()
;
d3.selectAll("circle")
.transition().duration(2500)
.style("fill", "steelblue")
.attr("r", 15)
.transition().duration(1000)
.attr("cy", (height / 2))
.each(function (d, i) {
d3.select(this)
.transition().duration(1000)
.attr("cx", 30 + (i * width / 25));
});
}
Run Code Online (Sandbox Code Playgroud)
这很好,并且正确地沿着页面中间水平排列它们.
但是,我无法弄清楚如何将每个圆变换为正方形或矩形.
我该如何处理这个问题?
我们来看看Java中的以下简单代码片段.
interface Sum
{
abstract public void showSum();
}
interface Mul
{
abstract public void showMul();
}
abstract class Super implements Sum
{
protected int x;
protected int y;
public Super(int x, int y)
{
this.x=x;
this.y=y;
}
//No error, though the method showSum() of the implementing iterface Sum is commented. Why?
/*public void showSum()
{
System.out.println("Sum = "+(x+y));
}*/
}
final class Calculation extends Super implements Mul
{
public Calculation(int x, int y)
{
super(x,y);
}
public void showSum() …Run Code Online (Sandbox Code Playgroud) 在官方的mongoose网站上,我发现如何通过数组中的_id删除嵌入式文档:
post.comments.id(my_id).remove();
post.save(function (err) {
// embedded comment with id `my_id` removed!
});
Run Code Online (Sandbox Code Playgroud)
我很感兴趣如何更新而不是删除这个?
我正在研究这个过滤的东西,我有大约50-100个列表项.每个项目都有这样的标记:
<li>
<input type="checkbox" name="services[]" value="service_id" />
<span class="name">Restaurant in NY</span>
<span class="filters"><!-- hidden area -->
<span class="city">@city: new york</span>
<span class="region">@reg: ny</span>
<span class="date">@start: 02/05/2012</span>
<span class="price">@price: 100</span>
</span>
</li>
Run Code Online (Sandbox Code Playgroud)
我创建了这样的标记因为我最初使用了List.js
所以,可能你已经猜到了,我想要的是做这样的搜索:@region: LA @price: 124等等.问题是我还想显示多个项目,以便选择超过......一个:)
我认为这需要模糊搜索,但问题是我找不到任何功能.
任何想法或起点?
//编辑:因为我有相当少量的项目,我想要一个客户端解决方案.
假设我的grunt配置中有一个变量,数组作为值.一个真实世界的例子grunt.regarde.changed来自grunt-regarde插件,它列出了所有已更改的文件.
我想使用模板解析该数组,以便我可以(在这种情况下)复制更改的文件:
copy: {
staticWeb: {
src: '<%= grunt.regarde.changed %>',
dest: 'someDir'
},
Run Code Online (Sandbox Code Playgroud)
什么src得到在这种情况下是一个单一的逗号分隔的字符串,而不是一个数组.Grunt的文件处理器不解析字符串,因此无法找到src文件.
我无法删除模板周围的单引号,因为它是无效的javascript.
那么如何将该grunt.regarde.changed数组传递给src变量呢?
我有一个MongoDB数据存储区,其中存储的位置数据如下:
{
"_id" : ObjectId("51d3e161ce87bb000792dc8d"),
"datetime_recorded" : ISODate("2013-07-03T05:35:13Z"),
"loc" : {
"coordinates" : [
0.297716,
18.050614
],
"type" : "Point"
},
"vid" : "11111-22222-33333-44444"
}
Run Code Online (Sandbox Code Playgroud)
我希望能够执行类似于日期范围示例的查询,而不是在时间范围内.即检索在上午12点到下午4点之间记录的所有点(也可以在1200和1600小时时间内完成).
例如
有分:
"datetime_recorded" : ISODate("2013-05-01T12:35:13Z"),"datetime_recorded" : ISODate("2013-06-20T05:35:13Z"),"datetime_recorded" : ISODate("2013-01-17T07:35:13Z"),"datetime_recorded" : ISODate("2013-04-03T15:35:13Z"),一个问题
db.points.find({'datetime_recorded': {
$gte: Date(1200 hours),
$lt: Date(1600 hours)}
});
Run Code Online (Sandbox Code Playgroud)
只会产生第一点和最后一点.
这可能吗?或者我每天都必须这样做?
我一直在试图弄清楚这种递归方法的堆栈是什么样的.
public class Apples {
public static void main (String [] args) {
q1(5);
}
public static int q1 (int x) {
if (x < 1) {
System.out.println(x);
return 1;
}
int a = 3 + q1(x / 2);
int b = 2 * q1(x - 2) + 1;
System.out.println(x + ";" + a + ";" + b);
return a + b;
}
}
Run Code Online (Sandbox Code Playgroud)
但到目前为止,我只认为堆栈按x/2增长:
x=0 returns 1;
x=1 a=4 b=3 returns 7;
x=2 a=10 b=3 returns 13;
x=5 a=16 …Run Code Online (Sandbox Code Playgroud) 我在业余时间开始学习PHP,我给出的第一个代码示例如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<?php
echo "Hello World";
?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
据我所知,这应该写出"Hello World".但是,我看到的只是一个空白的网页.任何想法为什么这样,我应该如何解决它?
我想将用户从一个页面重定向到Node.js中的另一个页面(plain node.js)
现实生活场景:注册成功后(example.com/sigup),注册成功后我想将用户重定向到登录页面(example.com/login).
if (signUpSuccessful(request, response)) {
// I want to redirect to "/login" using request / response parameters.
}
Run Code Online (Sandbox Code Playgroud)