灯角

文章 0 评论 0 浏览 23

灯角 2024-11-26 21:35:44

是的,只需将所有命令放入一个文件中,然后

bash filename

这将按顺序运行命令。如果您希望它们全部并行运行(即不等待命令完成),则将 & 添加到文件中每行的末尾

Yep, just put all your commands in one file and then

bash filename

This will run the commands in sequence. If you want them all to run in parallel (i.e. don't wait for commands to finish) then add an & to the end of each line in the file

如何一次运行多个 Unix 命令?

灯角 2024-11-26 21:20:02

RPC 接口和实现必须匹配,否则将无法编译。我很确定您放入 ArrayList 中的内容导致了问题。它是一个通用的 ArrayList 还是某些类型的列表?尝试使用Java Generic(例如ArrayList)来帮助GWT 编译器优化您的代码。

The RPC interfaces and implementation do match, otherwise you would not be able to compile. I'm quite sure what you put in the ArrayList is causing the problem. Is it a generic ArrayList or a list of certain types? Try using Java Generic (e.g. ArrayList) to help the GWT compiler optimizing your code.

GWT序列化异常

灯角 2024-11-26 21:10:35

您可以通过执行“但是”来判断它将循环或应该循环多少次,

$loops = count($items); 

但是只有当您的代码不以任何方式跳过迭代时,这才有效。

You could tell how many time it WILL loop or SHOULD have looped by doing a

$loops = count($items); 

However that will only work if your code does not skip an iteration in any way.

如何在不使用“计数器”的情况下找出 PHP 中 foreach 构造循环的次数?多变的?

灯角 2024-11-26 18:50:08

如果您使用字符类简写和 Unicode 识别正则表达式引擎,您就可以做到这一点。 \w 类匹配“单词字符”(字母、数字和下划线)。

请注意某些正则表达式风格不能很好地做到这一点:JavaScript 使用 ASCII 表示 \d (数字)和 \w,但使用 Unicode 表示 \s< /代码>(空格)。 XML 则相反。

If you use character class shorthands and a Unicode aware regex engine you can do that. The \w class matches "word characters" (letters, digits, and underscores).

Beware of some regex flavors that don't do this so well: JavaScript uses ASCII for \d (digits) and \w, but Unicode for \s (whitespace). XML does it the other way around.

如何为所有语言创建字母数字正则表达式?

灯角 2024-11-26 06:59:26

对于 Internet Explorer 我没有想法。但正如您在标题中询问有关 Firefox 的问题: QuickJava 是一个很棒的工具Firefox AddOn 允许您通过单击按钮来禁用/启用 Flash(以及 Java、Javascript、Silverlight 和 CSS)。

For Internet Explorer I don't have an idea. But as you are also asking about Firefox in the title: QuickJava is a great Firefox AddOn that allows you to disable/enable Flash (and Java, Javascript, Silverlight and CSS) with the click of a button.

在 Internet Explorer/Firefox/Chrome 中出于测试目的禁用 Flash

灯角 2024-11-26 05:25:48

您可能最适合定义一个数据模板选择器并创建多个数据模板。选择器可以评估各种逻辑规则,并返回您想要的模板。

这是一个非常好的入门关于 DataTemplateSelectors 的教程

编辑

重读你的问题后,这就是我所得到的。

您的模型类是否具有访问父对象的导航属性?如果是这样,您可以在 ViewModel 上使用触发器(如果您使用 MVVM,则更佳)属性来根据父对象而不是父 TreeViewItem 启用/禁用/更改可见性。按照您描述的方式访问可视化树有点困难。

You would likely be best served with defining a DataTemplate selector, and creating several datatemplates. The selector can evaluate all kinds of logical rules, and return the template that you want.

Here is a pretty good getting started tutorial on DataTemplateSelectors.

EDIT

After rereading your question here is what I have got.

Do your model classes have navigation properties to get to parent objects? If so, you can use triggers (or more preferable if you are using MVVM) properties on the ViewModel to enable/disable/alter visibility based on what the parent object is rather than the parent TreeViewItem. It is a bit more difficult to access the visual tree the way you are describing.

仅当其他 TreeViewItem 的子级时才数据绑定到选定的 TreeViewItem

灯角 2024-11-26 04:43:48

您将其设置为 100%,但是 100% 是什么?尝试为主体赋予相同的 100% 高度和宽度属性,看看会发生什么。

You're setting it to 100%, but 100% of what? Try giving the body the same 100% height and width properties and see what happens.

可调整大小的背景图像

灯角 2024-11-26 04:34:33

KeyboardEvent.KEY_DOWN 由焦点中的物体触发。空剪辑无法对焦。

适合您情况的可靠方法是订阅 stage。

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);

KeyboardEvent.KEY_DOWN is triggered by something in focus. Empty clip can not be in focus.

Reliable way for your situation is to subscribe to stage.

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);

按键未触发 KeyboardEvent

