问:
using AventStack.ExtentReports gives an error
In a YouTube Demo I was given this code and I get this error which has me stumped - 'ExtentReports' does not contain a constructor that takes 2 arguments. is my reference wrong? I am using version 3.03 of ExtentReports</p>

```<code>using NUnit.Framework;
using AventStack.ExtentReports;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

    namespace ExtentDemoYoutube
    {
        [TestFixture]
        public class BasicReport
        {
            public ExtentReports extent;
            public ExtentTest test;

            [OneTimeSetUp]
            public void StartReport()
            {
                string pth = System.Reflection.Assembly.GetCallingAssembly().CodeBase;
                string actualPath = pth.Substring(0, pth.LastIndexOf("bin"));
            string projectPath = new Uri(actualPath).LocalPath;

            string reportPath = projectPath + "Reports\\MyOwnReport.html";

            extent = new ExtentReports(reportPath, true);

            extent.AddSystemInfo("Host Name", "Joe Loyzaga")
                .AddSystemInfo("Environment", "QA")
                .AddSystemInfo("User Name", "Joe Loyzaga");

            extent.LoadConfig(projectPath + "extent-config.xml");

        }

        [Test]
        public void DemoReportPass()
        {
            test = extent.StartTest("DemoReportPass");
            Assert.IsTrue(true);
            test.log(LogStatus.Pass, "Assert Pass as condition is True");
        }

        [Test]
        public void DemoReportFail()
        {
            test = extent.StartTest("DemoReportFail");
            Assert.IsTrue(false);
            test.log(LogStatus.Pass, "Assert Pass as condition is Fail");

        }

        [TearDown]
        public void GetResult()
        {
            var status = TestContext.CurrentContext.Result.Outcome.Status;
            var stackTrace = "```" +TestContext.CurrentContext.Result.StackTrace+"```";
            var errorMessage = TestContext.CurrentContext.Result.Message;

            if(status==NUnit.Framework.Interfaces.TestStatus.Failed)

            {
                test.Log(LogStatus.Fail, stackTrace + errorMessage);
            }
            extent.EndTest(test);
        }

        [OneTimeTearDown]
        public void EndReport()
        {
            extent.Flush();
            extent.Close();
        }

    }
}
</code>```

答:
This is a sample extentreport using selenium that produces a report that uses selenium webdriver</p>

```<code>using AventStack.ExtentReports;
using AventStack.ExtentReports.Reporter;
using AventStack.ExtentReports.Reporter.Configuration;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;

namespace FrameworkForJoe
{
    [TestFixture]
    public class SampleTest
    {
        private static IWebDriver driver;
        private static ExtentReports extent;
        private static ExtentHtmlReporter htmlReporter;
        private static ExtentTest test;

        [OneTimeSetUp]
        public void SetupReporting()
        {
            htmlReporter = new ExtentHtmlReporter(@"C:\Git\joesreport.html");

            htmlReporter.Configuration().Theme = Theme.Dark;

            htmlReporter.Configuration().DocumentTitle = "JoesDocument";

            htmlReporter.Configuration().ReportName = "JoesReport";

            /*htmlReporter.Configuration().JS = "$('.brand-logo').text('test image').prepend('<img src=@"file:///D:\Users\jloyzaga\Documents\FrameworkForJoe\FrameworkForJoe\Capgemini_logo_high_res-smaller-2.jpg"> ')";*/
            htmlReporter.Configuration().JS = "$('.brand-logo').text('').append('<img src=D:\\Users\\jloyzaga\\Documents\\FrameworkForJoe\\FrameworkForJoe\\Capgemini_logo_high_res-smaller-2.jpg>')";
            extent = new ExtentReports();

            extent.AttachReporter(htmlReporter);
        }

        [SetUp]
        public void InitBrowser()
        {
            driver = new ChromeDriver();
            driver.Manage().Window.Maximize();
        }

        [Test]
        public void PassingTest()
        {
            test = extent.CreateTest("Passing test");

            driver.Navigate().GoToUrl("http://www.google.com");

            try {
                Assert.IsTrue(true);
                test.Pass("Assertion passed");
            } catch (AssertionException)
            {
                test.Fail("Assertion failed");
                throw;
            }
        }

        [Test]
        public void FailingTest()
        {
            test = extent.CreateTest("Failing test");

            driver.Navigate().GoToUrl("http://www.yahoo.com");

            try
            {
                Assert.IsTrue(false);
                test.Pass("Assertion passed");
            }
            catch (AssertionException)
            {
                test.Fail("Assertion failed");
                throw;
            }
        }

        [TearDown]
        public void CloseBrowser()
        {
            driver.Quit();
        }

        [OneTimeTearDown]
        public void GenerateReport()
        {
            extent.Flush();
        }
    }
}
</code>```

Body:
In a YouTube Demo I was given this code and I get this error which has me stumped - 'ExtentReports' does not contain a constructor that takes 2 arguments. is my reference wrong? I am using version 3.03 of ExtentReports

using NUnit.Framework;
using AventStack.ExtentReports;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

    namespace ExtentDemoYoutube
    {
        [TestFixture]
        public class BasicReport
        {
            public ExtentReports extent;
            public ExtentTest test;

            [OneTimeSetUp]
            public void StartReport()
            {
                string pth = System.Reflection.Assembly.GetCallingAssembly().CodeBase;
                string actualPath = pth.Substring(0, pth.LastIndexOf("bin"));
            string projectPath = new Uri(actualPath).LocalPath;

            string reportPath = projectPath + "Reports\\MyOwnReport.html";

            extent = new ExtentReports(reportPath, true);

            extent.AddSystemInfo("Host Name", "Joe Loyzaga")
                .AddSystemInfo("Environment", "QA")
                .AddSystemInfo("User Name", "Joe Loyzaga");

            extent.LoadConfig(projectPath + "extent-config.xml");

        }

        [Test]
        public void DemoReportPass()
        {
            test = extent.StartTest("DemoReportPass");
            Assert.IsTrue(true);
            test.log(LogStatus.Pass, "Assert Pass as condition is True");
        }

        [Test]
        public void DemoReportFail()
        {
            test = extent.StartTest("DemoReportFail");
            Assert.IsTrue(false);
            test.log(LogStatus.Pass, "Assert Pass as condition is Fail");

        }

        [TearDown]
        public void GetResult()
        {
            var status = TestContext.CurrentContext.Result.Outcome.Status;
            var stackTrace = "
" +TestContext.CurrentContext.Result.StackTrace+"
";
            var errorMessage = TestContext.CurrentContext.Result.Message;

            if(status==NUnit.Framework.Interfaces.TestStatus.Failed)

            {
                test.Log(LogStatus.Fail, stackTrace + errorMessage);
            }
            extent.EndTest(test);
        }

        [OneTimeTearDown]
        public void EndReport()
        {
            extent.Flush();
            extent.Close();
        }

    }
}

Body:
This is a sample extentreport using selenium that produces a report that uses selenium webdriver

using AventStack.ExtentReports;
using AventStack.ExtentReports.Reporter;
using AventStack.ExtentReports.Reporter.Configuration;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;

namespace FrameworkForJoe
{
    [TestFixture]
    public class SampleTest
    {
        private static IWebDriver driver;
        private static ExtentReports extent;
        private static ExtentHtmlReporter htmlReporter;
        private static ExtentTest test;

        [OneTimeSetUp]
        public void SetupReporting()
        {
            htmlReporter = new ExtentHtmlReporter(@"C:\Git\joesreport.html");

            htmlReporter.Configuration().Theme = Theme.Dark;

            htmlReporter.Configuration().DocumentTitle = "JoesDocument";

            htmlReporter.Configuration().ReportName = "JoesReport";

            /*htmlReporter.Configuration().JS = "$('.brand-logo').text('test image').prepend('<img src=@"file:///D:\Users\jloyzaga\Documents\FrameworkForJoe\FrameworkForJoe\Capgemini_logo_high_res-smaller-2.jpg"> ')";*/
            htmlReporter.Configuration().JS = "$('.brand-logo').text('').append('<img src=D:\\Users\\jloyzaga\\Documents\\FrameworkForJoe\\FrameworkForJoe\\Capgemini_logo_high_res-smaller-2.jpg>')";
            extent = new ExtentReports();

            extent.AttachReporter(htmlReporter);
        }

        [SetUp]
        public void InitBrowser()
        {
            driver = new ChromeDriver();
            driver.Manage().Window.Maximize();
        }

        [Test]
        public void PassingTest()
        {
            test = extent.CreateTest("Passing test");

            driver.Navigate().GoToUrl("http://www.google.com");

            try {
                Assert.IsTrue(true);
                test.Pass("Assertion passed");
            } catch (AssertionException)
            {
                test.Fail("Assertion failed");
                throw;
            }
        }

        [Test]
        public void FailingTest()
        {
            test = extent.CreateTest("Failing test");

            driver.Navigate().GoToUrl("http://www.yahoo.com");

            try
            {
                Assert.IsTrue(false);
                test.Pass("Assertion passed");
            }
            catch (AssertionException)
            {
                test.Fail("Assertion failed");
                throw;
            }
        }

        [TearDown]
        public void CloseBrowser()
        {
            driver.Quit();
        }

        [OneTimeTearDown]
        public void GenerateReport()
        {
            extent.Flush();
        }
    }
}


来源: stackexchange

问:
Order By 2 columns
I have this table and .

```<code> id  |  item_id  | created_at
-----+-----------+------------
  1  |   Apple   | 2017-03-21
  2  |   Grape   | 2017-03-23
  3  |   Grape   | 2017-03-24
  4  |   Apple   | 2017-03-25
</code>```

I want to order by created_at and also at the same time order by item_id like this:

```<code> id  |  item_id  | created_at
-----+-----------+------------
  4  |   Apple   | 2017-03-25
  1  |   Apple   | 2017-03-21
  3  |   Grape   | 2017-03-24
  2  |   Grape   | 2017-03-23
</code>```

So if i add a new row for item_id: Grape my new results should be like this:

```<code> id  |  item_id  | created_at
-----+-----------+------------
  5  |   Grape   | 2017-03-28  (NEW)
  3  |   Grape   | 2017-03-24
  2  |   Grape   | 2017-03-23
  4  |   Apple   | 2017-03-25
  1  |   Apple   | 2017-03-21
</code>```

and then if i add new row for item_id: Apple it should be like this:

```<code> id  |  item_id  | created_at
-----+-----------+------------
  6  |   Apple   | 2017-03-28  (NEW)
  4  |   Apple   | 2017-03-25
  1  |   Apple   | 2017-03-21
  5  |   Grape   | 2017-03-27
  3  |   Grape   | 2017-03-24
  2  |   Grape   | 2017-03-23
</code>```

...So it orders by the latest created_at and show the other rows with the same item_id below it

I have tried ORDER BY created_at, item_id  DESC but it does not works and give me this instead:

```<code> id  |  item_id  | created_at
-----+-----------+------------
  6  |   Apple   | 2017-03-28
  5  |   Grape   | 2017-03-27
  4  |   Apple   | 2017-03-25
  3  |   Grape   | 2017-03-24
  2  |   Grape   | 2017-03-23
  1  |   Apple   | 2017-03-21
</code>```

答:
Here is a mysql version</p>

