小编Bob*_*ijt的帖子

如果提交格式不正确,是否可以拒绝 Github 上的提交?

正如这个答案中提到的,可以在 Github 提交中引用一个问题。

是否可以拒绝提交不是这样格式化的?

示例:
fix gh-12 foo bar正确
foo bar就会错误

更新:

快到了,这仍然不起作用......有什么想法吗?

我现在有以下内容: .git/hooks/commit-msg

#!/bin/bash
commit_regex='(gh-[0-9]+|merge)'

error_msg="Aborting commit. Your commit message is missing either a Github Issue ('gh-1111') or 'Merge'."

if ! grep -E "$commit_regex" <<< "$0"; then
    echo "$error_msg" >&2
    exit 1
fi
Run Code Online (Sandbox Code Playgroud)

git github webhooks

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

如何检查DOM元素和/或属性是否有效?

我有一系列元素:
var elements = ['div', 'a', 'p', 'foo']

我也有一系列属性:
var attributes = ['src', 'href', 'quux', 'id']

我想了解如何验证以上各项的组合是否可以构成有效的DOM对象。
或者,换句话说:
如何针对DOM模式验证DOM对象?*

例如(基于上述元素和属性):

DOM_result = '<div src />';  // = false
DOM_result = '<div href />'; // = false
DOM_result = '<div quux />'; // = false
DOM_result = '<div id />';   // = true
DOM_result = '<a src />';    // = false
DOM_result = '<a href />';   // = true
DOM_result = '<a quux />';   // = false
DOM_result = '<a …
Run Code Online (Sandbox Code Playgroud)

html javascript dom

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

如何使用PHP-FPM和Nginx Docker容器解析未知的PHP-FPM主脚本?

我的情况是这样的,我有两个Docker容器:

  1. 在端口9000上运行PHP-FPM
  2. 运行nginx并拥有PHP文件(PHP-FPM容器是否可以访问这些文件?)

我一直收到以下错误:

FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.17.0.1, ser
ver: _, request: "GET / HTTP/1.1", upstream: "fastcgi://172.17.0.2:9000", host: "172.17.0.3"
Run Code Online (Sandbox Code Playgroud)

在这里读到,这"总是与SCRIPT_FILENAMEnginx fastcgi_param指令中的错误设置有关."

问题是,我不知道如何解决它:-P

