我有一个app.js,用于在收到一些POST数据时触发两个事件:
这是app.js(只有重要的行)
var express = require('express');
var bodyParser = require('body-parser');
var server = require('./server');
var app = express();
var port = process.env.PORT || 3000;
app.post('/server', server);
app.listen(port, function(){
console.log('Slack bot listening');
});
Run Code Online (Sandbox Code Playgroud)
这里是server.js(只有重要的行)
var db = require('./DB');
var WebSocketServer = require('ws').Server;
var insertData = function(req, res){
var wss = new WebSocketServer({server: server});
console.log('WebSocketServer created');
wss.on('connection', function(wss){
wss.send(JSON.stringify('Socket open'));
});
wss.on('close', function(){
console.log('WebServerSocket has been closed');
});
};
module.exports = insertData;
Run Code Online (Sandbox Code Playgroud)
我想要实现的是设置WebSocketServer以便它监听应用程序的同一端口.我想过将服务器 var从app.js …
我必须对数据集进行统计分析.我想创建所有可能的模型并使用挖泥功能测试它们但它不起作用.的确,当我输入:
glm1<-glm(presabs~dca1+dca2+se1+se2, family=binomial(logit))
dredge(glm1)
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误:
Erreur in dredge(glm1) :
'global.model''s 'na.action' argument is not set and options('na.action') is "na.omit"
Run Code Online (Sandbox Code Playgroud)
有人能帮我吗?
我正在尝试编辑以下 YAML 文件
db:
host: 'x.x.x.x.x'
main:
password: 'password_main'
admin:
password: 'password_admin'
Run Code Online (Sandbox Code Playgroud)
为了编辑该host部分,我开始使用它
sed -i "/^\([[:space:]]*host: \).*/s//\1'$DNS_ENDPOINT'/" config.yml
Run Code Online (Sandbox Code Playgroud)
但是我找不到更新main和admin(它们是不同的值)的密码的方法。
我试图玩弄\n和[[:space:]],得到了不同的口味:
sed -i "/^\([[:space:]]*main:\n*[[:space:]]*password: \).*/s//\1'$DNS_ENDPOINT'/" config.yml
Run Code Online (Sandbox Code Playgroud)
但从来没有让它工作。非常感谢任何帮助!
编辑- 要求:没有外部二进制文件/工具。只是好 ol' bash。
我有一个在每行显示ListViewa checkbox.
每次checkbox触摸时,我都会检查它是否被检查过.
但每次,第一个项目总是返回false.但是,如果选中第2项,.ischecked()则第一项的复选框的方法总是返回true.
这是我的代码:
public class CustomSpecificCar extends ArrayAdapter<JSONObject>{
ListSpecificCars caller;
private JSONObject currentJson;
private CheckBox cbSelectedCar;
private int position;
public CustomSpecificCar(Context ctxt, List<JSONObject> list, ListSpecificCars caller){
super(ctxt, R.layout.custom_specific_car_row, list);
this.caller = caller;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(getContext());
View customView = inflater.inflate(R.layout.custom_specific_car_row, parent, false);
this.position = position;
// Set the reference of the layout
currentJson = …Run Code Online (Sandbox Code Playgroud) 我目前有以下 Promql 查询,它允许我查询每个 K8S pod 使用的内存:
sum(container_memory_working_set_bytes{image!="",name=~"^k8s_.*"}) by (pod_name)
Pod 的名称后跟由 K8S 定义的哈希:
weave-net-kxpxc
weave-net-jjkki
weave-net-asdkk
Run Code Online (Sandbox Code Playgroud)
哪些都属于同一个应用程序: weave-net
我想要的是聚合属于同一个应用程序的所有 pod 的内存。
因此,查询会将所有weave-netPod的内存相加,并将结果放在名为weave. 比如结果是:
{pod_name="weave-net"} 10
Run Code Online (Sandbox Code Playgroud)
代替
{pod_name="weave-net-kxpxc"} 5
{pod_name="weave-net-jjkki"} 3
{pod_name="weave-net-asdkk"} 2
Run Code Online (Sandbox Code Playgroud)
甚至有可能这样做,如果是,如何?
我想知道我们是否可以选择配置docker-compose忽略其中一个容器的错误并继续启动其他容器。
例如,这是我的 docker-compose.yml
version: '3'
services:
web:
build: .
redis:
image: redis
Run Code Online (Sandbox Code Playgroud)
如果redis容器启动失败,web容器仍然启动。
我有一个 Dataframe ( data),其头部如下所示:
status datetime country amount city
601766 received 1.453916e+09 France 4.5 Paris
669244 received 1.454109e+09 Italy 6.9 Naples
Run Code Online (Sandbox Code Playgroud)
我想预测status给定的datetime, country, amount和city
由于status, country, city是字符串,我对它们进行了单热编码:
one_hot = pd.get_dummies(data['country'])
data = data.drop(item, axis=1) # Drop the column as it is now one_hot_encoded
data = data.join(one_hot)
Run Code Online (Sandbox Code Playgroud)
然后我创建一个简单的 LinearRegression 模型并拟合我的数据:
y_data = data['status']
classifier = LinearRegression(n_jobs = -1)
X_train, X_test, y_train, y_test = train_test_split(data, y_data, test_size=0.2)
columns = X_train.columns.tolist()
classifier.fit(X_train[columns], y_train)
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
无法将字符串转换为浮点数:'收到' …
我正在尝试查询 ElasticSearch 以获得两个时间戳之间的结果。一个典型的记录看起来像
{
"_index": "cost-2018.08.09",
"_type": "log",
"_id": "asdasdasxsa-sdsds",
"_score": 4.281278,
"_source": {
"index": "cost-2018.08.09",
"app_group": "shop",
"timestamp": "2018-08-09T00:00:04.349692"
}
}
Run Code Online (Sandbox Code Playgroud)
我用来shop从app_group2 个时间戳中检索每一个的查询:
GET /cost-2018.08.09/_search?q=app_group:shop
{
"query": {
"range": {
"timestamp": {
"gte": "2018-08-09 04:00:04",
"lt": "2018-08-09 04:30:06"
}
}
}
Run Code Online (Sandbox Code Playgroud)
只返回 every shop,但不检查 any timestamp。奇怪的是,即使我故意在查询中包含错误:
GET /cost-2018.08.09/_search?q=app_group:shop
{
"query": {
"range": {
"timestamp": {
"gte": "2018-08-asdadsx09 04:00:04",
"lt": "2018-08-09asdasd 04:30:06"
}
}
}
Run Code Online (Sandbox Code Playgroud)
我得到了完全相同的答案。就像它没有考虑query到。
一些注意事项:在 Python 中,我的代码如下所示:
result = es_client.search(index='cost-2018.07.26', …Run Code Online (Sandbox Code Playgroud) 我有一个python脚本,它将执行一些操作,并根据结果,将退出代码0(可以)或1(不好).
我想捕获这个结果,将其存储到变量中并通过UDP发送.这不能在python脚本(要求)内完成.
所以让我们说我的脚本是这样的:
import sys
# Do some stuff
sys.exit(0) # or sys.exit(1)
Run Code Online (Sandbox Code Playgroud)
我和谁一起跑python script.py.
如何获取此退出状态代码(0或1).
我试着回声$errorlevel,但它只打印一个空行.也尝试使用exit(0)而不是sys.exit()(参见此处)和其他一些不成功的尝试.
我尝试在bash中的dot(.)之前减去第一个字符串.
例如:
1.2.3 -> 1
11.4.1 -> 11
Run Code Online (Sandbox Code Playgroud)
我根据文档使用了以下命令:
s=4.5.0
echo "${s%.*}"
Run Code Online (Sandbox Code Playgroud)
但它4.5取而代之的是ouptuts 4.我不明白.
这是为什么?
python ×3
bash ×2
android ×1
awk ×1
checkbox ×1
docker ×1
exit ×1
java ×1
javascript ×1
node.js ×1
pandas ×1
prometheus ×1
promql ×1
r ×1
regression ×1
sed ×1
shell ×1
statistics ×1
websocket ×1
yaml ×1