我的问题就像来自http://my.safaribooksonline.com/0596007973/pythoncook2-CHP-10-SECT-17的模拟问题 ,最终使用2005年的过时xpath方法进入Python Cookbook,第2版无法使用10.6的内置python(也没有安装旧的软件包)
我希望..."检索有关Mac OS X系统的详细信息",使用system_profiler在每次计算机启动时在脚本中对其进行汇总(脚本将在登录时启动).
我收集的信息从SW版本到HW配置各不相同.
示例行是system_profiler SPSoftwareDataType | grep'Boot Volume',它返回启动卷名.我打了15到20个其他的信息电话.
我试图输出完整的'system_profiler>数据'并使用cat数据解析它 grep,但是如果我像上面的例子一样运行每一行,这显然效率低下.
如果输入文件和cat |,则为18秒 grep的.
如果打个人电话,则需要13秒
*我正试图尽可能快地完成它.
我推断我可能需要创建一个字典并使用键来引用数据,但我想知道解析和检索数据的最有效方法是什么?我在其他地方看到过使用system_profiler输出到XML并使用XML解析器的建议,但我认为可能有一些缓存和解析方法比首先输出到文件更有效.
编辑:正如我在第一个答案中所看到的,下划线是错误的.我想要在标题下面有一行,将标题与以下文本分开.
我想用水平线从下面的文本中分隔章节标题.目前我使用以下内容:
\newcommand{\tmpsection}[1]{}
\let\tmpsection=\section
\renewcommand{\section}[1]{\tmpsection{#1}\hrule\nobreak}
Run Code Online (Sandbox Code Playgroud)
但是这会产生一条直线,它离剖面标题太远,接近下面的文字.谁有更好的主意?
我一直在研究以下内容,看起来使用编译查询可以获得很多好处... http://blogs.msdn.com/ricom/archive/2008/01/14/performance-quiz- 13 LINQ到SQL编译查询成本,solution.aspx
我的问题是我想对我的查询进行单元测试,但是编译的查询需要一个派生自DataContext的类的具体实例(特别难以模拟出来)...因此我提出了以下代码,我是想知道是否有人知道我是否仍然可以获得编译查询的性能优势......
private static readonly Func<IDatabase, IActionParameters, ISportProgramMapper, IQueryable<ISportProgram>> _GetQueryUnCompiled =
(db, parameters, mapper) => from x in db.SportProgramDataSource.ThatHaveActiveSports()
where x.SportProgramId == parameters.Id
select mapper.FromDataToEntity(x);
private static readonly Func<Database, IActionParameters, ISportProgramMapper, IQueryable<ISportProgram>> _GetQuery = CompiledQuery.Compile<Database, int, ISportProgramMapper, IQueryable<ISportProgram>>((db, parameters, mapper) => _GetQueryUnCompiled(db, parameters, mapper));
public IActionResult<ISportProgram> Get(IActionParameters parameters)
{
Check.Argument("parameters").ThatValue(parameters).IsNotNull();
IDatabase db = this.CreateDatabase();
ISportProgramMapper mapper = this.CreateMapper<ISportProgramMapper>();
Database typedDb = db as Database;
var result = typedDb != null ? _GetQuery(typedDb, parameters, mapper).FirstOrDefault() : _GetQueryUnCompiled(db, parameters, …Run Code Online (Sandbox Code Playgroud) 我正在YYYY-MM-DD使用格式验证用户输入的日期字符串Zend_Validate::is($value,'Date').
此调用创建此层次结构:
Zend_Validate::is()
Zend_Validate_Date->isValid()
Zend_Date::isDate()
Zend_Locale_Format::getDate()
Zend_Locale_Format::_parseDate()
Run Code Online (Sandbox Code Playgroud)
最后,它失败了这个例外:
Zend_Locale_Exception: Unable to parse date '2009-09-08' using 'MMM d, y' (M <> y) in /usr/share/php/Zend/Locale/Format.php on line 1001
Run Code Online (Sandbox Code Playgroud)
我使用en_US作为我的应用程序区域设置.如何配置Zend_Validate以接受此日期格式?例如,是否可以更改日期的区域设置格式?
我正在使用SnowFall应用程序,其中图像从屏幕顶部下降到底部.这个应用程序使用动画来完成这项任务.
//把片放在我们的主视图中[self.view addSubview:flakeView];
[UIView beginAnimations:nil context:flakeView];
// set up how fast the flake will fall
[UIView setAnimationDuration:4 * speed];
// set the postion where flake will move to
//flakeView.frame = CGRectMake(endX, 500.0, 25.0 * scale, 25.0 * scale);
flakeView.frame = CGRectMake(endX, 500.0,16, 16);
// set a stop callback so we can cleanup the flake when it reaches the
// end of its animation
[UIView setAnimationDidStopSelector:@selector(onAnimationComplete:finished:context:)];
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)
我的问题是我需要捕捉它们移动的图像帧.
有什么办法可以让我找到屏幕上图像的当前位置.
谢谢
编辑:我正在尝试使用:CGRectIntersectsRect(frame1,frame2)其中frame1是动画的图像,frame2是一个对象.如果图像与物体相交,我必须要做一些事情.
我喜欢maven.我非常喜欢它.自从我从Ant切换到它以来,我已经节省了大量的工作时间,构建构建文件,管理依赖项等,并在我的源代码控制存储库中节省了大量空间.
问题是maven文件太冗长了.并不是说Ant文件不那么冗长,但它们的冗长程度适合他们的工作.
例如,而不是写:
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
<dependency>
<groupId>com.myosproject</groupId>
<artifactId>superlibrary</artifactId>
<version>7.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
我想写点类似的东西
<dependencies>
commons-logging/commons-logging/1.1.1
com.myosproject/superlibrary/7.5
test:junit/junit/3.8.1
</dependencies>
Run Code Online (Sandbox Code Playgroud)
或者代替
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
我想要
<build version="1.5"/>
Run Code Online (Sandbox Code Playgroud)
并且(最后一个例子,我们已经完成),而不是写:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native2ascii-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>native2ascii</goal>
</goals>
<configuration>
<encoding>UTF8</encoding>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我不想写任何东西.即,maven将检测native2ascii文件夹的存在,并默认做正确的事情.
我知道我正在将内置功能与插件和其他东西混合使用,但请尝试从对该工具非常满意的maven用户的角度来看,但认为他可能会更快乐.
所以:
有没有办法让maven像这样工作?(这样做是否明智)
是否有另一种我不知道的工具呢?
为什么以下代码行不能在方法中工作?
return (count > 0) ? true : false;
Run Code Online (Sandbox Code Playgroud)
如果我这样做,它完全正常:
bool ret = (count > 0) ? true : false;
return ret;
Run Code Online (Sandbox Code Playgroud)
奖金问题:它是否比标准if语句更快或更有效?
bool ret = false;
if(count > 0)
ret = true;
return ret;
Run Code Online (Sandbox Code Playgroud)
你会推荐哪一个?
令我惊讶的是,我发现在当前浏览器中支持将text-alignment应用于表列是相当糟糕的.Firefox 3.5.2,Safari 4.0.3或IE8都没有将右下方的"金额"列显示为右对齐.
HTML:
<table class="full_width">
<caption>Listing employees of department X</caption>
<col></col>
<col></col>
<col></col>
<col class="amount" width="180"></col>
<thead>
<tr>
<th>Name</th>
<th>Phone number</th>
<th>Email</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Doe</td>
<td>+45 2373 6220</td>
<td>john@doe.com</td>
<td>20000</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
CSS
.amount{
text-align: right;
}
Run Code Online (Sandbox Code Playgroud)
为什么这不起作用?此外,我尝试(通过firebug)关闭Firefox左对齐TD元素的原生规则,但这也不起作用.
我可以看到在css类中设置背景颜色规则实际上是有效的.所以我知道.amount类适用于所有列:
CSS
.amount{
text-align: right;
background-color: aqua;
}
Run Code Online (Sandbox Code Playgroud)
CSS 2规范显然说col元素只支持四个属性 - 请参阅为什么不允许样式表列?
选择最佳解决方案的标准:必须得到相当跨浏览器的支持(不一定在IE6中,我可以使用jquery或条件注释来包含特定的解决方案).此外,我希望多个不同的列应用多个类(即.class="amount before_tax")
我讨厌在每一行的相关td上设置类.我有什么选择?
c# ×2
iphone ×2
.net ×1
alignment ×1
animation ×1
css ×1
datacontext ×1
formatting ×1
heading ×1
html-table ×1
java ×1
latex ×1
linq-to-sql ×1
listbox ×1
macos ×1
maven-2 ×1
mocking ×1
parsing ×1
php ×1
profiler ×1
python ×1
syntax ×1
tex ×1
unit-testing ×1
wpf ×1