问题列表 - 第279849页

Elixir 案例说明

我写了一个声明如下:

case length(clicks) do
      0 ->
        date_list = []
      1 ->
        date_list = start_date
      _ ->
        date_list = Interval.new(from: start_date, until: end_date) |> Enum.to_list
    end
Run Code Online (Sandbox Code Playgroud)

似乎date_list从未设置过。我究竟做错了什么?

elixir

1
推荐指数
1
解决办法
645
查看次数

Nginx将CSS文件加载为文本/纯文本

我将nginx配置为仅加载静态文件,但我不知道为什么.css文件被解释为文本/纯文本-最终浏览器无法加载它。

Resource interpreted as Stylesheet but transferred with MIME type text/plain: "http://localhost:13000/styles.css".
Run Code Online (Sandbox Code Playgroud)

当我在CSS文件的Web浏览器中检查响应标头时:

Content-Type: text/plain
Run Code Online (Sandbox Code Playgroud)

我知道在堆栈上我们有很多问题,我已经读过它们,但仍然无法正常工作。

在html文件中,我刚刚导入了CSS:

<link href="styles.css" rel="stylesheet" type="text/css"/>
Run Code Online (Sandbox Code Playgroud)

我的/etc/nginx/nginx.conf是:

worker_processes        1;
events {
    worker_connections  512;
}

