小编PHA*_*PHA的帖子

phantomjs是否会定期自动清除缓存?

如果有这样的功能,我需要更改Phantomjs的自动缓存清除的默认时间.任何的想法?

browser-cache phantomjs

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

youtube数据api完全免费

我将实现一个python客户端,使用不同的查询在youtube上搜索视频.显然我应该使用youtube数据api.即使我读取quata成本,我只想确保使用youtube api是完全免费的.对不起,这太基础了.

youtube-api youtube-data-api

11
推荐指数
2
解决办法
9649
查看次数

使用uinput模拟Linux中的绝对鼠标移动

我正试图用绝对坐标移动光标.这是代码:

#include <stdio.h>                                                              
#include <stdlib.h>                                                             
#include <string.h>                                                             
#include <unistd.h>                                                             
#include <fcntl.h>                                                              
#include <errno.h>                                                              
#include <linux/input.h>                                                        
#include <linux/uinput.h>                                                       
#include <signal.h>                                                             

#define die(str, args...) do { \                                                
        perror(str); \                                                          
        exit(EXIT_FAILURE); \                                                   
    } while(0)                                                                  

    int                    fd;                                                  

static void signal_handler(int signo)                                           
{                                                                               
    printf("\nCaught SIGINT\n");                                                
        if(ioctl(fd, UI_DEV_DESTROY) < 0)                                       
           die("error: cannot destroy uinput device\n");                        
    else printf("Destroyed uinput_user_dev\n\n");                               
    close(fd);                                                                  
    exit(EXIT_SUCCESS);                                                         
}                                                                               

int                                                                             
main(void)                                                                      
{                                                                               

    struct uinput_user_dev uidev;                                               
    struct input_event     ev;                                                  
    int                    x, y;                                                
    int                    i;                                                   

    if(signal(SIGINT,signal_handler)==SIG_ERR)                                  
    {                                                                           
    printf("error registering signal handler\n");                               
    exit(EXIT_FAILURE);                                                         

    }                                                                           

    fd = open("/dev/uinput", …
Run Code Online (Sandbox Code Playgroud)

linux mouse linux-device-driver

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

停止gitlab runner以不删除目录

我有一个在构建期间生成的目录,不应该在下一个版本中删除它.我试图在.gitlab-ci.yml中使用缓存保留目录:

cache:
  key: "$CI_BUILD_REF_NAME"
  untracked: true
  paths:
    - target_directory/
build-runner1:
  stage: build
  script:
    - ./build-platform.sh target_directory
Run Code Online (Sandbox Code Playgroud)

在第一个构建中,生成了cache.zip但是对于下一个构建,删除了target_directory并且提取了cache.zip,这需要很长时间.这是第二个构建的日志:

Running with gitlab-ci-multi-runner 1.11.
  on Runner1
Using Shell executor...
Running on Runner1...
Fetching changes...
Removing target_directory/
HEAD is now at xxxxx Update .gitlab-ci.yml
From xxxx
Checking out xxx as master...
Skipping Git submodules setup
Checking cache for master...
Successfully extracted cache
Run Code Online (Sandbox Code Playgroud)

有没有办法让gitlab runner首先删除目录?

gitlab gitlab-ci gitlab-ci-runner

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

在块中迭代一个hashmap'

我需要遍历一个包含5000个项目的hashmap,但是在迭代了第500个项目之后我需要进行一次睡眠然后继续下一个500项目.这是从这里偷来的例子.任何帮助将不胜感激.

import java.util.HashMap;
import java.util.Map;

public class HashMapExample {

    public static void main(String[] args) {
        Map vehicles = new HashMap();

        // Add some vehicles.
        vehicles.put("BMW", 5);
        vehicles.put("Mercedes", 3);
        vehicles.put("Audi", 4);
        vehicles.put("Ford", 10);
        // add total of 5000 vehicles 

        System.out.println("Total vehicles: " + vehicles.size());

        // Iterate over all vehicles, using the keySet method.
        // here are would like to do a sleep iterating through 500 keys
        for(String key: vehicles.keySet())
            System.out.println(key + " - " + vehicles.get(key));
        System.out.println();

        String searchKey …
Run Code Online (Sandbox Code Playgroud)

java

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

向多个收件人发送 smtp 电子邮件

我用这个来发送smtp. 它适用于一个接收器,但我想要多个接收器。我尝试了以下方法:

func sendemail(body string) {  
    from := "smtpemail" 
    pass := "pass"
    to := "a@gmail.com,b@gmail.com"
    ....
}
Run Code Online (Sandbox Code Playgroud)

我也试过:

to := "\"a@gmail.com\",\"b@gmail.com\""
Run Code Online (Sandbox Code Playgroud)

和:

to := []string{"a@gmail.com","b@gmail.com"}
Run Code Online (Sandbox Code Playgroud)

他们都没有工作。对不起,它太简单了,我才开始使用golang.

go

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

我该如何决定何时使用原始指针更合适?

我得到的印象是,Rust旨在用于高度安全的系统.然后我注意到原始指针允许任意指针算术,它们可能导致内存安全和安全问题.

pointers rust raw-pointer

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

在qml中的qtcharts上拖动一个点

我正在尝试在 qtcharts 上拖动 LineSeries 上的一个点。这是我的代码:

import QtQuick 2.0
import QtCharts 2.0

Item {
    anchors.fill: parent

    ChartView {
        title: "Two Series, Common Axes"
        anchors.fill: parent

        ValueAxis {
            id: axisX
            min: 0
            max: 10
            tickCount: 5
        }

        ValueAxis {
            id: axisY
            min: -0.5
            max: 1.5
        }

        LineSeries {
            id: series1
            axisX: axisX
            axisY: axisY
            onPressed: console.log("Pressed: " + point.x + ", " + point.y);   
            onReleased: console.log("Released: " + point.x + ", " + point.y);
        }


    }
    // Add data dynamically to the …
Run Code Online (Sandbox Code Playgroud)

qt qml qt5 qtcharts

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

如何检查socketcan中的总线状态

我在嵌入式 Linux 上使用Flexcan 驱动程序,并且有C程序控制 CAN 消息。在我的C程序中,我需要检查 can 总线的状态,例如buss-offerror-active。我可以使用 linux 命令, ip -details -statistics link show can0结果如下:

2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
    link/can  promiscuity 0 
    can state *ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 100 
          bitrate 250000 sample-point 0.866 
          tq 266 prop-seg 6 phase-seg1 6 phase-seg2 2 sjw 1
          flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1 …
Run Code Online (Sandbox Code Playgroud)

can-bus embedded-linux socketcan

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

每个start_url已经删除了多少项

我使用scrapy爬行1000个网址并将刮下的物品存放在一个mongodb中.我想知道每个网址找到了多少项.从scrapy stats我可以看到'item_scraped_count': 3500 但是,我需要分别为每个start_url计算这个数.还有referer对于我可能会使用手动计算每个网址项目的每个项目领域:

2016-05-24 15:15:10 [scrapy] DEBUG: Crawled (200) <GET https://www.youtube.com/watch?v=6w-_ucPV674> (referer: https://www.youtube.com/results?q=billys&sp=EgQIAhAB)
Run Code Online (Sandbox Code Playgroud)

但我想知道是否有来自scrapy的内置支持.

python scrapy scrapy-spider

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