```<code>set @ordr = 0;
select t.*
from tbl t
join (
    select o.item_id, o.created_at, @ordr := @ordr + 1 as `order`
    from (
        select tbl.item_id, max(tbl.created_at) as created_at
        from tbl
        group by tbl.item_id
        order by created_at desc
    ) as o
) sub
on t.item_id = sub.item_id
order by sub.`order`, sub.created_at desc
</code>```

ContentLicense: CC BY-SA 3.0

Title: Order By 2 columns

Body:
I have this table and .

 id  |  item_id  | created_at
-----+-----------+------------
  1  |   Apple   | 2017-03-21
  2  |   Grape   | 2017-03-23
  3  |   Grape   | 2017-03-24
  4  |   Apple   | 2017-03-25

I want to order by created_at and also at the same time order by item_id like this:

 id  |  item_id  | created_at
-----+-----------+------------
  4  |   Apple   | 2017-03-25
  1  |   Apple   | 2017-03-21
  3  |   Grape   | 2017-03-24
  2  |   Grape   | 2017-03-23

So if i add a new row for item_id: Grape my new results should be like this:

 id  |  item_id  | created_at
-----+-----------+------------
  5  |   Grape   | 2017-03-28  (NEW)
  3  |   Grape   | 2017-03-24
  2  |   Grape   | 2017-03-23
  4  |   Apple   | 2017-03-25
  1  |   Apple   | 2017-03-21

and then if i add new row for item_id: Apple it should be like this:

 id  |  item_id  | created_at
-----+-----------+------------
  6  |   Apple   | 2017-03-28  (NEW)
  4  |   Apple   | 2017-03-25
  1  |   Apple   | 2017-03-21
  5  |   Grape   | 2017-03-27
  3  |   Grape   | 2017-03-24
  2  |   Grape   | 2017-03-23

...So it orders by the latest created_at and show the other rows with the same item_id below it

I have tried ORDER BY created_at, item_id  DESC but it does not works and give me this instead:

 id  |  item_id  | created_at
-----+-----------+------------
  6  |   Apple   | 2017-03-28
  5  |   Grape   | 2017-03-27
  4  |   Apple   | 2017-03-25
  3  |   Grape   | 2017-03-24
  2  |   Grape   | 2017-03-23
  1  |   Apple   | 2017-03-21

Body:
Here is a mysql version

set @ordr = 0;
select t.*
from tbl t
join (
    select o.item_id, o.created_at, @ordr := @ordr + 1 as `order`
    from (
        select tbl.item_id, max(tbl.created_at) as created_at
        from tbl
        group by tbl.item_id
        order by created_at desc
    ) as o
) sub
on t.item_id = sub.item_id
order by sub.`order`, sub.created_at desc


问:
Three20，TTLauncherItem set the image not in @"bundle://12.png"
if the image of TTLauncherItem is not from @"bundle://12.png" but as the following, it would not appear as a image.

```<code>    [pageArray addObject:[[[TTLauncherItem alloc] initWithTitle:[titleArray objectAtIndex:(j+i*pageCount)]
                                                                  image:@"/Users/alex/Library/Application Support/iPhone Simulator/4.1/Applications/457F60DD-86EF-42E3-95F5-3BFC7C223987/Documents/magazine_covers/12.png"
                                                                    URL:@"tt://setUp"
                                                              canDelete:NO] autorelease]];
</code>```

Does this kind of init is not supported?

答:
I am not sure about a direct URL to an image on the file system.
But I do the following for using an image within my project as a TTLauncherItem image:</p>

```<code>NSString* imageName  = @"my-sweet-icon.png";
UIImage* thumbnail = [UIImage imageNamed:@"mySweetImage.png"];
[[TTURLCache sharedCache] storeImage:thumbnail forURL:imageName];
TTLauncherItem* item1 =  [[[TTLauncherItem alloc] initWithTitle:@"Title"
                                                        image:imageName
                                                        URL:@"tt://url" canDelete:NO] autorelease];
</code>```

ContentLicense: CC BY-SA 2.5

Body:
if the image of TTLauncherItem is not from @"bundle://12.png" but as the following, it would not appear as a image.

    [pageArray addObject:[[[TTLauncherItem alloc] initWithTitle:[titleArray objectAtIndex:(j+i*pageCount)]
                                                                  image:@"/Users/alex/Library/Application Support/iPhone Simulator/4.1/Applications/457F60DD-86EF-42E3-95F5-3BFC7C223987/Documents/magazine_covers/12.png"
                                                                    URL:@"tt://setUp"
                                                              canDelete:NO] autorelease]];

Does this kind of init is not supported?

Body:
I am not sure about a direct URL to an image on the file system.
But I do the following for using an image within my project as a TTLauncherItem image:

NSString* imageName  = @"my-sweet-icon.png";
UIImage* thumbnail = [UIImage imageNamed:@"mySweetImage.png"];
[[TTURLCache sharedCache] storeImage:thumbnail forURL:imageName];
TTLauncherItem* item1 =  [[[TTLauncherItem alloc] initWithTitle:@"Title"
                                                        image:imageName
                                                        URL:@"tt://url" canDelete:NO] autorelease];


问:
Celery worker and beat load in one command
Is there a way to start the celery worker and beat in one command? I would like to add celery to my automated deployment procedure with Fabric.

I am currently running:

```<code>celery -A prj worker -B
</code>```

followed by

```<code>celery -A prj beat -l info -S django
</code>```

However, the first command starts the worker and does not allow the next command (starting the beat) to be run because the worker start-up messages appear.

Is there a way to avoid the start-up messages appearing? Or do both of these actions in one command? Perhaps there is even a way to start these from my Django config?

Thanks!

答:
Celery allows for you to run the worker and beat in the same process (mostly used for development purposes). Check out the help for celery worker:

```<code>> celery worker -h

...

Embedded Beat Options:
  -B, --beat            Also run the celery beat periodic task scheduler. Please note that there must only be
                        one instance of this service. .. note:: -B is meant to be used for development
                        purposes. For production environment, you need to start celery beat separately.
  -s SCHEDULE_FILENAME, --schedule-filename SCHEDULE_FILENAME, --schedule SCHEDULE_FILENAME
                        Path to the schedule database if running with the -B option. Defaults to celerybeat-
                        schedule. The extension ".db" may be appended to the filename. Apply optimization
                        profile. Supported: default, fair
  --scheduler SCHEDULER
                        Scheduler class to use. Default is celery.beat.PersistentScheduler
</code>```

So the combined command, including your use of the django scheduler, would be the following:

```<code>celery -A prj worker --beat --scheduler django --loglevel=info
</code>```

Body:
Is there a way to start the celery worker and beat in one command? I would like to add celery to my automated deployment procedure with Fabric.

I am currently running:

celery -A prj worker -B

followed by

celery -A prj beat -l info -S django

However, the first command starts the worker and does not allow the next command (starting the beat) to be run because the worker start-up messages appear.

Is there a way to avoid the start-up messages appearing? Or do both of these actions in one command? Perhaps there is even a way to start these from my Django config?

Thanks!

Body:
Celery allows for you to run the worker and beat in the same process (mostly used for development purposes). Check out the help for celery worker:

> celery worker -h

...

Embedded Beat Options:
  -B, --beat            Also run the celery beat periodic task scheduler. Please note that there must only be
                        one instance of this service. .. note:: -B is meant to be used for development
                        purposes. For production environment, you need to start celery beat separately.
  -s SCHEDULE_FILENAME, --schedule-filename SCHEDULE_FILENAME, --schedule SCHEDULE_FILENAME
                        Path to the schedule database if running with the -B option. Defaults to celerybeat-
                        schedule. The extension ".db" may be appended to the filename. Apply optimization
                        profile. Supported: default, fair
  --scheduler SCHEDULER
                        Scheduler class to use. Default is celery.beat.PersistentScheduler

So the combined command, including your use of the django scheduler, would be the following:

celery -A prj worker --beat --scheduler django --loglevel=info


问:
Custom error messages in package for Laravel 5.x
I am creating a package for Laravel 5.4 and have a few custom regexes with error messages. Normally you put these messages in de validation.php file (which works). But when installing a package I want the user to not have to copy paste those in.

Is there way for a package to have an extra validation language file that will automatically be called when the rule is not found in the regular validation language file?

答:
OK Figured it out.

If you're using Validator::make() call. You can do this

```<code>$fields = [
    "fieldA" => "Testing",
    "fieldB" => "TextB",
];

$rules = [
    "fieldA" => [
        "alpha",
    ],
    "fieldB" => [
        "regex:/TextC/",
    ],
];

$messages = [
    "fieldA.alpha" => "Sorry champ, but fieldA must be only characters",
    "fieldB.regex" => "The regex failed here",
];

$validator = Validator::make($fields, $rules, $messages);
if ($validator->fails()) return $validator->messages()->all();
</code>```

I haven't tested this code - mine is a little different, but this should work.

Reference here: https://laravel.com/docs/5.4/validation#custom-error-messages

Body:
OK Figured it out.

If you're using Validator::make() call. You can do this

$fields = [
    "fieldA" => "Testing",
    "fieldB" => "TextB",
];

$rules = [
    "fieldA" => [
        "alpha",
    ],
    "fieldB" => [
        "regex:/TextC/",
    ],
];

$messages = [
    "fieldA.alpha" => "Sorry champ, but fieldA must be only characters",
    "fieldB.regex" => "The regex failed here",
];

$validator = Validator::make($fields, $rules, $messages);
if ($validator->fails()) return $validator->messages()->all();

I haven't tested this code - mine is a little different, but this should work.

Reference here: https://laravel.com/docs/5.4/validation#custom-error-messages


问:
understanding the creation of the array of lists in python
I was reading about how to declare a matrices in python and I find this question How to define two-dimensional array in python

It's work with me, but I understanding what was done here in part, what I don't understanding is the parameter before the "for" in both loops...So I going to my terminal and testing parts of this for one by one, so when I type:

```<code>0 for x in range(w):
</code>```

I receive:

File "< stdin >", line 1

So I try:

```<code>[0 for x in range(w)] for y in range(h):
</code>```

receive:

File "< stdin >", line 1
      [0 for x in range(w)] for y in range(h):

So I try:

```<code>[0 for x in range(w)]
</code>```

and

```<code>[[0 for x in range(w)] for y in range(h)]
</code>```

and it's work...

So why the loop works when I put the brackets and not work without the brackets?

Thanks in advance.

答: You need the brackets so that the python interpreter processes the operations within the brackets in the correct order. Otherwise, the statement is not being interpreted correctly.</p>

Body:
I was reading about how to declare a matrices in python and I find this question How to define two-dimensional array in python

It's work with me, but I understanding what was done here in part, what I don't understanding is the parameter before the "for" in both loops...So I going to my terminal and testing parts of this for one by one, so when I type:

0 for x in range(w):

I receive:

File "< stdin >", line 1

So I try:

[0 for x in range(w)] for y in range(h):

receive:

File "< stdin >", line 1
      [0 for x in range(w)] for y in range(h):

So I try:

[0 for x in range(w)]

and

[[0 for x in range(w)] for y in range(h)]

and it's work...

So why the loop works when I put the brackets and not work without the brackets?

Thanks in advance.


问:
Matching enum Strings in Java in If conditions
I have an enum:

```<code>public enum Status{
   A("A"),
   B("B"),
   C("C"),
   D("D"),
   E("E")
}
</code>```

A,B,C are in one category and D&E are a different category.
Now when I get a string, I want to decide which category it falls in.
Basically,

