你会怎样用bash来判断某个目录中是否存在特定扩展名的文件?
就像是
if [ -e *.flac ]; then
echo true;
fi
Run Code Online (Sandbox Code Playgroud) 我在后面的代码中设置变量并在ASP.NET页面中使用它(将其设置为文本框中的值)时遇到了一些困难.我的网页只是错误,并表示它在当前上下文中不存在.该变量在Page_Load方法中声明并设置全部.
这是相关的ASP.NET代码.我假设您不需要看到后面的代码,因为我已经测试了通过代码隐藏输出变量(使用Response.Write)并且工作正常.
<asp:TemplateField HeaderText="Initial Path"
SortExpression="Initial_Path">
<EditItemTemplate>
<asp:TextBox ID="TextBox6" runat="server"
Text='<%# initialPath %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox8" runat="server"
Text='<%# initialPath %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# initialPath %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Run Code Online (Sandbox Code Playgroud)
谢谢 :)
编辑:好的,这是代码背后的相关部分
string schedID = sched.SchedulerInstanceId;
JobDetail jobDetail2 = sched.GetJobDetail(Request.QueryString["JOB_NAME"], "sched1");
JobDataMap dataMap2 = jobDetail2.JobDataMap;
initialPath = dataMap2.GetString("initialPath");
Response.Write(initialPath);
Run Code Online (Sandbox Code Playgroud)
response.write用于调试 - 它正确输出变量,因此实际设置了变量
编辑2:这是背后的代码
public partial class EditJobDetails : System.Web.UI.Page
{
public string initialPath { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
//Scheduler stuff for Quartz.NET, …Run Code Online (Sandbox Code Playgroud) 我有一个定义为的服务:
public class SleepAccelerometerService extends Service implements SensorEventListener
Run Code Online (Sandbox Code Playgroud)
从本质上讲,我正在制作一个应用程序,可以在用户使用他或她的手机/设备睡在床上时,出于各种原因监控加速度计活动.这是一项长期服务,不得在夜间杀死.根据夜间有多少后台应用程序和定期进程,android有时会终止我的进程,从而结束我的服务.例:
10-04 03:27:41.673: INFO/ActivityManager(1269): Process com.androsz.electricsleep (pid 16223) has died.
10-04 03:27:41.681: INFO/WindowManager(1269): WIN DEATH: Window{45509f98 com.androsz.electricsleep/com.androsz.electricsleep.ui.SleepActivity paused=false}
Run Code Online (Sandbox Code Playgroud)
我不想强迫用户将"SleepActivity"或我的应用中的其他活动作为前景.我不能定期运行我的服务,因为它会不断拦截onSensorChanged.
有小费吗?源代码在这里:http://code.google.com/p/electricsleep/
我正在使用C++ std :: map来保存大量实体:
using std::map;
map {structureEntityID, classEntityRecord} tableEntityRecords; //(replace {}s with arrows)
Run Code Online (Sandbox Code Playgroud)
我会经常修改表格中的实体(每秒多次).通过指针修改这些记录是更好还是更好地制作本地副本,修改它,然后更新表?
例如...
通过指针:
classEntityRecord* getEntityRecord(structureEntityID entityID)
{
map {structureEntityID, classEntityRecord}::iterator iteratorEntityRecord;
iteratorEntityRecord = tableEntityRecords.find(entityID);
return &iteratorEntityRecord->second;
}
classEntityRecord *entityRecord;
entityRecord = getEntityRecord(entityID);
entityRecord->x = 15;
Run Code Online (Sandbox Code Playgroud)
通过复制/修改/更新:
classEntityRecord getEntityRecord(structureEntityID entityID)
{
map {structureEntityID, classEntityRecord}::iterator iteratorEntityRecord;
iteratorEntityRecord = tableEntityRecords.find(entityID);
return iteratorEntityRecord->second;
}
classEntityRecord entityRecord;
entityRecord = getEntityRecord(entityID);
entityRecord.x = 15;
tableEntityRecords[entityID] = entityRecord;
Run Code Online (Sandbox Code Playgroud)
我认为最好使用指针,但这是我第一次使用C++地图,所以我不完全了解它们是如何工作的.
我最担心的是,如果我指向表中的一个值,是否有可能重新排序C++映射并使该指针不再有效?该程序是多线程的,因此可以将实体添加到表中,而其他实体则被修改.
我很感激帮助!
为什么.net MVC源代码ControllerBuilder使用委托来分配控制器工厂?:
private Func<IControllerFactory> _factoryThunk;
public void SetControllerFactory(IControllerFactory controllerFactory) {
_factoryThunk = () => controllerFactory;
}
Run Code Online (Sandbox Code Playgroud)
为什么不能直接分配ControllerFactory?,即:
private IControllerFactory _factory;
public void SetControllerFactory(IControllerFactory controllerFactory) {
_factory = controllerFactory;
}
public void SetControllerFactory(Type controllerFactoryType) {
_factory = (IControllerFactory)Activator.CreateInstance(controllerFactoryType);
}
Run Code Online (Sandbox Code Playgroud) 使用Silverlight 4和WPF 4,我正在尝试创建一个按钮样式,当按钮被鼠标悬停时,它会改变任何包含文本的文本颜色.因为我试图使它与Silverlight和WPF兼容,所以我使用了可视状态管理器:
<Style TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="outerBorder" CornerRadius="4" BorderThickness="1" BorderBrush="#FF757679">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimation Duration="0" To="#FFFEFEFE"
Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
Storyboard.TargetName="contentPresenter"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid>
<Border x:Name="Background" CornerRadius="3" BorderThickness="1" BorderBrush="Transparent">
<Grid>
<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}"/>
</Grid>
</Border>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
Run Code Online (Sandbox Code Playgroud)
由于这是一个常规旧按钮的模板,我知道不能保证里面甚至有一个文本块,起初我不确定这是否可能.奇怪的是,如果按钮声明如下,文本颜色确实会改变:
<Button Content="Hello, World!" />
Run Code Online (Sandbox Code Playgroud)
但如果按钮声明如下,它不会改变:
<Button>
<TextBlock Text="Hello, World!" /> <!-- Same result with <TextBlock>Hello, World </TextBlock> -->
</Button>
Run Code Online (Sandbox Code Playgroud)
即使可视树(在snoop中检查时)是相同的(Button - > ContentPresenter …
有些人可以推荐在C++中进行并行化的方法,当要执行的数据非常庞大时.我一直在阅读有关openMP和英特尔TBB在C++中进行并行化的内容,但尚未对它们进行过实验.哪些对并行数据处理更好?还有其他图书馆/方法吗?
我已经为macosx Leopard 10.5.8下载了igraph 0.5.4 tar球.当我解压缩然后运行:
sudo python setup.py install
Run Code Online (Sandbox Code Playgroud)
我收到以下很长的错误消息:
Include path: /usr/include /usr/local/include
Library path:
running install
running bdist_egg
running egg_info
writing python_igraph.egg-info/PKG-INFO
writing top-level names to python_igraph.egg-info/top_level.txt
writing dependency_links to python_igraph.egg-info/dependency_links.txt
reading manifest file 'python_igraph.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'python_igraph.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.3-fat/egg
running install_lib
running build_py
creating build
creating build/lib.macosx-10.3-fat-2.6
creating build/lib.macosx-10.3-fat-2.6/igraph
copying igraph/__init__.py -> build/lib.macosx-10.3-fat-2.6/igraph
copying igraph/clustering.py -> build/lib.macosx-10.3-fat-2.6/igraph
copying igraph/colors.py -> build/lib.macosx-10.3-fat-2.6/igraph
copying igraph/configuration.py -> build/lib.macosx-10.3-fat-2.6/igraph
copying igraph/datatypes.py -> build/lib.macosx-10.3-fat-2.6/igraph …Run Code Online (Sandbox Code Playgroud) 我是C#4.0和WPF的新手,我即将开始一个新的应用程序.
来自C++/MFC世界,我对测试与最新技术一起使用的策略感兴趣.
例如:
任何意见,将不胜感激.
谢谢.
好的,所以我有一些 C 代码来执行数学运算,这几乎可以花费任何时间(当然,这取决于提供给它的操作数)。我想知道是否有一种方法可以注册某种方法,该方法每n秒调用一次,可以分析操作的状态,即它当前处于什么迭代,可能使用硬件定时器中断或其他什么?
我问这个的原因是因为我知道实现这一点的常用方法是跟踪变量中的当前迭代;比如说,一个整数被调用progress并且在代码中有一个像这样的 IF 语句:
if ((progress % 10000) == 0)
printf("Currently at iteration %d\n", progress);
Run Code Online (Sandbox Code Playgroud)
但我相信一个 mod 操作需要相对较长的时间来执行,所以从优化的角度来看,将它放在一个循环中的想法会运行很多很多次让我感到害怕。
所以我觉得有一种外部方式来表示进度打印是好的和有效的。有什么好的方法可以执行此操作,还是简单的“mod 检查”是最好的(在优化方面)?