我有一位教授随机更新他的网站,明天就要完成作业,似乎希望我们每小时检查一次.
这听起来像是一个程序的工作.
他的网站很简单,完全是HTML,甚至没有任何javascript.我怎么能以编程方式检测到他网站的任何更改/更新?
提供以下代码段
function countZeroes(array) {
function counter(total, element) {
return total + (element === 0 ? 1 : 0);
}
return reduce(counter, 0, array);
}
Run Code Online (Sandbox Code Playgroud)
reduce内置功能吗?它有什么作用?我正在使用jQuery UI Sortable功能.
$('#sortablelist).sortable{
update: function(ev, ui){...},
placeholder: "ui-state-highlight",
connectWith: ".ui-sortable"
}
Run Code Online (Sandbox Code Playgroud)
默认情况下,dropOnEmpty = true我没有设置它.
因为列表是空的,但是我想在空列表中给它一个"占位符"目标,我给了sortablelistdiv一个额外的帮助类来给空的#sortablelist一些"表面区域"可以这么说(所以在附加列表上拖动元素时获得占位符)
<div id="sortablelist" class="ui-sortable ui-sortable-helper"></div>
Run Code Online (Sandbox Code Playgroud)
.ui-sortable-helpclass {
height: 100px;
width: 100%;
}
Run Code Online (Sandbox Code Playgroud)
这适用于Firefox,IE,Safari,但占位符不会出现(因此无法在Google Chrome中使用
有什么想法吗?
我有一些基本上看起来像这样的LessCSS:
.foo {
@height: 20px;
@iconHeight: 13px;
background-position: 0 (@height - @iconHeight) / 2;
}
Run Code Online (Sandbox Code Playgroud)
然而,这显然是background-position: 0 3.5px,并且我更喜欢它是一个整数(值Math.ceil),但是这不起作用:
background-position: 0 Math.ceil((@height - @iconHeight) / 2)
Run Code Online (Sandbox Code Playgroud)
也没有使用javascript评估运算符:
background-position: 0 `Math.ceil((@height - @iconHeight) / 2)`
Run Code Online (Sandbox Code Playgroud)
...因为这被解析为Math.ceil(20px - 13px)和"px"存在语法错误.
我甚至尝试过使用过 parseInt
0 `Math.ceil((parseInt('@{height}', 10) - parseInt('@{iconHeight}', 10)) / 2)`px
Run Code Online (Sandbox Code Playgroud)
然而,结果如下:
background-position: 0 4 px
Run Code Online (Sandbox Code Playgroud)
......这是不对的.最后,即使在JS评估中添加"px"也行不通
background-position: 0 `Math.ceil(....) + "px"`;
// becomes
background-position: 0 "4px";
Run Code Online (Sandbox Code Playgroud)
当然有更好的方法!
我正在使用CompoundPropertyModel(通过PropertyListView)来打印对象(User)的属性.
User对象的一个属性是布尔值.我希望使用自定义转换来呈现布尔值(false - >"disabled",true - >"enabled").
如何在不向User对象添加新方法的情况下实现此目的?
add(new PropertyListView<User>("users", new LoadableUsersModel()) {
@Override
protected void populateItem(ListItem<User> item) {
item.add(new Label("firstname"));
item.add(new Label("surname"));
item.add(new Label("username"));
item.add(new Label("email"));
item.add(new Label("active"));
}
});
Run Code Online (Sandbox Code Playgroud) 我几乎不好意思问,但是当我git diff在特定文件上运行时,它只显示前26行左右的变化.
是否有一个页面向下命令将显示其余的更改?
我正在查看另一个stackoverflow问题,我尝试了以下内容:
d3.selectAll(links.filter(function(db) {
return db.source.id == 'foo'
})).each(function(p) {
console.log (p.source.id)
})
Run Code Online (Sandbox Code Playgroud)
并发现它返回了一个
TypeError:无法读取未定义的属性"source"
即使过滤后的选择返回为具有.source.id值的对象的正确数组(此示例使用D3的强制定向网络中的标准链接符号).
我只是好奇为什么这不起作用.
我跑的时候
rails server
Run Code Online (Sandbox Code Playgroud)
我收到了错误.
加载gemsets有一些问题
$rvm list
rvm rubies
ruby-1.9.3-p484 [ i686 ]
ruby-2.0.0-p353 [ i686 ]
=* ruby-2.1.0 [ i686 ]
# => - current
# =* - current && default
# * - default
$ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [i686-linux]
$rails -v
Your Ruby version is 1.9.3, but your Gemfile specified 2.1.0
$bundle show rails
/home/prasad/.rvm/gems/ruby-2.1.0/gems/rails-4.0.1
$bundle exec rails s
Your Ruby version is 1.9.3, but your Gemfile specified 2.1.0
bundle exec ruby -v
ruby 2.1.0p0 …Run Code Online (Sandbox Code Playgroud) 我正在研究在Ruby中解析JSON.有人可以让我知道如何采取response.body并发布在字符串内.
是否有任何宝石可通过解析对此信息进行排序?
require 'net/http'
require 'json'
uri = URI('https://api.wmata.com/StationPrediction.svc/json/GetPrediction/all')
uri.query = URI.encode_www_form({
# Specify your subscription key
'api_key' => '#',
})
request = Net::HTTP::Get.new(uri.request_uri)
# Basic Authorization Sample
# request.basic_auth 'username', 'password'
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request(request)
@data = response
end
Run Code Online (Sandbox Code Playgroud) 我的表结构如下所示:
tbl.users tbl.issues
+--------+-----------+ +---------+------------+-----------+
| userid | real_name | | issueid | assignedid | creatorid |
+--------+-----------+ +---------+------------+-----------+
| 1 | test_1 | | 1 | 1 | 1 |
| 2 | test_2 | | 2 | 1 | 2 |
+--------+-----------+ +---------+------------+-----------+
Run Code Online (Sandbox Code Playgroud)
基本上我想编写一个查询,它将在结果表中结束,如下所示:
(results table)
+---------+------------+---------------+-----------+--------------+
| issueid | assignedid | assigned_name | creatorid | creator_name |
+---------+------------+---------------+-----------+--------------+
| 1 | 1 | test_1 | 1 | test_1 |
| 2 | 1 | test_1 | 2 …Run Code Online (Sandbox Code Playgroud)