```<code>String s;
if   s.equals( Status.A.toString()) || s.equals(Status.B.toString()) || s.equals( Status.C.toString())
            return 1;

        else return 2;
</code>```

Now, this is manageable with 5 letters. If I have 26 letters, the number of if conditions will be unmanageable. Is there a better way to write this?

答:
Rather than deciding the category in the code, store it in the enum itself. You are not limited to a single stored attribute; you can have as many as you wish.

Change the constructor to take the category in addition to the letter, and store it in the enum:

```<code>public enum Status {
    A("A", 1),
    B("B", 1),
    C("C", 1),
    D("D", 2),
    E("E", 2);
    private String name;
    private int category;
    public String getName() { return name; }
    public int getCategory() { return category; }
    Status(String name, int category) {
        this.name = name;
        this.category = category;
    }
}
</code>```

Now it is very clear which enum belongs to what category, because categories are assigned declaratively rather than algorithmically.

Body:
I have an enum:

public enum Status{
   A("A"),
   B("B"),
   C("C"),
   D("D"),
   E("E")
}

A,B,C are in one category and D&E are a different category.
Now when I get a string, I want to decide which category it falls in.
Basically,

String s;
if   s.equals( Status.A.toString()) || s.equals(Status.B.toString()) || s.equals( Status.C.toString())
            return 1;

        else return 2;

Now, this is manageable with 5 letters. If I have 26 letters, the number of if conditions will be unmanageable. Is there a better way to write this?

Body:
Rather than deciding the category in the code, store it in the enum itself. You are not limited to a single stored attribute; you can have as many as you wish.

Change the constructor to take the category in addition to the letter, and store it in the enum:

public enum Status {
    A("A", 1),
    B("B", 1),
    C("C", 1),
    D("D", 2),
    E("E", 2);
    private String name;
    private int category;
    public String getName() { return name; }
    public int getCategory() { return category; }
    Status(String name, int category) {
        this.name = name;
        this.category = category;
    }
}

Now it is very clear which enum belongs to what category, because categories are assigned declaratively rather than algorithmically.


问:
PyQt binding current instance of 'self' to imported UI 'self'
Sorry if there is more correct jargon for what I am trying to convey in the subject line.

lets say i use pyuic on a .ui file generated by Qt 4 Designer and save it as gui.py. Since I shouldn't modify the file as noted in the header by # WARNING! All changes made in this file will be lost!, in another source file I import the Ui_MainWindow from gui.py with from gui import Ui_MainWindow. I subclass QMainWindow and set the ui to the main window from the gui.py with self.ui = Ui_MainWindow() and set it up with self.setupUi(self). My problem is that the auto-complete now doesn't recognize the variables from gui.py in the current file.

How would I set up the editor so when I type self for the results to populate respectively.

```<code>form_class = uic.loadUiType("qt_designed_ui.ui")[0]

class MyWindowClass(QMainWindow, form_class):

    def __init__(self, parent=None):
        super().__init__(parent)

        # bind this subclassed code based UI to the actual UI made with Qt Designer 4
        self.ui = Ui_MainWindow()
        self.setupUi(self)
</code>```

with the above, something like self.ui.var will provide introspection for var, but it's an illegal statement. I must use self.var, which is legal but does not provide introspection. Furthermore, I know self.var works because the entire application works and I address many attributes of the class with that form, I'm just lacking the introspection on PyCharm.

答:
I prefer a single inheritance approach:

```<code>from gui import Ui_MainWindow

class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
</code>```

Introspection on the Ui_MainWindow via self.ui and on QMainWindow via self are both available:

UI components are members of the Ui_MainWindow instance, so they are accessed through self.ui:

```<code>self.text_save = self.ui.txt_save
</code>```

Body:
Sorry if there is more correct jargon for what I am trying to convey in the subject line.

lets say i use pyuic on a .ui file generated by Qt 4 Designer and save it as gui.py. Since I shouldn't modify the file as noted in the header by # WARNING! All changes made in this file will be lost!, in another source file I import the Ui_MainWindow from gui.py with from gui import Ui_MainWindow. I subclass QMainWindow and set the ui to the main window from the gui.py with self.ui = Ui_MainWindow() and set it up with self.setupUi(self). My problem is that the auto-complete now doesn't recognize the variables from gui.py in the current file.

How would I set up the editor so when I type self for the results to populate respectively.

form_class = uic.loadUiType("qt_designed_ui.ui")[0]

class MyWindowClass(QMainWindow, form_class):

    def __init__(self, parent=None):
        super().__init__(parent)

        # bind this subclassed code based UI to the actual UI made with Qt Designer 4
        self.ui = Ui_MainWindow()
        self.setupUi(self)

with the above, something like self.ui.var will provide introspection for var, but it's an illegal statement. I must use self.var, which is legal but does not provide introspection. Furthermore, I know self.var works because the entire application works and I address many attributes of the class with that form, I'm just lacking the introspection on PyCharm.

Body:
I prefer a single inheritance approach:

from gui import Ui_MainWindow

class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

Introspection on the Ui_MainWindow via self.ui and on QMainWindow via self are both available:

UI components are members of the Ui_MainWindow instance, so they are accessed through self.ui:

self.text_save = self.ui.txt_save


问:
Add Reserved IP to Azure Cloud Service
I have a cloud service in Azure that I want to give a reserved IP to.  I basically followed the steps here: https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-reserved-public-ip/

I performed the "New-AzureReservedIP" cmd, giving an ip name of "MyIPName" and a location of the East US - the same location of my current cloud service.

In my service config, I used the following:

```<code>    <NetworkConfiguration>
        <AddressAssignments>
        <ReservedIPs>
        <ReservedIP name="MyIPName"/>
      </ReservedIPs>
    </AddressAssignments>
  </NetworkConfiguration>
</code>```

When I attempted to deploy my cloud service, I got the error "The Reserved IP MyIPName does not exist.  Although I just created it, its not recognizing my aptly named reserved ip address.  Thoughts?

答:
I just had the same problem after creating a Reserved IP through the Azure Portal. The answer from June 2015 did not work for me. For me the solution was to use Powershell to connect to the Azure subscription and then get the FULL name of the Reserved IP and use it in the service config.  The full name of my Reserved IP was in the format "Group {Resource Name} {Reserved IP Name}".

Publishing from Visual Studio 2013 then worked.

To confirm that this wasn't a timing issue I then tried again using only the {Reserved IP Name} value and found that it still did not work (ie received Error: The Reserved IP xyz does not exist.).  Hence it would seem that the full Reserved IP name must be used when it has been created from the Azure Portal and then publishing from Visual Studio.

Note: I am using a Classic app service.

Title: Add Reserved IP to Azure Cloud Service

Body:
I have a cloud service in Azure that I want to give a reserved IP to.  I basically followed the steps here: https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-reserved-public-ip/

I performed the "New-AzureReservedIP" cmd, giving an ip name of "MyIPName" and a location of the East US - the same location of my current cloud service.

In my service config, I used the following:

    <NetworkConfiguration>
        <AddressAssignments>
        <ReservedIPs>
        <ReservedIP name="MyIPName"/>
      </ReservedIPs>
    </AddressAssignments>
  </NetworkConfiguration>

When I attempted to deploy my cloud service, I got the error "The Reserved IP MyIPName does not exist.  Although I just created it, its not recognizing my aptly named reserved ip address.  Thoughts?


问:
What does :: mean in front of a function call?
```<code>I2CDevice::I2CDevice(unsigned int bus, unsigned int device) {
    this->file=-1;
    this->bus = bus;
    this->device = device;
    this->open();
}

int I2CDevice::open(){
   string name;
   if(this->bus==0) name = BBB_I2C_0;
   else name = BBB_I2C_1;

   if((this->file=::open(name.c_str(), O_RDWR)) < 0){
      perror("I2C: failed to open the bus\n");
      return 1;
   }

   if(ioctl(this->file, I2C_SLAVE, this->device) < 0){
      perror("I2C: Failed to connect to the device\n");
      return 1;
   }

   return 0;
}
</code>```

The above is part of a code doing Linux I2C interface, my question is in the line:

```<code>this->file=::open(name.c_str(), O_RDWR)
</code>```

I think this is trying to assign a value to the file descriptor this->file using open() function. But why there is a "::" symbol? Why not just "open()".

答:
That is C++ name resolution. The :: operator separates namespaces. When it starts a name, it is an explicit reference to the top level, global namespace. Its use here guarantees that it is referring to the open function declared by the C library and not any open that happens to be in the class, the current namespace, or any using namespace declarations.

In this specific example, ::open is required because it is inside an open class function. Simply calling open here would cause a name resolution error because there's an open in the class but no matching override. If the arguments did match, it would be a recursive call which isn't what you want.

Body:
I2CDevice::I2CDevice(unsigned int bus, unsigned int device) {
    this->file=-1;
    this->bus = bus;
    this->device = device;
    this->open();
}

int I2CDevice::open(){
   string name;
   if(this->bus==0) name = BBB_I2C_0;
   else name = BBB_I2C_1;

   if((this->file=::open(name.c_str(), O_RDWR)) < 0){
      perror("I2C: failed to open the bus\n");
      return 1;
   }

   if(ioctl(this->file, I2C_SLAVE, this->device) < 0){
      perror("I2C: Failed to connect to the device\n");
      return 1;
   }

   return 0;
}

The above is part of a code doing Linux I2C interface, my question is in the line:

this->file=::open(name.c_str(), O_RDWR)

I think this is trying to assign a value to the file descriptor this->file using open() function. But why there is a "::" symbol? Why not just "open()".


问:
Why this firebase calling always returns null?
Consider the following firebase structure:

```<code>{
  "users": {
    "h7iStd4QvAYWh9xPbsiFuByDd1j1" : {
      "email" : "jobs@apple.com",
      "name" : "Steve Jobs",
      "rank" : 0
    },
    "wkA0DrJs9wdBlfAkJuKIrnhNzyq2" : {
      "email" : "gates@microsoft.com",
      "name" : "Bill Gates",
      "rank" : 0
    }
  }
}
</code>```

and this data retrieval:

```<code>const email = 'jobs@apple.com';

firebase.database().ref('users').equalTo(email, 'email').once('value')
    .then((snapshot) => {

      console.log(email, snapshot.key, snapshot.val());

      // snapshot.val() always returns null

    })
    .catch((error) => {

      console.error(error);

    });
</code>```

Why snapshot.val() returns null? What is the correct approach to fetch the whole object concerning Steve Jobs data, the child with h7iStd4QvAYWh9xPbsiFuByDd1j1 key?

答:
Try this instead:</p>

```<code>firebase.database().ref('users').orderByChild('email').equalTo(email).once('value')
</code>```

Body:
Consider the following firebase structure:

{
  "users": {
    "h7iStd4QvAYWh9xPbsiFuByDd1j1" : {
      "email" : "jobs@apple.com",
      "name" : "Steve Jobs",
      "rank" : 0
    },
    "wkA0DrJs9wdBlfAkJuKIrnhNzyq2" : {
      "email" : "gates@microsoft.com",
      "name" : "Bill Gates",
      "rank" : 0
    }
  }
}

and this data retrieval:

const email = 'jobs@apple.com';

firebase.database().ref('users').equalTo(email, 'email').once('value')
    .then((snapshot) => {

      console.log(email, snapshot.key, snapshot.val());

      // snapshot.val() always returns null

    })
    .catch((error) => {

      console.error(error);

    });

