我很习惯这样做:
:vimgrep /whatever/ **/*
Run Code Online (Sandbox Code Playgroud)
要么
:vimgrep /whatever/ **/*.txt
Run Code Online (Sandbox Code Playgroud)
但有没有办法用vim globbing来做,比方说,2种文件类型?我想我想要的东西有点像这样:
:vimgrep /whatever/ \*\*/.(txt|vb)
Run Code Online (Sandbox Code Playgroud) 我分析了我的代码,发现我的程序花了大约85%的时间执行这个特定的递归函数.该函数旨在计算在给定初始位置(x,y)的情况下到达马尔可夫链中的一组状态的概率.
private static boolean condition(int n){
int i = 0;
while ( n >= i){
if( n == i*4 || n == (i*4 - 1))
return true;
i++;
}
return false;
}
public static double recursiveVal(int x, int y, double A, double B){
if(x> 6 && (x- 2 >= y)){ return 1;}
if(y> 6 && (y- 2 >= x)){ return 0;}
if(x> 5 && y> 5 && x== y){ return (A*(1-B) / (1 -(A*B) - ((1-A)*(1-B))));}
if(condition(x+ y)){
return (recursiveVal(x+1, …Run Code Online (Sandbox Code Playgroud) 看起来好像我应该能够在谷歌搜索和测试几个小时后找到这个问题的明显答案.
我希望能够在caredate工厂中设置caredate.user_id => provider.user_id.
测试错误:
ActiveRecord :: RecordInvalid:验证失败:用户必须与提供者用户相同
我有一个ActiveRecord验证,通过浏览器测试时有效:
class Caredate < ActiveRecord::Base //works fine when testing via browser
belongs_to :user
belongs_to :provider
validates_presence_of :user_id
validates_presence_of :provider_id
validate :user_must_be_same_as_provider_user
def user_must_be_same_as_provider_user
errors.add(:user_id, "must be same as provider user") unless self.user_id == self.provider.user_id
end
end
//factories.rb
Factory.define :user do |f|
f.password "test1234"
f.sequence(:email) { |n| "foo#{n}@example.com" }
end
Factory.define :caredate do |f|
f.association :provider
**f.user_id { Provider.find_by_id(provider_id).user_id } //FAILS HERE**
end
Factory.define :provider do |f|
f.association :user
end
Run Code Online (Sandbox Code Playgroud)
如果以前已经回答过,我很抱歉; 我尝试了几种不同的选择,无法让它发挥作用.
更新:这通过验证,所以我越来越近了.我可以用一个随机数来破解. …
我正在使用subplot命令绘制5 x 3图,但每个子图周围都有很大的边距.
如何控制它们周围的边距大小?
有人可以帮忙吗?
figure;
for c=1:15
subplot(5,3,c);
imagesc(reshape(image(:,c), 360,480));
colormap gray;
axis image;
end
Run Code Online (Sandbox Code Playgroud)

我有一个带有字段的表:: ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
我的问题是,如果我使用延迟插入此表上,将时间戳是当插入实际上是由当请求排队的时间或时间?
我正在使用eclipse制作动态网页.它是一个依赖servlet传递/检索数据的简单程序.我的一个servlet必须打开.txt文件来读取其内容并将其发送到客户端.但是我收到了FileNotFound异常.我知道它,因为我不知道如何/在哪里放置txt文件,以便servlet可以在运行时找到该文件.我正在研究日食.你能提供一些提示吗?
谢谢
我不确定这是可能的,但我认为值得一提.我已经弄清楚如何使用pdfstamper和acrofields方法设置一个formfield的字体,但我真的希望能够在同一个字段中设置文本的不同部分的字体.这是我如何设置当前表单字段的字体:
// Use iTextSharp PDF Reader, to get the fields and send to the
//Stamper to set the fields in the document
PdfReader pdfReader = new PdfReader(fileName);
// Initialize Stamper (ms is a MemoryStream object)
PdfStamper pdfStamper = new PdfStamper(pdfReader, ms);
// Get Reference to PDF Document Fields
AcroFields pdfFormFields = pdfStamper.AcroFields;
//create a bold font
iTextSharp.text.Font bold = FontFactory.GetFont(FontFactory.COURIER, 8f, iTextSharp.text.Font.BOLD);
//set the field to bold
pdfFormFields.SetFieldProperty(nameOfField, "textfont", bold.BaseFont, null);
//set the text of the form field
pdfFormFields.SetField(nameOfField, "This: …Run Code Online (Sandbox Code Playgroud) 这仅仅是一个我想根据其他人的反馈和类似的经历得出的理论.
一直在使用mySQL来运行测试,但当然内存中的SQLite数据库要快得多.但是,它似乎遇到了一些问题.
何时DATABASE_ENGINE设置为use django.db.backends.sqlite3并且我运行manage.py test,输出不符合预期:
(删除了大多数行,但指出了有趣的失败点)
$ python manage.py test
Traceback (most recent call last):
File "manage.py", line 12, in
execute_manager(settings)
File "/Users/bartekc/.virtualenvs/xx/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Users/bartekc/domains/xx/xx/associates/yy/models.py", line 51, in
class AcvTripIncentive(models.Model):
# First interesting failure
File "/Users/bartekc/domains/xx/xx/associates/yy/models.py", line 55, in AcvTripIncentive
trip = models.OneToOneField(Trip, limit_choices_to={'sites' : Site.objects.get(name='ZZ'), 'is_active' : True,})
# Next interesting failure
File "/Users/bartekc/domains/xx/xx/associates/yyz/models.py", line 252, in
current_site = Site.objects.get_current()
有这样的多个失败,但只是指出了一对.问题很明显.站点模型没有实际数据,但文件包含尝试获取站点模型下的当前或特定实例的代码.
现在,我可以想到一个简单的解决方案:OneToOneField应该切换为使用函数limit_choices_to,第二个使用相同的函数.然后在需要时调用这些函数,而不是在Django对文件进行初始扫描时调用.
但是,我的实际问题是:为什么这会发生在SQLite而不是mySQL?.两个数据库引擎通过测试有不同的方式吗?我不这么认为,因为Python正在对模型进行所有编译.
到底发生了什么? …
我试图调用动态参数,同时调用模板来抑制xml中的节点.
我会称这个模板为:
transform employee.xml suppress.xsl ElementsToSuppress=id,fname
Run Code Online (Sandbox Code Playgroud)
employee.xml
<?xml version="1.0" encoding="utf-8" ?>
<Employees>
<Employee>
<id>1</id>
<firstname>xyz</firstname>
<lastname>abc</lastname>
<age>32</age>
<department>xyz</department>
</Employee>
<Employee>
<id>2</id>
<firstname>XY</firstname>
<lastname>Z</lastname>
<age>21</age>
<department>xyz</department>
</Employee>
</Employees>
Run Code Online (Sandbox Code Playgroud)
Suppress.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0" xmlns:elements="http://localhost">
<elements:name abbrev="id">id</elements:name>
<elements:name abbrev="fname">firstname</elements:name>
<xsl:param name="ElementsToSuppress" ></xsl:param>
<xsl:variable name="tokenizedSample" select="tokenize($ElementsToSuppress,',')"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
<xsl:for-each select="$tokenizedSample">
<xsl:call-template name ="Suppress" >
<xsl:with-param name="parElementName">
<xsl:value-of select="."/>
</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="Suppress">
<xsl:param name="parElementName" select="''"></xsl:param>
<xsl:variable name="extNode" select="document('')/*/elements:name[@abbrev=$parElementName]"/>
<xsl:call-template name="test" >
<xsl:with-param name="parElementName" >
<xsl:value-of …Run Code Online (Sandbox Code Playgroud) 是否有一个功能可以在Xcode的属性列表编辑器中一次扩展当前所选节点的所有后代节点?