灯角 2024-11-26 04:23:16

好吧,

我挖了很长时间,没能找到任何直接传递 CLI 参数的方法。

然而,有一个非常好的解决方法:

  1. 您需要一个类,它是 CLI 参数的解析器和持有者。就我而言,它是具有静态属性的静态类。当然,它在单元测试期间返回空值(无法识别的 CLI 参数)
  2. 您的 CLIArgsHolder 类必须以合理的方式编写,以返回空值,并且在初始化时如果缺少任何 CLI 参数,则不会抛出异常。就我而言,我仅在私有字段为 null 或为空时使用静态属性的 get 进行解析。

    公共静态类 MyCLIArgsHandler
    {
         私有字符串 mAppName = null;
         私有字符串 mStationName = null;
    
         公共字符串 StationName
         {
             得到
             {
                 if(string.isNullOrEmpty(MyCLIArgsHandler.mStationName))
                 {
                    //解析 CLI 参数
                 }
                 返回 MyCLIArgsHandler.mStationName;
             }
         }
         //...
    }
    
  3. 在开始实际测试之前,您可以将示例值注入到该类的字段中,以便:

    <前><代码>[ClassInitialize()]

    公共静态无效MyClassInitialize(TestContext testContext)
    {
    PrivateType 类型 = new PrivateType(typeof (MyCLIArgsHolder));
    type.SetStaticFieldOrProperty("mAppName", "myTestAppName");
    type.SetStaticFieldOrProperty("mStationName", "myTestStationName");
    }

瞧!

现在,您的所有类都可以将 MyCLIArgsHolder 与您在测试类初始化中放入的值一起使用。

Ok,

I was digging for a long time and was not able to find any way to pass CLI arguments directly.

However there is pretty nice workaround:

  1. You need a class which is parser and holder for CLI agruments. In my case it is astatic class with static properties. Of course it was returning null values during unit testing (no recognized CLI arguments)
  2. Your CLIArgsHolder class must be written in a sane way to return nulls and NOT throw exceptions when it initializes if any of CLI args is missing. In my case I parse only when private field is null or empty using static property's get.

    public static class MyCLIArgsHandler
    {
         private string mAppName = null;
         private string mStationName = null;
    
         public string StationName
         {
             get
             {
                 if(string.isNullOrEmpty(MyCLIArgsHandler.mStationName))
                 {
                    //PARSE CLI ARGS
                 }
                 return MyCLIArgsHandler.mStationName;
             }
         }
         //...
    }
    
  3. Before you start actuall testing you can inject sample values to fields of that class so when:

    [ClassInitialize()]
    
    public static void MyClassInitialize(TestContext testContext)
    {            
        PrivateType type = new PrivateType(typeof (MyCLIArgsHolder));
        type.SetStaticFieldOrProperty("mAppName", "myTestAppName");
        type.SetStaticFieldOrProperty("mStationName", "myTestStationName");
    }
    

Voila!

Now all your classes can use your MyCLIArgsHolder with values you put in your test class initialization.

在 Visual Studio 2008 IDE 中运行单元测试时如何传递命令行参数?

灯角 2024-11-26 03:51:08

如果您不需要它是动态的,我会在资源中包含一个字符串数组,然后在即将查看 AutoCompleteTextView 时加载该数组。喜欢:

 public class CountriesActivity extends Activity {
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
         setContentView(R.layout.countries);

         ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                 android.R.layout.simple_dropdown_item_1line, COUNTRIES);
         AutoCompleteTextView textView = (AutoCompleteTextView)
                 findViewById(R.id.countries_list);
         textView.setAdapter(adapter);
     }

     private static final String[] COUNTRIES = new String[] {
         "Belgium", "France", "Italy", "Germany", "Spain"
     };
 }

可以在 http://developer.android.com/reference/ 上找到android/widget/AutoCompleteTextView.html

我已经做过几次的另一种允许它向用户学习的方法是使用 IE 的数据库连接和简单的光标。创建数据库时,您可以插入一些默认值。
这是使用简单光标适配器的示例: http ://androidcommunity.com/forums/f4/how-to-use-autocompletetextview-with-simplecursoradapter-15875/

编辑1:

在用户开始输入之前显示列表的一种想法是在 EditText 下面有一个简单的列表视图。不确定您是否可以调用 autocompletetextview 来显示建议,应该可以。也许您需要创建自己的 autocompletetextiew 类。

If you dont need it to be dynamic I would go by having a string array in the resources, and then just load the array when the AutoCompleteTextView is about to be viewed. Like:

 public class CountriesActivity extends Activity {
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
         setContentView(R.layout.countries);

         ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                 android.R.layout.simple_dropdown_item_1line, COUNTRIES);
         AutoCompleteTextView textView = (AutoCompleteTextView)
                 findViewById(R.id.countries_list);
         textView.setAdapter(adapter);
     }

     private static final String[] COUNTRIES = new String[] {
         "Belgium", "France", "Italy", "Germany", "Spain"
     };
 }