Why snapshot.val() returns null? What is the correct approach to fetch the whole object concerning Steve Jobs data, the child with h7iStd4QvAYWh9xPbsiFuByDd1j1 key?

Body:
Try this instead:

firebase.database().ref('users').orderByChild('email').equalTo(email).once('value')


问:
Have no idea why Facebook login doesn't work
Have no idea why Facebook login doesn't work. Tried all answers to similar questions.The weirdest thing is that there is another app with same settings which works just fine. Maybe there is some kind of update I don't know about.. App runs locally on http://127.0.0.1:8000

Added facebook login product and in value OAuth redirect URLS entered everything possible: localhost,  http://127.0.0.1, http://127.0.0.1:8000

Made app public, tried also creating test app. In app domains it's localhost and in Site Urls I tried both localhost and localhost:8000

EDIT: FB init doesn't even work. So no response to debug or something

And anyways I get this error:

```<code>Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings.
</code>```

Id and code is correct. The same works on different project(Checked id, all comas and etc). What else could be theoretically wrong? At least does the error mean what it says The domain of this URL isn't included in the app's domains. ?

答:
Same problem here, Just started happening with no warning.

I was using .Net Identity 2.0 with Microsoft.Owin.Security.Facebook 3.0.1 however it seems Facebook may have deprecated support for this.

The only symptom I got when debugging is that the call to AuthenticationManager.GetExternalLoginInfoAsync() returns a null which is extremely not useful.

In the end I upgraded to the release candidate using the NuGet Package Manager Console command "Install-Package Microsoft.Owin.Security.Facebook -Pre"

If you're using .Net with this package then I recommend you test this solution in a staging environment first and see if it fixes the issues (and that it doesn't cause any new issues).

Body:
Have no idea why Facebook login doesn't work. Tried all answers to similar questions.The weirdest thing is that there is another app with same settings which works just fine. Maybe there is some kind of update I don't know about.. App runs locally on http://127.0.0.1:8000

Added facebook login product and in value OAuth redirect URLS entered everything possible: localhost,  http://127.0.0.1, http://127.0.0.1:8000

Made app public, tried also creating test app. In app domains it's localhost and in Site Urls I tried both localhost and localhost:8000

EDIT: FB init doesn't even work. So no response to debug or something

And anyways I get this error:

Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings.

Id and code is correct. The same works on different project(Checked id, all comas and etc). What else could be theoretically wrong? At least does the error mean what it says The domain of this URL isn't included in the app's domains. ?


问:
Need explanation on the behaviour of "echo" in batch file (windows)
My problem is that I can echo what I would like to but not the way I want it to. Nonetheless, depending on how I write/arrange the code, I get echo to behave variously, never the way I want it though. Could someone explain me what is happening and why the result is as it is, it would likely help me to understand how I should change my code to make it right. Here are some solutions (limited to 5) and how it then behaves (loop concerns the echo of the second line):

The elements of the matrix I want to echo are (2 rows, commas split columns)

```<code>, rim_no , account_no , observation_date , observation_month , start_date , maturity_date , days_past_due , rate , spread
1, 2517, 1000008332, 20160831, 201608, NA, NA, 0, 17, 0
</code>```

What I want

when it reaches this loop, it just exit and close the command window

```<code>:EchoData
SET _var=""
FOR /L %%H IN (0,1,%_colonne%) DO (
if %%H equ 0 set _var=!_matrice[%_ligneAct%][%%H]!
set _help=!_var!
if %%H gtr 0 set _var=!_help!, !_matrice[%_ligneAct%][%%H]!
)
echo !_var!>>%_fileOut%
</code>```

What works but is slow

Now my first try, which is slow as it echoes element/comma/element/comma... till the end of the line before echoing a line feed

```<code>:EchoData
SET _var=""
FOR /L %%H IN (0,1,%_colonne%) DO (
echo|set /p=!_matrice[%_ligneAct%][%%H]!>>%_fileOut%
if not %%H equ %_colonne% echo|set /p=,>>%_fileOut%
if %%H equ %_colonne% echo.>>%_fileOut%
)
</code>```

the output looks like

```<code>, rim_no , account_no , observation_date , observation_month , start_date , maturity_date , days_past_due , rate , spread
1 , 2517 , 1000008332 , 20160831 , 201608 , NA , NA , 0 , 17 , 0
</code>```

Strange way that echoes both what I want and what I do not, and is slow

Another try that does work, echoing the result twice, first row the slow way, second row the quick way

```<code>:EchoData
SET _var=""
FOR /L %%H IN (0,1,%_colonne%) DO (
if %%H equ 0 set _var=!_matrice[%_ligneAct%][%%H]!
set _help=!_var!
if %%H gtr 0 set _var=!_help!, !_matrice[%_ligneAct%][%%H]!
echo !_var!
echo|set /p=!_matrice[%_ligneAct%][%%H]!>>%_fileOut%
if not %%H equ %_colonne% echo|set /p=,>>%_fileOut%
if %%H equ %_colonne% echo.>>%_fileOut%
)
echo !_var!>>%_fileOut%
</code>```

the output looks like

```<code>, rim_no , account_no , observation_date , observation_month , start_date , maturity_date , days_past_due , rate , spread
1 , 2517 , 1000008332 , 20160831 , 201608 , NA , NA , 0 , 17 , 0
1, 2517, 1000008332, 20160831, 201608, NA, NA, 0, 17, 0
</code>```

Strange way 2

Another strange way, echoes row with commas, then twice my second row

```<code>:EchoData
SET _var=""
FOR /L %%H IN (0,1,%_colonne%) DO (
if %%H equ 0 set _var=!_matrice[%_ligneAct%][%%H]!
set _help=!_var!
if %%H gtr 0 set _var=!_help!, !_matrice[%_ligneAct%][%%H]!
echo !_var!
if not %%H equ %_colonne% echo|set /p=,>>%_fileOut%
if %%H equ %_colonne% echo.>>%_fileOut%
if %%H equ %_colonne% echo|set /p=!_var!>>%_fileOut%
if %%H equ %_colonne% echo.>>%_fileOut%
)
echo !_var!>>%_fileOut%
</code>```

the output looks like

```<code>, rim_no , account_no , observation_date , observation_month , start_date , maturity_date , days_past_due , rate , spread
, , , , , , , , ,
1, 2517, 1000008332, 20160831, 201608, NA, NA, 0, 17, 0
1, 2517, 1000008332, 20160831, 201608, NA, NA, 0, 17, 0
</code>```

Modification of strange way 2

When commenting one line, it then just exit the script and do not echo anything...

```<code>:EchoData
SET _var=""
FOR /L %%H IN (0,1,%_colonne%) DO (
if %%H equ 0 set _var=!_matrice[%_ligneAct%][%%H]!
set _help=!_var!
if %%H gtr 0 set _var=!_help!, !_matrice[%_ligneAct%][%%H]!
echo !_var!
::if not %%H equ %_colonne% echo|set /p=,>>%_fileOut%
if %%H equ %_colonne% echo.>>%_fileOut%
if %%H equ %_colonne% echo|set /p=!_var!>>%_fileOut%
if %%H equ %_colonne% echo.>>%_fileOut%
)
echo !_var!>>%_fileOut%

Basically, I expected solutions 2,3,4 to behave as they do.
I would expect solutions 1 and 5 to behave differently (do not get what is wrong)...
Especially, I do not get why 3 and 4 do work but not 5 and 1. Is it something to do with the echo| set /p?

One more thing is that when echoing the slow way, element by element, it keeps returning "The system cannot find the drive specified".
</code>```

For clarification purposes, I add the full code here (the input file is the file mentioned above, as a csv in my case):

```<code>@ECHO off
SETLOCAL EnableDelayedExpansion

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::Adress of the input and output files
GOTO InFile
:FalseIN
ECHO You need to enter a valid location for the source file.
GOTO InFile
:InFile
ECHO Please enter the location of your file in like C:\Users\VerchieD\Desktop\Command_line\example.csv
SET _fileIn
SET /P _fileIn=Type input: %=%
IF NOT EXIST "%_fileIn%" GOTO FalseIn
ECHO The selected input file to work with is %_fileIn%

:OutFile
echo Please enter the name of your output like C:\Users\VerchieD\Desktop\Command_line\output.csv
SET _fileOut
SET /P _fileOut=Type input: %=%
IF NOT DEFINED "%_fileOut%" set "_fileOut=C:\Users\VerchieD\Desktop\Command_line\Output.csv"
ECHO.>"%_fileOut%"
ECHO The selected output file to work with is %_fileOut%

ECHO stop 1
@PAUSE

SET _countParse=0
SET _countParseBis=0
SET _countNext=0
SET _countNextBis=0
SET _ligneAct=0

SET _ligne=0
SET _colonne=0

CALL :ParseHeader "%_fileIn%"

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
GOTO :eof
::Parse input file header, first element
:ParseHeader
SET /a _countParse+=1
SET _list=%1
SET _list=%_list:"=%
FOR /F "tokens=1* delims=, " %%a IN ('TYPE "%_list%"') DO (
set _matrice[%_ligne%][%_colonne%]=%%a
set /a _colonne+=1
if not "%%b"=="" call :ParseHeaderBis "%%b"
)

GOTO :eof
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
GOTO :eof
::Parse input file header, from second element onward
:ParseHeaderBis
SET /a _countParseBis+=1
SET _list=%1
SET _list=%_list:"=%
FOR /F "tokens=1* delims=, " %%a IN ("%_list%") DO (
set _matrice[%_ligne%][%_colonne%]=%%a
if not "%%b"=="" set /a _colonne+=1
if not "%%b"=="" if %_ligne% equ 0 call :ParseHeaderBis "%%b"
if "%%b"=="" set /a _ligne+=1
)

@PAUSE
IF %_ligne% gtr 0 GOTO :EchoHeader

GOTO :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::Echoes one element at a time for now, will be changed
:EchoHeader
FOR /L %%H IN (0,1,%_colonne%) DO (
::echo The column %%H
::echo variable is !_matrice[0][%%H]!
echo|set /p=!_matrice[0][%%H]!>>%_fileOut%
if not %%H equ %_colonne% echo|set /p=,>>%_fileOut%
if %%H equ %_colonne% echo.>>%_fileOut%
)

@PAUSE

CALL :Next
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
GOTO :eof
::Parse input file data, from second row onward, get lines
:Next
SET /a _countNext+=1
SET /a _ligneAct=%_ligne%
SET _colonne=0
FOR /F "skip=%_ligne% tokens=* delims=" %%a IN ('type "%_fileIn%"') DO (
if not "%%a"=="" call :NextBis "%%a"
if "%%a"=="" goto :eof
)

GOTO :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
GOTO :eof
::Parse the lines from the input file
:NextBis
SET /a _countNextBis+=1
SET _list=%1
SET _list=%_list:"=%
FOR /F "tokens=1* delims=, " %%a IN ("%_list%") DO (
set _matrice[%_ligne%][%_colonne%]=%%a
if not "%%b"==""  set /a _colonne+=1
if not "%%b"==""  if %_ligne% equ %_ligneAct%  call :NextBis "%%b"
if "%%b"==""  set /a _ligne+=1
 )

 IF %_ligne% gtr %_ligneAct% GOTO :EchoData

 GOTO :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:EchoData
::SET _var=""
::FOR /L %%G IN (0,1,%_ligneAct%) DO (
::FOR /L %%H IN (0,1,%_colonne%) DO (
    ::echo The row %%G
    ::echo and column %%H
    ::echo value is !_matrice[%%G][%%H]!
    ::if %%H equ 0 set _var=!_matrice[%_ligneAct%][%%H]!
    ::set _help=!_var!
    ::if %%H gtr 0 set _var=!_help!, !_matrice[%_ligneAct%][%%H]!
    ::echo|set /p=!_matrice[%_ligneAct%][%%H]!>>%_fileOut%
    ::if not %%H equ %_colonne% echo|set /p=,>>%_fileOut%
    ::if %%H equ %_colonne% echo.>>%_fileOut%
    ::if %%H equ %_colonne% echo|set /p=!_var!>>%_fileOut%
    ::if %%H equ %_colonne% echo.>>%_fileOut%
    ::if %%H==0 (set "_var=!_matrice[%_ligneAct%][%%H]!") else (set "_var=!_var!, !_matrice[%_ligneAct%][%%H]!")
    ::echo !_var!
::)
 ::)

 :: for /l %%c in (0 1 %col%) do (
 ::     if %%c==0 ( set "line=!_M[%%r,%%c]!" ) else ( set "line=!line!, !_M[%%r,%%c]!" )
 :: )
 :: echo !line!

>%_fileOut% (
    ::for /l %%r in (0 1 %row%) do (
        set "line="
        for /l %%c in (0 1 %_colonne%) do (
            if %%c==0 ( set "line=!_matrice[%_ligneAct%][%%c]!" ) else ( set "line=!line!, !_matrice[%_ligneAct%][%%c]!" )
        )
        echo !line!
    ::)
)

::echo !_var!>>%_fileOut%
@PAUSE

CALL :Next

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:eof
@PAUSE
</code>```

