conditional

When using ANT, how can I define a task only if I have some specific java version?

旧街凉风 提交于 2019-12-21 14:39:12
问题 I have the problem that an specific step in Ant can only be executed when we have Java 1.5 installed in the build computer. The task definition uses uses a jar file that was compiled using 1.5, so running with a 1.4 virtual machine will throw an IncompatibleClassVersion exception. I have to find a solution meanwhile to have this task working for this specific project that requires 1.4, but a question came to me. How can I avoid defining this task and executing this optional step if I don't

pthread_cond_timedwait returning immediately

我怕爱的太早我们不能终老 提交于 2019-12-21 12:10:36
问题 I'm having a strange problem. I have the following code: dbg("condwait: timeout = %d, %d\n", abs_timeout->tv_sec, abs_timeout->tv_nsec); ret = pthread_cond_timedwait( &q->q_cond, &q->q_mtx, abs_timeout ); if (ret == ETIMEDOUT) { dbg("cond timed out\n"); return -ETIMEDOUT; } dbg calls gettimeofday before every line and prepends the line with the time. It results in the following output: 7.991151: condwait: timeout = 5, 705032704 7.991158: cond timed out As you can see, only 7 microseconds

If Statement True Block Executed When Condition is False

折月煮酒 提交于 2019-12-21 07:55:55
问题 I optimized an extension method to compare two streams for equality (byte-for-byte) - knowing that this is a hot method I tried to optimize it as far as possible (the streams can reach into multi-megabyte lengths). I essentially came up with the following approach: [StructLayout(LayoutKind.Explicit)] struct Converter { [FieldOffset(0)] public Byte[] Byte; [FieldOffset(0)] public UInt64[] UInt64; } /// <summary> /// Compares two streams for byte-by-byte equality. /// </summary> /// <param name

How to indent long conditionals for 'if' statements?

℡╲_俬逩灬. 提交于 2019-12-21 07:03:03
问题 My question relates to this previous question, but the solutions offered don't address the problem I have outlined below. After a google search I haven't found any code style guidelines that address the specific problem of long conditionals in an if statement like this. if( isNull(value1) || isToLong(value1) || hasBadFormat(valule1)){ doSomething(); }else{ doSomethingElse(); } OR: if( isNull(value1) || isToLong(value1) || hasBadFormat(valule1) ){ doSomething(); }else{ doSomethingElse(); } The

A conditional SQL update statement for two tables at once

大兔子大兔子 提交于 2019-12-21 05:30:34
问题 I want to update two tables at once. The code below seems to work fine. However, in some cases, there is no entry in bidGroups which means the entire statement would fail. How can I adjust it so it updates the first bit (watchedItems) and does not try the second part if watchedItems.bidGroupID IS NULL UPDATE watchedItems, bidGroups SET watchedItems.won=1, bidGroups.bidGroupQty=bidGroups.bidGroupQty-1 WHERE watchedItems.id=2 AND watchedItems.aid=200618152822 AND bidGroups.bidGroupID

Ninject conditional binding based on parameter type

风格不统一 提交于 2019-12-21 04:14:41
问题 I'm using a factory to return a datasender: Bind<IDataSenderFactory>() .ToFactory(); public interface IDataSenderFactory { IDataSender CreateDataSender(Connection connection); } I have two different implementations of datasender (WCF and remoting) which take different types: public abstract class Connection { public string ServerName { get; set; } } public class WcfConnection : Connection { // specificProperties etc. } public class RemotingConnection : Connection { // specificProperties etc.

MySQL update conditions in one query (UPDATE, SET & CASE)

天大地大妈咪最大 提交于 2019-12-21 03:44:14
问题 I'm trying to update a set of records ( boolean fields ) in a single query if possible. The input is coming from paginated radio controls, so a given POST will have the page's worth of IDs with a true or false value. I was trying to go this direction: UPDATE my_table SET field = CASE WHEN id IN (/* true ids */) THEN TRUE WHEN id IN (/* false ids */) THEN FALSE END But this resulted in the "true id" rows being updated to true , and ALL other rows were updated to false . I assume I've made some

How to check if a value is empty in Lua?

时光总嘲笑我的痴心妄想 提交于 2019-12-20 17:35:54
问题 What is the proper way to make a conditional which checks of something is or is not empty in Lua? if x == "" and f x ~= "" does not seem to work. 回答1: Lua is a dynamically type-based language . Any variable can hold one of the following types: nil , boolean , number , string , table , function , thread , or userdata . Any variable in a table (including _G , the table where globals reside) without a value gives a value of nil when indexed. When you set a table variable to nil , it essentially

AngularJS ng-class multiple conditions with OR operator

二次信任 提交于 2019-12-20 17:27:57
问题 I try to find out the good syntax for adding classes depending on angular values. I want to activate a class regarding 2 conditions (one on live user changes, and one on loading datas) with a OR operator. Here is the line : <a href="" ng-click="addFavorite(myfav.id);favorite=!favorite"> <i class="fa orange" ng-class="{'fa-star': (favorite || (fav==myfav.id)), 'fa-star-o': !favorite}"></i> </a> I tried some different codes like this one : ng-class="{'fa-star': favorite, 'fa-star': (fav==myfav

Attribute在.net编程中的应用

流过昼夜 提交于 2019-12-20 16:28:06
Attribute的基本概念 经常有朋友问,Attribute是什么?它有什么用?好像没有这个东东程序也能运行。实际上在.Net中,Attribute是一个非常重要的组成部分,为了帮助大家理解和掌握Attribute,以及它的使用方法,特地收集了几个Attribute使用的例子,提供给大家参考。 在具体的演示之前,我想先大致介绍一下Attribute。我们知道在类的成员中有property成员,二者在中文中都做属性解释,那么它们到底是不是同一个东西呢?从代码上看,明显不同,首先就是它们的在代码中的位置不同,其次就是写法不同(Attribute必须写在一对方括符中)。 什么是Atrribute 首先,我们肯定Attribute是一个类,下面是msdn文档对它的描述: 公共语言运行时允许你添加类似关键字的描述声明,叫做attributes, 它对程序中的元素进行标注,如类型、字段、方法和属性等。Attributes和Microsoft .NET Framework文件的元数据保存在一起,可以用来向运行时描述你的代码,或者在程序运行的时候影响应用程序的行为。 在.NET中,Attribute被用来处理多种问题,比如序列化、程序的安全特征、防止即时编译器对程序代码进行优化从而代码容易调试等等。下面,我们先来看几个在.NET中标准的属性的使用