http {
    server {
        listen       80;
        server_name  0.0.0.0:80;
        include /etc/nginx/mime.types;
        root   /project/app;

        location ~* ^.+\.(js|css)$ {
            expires 10d;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我尝试了没有任何位置部分或尝试:

location ~ \.css {
 add_header Content-Type text/css;
}
Run Code Online (Sandbox Code Playgroud)

在其他线程的一些响应中,我看到这是必需的:

default_type  application/octet-stream;
include       /etc/nginx/mime.types;
Run Code Online (Sandbox Code Playgroud)

我添加了http一部分,server然后再添加到中location,仍然没有帮助。

还有什么我可以解决的吗?

css mime nginx

1
推荐指数
1
解决办法
1898
查看次数

ValueError:使用 Stomp 时信号仅在主线程中起作用

当我运行此代码时,我收到此错误:

ValueError: signal only works in main thread
Run Code Online (Sandbox Code Playgroud)

我正在使用 ActiveMQ。

RealTor 是我的 Spider(selogerSpider) 的名称,它可以帮助我进行抓取。

ValueError: signal only works in main thread
Run Code Online (Sandbox Code Playgroud)

python stomp web-scraping

10
推荐指数
1
解决办法
5万
查看次数

如何为 API Gateway Websocket 编写 Java Lambda 处理程序?

我很难弄清楚如何编写处理 Websocket 消息的 Java Lambda 函数,其中 Websocket 由 2018 年底刚刚发布的新 API 网关函数处理。具体问题: * 我应该使用什么类型对于输入对象?我目前正在使用 APIGatewayProxyRequestEvent。是否有特定于 Websocket 请求的类型?我在 aws-lambda-java-events-2.2.5.jar 中没有看到一个。* 如果我使用了正确的类型,我该如何访问连接 ID?我是否需要使用 API 映射?我看到了这个链接,但它实际上并没有告诉您如何为 Websockets 进行映射,对于这类事情,Websockets 似乎与 REST API 有不同的选项。https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-mapping-template-reference.html

提前致谢!

公共类 WebsocketHandler 实现 RequestHandler {

@Override
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) {
    context.getLogger().log("Input: " + input);
    context.getLogger().log("Context:  " + context);

    ProxyRequestContext requestContext = input.getRequestContext();
    context.getLogger().log("requestContext:  " + requestContext);

    // I don't see Connection ID in any of these

    APIGatewayProxyResponseEvent response = new APIGatewayProxyResponseEvent();
    response.setStatusCode(200);
    response.setBody("All good here.");
    return …
Run Code Online (Sandbox Code Playgroud)

aws-lambda aws-api-gateway

5
推荐指数
1
解决办法
2063
查看次数

WatchKey始终为null

我尝试查看某些文件以进行更改.但WatchKey我得到watch_object.watch_service.poll(16, TimeUnit.MILLISECONDS);的总是null.没有一个错误打印到控制台,所以我有点迷路.

public class FileWatcher implements Runnable {

    public FileWatcher() {
    }

    static public class Watch_Object {
        public File file;
        public WatchService watch_service;
    }

    static public HashMap<Object, Watch_Object> watched_files = new HashMap<>();

    static public boolean is_running = false;


    static public synchronized void watch(Object obj, String filename) {

        File file = new File(filename);

        if (file.exists()) {

            try {

                WatchService watcher = null;
                watcher = FileSystems.getDefault().newWatchService();

                Watch_Object watch_object = new Watch_Object();
                watch_object.file = file;
                watch_object.watch_service = …
Run Code Online (Sandbox Code Playgroud)

java watch

2
推荐指数
1
解决办法
299
查看次数

如何使用Javascript更新占位符颜色?

我在网上搜索,但没有找到任何东西.我正在尝试使用javascript更新文本框的占位符颜色,但我该怎么做?我有一个颜色选择器,颜色正在改变.

如果我在CSS中有这样的东西,我该如何更新它?

::placeholder {
  color: red;
}
Run Code Online (Sandbox Code Playgroud)
<input placeholder="placeholder" />
Run Code Online (Sandbox Code Playgroud)

是否有javascript命令来编辑它?就像是

document.getElementById('text').style.placeholderColor = newColor;
Run Code Online (Sandbox Code Playgroud)

html javascript css pseudo-element

21
推荐指数
2
解决办法
947
查看次数

无法使用 sed 命令编辑 pdf 文件

我有一本 PDF 格式的书,但我无法使用sed. 我无法真正使用 LibreOffice 来编辑它,因为它是一个 300 页的文档,其中包含大量图像,而且我的电脑在打开过程中会崩溃。我所需要做的就是仅在一个位置更改一两个字符(例如,将“+2”更改为“+3”,其中“+2”在整本书中仅出现一次),因此解决方案应该是基本的。

我解压缩它,然后尝试在其上使用 sed,sed没有改变任何内容,尽管echo $?会返回0.

pdftk file.pdf output uncompressed_file.pdf uncompress
sed -i 's/foo/bar/g' uncompressed_file.pdf
pdftk uncompressed_file.pdf output corrected_file.pdf compress
Run Code Online (Sandbox Code Playgroud)

这段代码与另一个文件一起工作,我怀疑某些 PDF 文件阻止编辑,我正在寻找一种方法来绕过它。

pdf bash sed

3
推荐指数
1
解决办法
2221
查看次数

列出元素的计数器

这里是Python的新手。

我正在寻找一种创建列表(输出)的简单方法,该方法在保留索引(?)的同时返回另一个目标列表(MyList)的元素计数。

这就是我想要得到的:

MyList = ["a", "b", "c", "c", "a", "c"]
Output = [ 2 ,  1 ,  3 ,  3 ,  2 ,  3 ]
Run Code Online (Sandbox Code Playgroud)

我找到了解决类似问题的方法。计算列表中每个元素的出现次数。

In  : Counter(MyList)
Out : Counter({'a': 2, 'b': 1, 'c': 3})
Run Code Online (Sandbox Code Playgroud)

但是,这将返回一个不保留索引的Counter对象。

我假设给定了计数器中的键,我可以构造所需的输出,但是我不确定如何进行操作。

额外的信息,我在脚本中导入了熊猫,而MyList实际上是熊猫数据框中的一列。

python counter list python-3.x pandas

9
推荐指数
3
解决办法
150
查看次数

传输或处理此请求时出错。错误代码 = 10,路径 = /wardeninit

我正在尝试将对象(工作表行的内容)传递给应用程序脚本模板。您可以在屏幕截图中看到该行。

在此处输入图片说明

我在应用程序脚本中的函数包含:

var sendableRows = rows.filter(function (row) { //ONLY CHECKED ROWS.
  return row['Index'] == true;
});  
var sendableRow = sendableRows[0];
Logger.log('sendableRow '+ JSON.stringify( sendableRow));

var html = HtmlService.createTemplateFromFile('RowPopup');
html.row = JSON.stringify(sendableRow);
var h =html.evaluate();

SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
  .showModalDialog(h, 'Create Documents');
Run Code Online (Sandbox Code Playgroud)

记录器语句产生:

 sendableRow {"Index":true,"Timestamp":"2019-02-12T21:09:14.000Z","FROM":222222,"CONVERSATION":"THIS IS A TEST","ME":"","relativeRow":14,"absoluteRow":15}
Run Code Online (Sandbox Code Playgroud)

我的 Rowpopup.html 是:

<!DOCTYPE html>
<html>
<head>
  <base target="_top">
  <script>
    // Prevent forms from submitting.
    function preventFormSubmit() {
      var forms = document.querySelectorAll('forms');
      for (var i = 0; i < forms.length; i++) …
Run Code Online (Sandbox Code Playgroud)

html web-applications google-sheets google-apps-script

8
推荐指数
2
解决办法
4392
查看次数

如何为 docker 容器设置 udp 缓冲区大小?

我想为 docker 容器设置 UDP 缓冲区大小。虽然 UDP 缓冲区大小是与内核相关的设置,它对应于主机的设置,但我看到了,我没有看到我的主机设置的缓冲区大小影响我的容器。

这是我尝试过的:

在主机上

sysctl -w net.core.rmem_default = 4194304
sysctl -w net.core.rmem_max = 4194304
Run Code Online (Sandbox Code Playgroud)

并验证(在主机上

sysctl net.core.rmem_default
net.core.rmem_default = 4194304

sysctl net.core.rmem_max
net.core.rmem_max = 4194304
Run Code Online (Sandbox Code Playgroud)

但是,当我在容器中运行时(比如高山)。

docker run -it alpine
Run Code Online (Sandbox Code Playgroud)

在高山灰烬中

sysctl net.core.rmem_default
sysctl: error: 'net.core.rmem_default' is an unknown key
Run Code Online (Sandbox Code Playgroud)

同样是与本案rmem_max也。

然而,令我惊讶的是,我看到

sysctl net.core.rmem_default
net.core.somaxconn = 128
Run Code Online (Sandbox Code Playgroud)

我可以使用--sysctl参数在 docker 容器上设置上述内容。

docker run -it --sysctl net.core.somaxconn=125 alpine
/ # sysctl net.core.somaxconn
net.core.somaxconn = 125
Run Code Online (Sandbox Code Playgroud)

但是,我需要的是rmem_defaultrmem_max尺寸。

如果此选项未通过 …

linux-kernel docker

9
推荐指数
1
解决办法
3047
查看次数