答:
Your question is confusing and lacks multiple details. Although your explanation is ample and have several examples, you never said what is the output you want. You have shown how several outputs looks, but you didn't said if one of them is the right one, and if not, what is the problem in each case. In this way, your several code examples are practically useless... Also, your problem is not related to "the behaviour of "echo" in batch file".

For this reason, I just shown here an example of the general method to read a bi-dimensional matrix from an input file when the elements are separated by spaces and/or commas (like in your data example), and output such a matrix to the output file:

```<code>@ECHO off
SETLOCAL EnableDelayedExpansion

set "_fileIn=input.txt"
set "_fileOut=output.txt"

rem Read the matrice line by line from the input file
SET /A _ligne=0
for /F "usebackq delims=" %%a in ("%_fileIn%") do (

   rem Separate all fields in this line and store they in the next matrice row
   set /A _ligne+=1, _colonne=0
   for %%b in ( %%a ) do (
      set /A _colonne+=1
      set _matrice[!_ligne!][!_colonne!]=%%b
   )

)

rem Write all matrice lines to the output file
(for /L %%G in (1,1,%_ligne%) do (

   rem Initialize the next output line
   set "_var="

   rem Join to it all elements in this matrice row
   for /L %%H in (1,1,%_colonne%) do set "_var=!_var! , !_matrice[%%G][%%H]!"

   rem Show the line
   echo !_var!

)) > "%_fileOut%"
</code>```

Please, do not reply that this code "does not solve your problem". There is no way that I could solve a problem if I don't know what the problem is.

If you analyze the output of this program and identify what are the differences vs. the desired output, perhaps we could fix the code...

Body:
My problem is that I can echo what I would like to but not the way I want it to. Nonetheless, depending on how I write/arrange the code, I get echo to behave variously, never the way I want it though. Could someone explain me what is happening and why the result is as it is, it would likely help me to understand how I should change my code to make it right. Here are some solutions (limited to 5) and how it then behaves (loop concerns the echo of the second line):

The elements of the matrix I want to echo are (2 rows, commas split columns)

, rim_no , account_no , observation_date , observation_month , start_date , maturity_date , days_past_due , rate , spread
1, 2517, 1000008332, 20160831, 201608, NA, NA, 0, 17, 0

What I want

when it reaches this loop, it just exit and close the command window

:EchoData
SET _var=""
FOR /L %%H IN (0,1,%_colonne%) DO (
if %%H equ 0 set _var=!_matrice[%_ligneAct%][%%H]!
set _help=!_var!
if %%H gtr 0 set _var=!_help!, !_matrice[%_ligneAct%][%%H]!
)
echo !_var!>>%_fileOut%

What works but is slow

Now my first try, which is slow as it echoes element/comma/element/comma... till the end of the line before echoing a line feed

:EchoData
SET _var=""
FOR /L %%H IN (0,1,%_colonne%) DO (
echo|set /p=!_matrice[%_ligneAct%][%%H]!>>%_fileOut%
if not %%H equ %_colonne% echo|set /p=,>>%_fileOut%
if %%H equ %_colonne% echo.>>%_fileOut%
)

the output looks like

, rim_no , account_no , observation_date , observation_month , start_date , maturity_date , days_past_due , rate , spread
1 , 2517 , 1000008332 , 20160831 , 201608 , NA , NA , 0 , 17 , 0

Strange way that echoes both what I want and what I do not, and is slow

Another try that does work, echoing the result twice, first row the slow way, second row the quick way

:EchoData
SET _var=""
FOR /L %%H IN (0,1,%_colonne%) DO (
if %%H equ 0 set _var=!_matrice[%_ligneAct%][%%H]!
set _help=!_var!
if %%H gtr 0 set _var=!_help!, !_matrice[%_ligneAct%][%%H]!
echo !_var!
echo|set /p=!_matrice[%_ligneAct%][%%H]!>>%_fileOut%
if not %%H equ %_colonne% echo|set /p=,>>%_fileOut%
if %%H equ %_colonne% echo.>>%_fileOut%
)
echo !_var!>>%_fileOut%

the output looks like

, rim_no , account_no , observation_date , observation_month , start_date , maturity_date , days_past_due , rate , spread
1 , 2517 , 1000008332 , 20160831 , 201608 , NA , NA , 0 , 17 , 0
1, 2517, 1000008332, 20160831, 201608, NA, NA, 0, 17, 0

Strange way 2

Another strange way, echoes row with commas, then twice my second row

:EchoData
SET _var=""
FOR /L %%H IN (0,1,%_colonne%) DO (
if %%H equ 0 set _var=!_matrice[%_ligneAct%][%%H]!
set _help=!_var!
if %%H gtr 0 set _var=!_help!, !_matrice[%_ligneAct%][%%H]!
echo !_var!
if not %%H equ %_colonne% echo|set /p=,>>%_fileOut%
if %%H equ %_colonne% echo.>>%_fileOut%
if %%H equ %_colonne% echo|set /p=!_var!>>%_fileOut%
if %%H equ %_colonne% echo.>>%_fileOut%
)
echo !_var!>>%_fileOut%

the output looks like

, rim_no , account_no , observation_date , observation_month , start_date , maturity_date , days_past_due , rate , spread
, , , , , , , , ,
1, 2517, 1000008332, 20160831, 201608, NA, NA, 0, 17, 0
1, 2517, 1000008332, 20160831, 201608, NA, NA, 0, 17, 0

Modification of strange way 2

When commenting one line, it then just exit the script and do not echo anything...

:EchoData
SET _var=""
FOR /L %%H IN (0,1,%_colonne%) DO (
if %%H equ 0 set _var=!_matrice[%_ligneAct%][%%H]!
set _help=!_var!
if %%H gtr 0 set _var=!_help!, !_matrice[%_ligneAct%][%%H]!
echo !_var!
::if not %%H equ %_colonne% echo|set /p=,>>%_fileOut%
if %%H equ %_colonne% echo.>>%_fileOut%
if %%H equ %_colonne% echo|set /p=!_var!>>%_fileOut%
if %%H equ %_colonne% echo.>>%_fileOut%
)
echo !_var!>>%_fileOut%

Basically, I expected solutions 2,3,4 to behave as they do.
I would expect solutions 1 and 5 to behave differently (do not get what is wrong)...
Especially, I do not get why 3 and 4 do work but not 5 and 1. Is it something to do with the echo| set /p?

One more thing is that when echoing the slow way, element by element, it keeps returning "The system cannot find the drive specified".

For clarification purposes, I add the full code here (the input file is the file mentioned above, as a csv in my case):

@ECHO off
SETLOCAL EnableDelayedExpansion

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::Adress of the input and output files
GOTO InFile
:FalseIN
ECHO You need to enter a valid location for the source file.
GOTO InFile
:InFile
ECHO Please enter the location of your file in like C:\Users\VerchieD\Desktop\Command_line\example.csv
SET _fileIn
SET /P _fileIn=Type input: %=%
IF NOT EXIST "%_fileIn%" GOTO FalseIn
ECHO The selected input file to work with is %_fileIn%

:OutFile
echo Please enter the name of your output like C:\Users\VerchieD\Desktop\Command_line\output.csv
SET _fileOut
SET /P _fileOut=Type input: %=%
IF NOT DEFINED "%_fileOut%" set "_fileOut=C:\Users\VerchieD\Desktop\Command_line\Output.csv"
ECHO.>"%_fileOut%"
ECHO The selected output file to work with is %_fileOut%

ECHO stop 1
@PAUSE

SET _countParse=0
SET _countParseBis=0
SET _countNext=0
SET _countNextBis=0
SET _ligneAct=0

SET _ligne=0
SET _colonne=0

CALL :ParseHeader "%_fileIn%"

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
GOTO :eof
::Parse input file header, first element
:ParseHeader
SET /a _countParse+=1
SET _list=%1
SET _list=%_list:"=%
FOR /F "tokens=1* delims=, " %%a IN ('TYPE "%_list%"') DO (
set _matrice[%_ligne%][%_colonne%]=%%a
set /a _colonne+=1
if not "%%b"=="" call :ParseHeaderBis "%%b"
)

GOTO :eof
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
GOTO :eof
::Parse input file header, from second element onward
:ParseHeaderBis
SET /a _countParseBis+=1
SET _list=%1
SET _list=%_list:"=%
FOR /F "tokens=1* delims=, " %%a IN ("%_list%") DO (
set _matrice[%_ligne%][%_colonne%]=%%a
if not "%%b"=="" set /a _colonne+=1
if not "%%b"=="" if %_ligne% equ 0 call :ParseHeaderBis "%%b"
if "%%b"=="" set /a _ligne+=1
)

@PAUSE
IF %_ligne% gtr 0 GOTO :EchoHeader

GOTO :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::Echoes one element at a time for now, will be changed
:EchoHeader
FOR /L %%H IN (0,1,%_colonne%) DO (
::echo The column %%H
::echo variable is !_matrice[0][%%H]!
echo|set /p=!_matrice[0][%%H]!>>%_fileOut%
if not %%H equ %_colonne% echo|set /p=,>>%_fileOut%
if %%H equ %_colonne% echo.>>%_fileOut%
)

@PAUSE

CALL :Next
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
GOTO :eof
::Parse input file data, from second row onward, get lines
:Next
SET /a _countNext+=1
SET /a _ligneAct=%_ligne%
SET _colonne=0
FOR /F "skip=%_ligne% tokens=* delims=" %%a IN ('type "%_fileIn%"') DO (
if not "%%a"=="" call :NextBis "%%a"
if "%%a"=="" goto :eof
)