容器2中的配置:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    charset UTF-8;
    root /var/www/WordPress;

    index index.php index.html index.htm;
    server_name _;
    location / {
        try_files $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_index index.php;
        fastcgi_pass 172.17.0.2:9000;
        include fastcgi_params;
        fastcgi_param …
Run Code Online (Sandbox Code Playgroud)

php nginx docker

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

如何在 Go 中迭代 []interface{}

我正在努力获取以下接口的键和值,这是 JSON 编组返回的结果的结果,Execute本例所示

[
    [
        {
            "id": 36,
            "label": "TestThing",
            "properties": {
                "schema__testBoolean": [
                    {
                        "id": 40,
                        "value": true
                    }
                ],
                "schema__testInt": [
                    {
                        "id": 39,
                        "value": 1
                    }
                ],
                "schema__testNumber": [
                    {
                        "id": 38,
                        "value": 1.0879834
                    }
                ],
                "schema__testString": [
                    {
                        "id": 37,
                        "value": "foobar"
                    }
                ],
                "uuid": [
                    {
                        "id": 41,
                        "value": "7f14bf92-341f-408b-be00-5a0a430852ee"
                    }
                ]
            },
            "type": "vertex"
        }
    ]
]
Run Code Online (Sandbox Code Playgroud)

Areflect.TypeOf(result)结果为:[]interface{}

我用它来循环数组:

s := reflect.ValueOf(result)
for i …
Run Code Online (Sandbox Code Playgroud)

interface go type-assertion

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

在Nginx中使用HHVM fastcgi处理fastcgi_param

通过fastcgi进入Nginx的HHVM不支持fastcgi_param是否正确?如果是这样,如何解决?

喜欢:

location ~ .php$ { ## Execute PHP scripts
    if (!-e $request_filename) { rewrite / /index.php last; }
    expires        off;
    fastcgi_pass   127.0.0.1:9999; <- my hhvm is set to port 9999 io 9000
    fastcgi_param  PHP_VALUE "error_log=/var/report/PHP.error.log";
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  MAGE_RUN_CODE admin;
    fastcgi_param  MAGE_RUN_TYPE store;
    include        fastcgi_params;
}
Run Code Online (Sandbox Code Playgroud)

fastcgi nginx hhvm

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

如何在 Golang 中运行数据存储区 GQL 查询?

我在 GQL 中有以下查询:

"SELECT * FROM Task WHERE Uuid = \"FOOBAR\" ORDER BY CreateTimeMs DESC LIMIT 1"

如何在 Golang 中直接运行此查询?

query := datastore.NewQuery("SELECT * FROM Task WHERE Uuid = \"FOOBAR\" ORDER BY CreateTimeMs DESC LIMIT 1")似乎是不正确的。

更新:
我非常了解查询类型。问题是我想直接使用 GQL,而不是将它们转换为查询类型。

gql go google-cloud-datastore

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

如何在 Gremlin 中使用 UUID 作为 id?

我正在添加这样的顶点:

g.addV("foobar").property("id", 1).property(...etc...

如何使用 uuid 而不是整数 id 设置属性?

gremlin tinkerpop gremlin-server

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

HHNVM与Nginx fastcgi无法正常工作

我想通过Nginx使用HHVM.(Ubuntu 12.04.2 LTS,PHP 5.3.10)

我按照这里提到的步骤进行了访问:http:
//www.hhvm.com/blog/1817/fastercgi-with-hhvm

这就是我的Nginx设置的外观:

server {
        listen  80;
        server_name demo1.dev
        server_name_in_redirect off;
        root /var/www/demo1;
        location / {
                index index.php;
                try_files $uri $uri/ @handler;
                expires 30d;
        }
        location @handler {
                rewrite / /index.php;
        }
        location ~ .php$ {
                fastcgi_keep_conn on;
                if (!-e $request_filename) { rewrite / /index.php last; }
                expires        off;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_param PHP_VALUE "error_log=/var/report/PHP.error.log";
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
        }
        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires 1y;
                log_not_found off;
        }
}
Run Code Online (Sandbox Code Playgroud)

我有一个名为hhvm.php的文件,其中包含:

function is_hhvm() { …
Run Code Online (Sandbox Code Playgroud)

fastcgi nginx hhvm

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

如何在Go中通过反射获取地图界面的值?

我正在努力获取Go中接口映射的价值。

val := reflect.ValueOf(Schema)
fmt.Println("VALUE = ", val)
fmt.Println("KIND = ", val.Kind())
if val.Kind() == reflect.Map {
    fmt.Println("len = ", val.Len())
    for key, element := range val.MapKeys() {
        fmt.Println(key, element) // how to get the value?
    }
}
Run Code Online (Sandbox Code Playgroud)

输出:

VALUE =  map[testString:foobar testInt:1 testBoolean:true testNumber:1 testDateTime:2017-10-06 08:15:30 +0100 +0100]
KIND =  map
len =  5
0 testString
1 testInt
2 testBoolean
3 testNumber
4 testDateTime
Run Code Online (Sandbox Code Playgroud)

我的问题
如何获取地图项的类型和值?

go

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

如何在受训模型上对Tensorflow进行简单预测?

我刚训练过这样的模型:

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    num_examples = len(X_train)

    print("W00T IT IS TRAINING ")
    print()
    for i in range(EPOCHS):
        X_train, y_train = shuffle(X_train, y_train)
        for offset in range(0, num_examples, BATCH_SIZE):
            end = offset + BATCH_SIZE
            batch_x, batch_y = X_train[offset:end], y_train[offset:end]
            sess.run(training_operation, feed_dict={x: batch_x, y: batch_y})

        validation_accuracy = evaluate(X_validation, y_validation)
        print("EPOCH {} ...".format(i+1))
        print("Validation Accuracy = {:.3f}".format(validation_accuracy))
        print()

saver.save(sess, 'LeNet')
print("Model saved")
Run Code Online (Sandbox Code Playgroud)

现在我加载了这样的图像: img1 = img.imread('./images_32x32/test_1.png')

现在我唯一想做的就是做一个基于的预测img1.

我该怎么做呢?

UPDATE

添加了我的softmax功能:

logits = LeNet(x)
cross_entropy = tf.nn.softmax_cross_entropy_with_logits(logits, one_hot_y)
loss_operation = …
Run Code Online (Sandbox Code Playgroud)

python tensorflow

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