我有一个与上一个问题类似的问题(将数据添加到socket.io套接字对象)。我正在使用socket.io 1.3.4,并且想在连接时向套接字添加其他数据。Socket.io曾经有一个名为set的方法,允许这样做,但似乎可以更长久地工作。现在有新的方法吗?
我有以下流程:
1)在一页上我得到一个字段的值:
var myID;
cy.get('#MYID').
then(($txt) => {
myID= $txt.text();
})
.should('not.equal', null);
Run Code Online (Sandbox Code Playgroud)
2)然后我导航到一个新页面并尝试检查这个新页面是否包含此 id:
cy.get('#myTable').find('td').contains(myID);
Run Code Online (Sandbox Code Playgroud)
它说 myID 未定义。我知道第一个函数是异步的,并且阅读文档它说我可以使用别名。别名的问题是它需要位于 beforeEach() 函数中,这不会成为我无法在这个测试用例中使用的长篇故事。我尝试使用 async/await 但它似乎对我不起作用,因为它仍然未定义。
在我的应用程序内部,当我访问我的一个html页面时,我希望控制器内部的代码尽可能快地执行.问题是我收到了错误:
错误:无法在'CanvasRenderingContext2D'上执行'getImageData':源宽度为0.
控制器正在拍摄图像,然后对其应用滤镜,然后创建一个全新的图像.然后将这个全新的图像存储在变量中.当我单击其中一个按钮时,通过获取存储在变量中的图像并将其应用于$ scope.mainImage来应用适当的过滤器,然后angularjs接管其双向数据绑定并在屏幕上显示新的过滤图像.问题是当视图最初加载时出现原始图像(img/testing.jpg),但是错误在控制台中,并且创建了非图像.
控制器:
app.controller('PhotoController', function ($ionicPlatform, $scope, $state, $localstorage, $ionicHistory, $http, $cordovaCapture, $cordovaFile) {
$ionicPlatform.ready(function ($cordovaStatusbar) {
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
$scope.mainImage = 'img/testing.jpg';
/*
Alot more code here
*/
// =================================
// piece of code where the error is occurring:
filterImage: function(filter, args) {
console.log("Filter = " + filter);
if (this.pixelData) { // if multiple filters are applied
console.log("inside this.pixelData");
this.ctx.putImageData(this.pixelData, 0, 0);
}
// !!!!!!!!ERROR OCCUR HERE!!!!!!!!!!! var params = [this.ctx.getImageData(0, 0, this.c.width, this.c.height)]; …Run Code Online (Sandbox Code Playgroud) 我有两个离子滚动标签.这些离子滚动标签中的每一个都是一个列表.这些列表中的每一个都以10个项目开头,当用户到达特定离子滚动的底部时,它应该加载更多.我面临的问题是这种方法无法正常工作.如果我滚动浏览第一个滚动窗口并对所有项目进行分页,则应该说不再有内容.但这不会发生,相反,如果我滚动浏览第二个滚动窗口,那么它将在第一个和第二个离子滚动窗口(我不想要)中加载更多项目.基本上我希望两个离子卷轴完全相互独立.我希望每个人都加载它自己的内容.我希望这是有道理的.这是我的代码:
http://codepen.io/polska03/pen/jWKRwP
HTML:
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>Ionic Pull to Refresh</title>
<link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
<script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
</head>
<body ng-app="ionicApp" ng-controller="MyCtrl" class="background-places">
<ion-view>
<ion-content class="" scroll='false'>
<ion-scroll style="height:50%">
<ion-list>
<ion-item collection-repeat="list in _list">
<h2>Item</h2>
</ion-item>
</ion-list>
<button class="button button-full button-outline button-positive" ng-if="noMoreContent">
No more Content
</button>
<ion-infinite-scroll ng-if="canWeLoadMoreContent()" on-infinite="populateList()" distance="1%">
</ion-infinite-scroll>
</ion-scroll>
<hr>
<hr>
<ion-scroll style="height:50%">
<ion-list>
<ion-item collection-repeat="list2 in _list2">
<h2>Item</h2>
</ion-item>
</ion-list>
<button class="button button-full button-outline button-positive" ng-if="noMoreContent2">
No More Content
</button>
<ion-infinite-scroll …Run Code Online (Sandbox Code Playgroud) 我没有找到任何很好的例子来概述使用Java新的HTTP2支持.
在以前的Java(Java 8)版本中,我REST使用多个线程对服务器进行了多次调用.
我有一个全局参数列表,我会通过参数来做出不同类型的请求.
例如:
String[] params = {"param1","param2","param3" ..... "paramSomeBigNumber"};
for (int i = 0 ; i < params.length ; i++){
String targetURL= "http://ohellothere.notarealdomain.commmmm?a=" + params[i];
HttpURLConnection connection = null;
URL url = new URL(targetURL);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
//Send request
DataOutputStream wr = new DataOutputStream (
connection.getOutputStream());
wr.writeBytes(urlParameters);
wr.close();
//Get Response
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
//Do some stuff with this specific http response …Run Code Online (Sandbox Code Playgroud) 我有一个在文档中找不到的问题。如果我使用 beanstalk 创建一个 nodejs 应用程序并使用多核机器,beanstalk 会使用所有这些核心吗?由于 nodejs 是单线程应用程序,那么 beanstalk 会为每个 cpu 创建一个新的 nodejs 实例吗?这究竟是如何工作的?
干杯
我将使用SHA256签署令牌,我想知道应该输入的机密长度。如果我使用sha256,那么具有超过256位的密钥长度是否有任何好处?因此,如果我的密钥是300位长,这是否更安全?
我想在UTC时区获得时间.所以我写了代码:
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.Date;
public class RegularSandbox {
public static void main(String[] args) {
ZonedDateTime utc = ZonedDateTime.now(ZoneOffset.UTC);
System.out.println("DATETIME = " + Date.from(utc.toInstant()));
}
}
Run Code Online (Sandbox Code Playgroud)
问题是输出显示我在PST(我当地时区)的时间.我需要它以UTC输出时间,所以我可以将它存储在我的数据库中.
我有一个页面,它将http请求发送到同一位置,只是根据用户的需要使用不同的参数.所以我的代码看起来像这样:
this.http.post( //I am open to POST methods or GET methods as I have security in the back to prevent malicious writes.
'http://192.168.1.45:3000/mylocation',
'p1=' + param1 + '&p2=' + param2,
{headers: headers}
)
Run Code Online (Sandbox Code Playgroud)
例如,在JQuery中,您已经在框架中构建了一个缓存属性,该属性可以自动缓存并且非常容易实现:
$.ajax({
cache: true,
//other options...
});
Run Code Online (Sandbox Code Playgroud)
Angular2有类似的东西吗?只要用户在应用程序中,我想缓存这些动态响应.因此,如果用户使用相同的参数请求相同的url,那么它只是从缓存中获取它,如果从未使用过params,那么它将进行网络调用.
我在请求选项中的Angular2文档中找不到任何内容:
https://angular.io/docs/js/latest/api/http/RequestOptions-class.html
我有一个看起来像这样的表:
CREATE TABLE `articles`
(
`article_id` INT(10) NOT NULL auto_increment,
`pubsrc_id` INT(10) NOT NULL,
`pub_id` VARCHAR(16) NOT NULL
PRIMARY KEY (`article_id`),
UNIQUE KEY `pubsrc_id` (`pubsrc_id`,`pub_id`),
CONSTRAINT `pub_articles_ibfk_1` FOREIGN KEY (`pubsrc_id`) REFERENCES `pub_sources` (`pubsrc_id`) ON
DELETE RESTRICT
ON
UPDATE RESTRICT,
CONSTRAINT `pub_articles_ibfk_2` FOREIGN KEY (`pubsrc_id`) REFERENCES `pub_sources` (`pubsrc_id`)
)
Run Code Online (Sandbox Code Playgroud)
还有另一个表,前一个表有一个键:
CREATE TABLE `pub_sources`
(
`pubsrc_id` INT(11) NOT NULL,
`pubsrc_name` VARCHAR(32) NOT NULL
PRIMARY KEY (`pubsrc_id`)
)
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用以下命令删除foregin 键:
SET SESSION SQL_SAFE_UPDATES = 0;
SET FOREIGN_KEY_CHECKS = 0;
ALTER TABLE `articles` DROP …Run Code Online (Sandbox Code Playgroud) javascript ×4
angularjs ×2
java ×2
node.js ×2
angular ×1
asynchronous ×1
caching ×1
cryptography ×1
cypress ×1
datetime ×1
foreign-keys ×1
hash ×1
http ×1
http2 ×1
java-11 ×1
java-8 ×1
jwt ×1
mysql ×1
pagination ×1
socket.io ×1
typescript ×1