GOTO :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
GOTO :eof
::Parse the lines from the input file
:NextBis
SET /a _countNextBis+=1
SET _list=%1
SET _list=%_list:"=%
FOR /F "tokens=1* delims=, " %%a IN ("%_list%") DO (
set _matrice[%_ligne%][%_colonne%]=%%a
if not "%%b"==""  set /a _colonne+=1
if not "%%b"==""  if %_ligne% equ %_ligneAct%  call :NextBis "%%b"
if "%%b"==""  set /a _ligne+=1
 )

 IF %_ligne% gtr %_ligneAct% GOTO :EchoData

 GOTO :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:EchoData
::SET _var=""
::FOR /L %%G IN (0,1,%_ligneAct%) DO (
::FOR /L %%H IN (0,1,%_colonne%) DO (
    ::echo The row %%G
    ::echo and column %%H
    ::echo value is !_matrice[%%G][%%H]!
    ::if %%H equ 0 set _var=!_matrice[%_ligneAct%][%%H]!
    ::set _help=!_var!
    ::if %%H gtr 0 set _var=!_help!, !_matrice[%_ligneAct%][%%H]!
    ::echo|set /p=!_matrice[%_ligneAct%][%%H]!>>%_fileOut%
    ::if not %%H equ %_colonne% echo|set /p=,>>%_fileOut%
    ::if %%H equ %_colonne% echo.>>%_fileOut%
    ::if %%H equ %_colonne% echo|set /p=!_var!>>%_fileOut%
    ::if %%H equ %_colonne% echo.>>%_fileOut%
    ::if %%H==0 (set "_var=!_matrice[%_ligneAct%][%%H]!") else (set "_var=!_var!, !_matrice[%_ligneAct%][%%H]!")
    ::echo !_var!
::)
 ::)

 :: for /l %%c in (0 1 %col%) do (
 ::     if %%c==0 ( set "line=!_M[%%r,%%c]!" ) else ( set "line=!line!, !_M[%%r,%%c]!" )
 :: )
 :: echo !line!

>%_fileOut% (
    ::for /l %%r in (0 1 %row%) do (
        set "line="
        for /l %%c in (0 1 %_colonne%) do (
            if %%c==0 ( set "line=!_matrice[%_ligneAct%][%%c]!" ) else ( set "line=!line!, !_matrice[%_ligneAct%][%%c]!" )
        )
        echo !line!
    ::)
)

::echo !_var!>>%_fileOut%
@PAUSE

CALL :Next

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:eof
@PAUSE

Body:
Your question is confusing and lacks multiple details. Although your explanation is ample and have several examples, you never said what is the output you want. You have shown how several outputs looks, but you didn't said if one of them is the right one, and if not, what is the problem in each case. In this way, your several code examples are practically useless... Also, your problem is not related to "the behaviour of "echo" in batch file".

For this reason, I just shown here an example of the general method to read a bi-dimensional matrix from an input file when the elements are separated by spaces and/or commas (like in your data example), and output such a matrix to the output file:

@ECHO off
SETLOCAL EnableDelayedExpansion

set "_fileIn=input.txt"
set "_fileOut=output.txt"

rem Read the matrice line by line from the input file
SET /A _ligne=0
for /F "usebackq delims=" %%a in ("%_fileIn%") do (

   rem Separate all fields in this line and store they in the next matrice row
   set /A _ligne+=1, _colonne=0
   for %%b in ( %%a ) do (
      set /A _colonne+=1
      set _matrice[!_ligne!][!_colonne!]=%%b
   )

)

rem Write all matrice lines to the output file
(for /L %%G in (1,1,%_ligne%) do (

   rem Initialize the next output line
   set "_var="

   rem Join to it all elements in this matrice row
   for /L %%H in (1,1,%_colonne%) do set "_var=!_var! , !_matrice[%%G][%%H]!"

   rem Show the line
   echo !_var!

)) > "%_fileOut%"

Please, do not reply that this code "does not solve your problem". There is no way that I could solve a problem if I don't know what the problem is.

If you analyze the output of this program and identify what are the differences vs. the desired output, perhaps we could fix the code...


问:
jQuery / Javascript: Show Image when link is clicked. Then when another link clicked, show different image, while hiding the previous visible image
I have 4 images and 4 links referencing each image.

Image 1 will appear by default. When users click on link 2, image 2 will replace image 1 and so on with link 3 & 4.

I've set the html as a list item like so:

```<code><ul class="nav-tabs">

    <li>
        <img class="activeImg" src="img1.jpg" />
        <img src="img2.jpg" />
        <img src="img3.jpg" />
        <img src="img4.jpg" />
    </li>

    <li><a href="#">Link 1</a></li>
    <li><a href="#">Link 2</a></li>
    <li><a href="#">Link 3</a></li>
    <li><a href="#">Link 4</a></li>

</ul>
</code>```

Css:

```<code>.nav-tabs li img.activeImg{
    visibility: visible;
    }
</code>```

jQuery:

```<code>$('.nav-tabs li:nth-child(2)').click(function(){
    $('.nav-tabs li img:nth-child(1)').addClass("activeImg");
    $('.nav-tabs li img:nth-child(2)').hide();
});

$('.nav-tabs li:nth-child(3)').click(function(){
    $('.nav-tabs li img:nth-child(2)').addClass("activeImg");
    $('.nav-tabs li img:nth-child(1)').hide();
});
</code>```

This doesn't work well since it hides everything.

I need help as you can see. Please provide some working examples in either jquery or javascript.

答:
HTML and JS only can do what you want(no css needed):

```<code><ul class="nav-tabs">
    <li>
        <img src="http://cue.me/kohana/media/frontend/js/full-page-scroll/examples/imgs/bg3.jpg" />
    </li>
    <li><a href="#" onclick="changeImage('http://cue.me/kohana/media/frontend/js/full-page-scroll/examples/imgs/bg3.jpg')">Link 1</a></li>
    <li><a href="#" onclick="changeImage('http://cue.me/kohana/media/frontend/js/full-page-scroll/examples/imgs/bg2.jpg')">Link 2</a></li>
    <li><a href="#" onclick="changeImage('https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSQ7r5XGxggyodPsnaEkQ9SAWjx1-zx8NKDkBz0EXATC78u-gBd')">Link 3</a></li>
    <li><a href="#" onclick="changeImage('https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQpsAzFOuzE07HdIByvXNGeBeflF-9wRpdDHAYKfkQQQjS1AiOZ')">Link 4</a></li>
</ul>

<script>
    function changeImage(img_name){
      document.getElementsByTagName('img')[0].src = img_name
    }
</script>
</code>```

TRY IT HERE https://jsfiddle.net/hnb9Lko3/1/

Body:
I have 4 images and 4 links referencing each image.

Image 1 will appear by default. When users click on link 2, image 2 will replace image 1 and so on with link 3 & 4.

I've set the html as a list item like so:

Link 1

Link 2

Link 3

Link 4

Css:

.nav-tabs li img.activeImg{
    visibility: visible;
    }

jQuery:

$('.nav-tabs li:nth-child(2)').click(function(){
    $('.nav-tabs li img:nth-child(1)').addClass("activeImg");
    $('.nav-tabs li img:nth-child(2)').hide();
});

$('.nav-tabs li:nth-child(3)').click(function(){
    $('.nav-tabs li img:nth-child(2)').addClass("activeImg");
    $('.nav-tabs li img:nth-child(1)').hide();
});

This doesn't work well since it hides everything.

I need help as you can see. Please provide some working examples in either jquery or javascript.

Body:
HTML and JS only can do what you want(no css needed):

<ul class="nav-tabs">
    <li>
        <img src="http://cue.me/kohana/media/frontend/js/full-page-scroll/examples/imgs/bg3.jpg" />
    </li>
    <li><a href="#" onclick="changeImage('http://cue.me/kohana/media/frontend/js/full-page-scroll/examples/imgs/bg3.jpg')">Link 1</a></li>
    <li><a href="#" onclick="changeImage('http://cue.me/kohana/media/frontend/js/full-page-scroll/examples/imgs/bg2.jpg')">Link 2</a></li>
    <li><a href="#" onclick="changeImage('https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSQ7r5XGxggyodPsnaEkQ9SAWjx1-zx8NKDkBz0EXATC78u-gBd')">Link 3</a></li>
    <li><a href="#" onclick="changeImage('https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQpsAzFOuzE07HdIByvXNGeBeflF-9wRpdDHAYKfkQQQjS1AiOZ')">Link 4</a></li>
</ul>

<script>
    function changeImage(img_name){
      document.getElementsByTagName('img')[0].src = img_name
    }
</script>

TRY IT HERE https://jsfiddle.net/hnb9Lko3/1/


问:
Hibernate postgresql comparing date
I'm using Hibernate and PostgreSQL 8.4 database in a Java application. I have the following query:

```<code>Query q = session.createQuery("from User where validStartDate < "  + getDate() +" and validEndDate >" + getDate());
</code>```

where validStartDate is a Date in a PostgreSQL database and getDate returns a String from the current date by using the SimpleDateFormat.

But I keep getting an error:

```<code>Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: date < integer
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1592)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1327)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:192)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:350)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254)
        at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
        at org.hibernate.loader.Loader.doQuery(Loader.java:674)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
        at org.hibernate.loader.Loader.doList(Loader.java:2220)
        ... 49 more
2010-11-29 20:42:19 org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 0, SQLState: 42883
2010-11-29 20:42:19 org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: ERROR: operator does not exist: date < integer
</code>```

How do I cast the value so it is of proper type Date rather than integer?

Thanks for help.

答: I'd suggest using parameters in your query and let the postgres driver handling converting from Strings to the appropriate types/escaping for you - this is why parameterized queries exist.</p>

Title: Hibernate postgresql comparing date

Body:
I'm using Hibernate and PostgreSQL 8.4 database in a Java application. I have the following query:

Query q = session.createQuery("from User where validStartDate < "  + getDate() +" and validEndDate >" + getDate());

where validStartDate is a Date in a PostgreSQL database and getDate returns a String from the current date by using the SimpleDateFormat.

But I keep getting an error:

Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: date < integer
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1592)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1327)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:192)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:350)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254)
        at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
        at org.hibernate.loader.Loader.doQuery(Loader.java:674)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
        at org.hibernate.loader.Loader.doList(Loader.java:2220)
        ... 49 more
2010-11-29 20:42:19 org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 0, SQLState: 42883
2010-11-29 20:42:19 org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: ERROR: operator does not exist: date < integer

How do I cast the value so it is of proper type Date rather than integer?

Thanks for help.


问:
How to do excel formula that would Sum values from column C if column A is 'X' or 'Y' and column B is 'Z'?
I have a spreadsheet from which I need to pick out some specific values that are in one of text columns but only if other column matches the year.

I have tried following SUM with IF but I think OR portion in textual column is failing...

=SUM(IF(B:B="*Nuoma*",B:B="*(Nuomininko)*",C:C=2016,D:D))

What I need is if in column B value contains Nuoma OR (Nuomininko) AND column C is 2016 then SUM column D...

答:
Try,

```<code>=SUM(SUMIFS(D:D, B:B, {"*Nuoma*","*(Nuomininko)*"}, C:C, 2016))
</code>```

The {"*Nuoma*","*(Nuomininko)*"} provides the OR to a wildcard match on Nuoma or a wildcard match containing (Nuomininko). You must wrap the SUMIFS in a SUM but no CSE is required.