Which can be found on http://developer.android.com/reference/android/widget/AutoCompleteTextView.html

Another way which I have done a couple of times which allows it to learn from the user is o use a database connection with IE a simple cursor. When you create the db you could insert some default values.
Here´s an example with using simple cursor adapter: http://androidcommunity.com/forums/f4/how-to-use-autocompletetextview-with-simplecursoradapter-15875/

Edit 1:

One idea to show the list before the user starts type is to have a simple listview below the EditText. Not sure if you could call the autocompletetextview to show the suggestions, should be possible somehow. Perhaps you need to create your own autocompletetextiew class.

Android:带有默认建议的 AutoCompleteTextView

灯角 2024-11-26 03:26:11

所以你知道你不能参数化表名,但你可以这样做,

cmd.CommandText = String.Format("SELECT {0} FROM [{1}] WHERE {2}={3}",
                "ParentID",
                sTable,
                sWhere,
                "?"

但是当且仅当 sTable 来自用户输入时,这才是危险的。如果您直接控制 sTable 则不必担心。

如果它确实来自用户输入,您将需要保护自己。最简单的方法是确保 sTable 是有效的表、附加表或查询名称。

为此,只需执行

 SELECT Name FROM Myssobjects Where Type in (1,5,6,)  

即可获取 sTable 的有效值列表。

根据您的应用程序,您可能可以执行一次并缓存结果,这样您就不必每次调用此方法时都执行此操作。

So you know that you can't parameterize table names but you could do this

cmd.CommandText = String.Format("SELECT {0} FROM [{1}] WHERE {2}={3}",
                "ParentID",
                sTable,
                sWhere,
                "?"

But this is dangerous if and only if sTable comes from user input. If you directly control the sTable you don't have to worry about it.

If it does indeed come from user input you'll need to protect yourself. The easiest way is to make sure that sTable is a valid table, Attached table, or query name

To do that just execute

 SELECT Name FROM Myssobjects Where Type in (1,5,6,)  

to get the list of valid values for sTable.

Depending on your application you could probably execute it once and cache the results so you don't have do it every time you call this method.

C# - 在表名上使用 OleDbParameter

灯角 2024-11-26 01:55:43

一般方法是仅选择您需要的列
foo->db->tablename->select('all', where date = $date)
快速浏览一下 cakephp 和 symfony 等框架,它可能会帮助您更好地了解它通常是如何完成的。

The general approach will be to select only the columns you need
foo->db->tablename->select('all', where date = $date).
Take a quick look at frameworks such as cakephp and symfony, it might help you get a better idea of how it's generally done.

PHP、OOP 和数据库 - 性能问题

灯角 2024-11-26 00:12:48

Base 无法查看/访问/了解派生对象的任何部分,因此 sizeof 仅报告对其可见的对象部分。更重要的是,Base 方法中的 sizeof 无法知道存在或将会有子类(您可以子类化 Base 而无需重新编译毕竟),所以除了它所知道的部分之外,它无法报告任何内容。 (sizeof 是在编译时而不是运行时计算的。)

Base can't see/access/know about anything that's part of derived objects, so sizeof only reports the part of the object that is visible to it. More to the point, sizeof in a method of Base can't know that there are or will be subclasses (you can subclass Base without recompiling it, after all) so it can't report on anything but the part it knows about. (sizeof is computed at compile time, not run time.)

关键字“this”的实际含义是什么?

灯角 2024-11-26 00:00:15

问题被标记为 C++,但每个人都在使用 C 字符串。以下是如何使用 C++ STL 字符串执行此操作

std::string s("DFF7DF");  

int val;
std::istringstream iss(s);
iss >> std::setbase(16) >> val;

int result = val & 0xFFF;  // take bottom 12 bits

if (val & 0x1000)    // assume sign + magnitude encoding
  result = - result;

(您的问题中的第二个“位摆弄”部分不清楚。如果您澄清的话,我将更新答案。)

The question is tagged C++ but everyone is using C strings. Here's how to do it with a C++ STL string

std::string s("DFF7DF");  

int val;
std::istringstream iss(s);
iss >> std::setbase(16) >> val;

int result = val & 0xFFF;  // take bottom 12 bits

if (val & 0x1000)    // assume sign + magnitude encoding
  result = - result;

(The second "bit-fiddling" part isn't clear from your question. I'll update the answer if you clarify it.)

十六进制和二进制运算

灯角 2024-11-25 23:45:31

我用这个:

SELECT IIF(str1 = str2, 0, -1)

I use this:

SELECT IIF(str1 = str2, 0, -1)

比较 SQL Server 中的两个字符串

更多

推荐作者

束缚m

文章 0 评论 0

alipaysp_VP2a8Q4rgx

文章 0 评论 0

α

文章 0 评论 0

一口甜

文章 0 评论 0

厌味

文章 0 评论 0

转身泪倾城

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文