小编Eht*_*ury的帖子

如何向tmux中的所有窗格发送命令?

我喜欢:clear-history用巨大的回滚来调用窗格.但是,我想编写一种方法来将此命令发送到各种窗口中的所有窗格.

我知道如何向所有窗口发送命令,这个问题是礼貌的,但是如何向所有窗口发送命令呢?

send-keyssynchronize-panes从TMUX手册页浮现在脑海中,但我不知道如何将它们一起结婚.但也许有一种更简单的方法可以做到这一点.

额外观察:

稍微考虑一下,tmux list-panes -a似乎列出了当前会话中的所有窗格.一开始非常有用.我从哪里开始?

tmux

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

将地图jj映射到inputrc中的Esc(readline)

我如何映射jjEscinputrc,以便使用GNU Readline(python,mongoshell,...)获取应用程序

所有在zsh上工作正常使用:

bindkey -M viins 'jj' vi-cmd-mode
Run Code Online (Sandbox Code Playgroud)

这是我目前的inputrc:

set editing-mode vi
set keymap vi

# turn off the stupid bell
set bell-style none
$if mode=vi
    set keymap vi-command
    "gg": beginning-of-history
    "G": end-of-history
    #"jj": vi-movement-mode
    set keymap vi-insert
    "\C-w": backward-kill-word
    "\C-p": history-search-backward
$endif
Run Code Online (Sandbox Code Playgroud)

vi vim bash zsh readline

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

如何临时重定向 Python 中的日志输出?

已经有一个问题可以回答如何在此处sys.stdoutsys.stderr此处执行此操作: /sf/answers/993795561/

但这并不适用于所有地方。日志模块似乎输出到sys.stdoutsys.stderr,但我无法使用上面的上下文管理器捕获它。

在下面的示例代码中,我试图捕获上下文管理器内的所有输出,但未能为 logger 语句执行此操作:

from __future__ import print_function
import contextlib
import sys
import logging
from StringIO import StringIO

# taken from /sf/answers/993795561/
@contextlib.contextmanager
def stdout_redirect(where):
    prev_stdout = sys.stdout
    prev_stderr = sys.stderr
    prev_stdout.flush()
    sys.stdout = where
    sys.stderr = where
    try:
        yield where
    finally:
        where.flush()
        sys.stdout = prev_stdout
        sys.stderr = prev_stderr

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger()

print("\t\tOUTSIDE: stdout", file=sys.stdout)
print("\t\tOUTSIDE: stderr", file=sys.stderr)
logger.info("\tOUTSIDE: info")
logger.debug("\tOUTSIDE: debug")
logger.warn("\tOUTSIDE: warn")
logger.error("\tOUTSIDE: error")
logger.critical("\tOUTSIDE: critical")

print("=============== …
Run Code Online (Sandbox Code Playgroud)

python logging python-2.7

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

Azure Functions - Application Insights - 自定义遥测 - EventSource 实例已存在

我正在尝试按照Insights Preview中的说明进行操作,我可以在其中创建自定义遥测。我完全按照说明操作。但也许我把它配置错了。

APPINSIGHTS_INSTRUMENTATIONKEYlocal.settings.json文件中设置了它,它似乎工作正常。但是当我添加一个新的时,TelemetryClient我开始收到那些重复的错误(如下)。它发生在函数被调用时。

我真的希望来自 AF 的遥测数据转到相同的 AI 仪器键,以便我可以一起查看。

我也退出了Microsoft.Extensions.Logging,因为我只想使用 AI,如果这有什么不同的话。

有人有什么建议吗?

见下文...

TIA

ERROR: Exception in Command Processing for EventSource Microsoft-ApplicationInsights-Core: An instance of EventSource with Guid 74af9f20-af6a-5582-9382-f21f674fb271 already exists.
ERROR: Exception in Command Processing for EventSource Microsoft-ApplicationInsights-Core: An instance of EventSource with Guid 74af9f20-af6a-5582-9382-f21f674fb271 already exists.
Microsoft.WindowsAzure.ServiceRuntime Critical: 102 : Unexpcted Exception During Runtime Startup:
System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> <CrtImplementationDetails>.ModuleLoadException: The C++ module …
Run Code Online (Sandbox Code Playgroud)

azure azure-application-insights azure-functions

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

在 Pyspark 中压平 Json

my_data=[
    {'stationCode': 'NB001',
       'summaries': [{'period': {'year': 2017}, 'rainfall': 449},
        {'period': {'year': 2018}, 'rainfall': 352.4},
        {'period': {'year': 2019}, 'rainfall': 253.2},
        {'period': {'year': 2020}, 'rainfall': 283},
        {'period': {'year': 2021}, 'rainfall': 104.2}]},
    {'stationCode': 'NA003',
       'summaries': [{'period': {'year': 2019}, 'rainfall': 58.2},
        {'period': {'year': 2020}, 'rainfall': 628.2},
        {'period': {'year': 2021}, 'rainfall': 120}]}]
Run Code Online (Sandbox Code Playgroud)

在 Pandas 中我可以:

import pandas as pd
from pandas import json_normalize
pd.concat([json_normalize(entry, 'summaries', 'stationCode') 
                     for entry in my_data])
Run Code Online (Sandbox Code Playgroud)

这会给我下表:

    rainfall  period.year stationCode
0     449.0         2017       NB001
1     352.4         2018       NB001
2     253.2         2019 …
Run Code Online (Sandbox Code Playgroud)

json python-3.x pyspark databricks

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

sprintf到std :: string直接?

我感兴趣(出于各种原因)格式使用sprintf将结果放在一个std::string对象中.我提出的语法最直接的方法是:

char* buf;
sprintf(buf, ...);
std::string s(buf);
Run Code Online (Sandbox Code Playgroud)

还有其他想法吗?

c++ performance printf stdstring

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

在 Python 中计算时间跨度

我在 Windows 64 位上使用 Python v2.x

我想实时记录两个时刻并计算时间跨度。请看以下代码:

current_time1 = datetime.datetime.now().time() # first moment

# ... some statement...some loops...take some time...

current_time2 = datetime.datetime.now().time() # second moment

time_span = current_time1 - current_time2
Run Code Online (Sandbox Code Playgroud)

显然最后一行是不可执行的,因为 current_time 不是整数,所以我的问题是,如何将此语句转换为整数来进行数学运算?转换为秒是我的第一个想法......

python datetime

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