当我开始时tmux,我的~/.config/fish/config.fish似乎又来源了。这意味着set PATH foo $PATH我的任何语句config都会再次执行,这会导致我的 PATH 变量中有重复的条目。这并不激烈,但对 ECHO 路径来说很烦人。当它这么长
我怎样才能防止这个问题?
编辑:我的 tmux 文件中唯一与鱼相关的内容是
#fix vim
set -g default-shell $SHELL
set -g default-command "reattach-to-user-namespace -l ${SHELL}"
set -g default-command 'reattach-to-user-namespace $SHELL --login'
昨天我学到了非常宝贵的一课:遵循三条法则.
我想我会更容易学习它,但错误只出现在删除声明中.这是场景:
foo.h
class foo{
public:
...
foo(int *Y);
~foo();
int *X;
}
foo.cpp
...
(.. constructor sets X to Y..)
foo:~foo(){
delete [] X;
}
main.cpp
vector<Foo> fooVec;
{ // this is just to demonstrate scope problems more easily.
Y = new int[10000];
(...init Y...)
fooVec.push(Foo(Y)) // I get it: this calls copy constructor, violating rule of three
(...forget to delete Y...)
}
// Y is now out of scope so this is a memory leak
cout << fooVec[0].[X][0] …Run Code Online (Sandbox Code Playgroud) 在python2.7中,下面的代码获取字典fd(在此示例中表示单词及其计数的频率分布),并将其分为两个列表的列表:[[keys],[values]]:
sortedDKandVs = [zip(*sorted(fd.items(), key=itemgetter(1), reverse=True))] #[word,word,...],[count,count]
Run Code Online (Sandbox Code Playgroud)
我可以做,例如:
keys = sortedDKandVs[0]
values = sortedDKandVs[1]
Run Code Online (Sandbox Code Playgroud)
这不再适用于Python3,我想知道如何转换代码.
这里没有答案如何将元组列表解压缩到单个列表中?因为在Python3中,zip对象返回迭代器而不是列表,但是我不知道如何转换答案.
我试图了解什么是Python名称绑定,以及何时解释此绑定.
在c中,
include <stdio.h>
int main()
{
int X = 42;
int* Y[1];
Y[0] = &X;
X = 666;
printf("%d", *Y[0]);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
打印666.我期待Python代码块:
X = 42
L = []
L.append(X) #3
X = 666
print(L) #5
Run Code Online (Sandbox Code Playgroud)
做同样的事情,但事实并非如此.标记为3和5的行之间到底发生了什么?#3是否对另一个称为"42"的对象进行引用,就像X一样,让它称之为X',并将X'存储在L指向的对象中,即[]?
例如,httpc库(http://erlang.org/doc/man/httpc.html#request-4)定义了一些类型:
status_line() = {http_version(), status_code(), reason_phrase()}
http_version() = string(), for example, "HTTP/1.1"
status_code() = integer()
reason_phrase() = string()
content_type() = string()
headers() = [header()]
header() = {field(), value()}
Run Code Online (Sandbox Code Playgroud)
在我的代码,我想编写一个函数,例如,消耗一个结果,产生别的东西.然而,rebar3 dialyzer抱怨:
===> Verifying dependencies...
===> Compiling xxx
===> Compiling src/httpabs.erl failed
src/httpabs.erl:35: type headers() undefined
src/httpabs.erl:35: type status_code() undefined
src/httpabs.erl:35: type status_line() undefined
Run Code Online (Sandbox Code Playgroud)
那么如何导入这些类型声明以便我可以重用它们呢?
我~/.config/fish/config.fish变得巨大.
编写另一个文件并从此文件中"源"它的惯用方法是什么,所以我的主配置不是那么大?
我可以制作一个~/.config/fish/config-work.fish并添加source ~/.config/fish/config-work.fish到我的主配置中吗?
Flask 有一个返回文件的方法:http : //flask.pocoo.org/docs/1.0/api/#flask.send_file
有一个参数被调用as_attachment,默认值为 False,并且有一个关于它的手动声明:“为了额外的安全性,您可能希望将某些文件作为附件发送(例如 HTML)”
我怎么知道我的用例是否是“那些特定的文件”?或者换句话说,这与将其保留为 False 相比有何作用?
为什么我不能创建临时表然后立即加入它?
\n\nmysql> CREATE TEMPORARY TABLE table2 as (select in_reply_to_id, COUNT(in_reply_to_id) as C from mentions where in_reply_to_id>0 group by in_reply_to_id);\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n\n\n\n查询正常,57149 行受影响(0.14 秒)\n 记录:57149 重复:0 警告:0
\n
mysql> select T.tweet_id, T.favorite_count, T.retweet_count, T2.C from \n-> tweets AS T JOIN table2\xc2\xa0AS T2 \n-> on T.tweet_id = T2.in_reply_to_id;\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n\n\n\n错误 1146 (42S02): 表 'twitter_analysis.table2\xc2\xa0as' 不存在\n mysql>
\n
但它确实存在,因为我可以从中选择!
\n\nselect count(*) from table2;\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n57149 1 行一组(0.01 秒)
\n …
我的行为模块中有以下停止功能:
start(_StartType, _StartArgs) ->
...
stop(_State) ->
lager:info("Stop recieved."),
erlang:display("Stop recieved."),
ok.
Run Code Online (Sandbox Code Playgroud)
我的应用程序主管看起来像:
-behaviour(supervisor).
%% API
-export([start_link/0]).
%% Supervisor callbacks
-export([init/1]).
-define(SERVER, ?MODULE).
%%====================================================================
%% API functions
%%====================================================================
start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
%%====================================================================
%% Supervisor callbacks
%%====================================================================
%% Child :: {Id,StartFunc,Restart,Shutdown,Type,Modules}
init([]) ->
{ok, { {one_for_all, 0, 1}, []} }.
Run Code Online (Sandbox Code Playgroud)
我不认为我曾经修改过那个文件。事实上,我觉得它如何连接到上面的start和stop函数有点神秘。
我的问题是,当我将 SIGTERM 发送到我正在运行的应用程序时,我没有看到stop函数中的日志记录语句出现。那看起来很糟糕。我需要向应用程序模块或主管模块添加一些东西吗?
(我需要处理 SIGTERM 并进行清理,因为我的应用程序是 Docker 化的并且 SIGTERM 被发送到在 Docker 内部运行的应用程序Docker stop,之后如果应用程序没有捕获 SIGTERM,它会在 10 秒后发送 SIGKILL。)
Redshift具有COPY操作,允许您将文件从S3复制到Redshift(http://docs.aws.amazon.com/redshift/latest/dg/r_COPY.html).
S3中的.json文件是"脏"的;它们还没有准备好直接复制到Redshift中,需要首先运行转换.我的问题是:我是否需要将新清理的JSON文件写回S3 ,然后从那些已清理的文件中执行COPY,或者有没有办法通过此转换运行jsons作为复制过程的一部分?
我想知道在一些非常大的列表中f(X)是否适用于所有人.现在我有:XL
lists:foldl(fun(X, Last) -> f(X) andalso Last end, true, L)
Run Code Online (Sandbox Code Playgroud)
问题是我不认为这种短路.即使它的第一个元素是错误的,L它仍然会一直持续着false.
是否有折叠标志,这样会短路或我可以使用的其他功能?
我现在看到有一个被调用的函数,all但它没有说它是否短路.
erlang ×3
fish ×2
c++ ×1
flask ×1
http ×1
mysql ×1
name-binding ×1
python ×1
python-3.x ×1
tmux ×1