Body:
Try,

=SUM(SUMIFS(D:D, B:B, {"*Nuoma*","*(Nuomininko)*"}, C:C, 2016))

The {"*Nuoma*","*(Nuomininko)*"} provides the OR to a wildcard match on Nuoma or a wildcard match containing (Nuomininko). You must wrap the SUMIFS in a SUM but no CSE is required.


问:
C# ErrorProvider Want to know if any are Active
I want to know if any ErrorProvider are active in my form.
being able to find this out might help reduce my code..

I did find this thing here Counting ErrorProvider

but incase someone knows a better way... so here goes.

Ok so basically I have a WinForm which has many TextBoxes
Now when user enters values I use Validating to perform validation and if it does not match Regex I set the ErrorProvider ON for that Control.. similarly if the user changes the value to a acceptable one I switch ErrorProvider OFF for that Control..

but when SAVE is clicked i have to do another check anyways incase the user did not listen to me and change the thing like he was supposed to and still clicked SAVE.. I dont want the thing crashing..

soo mm is there like a thing where I could say if ErrorProviders is not active then proceed with save else message box saying change it.

[ANOTHER QUESTION]

Umm When Validating it only Validates when the Control loses Focus... I kinda of want it to do validation when user stops typing.. I hope you get what I mean

Like Email Address(textbox) when user is typing his/her name in I [DON'T] want it to do validation yet, but when user has finished entering is waiting for ErrorProvider to disappear(But it doesn't coz it only does that when control loses focus) 2 odd seconds after typing can i make the validation take place?

答:
It seems like a logical thing to have but unfortunately it's not provided natively.

You could extend the ErrorProvider as other mentioned, or simply iterate all the controls under it and look for an error, something like

```<code>bool IsValidationError(ErrorProvider errorProvider, Control.ControlCollection controlCollection)
{
    foreach(Control child in controlCollection)
    {
        // The child or one of its children has an error.
        if (!errorProvider.GetError(child).IsNullOrEmpty() || IsValidationError(errorProvider, child.Controls))
            return true;
    }

    return false;
}
</code>```

and you'd call IsValidationError(errorProvider, errorProvider.ContainerControl.Controls), or passing a more limited control collection.

Obviously you'd want to avoid iterating tons of controls, but that simple solution should be fine in lots of cases. Also even if you do have tons of controls, you'd probably group them together using Panel, TabControl, GroupBox, ... so you could easily avoid iterating absolutely all the controls.

Note: this is similar to one of the possibilities described in https://stackoverflow.com/a/12327212/276648 except it looks for both null and empty, and it iterates possible grand children recursively.

Body:
It seems like a logical thing to have but unfortunately it's not provided natively.

You could extend the ErrorProvider as other mentioned, or simply iterate all the controls under it and look for an error, something like

bool IsValidationError(ErrorProvider errorProvider, Control.ControlCollection controlCollection)
{
    foreach(Control child in controlCollection)
    {
        // The child or one of its children has an error.
        if (!errorProvider.GetError(child).IsNullOrEmpty() || IsValidationError(errorProvider, child.Controls))
            return true;
    }

    return false;
}

and you'd call IsValidationError(errorProvider, errorProvider.ContainerControl.Controls), or passing a more limited control collection.

Obviously you'd want to avoid iterating tons of controls, but that simple solution should be fine in lots of cases. Also even if you do have tons of controls, you'd probably group them together using Panel, TabControl, GroupBox, ... so you could easily avoid iterating absolutely all the controls.

Note: this is similar to one of the possibilities described in https://stackoverflow.com/a/12327212/276648 except it looks for both null and empty, and it iterates possible grand children recursively.


问:
Are my subclasses causing memory leaks?
I'm subclassing UINavigationController and UITableview and for some reason, my views are leaking memory, although I've implemented all of the proper methods and release calls. When I use the native class instead of a subclass, everything works just fine, without leaking.

EDIT:

Here's my superclass header:

```<code>//
//  MBAbstractViewController.h
//  GabbaiHD
//
//  Created by Moshe Berman on 11/24/10.
//  Copyright 2010 MosheBerman.com. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface MBAbstractViewController : UIViewController {
    IBOutlet UIImageView *backgroundImageView;
    NSString *announcementText;
}

@property (nonatomic, retain) NSString *type;
@property (nonatomic, retain) NSDictionary *options;
@property (nonatomic, retain) NSString *announcementText;

-(void) setAnnouncementText:(NSString *)text;

@end
</code>```

Superclass implementation:

```<code>//
//  MBAbstractViewController.m
//  GabbaiHD
//
//  Created by Moshe Berman on 11/24/10.
//  Copyright 2010 MosheBerman.com. All rights reserved.
//

#import "MBAbstractViewController.h"

@implementation MBAbstractViewController

@synthesize type, options, announcementText;

 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
    UIColor *clearColor = [[UIColor alloc] colorWithAlphaComponent:0.0];
    [self.view setBackgroundColor: clearColor];
    [clearColor release];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||  interfaceOrientation == UIInterfaceOrientationLandscapeRight){
        return YES;
    }else{
        return NO;
    }
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;

}

- (void)dealloc {
    [announcementText release];
    [options release];
    [type release];
    [super dealloc];
}

@end
</code>```

Here's my subclass header:

```<code>//
//  MBAnnouncementViewController.h
//  GabbaiHD
//
//  Created by Moshe Berman on 11/24/10.
//  Copyright 2010 MosheBerman.com. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "MBAbstractViewController.h"

@interface MBAnnouncementViewController : MBAbstractViewController {
    IBOutlet UILabel *announcement;
}

- (void) setAnnouncementText:(NSString *)text withSize:(CGFloat)size;

@end
</code>```

and the subclass implementation:

```<code>        //
//  MBAnnouncementViewController.m
//  GabbaiHD
//
//  Created by Moshe Berman on 11/24/10.
//  Copyright 2010 MosheBerman.com. All rights reserved.
//

#import "MBAnnouncementViewController.h"
#import "Constants.h"[

@implementation MBAnnouncementViewController

 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];

    [announcement setText:announcementText];

    UIImage *slideImage = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[[NSString stringWithFormat:@"%@_slide", kTheme]description] ofType:@"png"]];
    [backgroundImageView setImage:slideImage];
    [slideImage release];

}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return YES;
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc. that aren't in use.
}

- (void) setAnnouncementText:(NSString *)text withSize:(CGFloat)size{
    UIFont *font = [[UIFont alloc] fontWithSize:size];
    [announcement setFont:font];
    [font release];
    [announcement setText:text];

}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)dealloc {
    [announcementText release];
    [super dealloc];
}

@end
</code>```

What could be causing memory leaks in a subclass? Am I missing something? (There is more relevant code here.)

答:
According to the UIViewController documentation

... if your view controller contains
  outlets (properties or raw variables
  that contain the IBOutlet keyword),
  you should use the viewDidUnload
  method to relinquish ownership of
  those outlets or any other
  view-related data that you no longer
  need.

Try releasing announcement in the viewDidUnload since it's an IBOutlet, Interface Builder retains it.

```<code>- (void)viewDidUnload {
    [super viewDidUnload];
    [announcement release];
    announcement = nil;
}
</code>```

Title: Are my subclasses causing memory leaks?

Body:
I'm subclassing UINavigationController and UITableview and for some reason, my views are leaking memory, although I've implemented all of the proper methods and release calls. When I use the native class instead of a subclass, everything works just fine, without leaking.

EDIT:

Here's my superclass header:

//
//  MBAbstractViewController.h
//  GabbaiHD
//
//  Created by Moshe Berman on 11/24/10.
//  Copyright 2010 MosheBerman.com. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface MBAbstractViewController : UIViewController {
    IBOutlet UIImageView *backgroundImageView;
    NSString *announcementText;
}

@property (nonatomic, retain) NSString *type;
@property (nonatomic, retain) NSDictionary *options;
@property (nonatomic, retain) NSString *announcementText;

-(void) setAnnouncementText:(NSString *)text;

@end

Superclass implementation:

//
//  MBAbstractViewController.m
//  GabbaiHD
//
//  Created by Moshe Berman on 11/24/10.
//  Copyright 2010 MosheBerman.com. All rights reserved.
//

#import "MBAbstractViewController.h"

@implementation MBAbstractViewController

@synthesize type, options, announcementText;

 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
    UIColor *clearColor = [[UIColor alloc] colorWithAlphaComponent:0.0];
    [self.view setBackgroundColor: clearColor];
    [clearColor release];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||  interfaceOrientation == UIInterfaceOrientationLandscapeRight){
        return YES;
    }else{
        return NO;
    }
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;

}

- (void)dealloc {
    [announcementText release];
    [options release];
    [type release];
    [super dealloc];
}

@end

Here's my subclass header:

//
//  MBAnnouncementViewController.h
//  GabbaiHD
//
//  Created by Moshe Berman on 11/24/10.
//  Copyright 2010 MosheBerman.com. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "MBAbstractViewController.h"

@interface MBAnnouncementViewController : MBAbstractViewController {
    IBOutlet UILabel *announcement;
}

- (void) setAnnouncementText:(NSString *)text withSize:(CGFloat)size;

@end

and the subclass implementation:

        //
//  MBAnnouncementViewController.m
//  GabbaiHD
//
//  Created by Moshe Berman on 11/24/10.
//  Copyright 2010 MosheBerman.com. All rights reserved.
//

#import "MBAnnouncementViewController.h"
#import "Constants.h"[

@implementation MBAnnouncementViewController

 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];

    [announcement setText:announcementText];

    UIImage *slideImage = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[[NSString stringWithFormat:@"%@_slide", kTheme]description] ofType:@"png"]];
    [backgroundImageView setImage:slideImage];
    [slideImage release];

}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return YES;
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc. that aren't in use.
}

- (void) setAnnouncementText:(NSString *)text withSize:(CGFloat)size{
    UIFont *font = [[UIFont alloc] fontWithSize:size];
    [announcement setFont:font];
    [font release];
    [announcement setText:text];

}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)dealloc {
    [announcementText release];
    [super dealloc];
}

@end

What could be causing memory leaks in a subclass? Am I missing something? (There is more relevant code here.)

Body:
According to the UIViewController documentation

... if your view controller contains
  outlets (properties or raw variables
  that contain the IBOutlet keyword),
  you should use the viewDidUnload
  method to relinquish ownership of
  those outlets or any other
  view-related data that you no longer
  need.

Try releasing announcement in the viewDidUnload since it's an IBOutlet, Interface Builder retains it.

- (void)viewDidUnload {
    [super viewDidUnload];
    [announcement release];
    announcement = nil;
}


问:
XMLStarlet: Using xpath to move an element to be before another one
Given:

```<code><x>
  <a />
  <d />
  <b />
  <c />
  <e />
  <f />
</x>
</code>```

I would like to use xmlstarlet to move <d /> to be before <e />.

The closest I've got is:

```<code>echo .. | xml ed -m "//d" "//e"
</code>```

Which produces:

```<code><e>
  <d/>
</a>
</code>```

This is unfortunately the example the manual gives.

```<code>echo .. | xml ed -m "//d" "//x"
</code>```

Puts <d /> at the end, which is not the right place.

I tried to get preceding-sibling to work (if indeed that is right approach), but while:

