在IPython中,我可以使用简单的命令加载自定义扩展:
%load_ext physics
Run Code Online (Sandbox Code Playgroud)
这将加载文件~/.config/ipython/extensions/physics.py.
如何告诉IPython在启动时自动加载扩展?
我添加了行/.config/ipython/profile_default/startup/import.py,但这不起作用:
from numpy import *
%load_ext physics
Run Code Online (Sandbox Code Playgroud)
当我启动IPython时,我得到以下错误:
File "~.config/ipython/profile_default/startup/import.py", line 17
%load_ext physics
^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud) 我ipython notebook在远程服务器上运行,即
ipython notebook --profile=nbserver
Run Code Online (Sandbox Code Playgroud)
我从本地机器访问.此外,我从我的机器ssh到远程服务器,并在该服务器上启动ipython控制台(终端).我发现以下命令运行良好:
ipython console --existing \
~/.config/ipython/profile_nbserver/security/kernel-*.json
Run Code Online (Sandbox Code Playgroud)
现在我从两个不同的客户端连接到同一个远程内核(可以叫他们browser和terminal).一切都运作良好,除了一个恼人的细节:
1)在browser,我输入a=1
2)在terminal,我输入b=2
3)在两个客户端中,我可以看到两个命令都使用%history.但是当我想循环使用历史(in terminal)时Up,它只显示在终端中输入的命令(即b=2).同样,我无法在终端中使用a+ PageDown,返回历史记录并找到以该命令开头的命令a.
根据我的理解,我的两个客户端使用两个单独的历史文件history.sqlite.但为什么要%history显示所有命令?
问题:
有没有办法history.sqlite为两个客户端配置一个?
我发现,轻松访问历史绝对是至关重要的.此外,我认为使用终端和浏览器作为补充,它们都有权衡,最好结合使用.
该ipython 文件说,认为"QT-控制台有emacs风格键绑定"
但是,当我按下时Ctrl+w,而不是预期的emacs样式的键绑定(向后删除单词),我的会话/窗口关闭
这是预期的行为吗?
Ctrl+w是最有用的emacs风格的键绑定.我发现有人决定用"关闭窗口"劫持它是非常不幸的
有没有办法将其重置为emacs风格
我有一个简单的python脚本,我连续读取logfile(相同tail -f)
while True:
line = f.readline()
if line:
print line,
else:
time.sleep(0.1)
Run Code Online (Sandbox Code Playgroud)
在通过logrotate旋转后,如何确保仍然可以读取日志文件?
即我需要做同样的tail -F事情.
我在用 python 2.7
当我编译程序时gcc -o myprog myprog.c,不会剥离生成的二进制文件:
myprog: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically
linked (uses shared libs), for GNU/Linux 2.6.26,
BuildID[sha1]=0x2697ed96b65e8a11239af0a44abc7896954b6e20, not stripped
Run Code Online (Sandbox Code Playgroud)
我想知道为什么gcc当我不提供任何调试参数时,默认情况下会生成非剥离的二进制文件。
是否应在编译后(即使用)剥离所有二进制文件strip myprog?还是具有二进制非剥离的优势?
AFAICS,在大多数二进制文件/bin/,/usr/bin/被剥离。
我的python脚本应该写入/dev/xconsole。当我从中读取内容时/dev/xconsole(例如使用),它可以正常工作tail -F /dev/xconsole。但是,如果我没有tail运行,我的脚本将挂起并等待。
我正在打开文件,如下所示:
xconsole = open('/dev/xconsole', 'w')
Run Code Online (Sandbox Code Playgroud)
并写:
for line in sys.stdin:
xconsole.write(line)
Run Code Online (Sandbox Code Playgroud)
当没有人从中读取输出时,为什么我的脚本挂起/dev/xconsole?
ipython notebook已设置默认工作目录
c.FileNotebookManager.notebook_dir = '/path/to/my/desired/dir'
Run Code Online (Sandbox Code Playgroud)
是否有类似的设置为ipython控制台(终端)?我试过调整以下配置参数:
c.TerminalInteractiveShell.ipython_dir = '/path/to/my/desired/dir'
Run Code Online (Sandbox Code Playgroud)
但这似乎没有效果.关于这个参数应该产生什么影响也没有评论.
我如何配置,ipython以便我的工作目录在启动时 /path/to/my/desired/dir,无论我从哪里开始ipython?
我有一个sha256使用 openSSL 库用 C 编写的最简单的示例。
// compile with: gcc -o sha256 sha256.c -lcrypto
#include <openssl/sha.h>
#include <stdio.h>
int main(int argc, char **argv)
{
unsigned char buffer[BUFSIZ];
FILE *f;
SHA256_CTX ctx;
size_t len;
if (argc < 2) {
fprintf(stderr, "usage: %s <file>\n", argv[0]);
return 1;
}
f = fopen(argv[1], "r");
if (!f) {
fprintf(stderr, "couldn't open %s\n", argv[1]);
return 1;
}
SHA256_Init(&ctx);
do {
len = fread(buffer, 1, BUFSIZ, f);
SHA256_Update(&ctx, buffer, len);
} while (len == BUFSIZ);
SHA256_Final(buffer, …Run Code Online (Sandbox Code Playgroud) 我想memtest86用 syslinux 从我的 USB 记忆棒启动。
我已经安装了这些软件包memtest86并将文件memtest86+复制.bin到我的 U 盘上。
我已将条目添加到syslinux.cfg:
LABEL memtest
MENU LABEL Memtest86
KERNEL memtest86.bin
LABEL memtest+
MENU LABEL Memtest86+
KERNEL memtest86+.bin
Run Code Online (Sandbox Code Playgroud)
但这不起作用。当我启动时,我的屏幕上会出现无尽的打印输出:
0104
0104
0104
...
Run Code Online (Sandbox Code Playgroud)
如何memtest86从 USB 记忆棒启动?
我有一个程序C,它计算sha256输入文件的哈希值。它正在使用openSSL图书馆。这是程序的核心:
#include <openssl/sha.h>
SHA256_CTX ctx;
unsigned char buffer[512];
SHA256_Init(&ctx);
SHA256_Update(&ctx, buffer, len);
SHA256_Final(buffer, &ctx);
fwrite(&buffer,32,1,stdout);
Run Code Online (Sandbox Code Playgroud)
我需要改变它来计算sha512哈希。
我可以(天真地)将函数的所有名称从SHA256to更改为SHA512,然后在最后一步更改fwrite64 个字节,而不是32bytes 吗?仅此而已,还是我必须进行更多更改?
ipython ×4
c ×3
openssl ×2
python ×2
sha ×2
cryptography ×1
file ×1
gcc ×1
python-3.x ×1
syslinux ×1