我正在使用"chai": "^4.2.0"
和"mocha": "^6.1.4",
。
当assert.equal()
用于比较两个日期时,即使这两个日期似乎相同,我也会出错:
这是我的示例测试:
it('check if dates are correctly added', async () => {
let dataArr = [{'rating_date':'6/6/2019','impact_on_price':'Low'}]
let priceServ = new PriceService()
// clear all records
priceServ.clearPriceTable()
// add 1 record
const res = await priceServ.createOrUpdatePrice(dataArr)
// get "all" records from the table that have a certain action attribute
const tableValues = await priceServ.getPricesByField('rating_date')
assert.equal(tableValues[0].rating_date, new Date(dataArr[0].rating_date));
Run Code Online (Sandbox Code Playgroud)
});
任何建议我做错了什么?
我感谢您的回复!
我在casperjs中创建了一个应用程序,它可以从网站上删除运动数据.
我想在heroku上按照cronjob运行此应用程序,以将运动结果保存在csv,数据库或外部google文档中(尚未确定).
但是,在我开始为heroku实现它之前,我有一个问题:
heroku
,其声称,它可以运行casperjs
scirpts.但是,我是否需要nodejs
运行预定的脚本?或者我可以在heroku上创建一个cronjob吗?我非常感谢你的回复!
有没有一种方法可以在不启动节点服务器的情况下逐步调试单个javascript文件?
例如knex的种子文件。
绝对需要节点,但是我不知道如何仅使用文件启动VSC调试器。
我已经Ubuntu 18.04.3 LTS
在我的虚拟机上安装了:
我还通过以下方式创建了一个 ssh 隧道来连接到我的远程数据库:
admin@admin-VirtualBox:~$ ssh -v -v -v root@xx.xx.xxx.xxx -CNL 13306:localhost:3306
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "xx.xx.xxx.xxx" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to xx.xx.xxx.xxx [xx.xx.xxx.xxx] port 22.
debug1: Connection established.
debug1: identity file /home/admin/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /home/admin/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or …
Run Code Online (Sandbox Code Playgroud) 我创建了以下图像作为fabricjs-json:
json 如下所示:
{
"version": "5.2.1",
"objects": [
{
"type": "circle",
"version": "5.2.1",
"originX": "center",
"originY": "center",
"left": "100",
"top": "100",
"width": "60",
"height": "60",
"fill": "#e53e3e",
"name": "a",
"radius": "30",
"stroke": null,
"padding": "0"
},
{
"type": "triangle",
"version": "5.2.1",
"originX": "center",
"originY": "center",
"left": "80",
"top": "229.13",
"fill": "#e0da2e",
"name": "b",
"height": "100",
"width": "100",
"stroke": null,
"padding": "0"
},
{
"type": "rect",
"version": "5.2.1",
"originX": "center",
"originY": "center",
"left": "303.02",
"top": "69.96",
"width": "50",
"height": "50",
"fill": …
Run Code Online (Sandbox Code Playgroud) 我创建了一个名为的视图signIn.gsp
.我把它放进了URLMapping.groovy
:
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?(.${format})?"{
constraints {
// apply constraints here
}
}
"/"(view:"/index")
"signIn"(view:'/signIn')
"500"(view:'/error')
}
}
Run Code Online (Sandbox Code Playgroud)
我还将它添加到弹簧安全部分Config.groovy
:
// Added by the Spring Security Core plugin:
grails.plugin.springsecurity.userLookup.userDomainClassName = 'com.testApplication.secureApplication.Person'
grails.plugin.springsecurity.userLookup.authorityJoinClassName = 'com.testApplication.secureApplication.PersonRole'
grails.plugin.springsecurity.authority.className = 'com.testApplication.secureApplication.Role'
grails.plugin.springsecurity.controllerAnnotations.staticRules = [
'/': ['permitAll'],
'/index': ['permitAll'],
'/signIn': ['permitAll'],
'/index.gsp': ['permitAll'],
'/**/js/**': ['permitAll'],
'/**/css/**': ['permitAll'],
'/**/images/**': ['permitAll'],
'/**/favicon.ico': ['permitAll']
]
Run Code Online (Sandbox Code Playgroud)
但是,在运行我的应用程序时,我得到:
|Running Grails application
Configuring Spring Security Core ...
... finished configuring Spring Security …
Run Code Online (Sandbox Code Playgroud) 我有一个围绕3000
元素长的向量。我用 提取了向量中的特定点which(...)
。现在我想拥有-120 before
这一点和+120 after
这一点。
我的清单是这样的:
> testList$Date
[1] "01.01.2002" "02.01.2002" "03.01.2002" "04.01.2002" "07.01.2002"
[6] "08.01.2002" "09.01.2002" "10.01.2002" "11.01.2002" "14.01.2002"
[11] "15.01.2002" "16.01.2002" "17.01.2002" "18.01.2002" "21.01.2002"
[16] "22.01.2002" "23.01.2002" "24.01.2002" "25.01.2002" "28.01.2002"
[21] "29.01.2002" "30.01.2002" "31.01.2002" "01.02.2002" "04.02.2002"
[26] "05.02.2002" "06.02.2002" "07.02.2002" "08.02.2002" "11.02.2002"
[31] "12.02.2002" "13.02.2002" "14.02.2002" "15.02.2002" "18.02.2002"ect....
Run Code Online (Sandbox Code Playgroud)
我可以做一个for-loop
迭代列表并将其保存为子列表。但是,我认为这不是很有效。我如何在 R 中实现它?
我很感激你的回答!
更新
使用时lapply
我得到:
> 120BeforeSublist <- lapply(event, function(x) c(x-120, x))
> (120BeforeSublist)
[[1]]
[1] 1875 1995 …
Run Code Online (Sandbox Code Playgroud) 我想将String数组与具有市场对象的列表进行比较.
我实现了这样的代码:
private List<Data> addMarketData(List<Data> list) {
String[] SEE = new String[]{"Albania", "Bosnia and Herzegovina", "Bulgaria", "Croatia", "Macedonia FYR", "Moldavia", "Montenegro", "Romania", "Serbia", "Slovenia" };
List<String> seeList = Arrays.asList(SEE);
String[] CEE = new String[]{"Czech Republic", "Hungary", "Poland", "Slovakia"};
List<String> ceeList = Arrays.asList(CEE);
for (int i = 0; i < list.size(); i++) {
for (int j = 0; j < seeList.size(); j++) {
if(list.get(i).getPropertyCountry().equals(seeList.get(j).toString())) {
list.get(i).setMarket("SEE");
}
}
for (int k = 0; k < ceeList.size(); k++) {
if(list.get(i).getPropertyCountry().equals(ceeList.get(k).toString())) {
list.get(i).setMarket("CEE"); …
Run Code Online (Sandbox Code Playgroud) 我有一个包含大约30个importxml
函数的大表,它们从一个通常每天更新两次的网站获取数据.
我想importxml
及时(每8小时)为我的Google电子表格运行该功能,以便将数据保存在另一张表格中.保存已经有效,但更新不行!
我在Google Spreadsheet行更新中读到它可能每2小时运行一次,但我不相信这是真的,因为我将其添加到我的工作表中没有更改或更新,当电子表格未打开时.
我如何importxml
以简单的方式"触发" 我的Google电子表格中的功能,因为我有很多importxml
功能?
我想在外部标签上附加/预先添加一个空格。
我尝试了以下方法:
var $elem = $('<span>', {
'data-function': "addSynonym",
'data-options': '[ test1, test2, test3]',
'html': $('<span>', {
'text': 'test4',
'css': {
backgroundColor: 'yellow'
}
})
});
$elem.append(" ")
$elem.prepend(" ");
console.log($elem[0]);
console.log($elem[0].innerHTML);
Run Code Online (Sandbox Code Playgroud)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
如您所见,只有内部标签有空格。
但是,我想将它放在外标签上。像下面这样:
<span data-function="addSynonym" data-options="[ test1, test2, test3]"><span style="background-color: yellow;">test4</span></span>
Run Code Online (Sandbox Code Playgroud)
任何建议如何做到这一点?
我感谢您的回复!
javascript ×4
node.js ×3
algorithm ×1
casperjs ×1
chai ×1
fabricjs ×1
grails ×1
grails-2.0 ×1
heroku ×1
java ×1
jquery ×1
mocha.js ×1
mysql ×1
node-canvas ×1
phantomjs ×1
php ×1
r ×1
ssh ×1
statistics ×1