我有一个脚本(源码)来解析svn info为Bash创建一个合适的字符串$PS1.不幸的是,这不适用于我正在使用的运行Perl 5.8.8的系统 - 它输出所有行而不是仅输出匹配.什么是Perl 5.8.8相当于以下?
__svn_ps1()
{
local result=$(
svn info 2>/dev/null | \
perl -pe 's;^URL: .*?/((trunk)|(branches|tags)/([^/]*)).*;\2\4 ;p')
if [ -n "$result" ]
then
printf "${1:- (%s)}" $result
fi
}
Run Code Online (Sandbox Code Playgroud)
Perl 5.10的输出只包含空格,括号,分支名称,标记名称或trunk最后括号之一.Perl 5.8.8(没有最终版本p)的输出包含此加上svn info输出的每个空格分隔部分的括号版本.
一个可能的解决方法涉及和命令grep '^URL: '之间的简单,但我希望避免这种情况,因为这将针对每个Bash提示执行.svnperl
尝试在Windows Server 2008上运行互操作依赖程序时,我遇到错误,它在Win Server 2003和XP上正常运行:
System.Runtime.InteropServices.COMException(0x800A03EC):来自HRESULT的异常:Microsoft.Office.Interop.Excel.WorkbookClass.SaveAs(.......)中的0x800A03EC
根据微软的说法,Windows Server 2008不在支持的操作系统列表中.
支持的操作系统:Windows 2000 Service Pack 3; Windows Server 2003; Windows XP
任何人都可以证实这一点..有没有人试过..?
我通过使用下面的代码片段从OnItemClickListener获取Checkbox
onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.w("TAG","onItemClick clicked position :"+position);
CheckBox cbx = (CheckBox)view.findViewById(R.id.c_checkbox);
if(cbx.isChecked()){
Toast.makeText(getApplicationContext(),
"Checked position " + shoppingList.get(position).getItem(),
Toast.LENGTH_SHORT).show();
}
Run Code Online (Sandbox Code Playgroud)
我需要获取所有位置以检查哪个列表项被选中.为此我在下面使用了代码片段
int firstPosition = list.getFirstVisiblePosition();
for(int i=firstPosition;i<=list.getCount();i++){
View v=list.getChildAt(i);
cbx = (CheckBox)v.findViewById(R.id.c_checkbox);
if(cbx.isChecked()){
}
}
Run Code Online (Sandbox Code Playgroud)
在下面的代码cbx给我空指针exception.i使用ViewHolder为自定义适配器.请给我解决方案.为什么同样的事情在OnItemClickListener工作?
此致,Rajendar
我有一个与Google教程非常相似的GridView,除了我想在运行时添加ImageViews(通过子活动).结果还可以,但View的布局搞砸了:GridView没有填充其父级的内容,我需要做些什么才能正确设计它?
这里添加孩子的代码:
public void initializeWorkbench(GridView gv, Vector<String> items) {
Prototype.workbench.setDimension(screenWidth, divider.height()+workbenchArea.height());
Prototype.workbench.activateWorkbench();
// this measures the workbench correctly
Log.d(Prototype.TAG, "workbench width: "+Prototype.workbench.getMeasuredWidth());
// 320
Log.d(Prototype.TAG, "workbench height: "+Prototype.workbench.getMeasuredHeight());
// 30
ImageAdapter imgAdapter = new ImageAdapter(this.getContext(), items);
gv.setAdapter(imgAdapter);
gv.measure(screenWidth, screenHeight);
gv.requestLayout();
gv.forceLayout();
Log.d(Prototype.TAG, "gv width: "+gv.getMeasuredWidth());
// 22
Log.d(Prototype.TAG, "gv height: "+gv.getMeasuredHeight());
// 119
Prototype.workbench.setDimension(screenWidth, divider.height()+workbenchArea.height());
}
}
Run Code Online (Sandbox Code Playgroud)
工作台中的activateWorkbench,setDimension和measure(GridView上方的LinearLayout):
public void activateWorkbench() {
if(this.equals(Prototype.workbench)) {
this.setOrientation(VERTICAL);
show = true;
measure();
}
}
public void setDimension(int w, int h) {
width = …Run Code Online (Sandbox Code Playgroud) 我有以下代码,但它没有给因子的完美结果你可以找到它plz
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<script type="text/javascript">
function fact(num)
{
var x=parseInt(num);
//alert(x+1);
if(x>0)
x=x* fact(x-1);
alert(x);
}
</script>
</head>
<body>
<form name="f1">
Enter the Number :<input type="text" length="8" name="txt1"><br>
<input type="button" value="Find factiorial" onclick="fact(txt1.value)">
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我试图在linux内核中找到它在进程死后进行清理的地方.具体来说,我想知道在使用-9信号杀死进程后它是否/如何处理打开的TCP连接.我很确定它会关闭所有连接,但我想查看详细信息,如果连接没有正确关闭的话.
欢迎使用指向Linux内核源代码的指针.
我想像这样创建一个别名bash:
alias tail_ls="ls -l $1 | tail"
Run Code Online (Sandbox Code Playgroud)
因此,如果有人输入:
tail_ls /etc/
Run Code Online (Sandbox Code Playgroud)
它只会显示目录中的最后10个文件.
但$1似乎并不适合我.有什么办法可以在bash中引入变量.
我编写了一个代码段来确定图中最长的路径.以下是代码.但由于中间的递归方法,我不知道如何在其中获得计算复杂性.由于找到最长的路径是NP完全问题,我认为它类似于O(n!)或者O(2^n),但我怎么能真正确定它呢?
public static int longestPath(int A) {
int k;
int dist2=0;
int max=0;
visited[A] = true;
for (k = 1; k <= V; ++k) {
if(!visited[k]){
dist2= length[A][k]+longestPath(k);
if(dist2>max){
max=dist2;
}
}
}
visited[A]=false;
return(max);
}
Run Code Online (Sandbox Code Playgroud) 我正在写我的测试代码,我不想写写:
List<string> nameslist = new List<string>();
nameslist.Add("one");
nameslist.Add("two");
nameslist.Add("three");
Run Code Online (Sandbox Code Playgroud)
我很想写
List<string> nameslist = new List<string>({"one", "two", "three"});
Run Code Online (Sandbox Code Playgroud)
但是{"one","two","three"}不是"IEnumerable string Collection".如何使用IEnumerable字符串Collection在一行中初始化它?
在Delphi XE上,此代码对我不起作用:
http://delphi.about.com/cs/adptips2000/a/bltip0800_5.htm
procedure TForm1.FormDeactivate(Sender: TObject) ;
begin
ReleaseCapture;
end;
procedure TForm1.FormMouseMove
(Sender: TObject; Shift: TShiftState; X,Y: Integer) ;
begin
If GetCapture = 0 then
SetCapture(Form1.Handle) ;
if PtInRect(Rect(Form1.Left,
Form1.Top,
Form1.Left + Form1.Width,
Form1.Top + Form1.Height),
ClientToScreen(Point(x, y))) then
Form1.Caption := 'Mouse is over form' else
Form1.Caption := 'Mouse is outside of form';
end;
Run Code Online (Sandbox Code Playgroud)
没有错误 - 它只是没有效果.
请帮忙.
编辑1
事实证明问题不在于代码,即使鼠标FormMouseEnter和FormMouseLeave也不起作用,因为我将表单传递给我用这样的函数创建的单元:
程序Slide(Form:TForm; Show:Boolean);
我正在从这个过程中调用Show方法.我怎样才能克服这个问题?
谢谢.
编辑2
我不想使用我现在发布的功能.我想使用下面人们建议的内容(FormMouseEnter和FormMouseLeave),但它在我的情况下也不起作用.