```<code>echo .. | xml sel -t -c "//e/preceding-sibling::*[1]"
</code>```

Results in <c />, that query doesn't work as a move destination (it complains that move destination is not a single node), nor would it really, since best case would be it would end up inside <c />.

I'm not sure if ed -m is the wrong approach, of if there is a form of XPATH which points to a location between elements instead of an element.

Edit: interestingly insert works more like how I'd expect, inserting what you pass it before the element picked with xpath:

```<code>$ xml ed -i "//c" -t elem -n "foo" -v "bar" test.xml
<?xml version="1.0"?>
<x>
  <a/>
  <d/>
  <b/>
  <foo>bar</foo>
  <c/>
  <e/>
  <f/>
</x>
</code>```

Unfortunately the value passed (bar above) cannot be XML, so I could pick it out of somewhere with sel and then inject it in with this command I don't think.

答:
This seems like it should be easy using ed. If it is, I'm not seeing it. (I don't use xmlstarlet very often.)

You may need to use XSLT...

XSLT 1.0

```<code><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output indent="yes"/>
  <xsl:strip-space elements="*"/>

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()[not(self::d)]"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="c">
    <xsl:copy-of select="."/>
    <xsl:copy-of select="../d"/>
  </xsl:template>

</xsl:stylesheet>
</code>```

Command Line

$ xml tr test.xsl test.xml
<?xml version="1.0"?>
<x>

  <c/>
  <d/>
  <e/>
  <f/>
</x>
```

Body:
Given:

<x>

  <d />

  <c />
  <e />
  <f />
</x>

I would like to use xmlstarlet to move <d /> to be before <e />.

The closest I've got is:

echo .. | xml ed -m "//d" "//e"

Which produces:

<e>
  <d/>

This is unfortunately the example the manual gives.

echo .. | xml ed -m "//d" "//x"

Puts <d /> at the end, which is not the right place.

I tried to get preceding-sibling to work (if indeed that is right approach), but while:

echo .. | xml sel -t -c "//e/preceding-sibling::*[1]"

Results in <c />, that query doesn't work as a move destination (it complains that move destination is not a single node), nor would it really, since best case would be it would end up inside <c />.

I'm not sure if ed -m is the wrong approach, of if there is a form of XPATH which points to a location between elements instead of an element.

Edit: interestingly insert works more like how I'd expect, inserting what you pass it before the element picked with xpath:

$ xml ed -i "//c" -t elem -n "foo" -v "bar" test.xml
<?xml version="1.0"?>
<x>

  <d/>

  <foo>bar</foo>
  <c/>
  <e/>
  <f/>
</x>

Unfortunately the value passed (bar above) cannot be XML, so I could pick it out of somewhere with sel and then inject it in with this command I don't think.

Body:
This seems like it should be easy using ed. If it is, I'm not seeing it. (I don't use xmlstarlet very often.)

You may need to use XSLT...

XSLT 1.0

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output indent="yes"/>
  <xsl:strip-space elements="*"/>

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()[not(self::d)]"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="c">
    <xsl:copy-of select="."/>
    <xsl:copy-of select="../d"/>
  </xsl:template>

</xsl:stylesheet>

Command Line

$ xml tr test.xsl test.xml
<?xml version="1.0"?>
<x>
  <a/>
  <b/>
  <c/>
  <d/>
  <e/>
  <f/>
</x>


问:
Restricting Uniques from Showing
I currently have this SQL query and this output.

```<code>SELECT b.HotelNo,g.guestName,b.dateFrom,b.dateToFrom Booking b, Guest g
FROM Booking b, Guest g
WHERE b.guestNo = g.guestNo
GROUP BY b.hotelNo,b.dateFrom,b.dateTo,g.guestName;
</code>```

I am getting this output:
Output

How do I remove all the rows that are not duplicates of first two columns?

Output would be (In words Get all the hotel numbers guest names and dates of stay of all guest only if they have stayed in the same hotel more than once):

```<code>1234 John Doe 2017-02-01 00:00:00.000 2017-02-28 00:00:00.000
1234 John Doe 2017-03-16 00:00:00.000 2017-03-21 00:00:00.000
</code>```

EDIT:

I got what I wanted but I when I add b.dateFrom,b.dateTo into my select statement. I get an error saying: Column 'Booking.dateFrom' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

This is the SQL query that gets this error:

```<code>SELECT b.hotelNo,g.guestName,b.dateFrom,b.dateTo
FROM Booking b, Guest g
WHERE b.guestNo = g.guestNo
GROUP BY b.hotelNo,g.guestName
HAVING COUNT(*) > 1;
</code>```

If I add those two column names in (which I need) I get the error above. How do I add them in without getting an error?

答:
If you want only those who have stayed in a hotel more than once, use either a JOIN or an EXISTS clause to check whether the count is greater than two.

Using EXISTS:

```<code>SELECT DISTINCT b.hotelNo,g.guestName,b.dateFrom,b.dateTo
FROM Booking AS b
JOIN Guest AS g
    ON b.guestNo = g.guestNo
WHERE EXISTS
(
    SELECT 1
    FROM Booking
    WHERE hotelNo = b.hotelNo
    AND guestNo = b.guestNo
    GROUP BY hotelNo, guestNo
    HAVING COUNT(*) > 1
);
</code>```

Using a JOIN (but same principle):

```<code>SELECT DISTINCT b.hotelNo,g.guestName,b.dateFrom,b.dateTo
FROM Booking AS b
JOIN Guest AS g
    ON b.guestNo = g.guestNo
JOIN
(
    SELECT hotelNo, guestNo
    FROM Booking
    GROUP BY hotelNo, guestNo
    HAVING COUNT(*) > 1
) AS j
    ON j.hotelNo = b.hotelNo
    AND j.guestNo = b.guestNo;
</code>```

NOTE: I'm not sure that you need DISTINCT or a GROUP BY on your columns unless you actually have duplicates in your tables (and if you do, you probably should get rid of those duplicates).

Title: Restricting Uniques from Showing

Body:
I currently have this SQL query and this output.

SELECT b.HotelNo,g.guestName,b.dateFrom,b.dateToFrom Booking b, Guest g
FROM Booking b, Guest g
WHERE b.guestNo = g.guestNo
GROUP BY b.hotelNo,b.dateFrom,b.dateTo,g.guestName;

I am getting this output:
Output

How do I remove all the rows that are not duplicates of first two columns?

Output would be (In words Get all the hotel numbers guest names and dates of stay of all guest only if they have stayed in the same hotel more than once):

1234 John Doe 2017-02-01 00:00:00.000 2017-02-28 00:00:00.000
1234 John Doe 2017-03-16 00:00:00.000 2017-03-21 00:00:00.000

EDIT:

I got what I wanted but I when I add b.dateFrom,b.dateTo into my select statement. I get an error saying: Column 'Booking.dateFrom' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

This is the SQL query that gets this error:

SELECT b.hotelNo,g.guestName,b.dateFrom,b.dateTo
FROM Booking b, Guest g
WHERE b.guestNo = g.guestNo
GROUP BY b.hotelNo,g.guestName
HAVING COUNT(*) > 1;

If I add those two column names in (which I need) I get the error above. How do I add them in without getting an error?

Body:
If you want only those who have stayed in a hotel more than once, use either a JOIN or an EXISTS clause to check whether the count is greater than two.

Using EXISTS:

SELECT DISTINCT b.hotelNo,g.guestName,b.dateFrom,b.dateTo
FROM Booking AS b
JOIN Guest AS g
    ON b.guestNo = g.guestNo
WHERE EXISTS
(
    SELECT 1
    FROM Booking
    WHERE hotelNo = b.hotelNo
    AND guestNo = b.guestNo
    GROUP BY hotelNo, guestNo
    HAVING COUNT(*) > 1
);

Using a JOIN (but same principle):

SELECT DISTINCT b.hotelNo,g.guestName,b.dateFrom,b.dateTo
FROM Booking AS b
JOIN Guest AS g
    ON b.guestNo = g.guestNo
JOIN
(
    SELECT hotelNo, guestNo
    FROM Booking
    GROUP BY hotelNo, guestNo
    HAVING COUNT(*) > 1
) AS j
    ON j.hotelNo = b.hotelNo
    AND j.guestNo = b.guestNo;

NOTE: I'm not sure that you need DISTINCT or a GROUP BY on your columns unless you actually have duplicates in your tables (and if you do, you probably should get rid of those duplicates).


问:
Unable to install loopback connector for IBM DB2
While I am trying to install loopback connector for IBM DB2, I am getting the below error:

```<code>D:\official\office works\loopback\DB2try\employee_details> npm install loopback-connector-db2

npm WARN deprecated graceful-fs@3.0.8: graceful-fs v3.0.0 and before will fail o
n node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible
. Use 'npm ls graceful-fs' to find it in the tree.

D:\official\office works\loopback\DB2try\employee_details>apic loopback:refresh

Updating swagger and product definitions
Error: The LoopBack application is not loaded.

WARNING: LoopBack connector "db2" is not installed as any of the following modules:

 ./connectors/db2
loopback-connector-db2

To fix, run:

    npm install loopback-connector-db2

Cannot load the LoopBack application: Cannot create data source "IBMDB2":
WARNING: LoopBack connector "db2" is not installed as any of the following modul
es:

 ./connectors/db2
loopback-connector-db2

To fix, run:

    npm install loopback-connector-db2

Please fix the problem and run `apic loopback:refresh`
</code>```

Kindly help me to resolve the issue.

答: How about npm install loopback-connector-db2 --save?

Body:
While I am trying to install loopback connector for IBM DB2, I am getting the below error:

D:\official\office works\loopback\DB2try\employee_details> npm install loopback-connector-db2

npm WARN deprecated graceful-fs@3.0.8: graceful-fs v3.0.0 and before will fail o
n node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible
. Use 'npm ls graceful-fs' to find it in the tree.

D:\official\office works\loopback\DB2try\employee_details>apic loopback:refresh

Updating swagger and product definitions
Error: The LoopBack application is not loaded.

WARNING: LoopBack connector "db2" is not installed as any of the following modules:

 ./connectors/db2
loopback-connector-db2

To fix, run:

    npm install loopback-connector-db2

Cannot load the LoopBack application: Cannot create data source "IBMDB2":
WARNING: LoopBack connector "db2" is not installed as any of the following modul
es:

 ./connectors/db2
loopback-connector-db2

To fix, run:

    npm install loopback-connector-db2

Please fix the problem and run `apic loopback:refresh`

Kindly help me to resolve the issue.


问:
angular 2 display array of images
i am new to angular 2 , i have an array of images and i want to display all the images in a row but none of them is being displayed even the array is not empty
i am using the img tag as shown in the code

html code:

```<code><div fxLayout="column">

    <div >

    </div>

    <div fxLayout="row" *ngIf="doneLoadingProjectData" >
      <div  *ngFor="let image of images" >
          <img src='image'/>
      </div>

    </div>

</div>
</code>```

答:
Need to use curly brackets when you are assigning value to src attribute

```<code><div  *ngFor="let image of images" >
  <img src='{{image}}'/>
</div>
</code>```

Or you can use a template expression:

```<code><img [src]="image" />
</code>```

Title: angular 2 display array of images

Body:
Need to use curly brackets when you are assigning value to src attribute

<div  *ngFor="let image of images" >
  <img src='{{image}}'/>
</div>

Or you can use a template expression:

<img [src]="image" />