这有效:
# echo 1 and exit:
$ docker run -i -t image /bin/bash -c "echo 1"
1
# exit
# echo 1 and return shell in docker container:
$ docker run -i -t image /bin/bash -c "echo 1; /bin/bash"
1
root@4c064f2554de:/#
Run Code Online (Sandbox Code Playgroud)
问题:我如何将source文件放入shell?(这不起作用)
$ docker run -i -t image /bin/bash -c "source <(curl -Ls git.io/apeepg) && /bin/bash"
# content from http://git.io/apeepg is sourced and shell is returned
root@4c064f2554de:/#
Run Code Online (Sandbox Code Playgroud) 我的数据集(ds1)如下所示:
2014_01_01_tableA
2014_01_01_tableB
2014_01_02_tableA
2014_01_02_tableB
Run Code Online (Sandbox Code Playgroud)
查询:
SELECT date, COUNT(1) AS counter
FROM [ds1.2014_01_01_tableA], [ds1.2014_01_01_tableB], [ds1.2014_01_02_tableA], [ds1.2014_01_02_tableB]
GROUP BY date;
Run Code Online (Sandbox Code Playgroud)
返回:
date, counter
2014-01-01, 100
2014-01-02, 200
Run Code Online (Sandbox Code Playgroud)
是否有可能按表名分组?这样的事可能吗?...
SELECT date, COUNT(1) AS counter, TABLE_NAME() AS table_name
FROM [ds1.2014_01_01_tableA], [ds1.2014_01_01_tableB], [ds1.2014_01_02_tableA], [ds1.2014_01_02_tableB]
GROUP BY table_name, date;
Run Code Online (Sandbox Code Playgroud)
预期结果:
date, counter, table_name
2014-01-01, 50, 2014_01_01_tableA
2014-01-01, 50, 2014_01_01_tableB
2014-01-02, 100, 2014_01_02_tableA
2014-01-02, 100, 2014_01_02_tableB
Run Code Online (Sandbox Code Playgroud)
TABLE_NAME() AS table_name 不幸的是,不存在.
我在Google Compute Engine(GCE)上运行多个CoreOS实例.CoreOS使用systemd的日志记录功能.如何将所有日志推送到远程目标?据我所知,systemd日志没有远程日志记录功能.我目前的解决方案看起来像这样:
journalctl -o short -f | ncat <addr> <ip>
Run Code Online (Sandbox Code Playgroud)
使用https://logentries.com 通过TCP使用基于令牌的输入:
journalctl -o short -f | awk '{ print "<token>", $0; fflush(); }' | ncat data.logentries.com 10000
Run Code Online (Sandbox Code Playgroud)
还有更好的方法吗?
编辑: https ://medium.com/coreos-linux-for-massive-server-deployments/defb984185c5
如何为没有x-goog-meta-前缀的Cloud CDN发送带有后端的自定义HTTP标头?
特别是,我正在尝试发送一个Content-Security-Policy标题,它会变成x-goog-meta-Content-Security-Policy浏览器而被忽略.
屏幕截图:Google Storage/Bucket Meta数据用户界面
屏幕截图:响应标头
google-cloud-storage content-security-policy google-cloud-platform google-cloud-cdn
如何从蜘蛛回调中收集统计数据?
例
class MySpider(Spider):
name = "myspider"
start_urls = ["http://example.com"]
def parse(self, response):
stats.set_value('foo', 'bar')
Run Code Online (Sandbox Code Playgroud)
不知道一般import会stats提供什么或如何提供.
以下示例似乎有效,但使用安全吗?我的目标是做一些非常简单的后台处理(而实际的任务队列工作感觉太重).
func MyHandler(w http.ResponseWriter, r *http.Request) {
go func() {
// do something ...
}()
return // 200
}
Run Code Online (Sandbox Code Playgroud) 假设我有一个 Go 中的常规 HTTP 服务器。如何获取当前空闲和活动的 TCP 连接?
httpServer := &http.Server{
Handler: newHandler123(),
}
l, err := net.Listen("tcp", ":8080")
if err != nil {
log.Fatal(err)
}
err = httpServer.Serve(l)
if err != nil {
log.Fatal(err)
}
Run Code Online (Sandbox Code Playgroud) 我如何通过名字获得任务?
from google.appengine.api import taskqueue
taskqueue.add(name='foobar', url='/some-handler', params={'foo': 'bar'}
task_queue = taskqueue.Queue('default')
task_queue.delete_tasks_by_name('foobar') # would work
# looking for a method like this:
foobar_task = task_queue.get_task_by_name('foobar')
Run Code Online (Sandbox Code Playgroud)
应该可以使用REST API(https://developers.google.com/appengine/docs/python/taskqueue/rest/tasks/get).但我更喜欢类似的东西task_queue.get_task_by_name('foobar').有任何想法吗?我错过了什么?
问题:
与 ProxyPassMatch 一起使用时,%0 不会被服务器名称(即 test.local)替换。
<VirtualHost *:80>
UseCanonicalName Off
# %0 is replaced by server name (works)
VirtualDocumentRoot /Users/mattes/sites/%0
# %0 is replaced by an empty string (problem!)
ProxyPassMatch ^(/.*\.php)$ fcgi://127.0.0.1:9000/Users/mattes/sites/%0/$1
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
解决办法:
我在这里找到了一篇有趣的博客文章:http : //holtstrom.com/michael/blog/post/225/Apache-2.2-Proxy.html。基本上,Michael 使用 RewriteEngine 来保存变量以供以后使用。像这样的事情会起作用,例如:
<VirtualHost *:80>
UseCanonicalName Off
VirtualDocumentRoot /Users/mattes/sites/%0
RewriteEngine On
RewriteRule .* - [E=SERVER_NAME:%{SERVER_NAME}]
ProxyPassInterpolateEnv On
ProxyPassMatch ^(/.*\.php)$ fcgi://127.0.0.1:9000/Users/mattes/sites/ \
${SERVER_NAME}$1 interpolate
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
虽然它有效,但我认为这是一个不太好的解决方法。我还收到诸如“AH00111:未定义配置变量 ${SERVER_NAME}”之类的错误。
有没有人知道如何解决这个问题?
如何更改 php-fpm.conf(或 php.ini),以便将所有错误/警告/...写入标准错误(或替代标准输出)?
我跑php5-fpm带daemonize = no,并希望看到我的终端的所有错误。