我正在尝试将cURL的输出分配给变量,如下所示:
#!/bin/sh
$IP=`curl automation.whatismyip.com/n09230945.asp`
echo $IP
sed s/IP/$IP/ nsupdate.txt | nsupdate
Run Code Online (Sandbox Code Playgroud)
但是,当我运行脚本时,会发生以下情况:
Run Code Online (Sandbox Code Playgroud)./update.sh: 3: =[my ip address]: not found
如何才能$IP正确输出?
我想要一个看起来像这样的div:

这可能与HTML + CSS有关吗?我也将用jQuery动画这个div.当隐藏div时,我希望标题和顶行显示.
我目前在JScrollPanes中嵌套了JTables,如下所示:

我的问题是,在创建表时,每个表中的行数是可变的.我想要做的是如果表太短,则使JScrollpane变小,但如果表太长,我想将它保持在设定的大小.
我怎么能做到这一点?
我需要向Web服务器发送一个POST请求,其中包含一个gzip压缩请求参数.我正在使用Apache HttpClient,我已经读过它支持开箱即用的Gzip,但我找不到任何如何做我需要的例子.如果有人能发布一些这方面的例子,我会很感激.
通过pathlibPython 3.4中的新模块,我注意到没有任何简单的方法来获取用户的主目录.获取用户主目录的唯一方法是使用较旧的os.pathlib,如下所示:
import pathlib
from os import path
p = pathlib.Path(path.expanduser("~"))
Run Code Online (Sandbox Code Playgroud)
这看起来很笨重.有没有更好的办法?
在Emacs中,我使用的是具有深色背景和浅色文本的配色方案.使用.rst文件时,我有一个使用rst.el的模式.然而,rst.el突出了具有浅色背景颜色的标题,这使得阅读光文本成为不可能!
我认为这是rst.el中负责背景颜色的代码部分:
(defgroup rst-faces-defaults nil
"Values used to generate default faces for section titles on all levels.
Tweak these if you are content with how section title faces are built in
general but you do not like the details."
:group 'rst-faces
:version "21.1")
(defun rst-define-level-faces ()
"Define the faces for the section title text faces from the values."
;; All variables used here must be checked in `rst-set-level-default'
(let ((i 1))
(while (<= i rst-level-face-max)
(let ((sym (intern (format "rst-level-%d-face" …Run Code Online (Sandbox Code Playgroud) 我正在使用JTable并将其添加到使用gridbaglayout的面板中,如下所示:
JTable qdbs = new JTable(rowData, columnNamesVector);
qdbs.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
panel.add(qdbs, c);
Run Code Online (Sandbox Code Playgroud)
我不希望表格在滚动窗格中,但我希望表格占据面板的整个宽度.我怎么做到这一点?
根据要求提供SSCCE:
import javax.swing.*;
import java.awt.*;
public class Main{
public static void main(String[] args) {
new TestFrame();
}
public static class TestFrame extends JFrame{
public TestFrame() {
this.setTitle("SSCCE");
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.insets = new Insets(10,10,10,10);
JTable testTable = new JTable(10,2);
panel.add(testTable, c);
this.add(panel);
this.pack();
this.setVisible(true);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我希望这个表总是占据面板的整个宽度(插图除外).目前,在调整帧大小时,表不会更改大小.
我需要在网络周围发送对象.我将使用Twisted,我刚刚开始查看文档.
据我所知,python实现套接字的唯一方法是通过文本.那么我如何使用字符串发送对象?泡菜?还是有更好的东西?
我正在使用Twisted来实现各种服务器.当我测试它时,它收到的第一行总是很奇怪:
Starting Server...
New connection from 192.168.1.140
192.168.1.140: ÿûÿû ÿûÿû'ÿýÿûÿý\NAME Blurr
192.168.1.140: \NAME Blurr
Run Code Online (Sandbox Code Playgroud)
(对于我发送的两个输入\NAME Blurr.)
这是打印输入的代码:
def lineReceived(self, line):
print "{0}: {1}".format(self.name, line)
Run Code Online (Sandbox Code Playgroud)
我通过Telnet通过Telnet连接到远程主机.这是一个我丢失的telnet协议,还是什么?当我使用Unix的telnet程序并在本地连接时,第一行很好.
我经常最终得到这样的代码块:
public class CustomFile {
public String path;
public String name;
public CustomFile (String pathToFile, String dbName) {
path = pathToFile;
name = dbName;
}
}
Run Code Online (Sandbox Code Playgroud)
我希望能够将光标放在上面的行上,public CustomFile并能够删除所有空格,但不包括public String name;.是否有允许我这样做的命令或宏?
java ×3
python ×3
emacs ×2
jtable ×2
networking ×2
swing ×2
twisted ×2
bash ×1
css ×1
curl ×1
elisp ×1
gzip ×1
html ×1
httpclient ×1
jscrollpane ×1
putty ×1
python-3.4 ×1
telnet ×1