我想让用户在看到页面之前登录.是否有用户登录的内置模板,以便我不必编写自己的登录页面?
我有一个HTML表单,如:
<html>
Name:<input type="text"/></br>
Email Address:<input type="text"/></br>
Description of the input value:<input type="text"/></br>
</html>
Run Code Online (Sandbox Code Playgroud)
现在标签都在同一列中开始,但文本框根据标签的文本长度以不同的位置开始.
有没有办法对齐输入字段,使得所有":"和文本框将从相同的位置开始,前面的文本将右对齐,直到":"?
我可以使用CSS,如果这可以帮助实现这一点.
如何在Linux中检索python中的进程启动时间(或正常运行时间)?
我只知道,我可以调用"ps -p my_process_id -f",然后解析输出.但这并不酷.
我只是想知道为什么大多数Delphi示例使用FillChar()来初始化记录.
type
TFoo = record
i: Integer;
s: string; // not safe in record, better use PChar instead
end;
const
EmptyFoo: TFoo = (i: 0; s: '');
procedure Test;
var
Foo: TFoo;
s2: string;
begin
Foo := EmptyFoo; // initialize a record
// Danger code starts
FillChar(Foo, SizeOf(Foo), #0);
s2 := Copy("Leak Test", 1, MaxInt); // The refcount of the string buffer = 1
Foo.s = s2; // The refcount of s2 = 2
FillChar(Foo, SizeOf(Foo), #0); // The refcount …
Run Code Online (Sandbox Code Playgroud) 我想使用TIdHttp(Indy10)实现一个简单的http下载器.我从互联网上找到了两种代码示例.不幸的是,他们都没有100%满足我.这是代码,我想要一些建议.
变式1
var
Buffer: TFileStream;
HttpClient: TIdHttp;
begin
Buffer := TFileStream.Create('somefile.exe', fmCreate or fmShareDenyWrite);
try
HttpClient := TIdHttp.Create(nil);
try
HttpClient.Get('http://somewhere.com/somefile.exe', Buffer); // wait until it is done
finally
HttpClient.Free;
end;
finally
Buffer.Free;
end;
end;
Run Code Online (Sandbox Code Playgroud)
代码紧凑,易于理解.问题是它在下载开始时分配磁盘空间.另一个问题是我们无法直接在GUI中显示下载进度,除非代码在后台线程中执行(或者我们可以绑定HttpClient.OnWork事件).
变式2:
const
RECV_BUFFER_SIZE = 32768;
var
HttpClient: TIdHttp;
FileSize: Int64;
Buffer: TMemoryStream;
begin
HttpClient := TIdHttp.Create(nil);
try
HttpClient.Head('http://somewhere.com/somefile.exe');
FileSize := HttpClient.Response.ContentLength;
Buffer := TMemoryStream.Create;
try
while Buffer.Size < FileSize do
begin
HttpClient.Request.ContentRangeStart := Buffer.Size;
if Buffer.Size + RECV_BUFFER_SIZE < FileSize then
HttpClient.Request.ContentRangeEnd := Buffer.Size + …
Run Code Online (Sandbox Code Playgroud) 我正在将我的登陆页面从Bootstrap转换为Semantic-UI.该页面的位置固定在顶部导航栏上.主要内容分为两列(3-cols和9-cols).左列用于显示侧栏,右栏用于显示当前内容.
我试图复制并粘贴Semantic-UI的演示页面.导航栏高45px.我注意到第一个45px的主要内容是重叠的.
<link href="//semantic-ui.com/dist/semantic.min.css" rel="stylesheet"/>
<script src="//semantic-ui.com/dist/semantic.min.js"></script>
<div id="navbar" class="ui fixed inverted main menu">
<div class="container">
<div class="title item">
<b>Dashboard</b>
</div>
</div>
</div>
<div id="maincontent" class="ui bottom attached segment pushable">
<div id="sidebar" class="ui visible left vertical sidebar menu">
<a class="item">First Item</a>
<a class="item">Second Item</a>
<a class="item">Third Item</a>
<a class="item">Fourth Item</a>
<a class="item">Fifth Item</a>
</div>
<div id="content" class="pusher">
<div class="ui basic segment">
<h3 class="ui header">Application Content</h3>
<p>First paragraph...</p>
<p>Second paragraph...</p>
<p>Third paragraph...</p>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我目前的解决方法是在导航栏后添加一个45px高的占位符.
<div style="height:45px"></div>
Run Code Online (Sandbox Code Playgroud)
我很确定有一些好的CSS样式名称可以修复内容重叠.
我遇到了一个奇怪的问题.我使用DIV作为容器,并将图像放入此DIV中.我希望这个图像垂直对齐到底部.以下代码有效.
#banner {
width: 700px;
height: 90px;
top: 60px;
left: 178px;
overflow: hidden;
text-align: center;
display: table-cell;
vertical-align: bottom;
position: relative;
}
<div id="banner">
<img src="http://www.google.de/intl/de_de/images/logo.gif"/>
</div>
Run Code Online (Sandbox Code Playgroud)
但是,如果我更改CSS代码"的位置是:相对"到"的位置是:绝对"时,图像无法对齐到底了.这是Firefox3的错误吗?我怎么解决这个问题?
我目前的解决方案是:
<div id="banner">
<table width="100%" height="100%"><tr><td valign="bottom" align="center">
<img src="http://www.google.de/intl/de_de/images/logo.gif"/>
</td></tr></table>
</div>
Run Code Online (Sandbox Code Playgroud)
但我不喜欢这个解决方案.
我用google搜索"python ssh".有一个很棒的模块pexpect
,它可以使用ssh(带密码)访问远程计算机.
连接远程计算机后,我可以执行其他命令.但是我无法再次在python中获得结果.
p = pexpect.spawn("ssh user@remote_computer")
print "connecting..."
p.waitnoecho()
p.sendline(my_password)
print "connected"
p.sendline("ps -ef")
p.expect(pexpect.EOF) # this will take very long time
print p.before
Run Code Online (Sandbox Code Playgroud)
如何得到ps -ef
我的结果?
我有以下代码.它看起来很丑,如果值等于下面的值之一,那么就做一些事情.
var
Value: Word;
begin
Value := 30000;
if (Value = 30000) or (Value = 40000) or (Value = 1) then
do_something;
end;
Run Code Online (Sandbox Code Playgroud)
我想按如下方式重构代码:
var
Value: Word;
begin
Value := 30000;
if (Value in [1, 30000, 40000]) then // Does not work
do_something;
end;
Run Code Online (Sandbox Code Playgroud)
但是,重构的代码不起作用.我假设Delphi中的有效集仅接受类型为byte的元素.如果有任何好的替代方法来重构我的原始代码(除了使用案例)?