问:
Collection was modified; enumeration operation may not execute
I keep getting the following warning (not error) in a production ASP.Net application:

```System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.Web.UI.ControlCollection.ControlCollectionEnumerator.MoveNext()
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
at System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at DMAC.UI.Master.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.scan_history_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)```

Here is the code for the Render method where the error is occurring:

```<code>protected override void Render(HtmlTextWriter writer)
    {
        Header header = new Header();
        List<Menu> menus = DMAC.Application.Current().Menus;
        Menu menu = menus.Find(m => m.MenuId == MenuId);

        SiteMapWindow siteWindow = new SiteMapWindow();
        siteWindow.OpenerId = Menu.PATHID;
        this.Page.Form.Controls.Add(siteWindow);

        SupportWindow supportWindow = new SupportWindow();
        supportWindow.OpenerId = Menu.SUPPORTID;
        this.Page.Form.Controls.Add(supportWindow);

        this.Page.Form.Controls.AddAt(0, menu);
        this.Page.Form.Controls.AddAt(0, header);

        Scripts.GoogleAnalytics.RegisterScript(this.Page);
        base.Render(writer);
    }
</code>```

I cannot recreate the error myself.  Any ideas?

答:
I would suspect the problem arises from adding (non-child) controls in Render

That is, the controls are added to the Page Control Collection which is likely being iterated over in order to Render children. (And I am presuming that includes this code; in a child control.)

Move the layout modifications (really, everything in the method) into CreateChildControls or what may be appropriate. (I'm not sure CreateChildControls is actually okay here -- the issue, I believe, is the Page Controls aren't children.)

Happy coding.

Body:
I keep getting the following warning (not error) in a production ASP.Net application:

System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.Web.UI.ControlCollection.ControlCollectionEnumerator.MoveNext()
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
at System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at DMAC.UI.Master.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.scan_history_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Here is the code for the Render method where the error is occurring:

protected override void Render(HtmlTextWriter writer)
    {
        Header header = new Header();
        List<Menu> menus = DMAC.Application.Current().Menus;
        Menu menu = menus.Find(m => m.MenuId == MenuId);

        SiteMapWindow siteWindow = new SiteMapWindow();
        siteWindow.OpenerId = Menu.PATHID;
        this.Page.Form.Controls.Add(siteWindow);

        SupportWindow supportWindow = new SupportWindow();
        supportWindow.OpenerId = Menu.SUPPORTID;
        this.Page.Form.Controls.Add(supportWindow);

        this.Page.Form.Controls.AddAt(0, menu);
        this.Page.Form.Controls.AddAt(0, header);

        Scripts.GoogleAnalytics.RegisterScript(this.Page);
        base.Render(writer);
    }

I cannot recreate the error myself.  Any ideas?


来源: stackexchange

问:
zsh delete subdirectory with wildcard in path
For a directory structure of:

```<code>└── bar
    ├── first
    │   └── tmp
    └── second
        └── tmp
</code>```

I want to delete all tmp directories.
However,

```<code>rm -rf 'bar/*/tmp/'
</code>```

does not delete the directory

```<code>ls bar/*/
</code>```

still retrurns both tmp directories:

```<code>bar/first/:
tmp

bar/second/:
tmp
</code>```

答:
your problem here is the single quotes

```<code>rm -rf 'bar/*/tmp/'
</code>```

if you remove them you'll be fine.

```<code>rm -rf bar/*/tmp
</code>```

The reason for this is that single quotes in (most, if not all) shell languages indicates that the contained string of characters is to be treated entirely as a string, which ignores the globbing you are trying to do.

ContentLicense: CC BY-SA 4.0

Body:
For a directory structure of:

└── bar
    ├── first
    │   └── tmp
    └── second
        └── tmp

I want to delete all tmp directories.
However,

rm -rf 'bar/*/tmp/'

does not delete the directory

ls bar/*/

still retrurns both tmp directories:

bar/first/:
tmp

bar/second/:
tmp

Body:
your problem here is the single quotes

rm -rf 'bar/*/tmp/'

if you remove them you'll be fine.

rm -rf bar/*/tmp

The reason for this is that single quotes in (most, if not all) shell languages indicates that the contained string of characters is to be treated entirely as a string, which ignores the globbing you are trying to do.


问:
Doxygen strange problem while documenting PHP if
I face a strange problem while I'm trying to document a project of mine. I have the following code:

```<code>//! Set default ::$action for called controller. If no action is called, default (index) will be set.
$action = isset($_GET[ 'action']) ? $_GET[ 'action'] : 'index';

if ($action) {
    echo 'something 1';
}else{
    echo 'something 2';
}

//! Set default ::$action2 for called controller. If no action is called, default (index) will be set.
$action2 = isset($_GET[ 'action']) ? $_GET[ 'action'] : 'index';

//! Set default ::$action3 for called controller. If no action is called, default (index) will be set.
$action3 = isset($_GET[ 'action']) ? $_GET[ 'action'] : 'index';
</code>```

Doxygen generates the following:

As you may see, $action2 is missing. I check one of my other files and saw same problem. Next thing after if statement is never documented, but the one after that is documented. If I remove the if statement from above example, I get documentation for all 4 variables - $page, $action, action2 and action3.

I spend enormous time of trying to understand what exactly is wrong, but no luck, so every suggestion is welcomed.

System is:
Windows XP x64 with Doxygen 1.7.4. (I'm using the Doxygen GUI)

UPDATE
Also, when I have something like that in my code (notice the missing else for the if statement). When I add the }else{} however it works. Next $variables is not documented again, but that update was about the if/else.

Doxygen converts it to this

答:
PHP only: Doxygen requires that all
  PHP statements (i.e. code) is wrapped
  in a functions/methods, otherwise you
  may run into parse problems.
  Source

Are you using an open source php framework? Is it possible to wrap your code into functions/methods where needed?

ContentLicense: CC BY-SA 3.0

Body:
I face a strange problem while I'm trying to document a project of mine. I have the following code:

//! Set default ::$action for called controller. If no action is called, default (index) will be set.
$action = isset($_GET[ 'action']) ? $_GET[ 'action'] : 'index';

if ($action) {
    echo 'something 1';
}else{
    echo 'something 2';
}

//! Set default ::$action2 for called controller. If no action is called, default (index) will be set.
$action2 = isset($_GET[ 'action']) ? $_GET[ 'action'] : 'index';

//! Set default ::$action3 for called controller. If no action is called, default (index) will be set.
$action3 = isset($_GET[ 'action']) ? $_GET[ 'action'] : 'index';

Doxygen generates the following:

As you may see, $action2 is missing. I check one of my other files and saw same problem. Next thing after if statement is never documented, but the one after that is documented. If I remove the if statement from above example, I get documentation for all 4 variables - $page, $action, action2 and action3.

I spend enormous time of trying to understand what exactly is wrong, but no luck, so every suggestion is welcomed.

System is:
Windows XP x64 with Doxygen 1.7.4. (I'm using the Doxygen GUI)

UPDATE
Also, when I have something like that in my code (notice the missing else for the if statement). When I add the }else{} however it works. Next $variables is not documented again, but that update was about the if/else.

Doxygen converts it to this


问:
how to put text at bottom of div that is inside another div
I have the following layout:

and I want to put some text at bottom of div2 just like in the pic.

I have the following code:

when I say div

```

答:
Add display: flex; and  align-items: flex-end; to .yellow-box. See the snippet below:

when I say div

```

Body:
Add display: flex; and  align-items: flex-end; to .yellow-box. See the snippet below:

<style>
        .grey_box {
            background-color: grey;
            width: 680px;
            height: 500px;
        }
        .yellow_box {
            display: flex;
            align-items: flex-end;
            background-color: yellow;
            width: 450px;
            height: 300px;
        }

    </style>
</head>
<body>
    <div class="grey_box">
        <div class="yellow_box">
            <h1>when I say div</h1>
        </div>
    </div>


问:
How to change value of a request parameter in laravel
I need to change value of my request parameter like this:

$request->name = "My Value!";
```

<p>I use this code but does not work:</p>

<pre class="lang-php prettyprint-override"><code>$request->offsetSet('img', $img);
</code>```

答:
If you need to update a property in the request, I recommend you to use the replace method from Request class used by Laravel</p>

```<code>$request->replace(['property to update' => $newValue]);
</code>```

Body:
I need to change value of my request parameter like this:

$request->name = "My Value!";

I use this code but does not work:

$request->offsetSet('img', $img);

Body:
If you need to update a property in the request, I recommend you to use the replace method from Request class used by Laravel

$request->replace(['property to update' => $newValue]);


问:
Execute server API call on beforeunload/ Limitations on page unload?
The below code is used to work in chrome and suddenly stopped due to chrome recent change "Disallow sync XHR in page dismissal". The recent update on Crome early April 2019, I think Chrome 73.0.3683.103 stopped this feature and they have suggested sendBeacon or fetch keepalive. I will post what I was tried so this might help someone else.

https://www.chromestatus.com/feature/4664843055398912

```<code>$(window).on('beforeunload', function (e) {
     //ajax call used work in Chrome
}
</code>```

https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload

I know there are several related posts related to the same situation, but still couldn't find a solution. I tried several ways to make a server call.

Step 1:

```<code>$(window).on('beforeunload', function (e) {
 if (navigator.sendBeacon) {
    navigator.sendBeacon('url', 'data');
 } else {
    $.ajax({
        type: 'POST',
        url: 'url',
        data: null,
        contentType: 'application/json;',
        async: false
    });
 }
}
</code>```

This did not work due to content type - application-json

Step 2:

```<code>$(window).on('beforeunload', function (e) {
 var data = { ajax_data: 22 };
 var blob = new Blob([JSON.stringify(data)], {type : 'application/json'});
 navigator.sendBeacon('url', blob);
}
</code>```

This code did not work due to sendBeacon only support these content-types

multipart/form-data

application/x-www-form-urlencoded

text/plain

Step 3:

```<code> $(window).on('beforeunload', function (e) {
  if (fetch) {
    fetch(url, {
        method: "POST", headers: { "Content-Type": "application/json" }
    }).then(function (response) {
        console.log(response.statusText);
    }).then(function (response) {
        console.log(response.statusText);
    });
    return false;
 } else {
    $.ajax({
        type: 'POST',
        url: 'url',
        data: null,
        contentType: 'application/json;',
        async: false
    });
 }
}
</code>```

This code works!. But only when you click on a link on the page or click on the Signout button. I need to work on this server method on when the user leaves the page on clicking on a link, signout, tab close and browser close.

Step 4:

```<code>$(window).on('beforeunload', function (e) {
     e.stopPropagation();
     e.preventDefault();
     fetch('url', { method: 'POST', headers: { 'Content-Type': 'application/json' } });
}
</code>```

This will show a popup "Leave site?", I don't want to the user to show any popup.

Step 5:

```<code>$(window).on('beforeunload', function (e) {
      setTimeout(function ()
      {
           fetch('url', { method: 'POST', headers: { 'Content-Type': 'application/json' } });
      }, 3000);
      return false;
}
</code>```

Also same as step 4, shows the "Leave site popup."

Now I'm running out of options and could not found a solution yet. Any help appreciated. I need a server call before page unloads by clicking on a link, logout, tab close, browser close. The above code will work if you put a breakpoint, which means it needs some time delay to send the server call before page unload. I don't mind putting a timeout if the user does not see any popup like "Leave site?"

答:
This is an old question, but you need to use fetch with the keepalive flag set to true in the beforeunload event:

```<code>fetch(url, {
   method: "POST",
   keepalive: true,
   headers: {
      "Content-Type": "application/json"
   }
});
</code>```

sendBeacon does not behave the way documentation claims it does. In my testing, it did not respect the MIME type of a Blob in the request body, even if the Blob was a "supported" MIME type.

Use fetch instead. It gives you more control over the request headers, while guaranteeing that your request will be issued like sendBeacon supposedly does.

You might also need to bind the beforeunload event in the body of the page. A jQuery binding might not work for beforeunload.

Body:
The below code is used to work in chrome and suddenly stopped due to chrome recent change "Disallow sync XHR in page dismissal". The recent update on Crome early April 2019, I think Chrome 73.0.3683.103 stopped this feature and they have suggested sendBeacon or fetch keepalive. I will post what I was tried so this might help someone else.

https://www.chromestatus.com/feature/4664843055398912

$(window).on('beforeunload', function (e) {
     //ajax call used work in Chrome
}

https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload

I know there are several related posts related to the same situation, but still couldn't find a solution. I tried several ways to make a server call.

Step 1:

$(window).on('beforeunload', function (e) {
 if (navigator.sendBeacon) {
    navigator.sendBeacon('url', 'data');
 } else {
    $.ajax({
        type: 'POST',
        url: 'url',
        data: null,
        contentType: 'application/json;',
        async: false
    });
 }
}

This did not work due to content type - application-json

Step 2:

$(window).on('beforeunload', function (e) {
 var data = { ajax_data: 22 };
 var blob = new Blob([JSON.stringify(data)], {type : 'application/json'});
 navigator.sendBeacon('url', blob);
}

This code did not work due to sendBeacon only support these content-types

multipart/form-data

application/x-www-form-urlencoded

text/plain

Step 3:

 $(window).on('beforeunload', function (e) {
  if (fetch) {
    fetch(url, {
        method: "POST", headers: { "Content-Type": "application/json" }
    }).then(function (response) {
        console.log(response.statusText);
    }).then(function (response) {
        console.log(response.statusText);
    });
    return false;
 } else {
    $.ajax({
        type: 'POST',
        url: 'url',
        data: null,
        contentType: 'application/json;',
        async: false
    });
 }
}

This code works!. But only when you click on a link on the page or click on the Signout button. I need to work on this server method on when the user leaves the page on clicking on a link, signout, tab close and browser close.

Step 4:

$(window).on('beforeunload', function (e) {
     e.stopPropagation();
     e.preventDefault();
     fetch('url', { method: 'POST', headers: { 'Content-Type': 'application/json' } });
}

This will show a popup "Leave site?", I don't want to the user to show any popup.

Step 5:

$(window).on('beforeunload', function (e) {
      setTimeout(function ()
      {
           fetch('url', { method: 'POST', headers: { 'Content-Type': 'application/json' } });
      }, 3000);
      return false;
}

Also same as step 4, shows the "Leave site popup."

Now I'm running out of options and could not found a solution yet. Any help appreciated. I need a server call before page unloads by clicking on a link, logout, tab close, browser close. The above code will work if you put a breakpoint, which means it needs some time delay to send the server call before page unload. I don't mind putting a timeout if the user does not see any popup like "Leave site?"

Body:
This is an old question, but you need to use fetch with the keepalive flag set to true in the beforeunload event:

fetch(url, {
   method: "POST",
   keepalive: true,
   headers: {
      "Content-Type": "application/json"
   }
});

sendBeacon does not behave the way documentation claims it does. In my testing, it did not respect the MIME type of a Blob in the request body, even if the Blob was a "supported" MIME type.

Use fetch instead. It gives you more control over the request headers, while guaranteeing that your request will be issued like sendBeacon supposedly does.

You might also need to bind the beforeunload event in the body of the page. A jQuery binding might not work for beforeunload.


问:
how to stop function save in jquery
When Save button clicked, I want to make sure date exist or not.

I tried to use return false , e.stopPropagation() , e.stopImmediatePropagation() and none of those works to stop execute saveEvent. As you can see in my example, button save  will always be executed. I want to stop that stop the SaveEvent . Could you help?

```<code>       $('#btnSave').click(function () {

                var StartDate = $('#txtStart').val();

                $.ajax({
                    type: "POST",
                    url: "/Home/Checkdate",
                    data: '{StartDate: "' + StartDate + '" }',

                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (response) {
                        var message = $("#message");
                        if (response) {
                            //Email available.
                            message.css("color", "green");
                            message.html(" date is not exist ");
                        }
                        else {
                            message.css("color", "red");
                            message.html("date existe ");
                            alert('date existe');

                            return;

                        }

                    }
                });

         var data = {

                    EventID: $('#hdEventID').val(),
                    EventTitle: $('#txtSubject').val().trim(),
                    StartDate: $('#txtStart').val().trim(),
                    EndDate: $('#chkIsFullDay').is(':checked') ? null : $('#txtEnd').val().trim(),
                    EventDescription: $('#txtDescription').val(),
                    ThemeColor: $('#ddThemeColor').val(),
                    IsFullDay: $('#chkIsFullDay').is(':checked')
                }

                    SaveEvent(data);

                // call function for submit data to the server
            })
</code>```

答:
Add the preventDefault like this to prevent the default behavior of elements.

Change your above 2 lines to like this.

```<code>$(document).on('click','#btnSave',function (e) {
    e.preventDefault();
</code>```

Title: how to stop function save in jquery

Body:
When Save button clicked, I want to make sure date exist or not.

I tried to use return false , e.stopPropagation() , e.stopImmediatePropagation() and none of those works to stop execute saveEvent. As you can see in my example, button save  will always be executed. I want to stop that stop the SaveEvent . Could you help?

       $('#btnSave').click(function () {

                var StartDate = $('#txtStart').val();

                $.ajax({
                    type: "POST",
                    url: "/Home/Checkdate",
                    data: '{StartDate: "' + StartDate + '" }',

                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (response) {
                        var message = $("#message");
                        if (response) {
                            //Email available.
                            message.css("color", "green");
                            message.html(" date is not exist ");
                        }
                        else {
                            message.css("color", "red");
                            message.html("date existe ");
                            alert('date existe');

                            return;

                        }

                    }
                });

         var data = {

                    EventID: $('#hdEventID').val(),
                    EventTitle: $('#txtSubject').val().trim(),
                    StartDate: $('#txtStart').val().trim(),
                    EndDate: $('#chkIsFullDay').is(':checked') ? null : $('#txtEnd').val().trim(),
                    EventDescription: $('#txtDescription').val(),
                    ThemeColor: $('#ddThemeColor').val(),
                    IsFullDay: $('#chkIsFullDay').is(':checked')
                }

                    SaveEvent(data);

                // call function for submit data to the server
            })

Body:
Add the preventDefault like this to prevent the default behavior of elements.

Change your above 2 lines to like this.

$(document).on('click','#btnSave',function (e) {
    e.preventDefault();


问:
Does setTimeout delay the creation of the function?
This doesn't work because when "log" is being created while "message" doesn't exist.

function x() {
  function log() {
    console.log(message)
  }
  const message = "hello"
   log()
}

x()```
</div>
</div>
</p>

<p>But this works? setTimeout isn't aware of the message and in my opinion, should throw an error. But it seems like the "log" is being created after "x" function is done executing? How is this explained?</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function x() {
  setTimeout(() => {
    console.log(message)
  }, 500)
  const message = "hello"
}

x()</code>```

答:
I think you're misunderstanding what the first snippet of code is doing.

You are defining a function x which is defining a function log inside it and then setting a constant message to "hello";

At no point in the snippet does the log function get called, so the console.log(message); is never invoked.

In the second snippet you are using setTimeout to invoke a function which will run after 500ms.

Body:
This doesn't work because when "log" is being created while "message" doesn't exist.

function x() {
  function log() {
    console.log(message)
  }
  const message = "hello"
   log()
}

x()

But this works? setTimeout isn't aware of the message and in my opinion, should throw an error. But it seems like the "log" is being created after "x" function is done executing? How is this explained?

function x() {
  setTimeout(() => {
    console.log(message)
  }, 500)
  const message = "hello"
}

x()


问:
ins-20802 - oracle net configuration assistant failed during installation - centos 7
Hello I am trying to folow the manual for installing the Oracle 12c. Actually it was already installed on the machine, and then deinstalled.

During installiation I get the "[ins-20802] oracle net configuration assistant failed during installation" error window. And proposed detail log file, where I can see:

```<code>INFO: ... GenericInternalPlugIn: starting read loop.
INFO: Read:
WARNING: Skipping line:
INFO: End of argument passing to stdin
INFO: Read: Parsing command line arguments:
WARNING: Skipping line: Parsing command line arguments:
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "orahome" = /u01/app/oracle/product/12.1.0/db_1
WARNING: Skipping line:     Parameter "orahome" = /u01/app/oracle/product/12.1.0/db_1
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "orahnam" = OraDB12Home1
WARNING: Skipping line:     Parameter "orahnam" = OraDB12Home1
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "instype" = typical
WARNING: Skipping line:     Parameter "instype" = typical
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "inscomp" = client,oraclenet,javavm,server,ano
WARNING: Skipping line:     Parameter "inscomp" = client,oraclenet,javavm,server,ano
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "insprtcl" = tcp
WARNING: Skipping line:     Parameter "insprtcl" = tcp
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "cfg" = local
WARNING: Skipping line:     Parameter "cfg" = local
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "authadp" = NO_VALUE
WARNING: Skipping line:     Parameter "authadp" = NO_VALUE
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "responsefile" = /u01/app/oracle/product/12.1.0/db_1/network/install/netca_typ.rsp
WARNING: Skipping line:     Parameter "responsefile" = /u01/app/oracle/product/12.1.0/db_1/network/install/netca_typ.rsp
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "silent" = true
WARNING: Skipping line:     Parameter "silent" = true
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "ouiinternal" = true
WARNING: Skipping line:     Parameter "ouiinternal" = true
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read: Done parsing command line arguments.
WARNING: Skipping line: Done parsing command line arguments.
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read: Oracle Net Services Configuration:
WARNING: Skipping line: Oracle Net Services Configuration:
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read: Profile configuration complete.
WARNING: Skipping line: Profile configuration complete.
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read: Oracle Net Listener Startup:
WARNING: Skipping line: Oracle Net Listener Startup:
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Running Listener Control:
WARNING: Skipping line:     Running Listener Control:
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:       /u01/app/oracle/product/12.1.0/db_1/bin/lsnrctl start LISTENER
WARNING: Skipping line:       /u01/app/oracle/product/12.1.0/db_1/bin/lsnrctl start LISTENER
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Listener Control complete.
WARNING: Skipping line:     Listener Control complete.
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Listener start failed.
WARNING: Skipping line:     Listener start failed.
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read: Check the trace file for details: /u01/app/oracle/cfgtoollogs/netca/trace_OraDB12Home1-1504033PM3901.log
WARNING: Skipping line: Check the trace file for details: /u01/app/oracle/cfgtoollogs/netca/trace_OraDB12Home1-1504033PM3901.log
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read: Oracle Net Services configuration failed.  The exit code is 1
WARNING: Skipping line: Oracle Net Services configuration failed.  The exit code is 1
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Completed Plugin named: Oracle Net Configuration Assistant
</code>```

Ans the corresponding trace_OraDB12Home1-1504033PM3901.log:

```<code>[main] [ 2015-04-03 15:39:06.329 MSK ] [OracleHome.getVersion:1059]  Current Version From Inventory: 12.1.0.2.0
[main] [ 2015-04-03 15:39:06.329 MSK ] [InitialSetup.<init>:4151]  Admin location is: /u01/app/oracle/product/12.1.0/db_1/network/admin
[main] [ 2015-04-03 15:39:06.718 MSK ] [ConfigureProfile.setProfileParam:140]  Setting NAMES.DIRECTORY_PATH: (TNSNAMES, EZCONNECT)
[main] [ 2015-04-03 15:39:06.735 MSK ] [HAUtils.getCurrentOracleHome:593]  Oracle home from system property: /u01/app/oracle/product/12.1.0/db_1
[main] [ 2015-04-03 15:39:06.735 MSK ] [HAUtils.getConfiguredGridHome:1343]  ----- Getting CRS HOME ----
[main] [ 2015-04-03 15:39:06.737 MSK ] [UnixSystem.getCRSHome:2878]  olrFileName = /etc/oracle/olr.loc
[main] [ 2015-04-03 15:39:06.795 MSK ] [HAUtils.getHASHome:1500]  Failed to get HAS home.
PRCI-1144 : Failed to retrieve Oracle Grid Infrastructure home path
PRKC-1144 : File "/etc/oracle/olr.loc" not found.
[main] [ 2015-04-03 15:39:06.795 MSK ] [InitialSetup.checkHAConfiguration:4808]  HA Server is NOT configured.
[main] [ 2015-04-03 15:39:06.797 MSK ] [NetCAResponseFile.<init>:75]  Response file initialized: /u01/app/oracle/product/12.1.0/db_1/network/install/netca_typ.rsp
[main] [ 2015-04-03 15:39:06.798 MSK ] [NetCAResponseFile.getInstalledComponents:114]  Installed components from response file: server, net8, javavm
[main] [ 2015-04-03 15:39:06.798 MSK ] [NetCAResponseFile.getVirtualHost:171]  Virtual Host from response file: null
[main] [ 2015-04-03 15:39:06.799 MSK ] [SilentConfigure.performSilentConfigure:198]  Typical profile configuration.
[main] [ 2015-04-03 15:39:06.801 MSK ] [ConfigureProfile.setProfileParam:140]  Setting NAMES.DIRECTORY_PATH: (TNSNAMES, EZCONNECT)
[main] [ 2015-04-03 15:39:06.802 MSK ] [SilentConfigure.performSilentConfigure:206]  Typical listener configuration.
[main] [ 2015-04-03 15:39:06.839 MSK ] [ConfigureListener.isHASConfigured:1596]  Calling SRVM api to check if Oracle Restart is configured ...
[main] [ 2015-04-03 15:39:06.840 MSK ] [HAUtils.getCurrentOracleHome:593]  Oracle home from system property: /u01/app/oracle/product/12.1.0/db_1
[main] [ 2015-04-03 15:39:06.840 MSK ] [HAUtils.getConfiguredGridHome:1343]  ----- Getting CRS HOME ----
[main] [ 2015-04-03 15:39:06.840 MSK ] [UnixSystem.getCRSHome:2878]  olrFileName = /etc/oracle/olr.loc
[main] [ 2015-04-03 15:39:06.841 MSK ] [HAUtils.getHASHome:1500]  Failed to get HAS home.
PRCI-1144 : Failed to retrieve Oracle Grid Infrastructure home path
PRKC-1144 : File "/etc/oracle/olr.loc" not found.
[main] [ 2015-04-03 15:39:06.841 MSK ] [ConfigureListener.isHASConfigured:1607]  Is Oracle Restart configured: false
[main] [ 2015-04-03 15:39:06.841 MSK ] [ConfigureListener.isHASRunning:1636]  Is Oracle Restart running: false
[main] [ 2015-04-03 15:39:06.842 MSK ] [ConfigureListener.listenerExists:396]  Is listener "LISTENER" already exists: false
[main] [ 2015-04-03 15:39:06.842 MSK ] [ConfigureListener.typicalConfigure:257]  Checking for free port in range: 1521-1540
[main] [ 2015-04-03 15:39:06.842 MSK ] [ConfigureListener.validateEndPoint:1059]  Validating end-point: TCP:1521
[main] [ 2015-04-03 15:39:06.944 MSK ] [ConfigureListener.isPortFree:1131]  Checking if port 1521 is free on local machine...
[main] [ 2015-04-03 15:39:06.945 MSK ] [ConfigureListener.isPortFree:1146]  InetAddress.getByName(127.0.0.1): /127.0.0.1
[main] [ 2015-04-03 15:39:06.945 MSK ] [ConfigureListener.isPortFree:1148]  Local host IP address: localhost.localdomain/127.0.0.1
[main] [ 2015-04-03 15:39:06.945 MSK ] [ConfigureListener.isPortFree:1150]  Local host name: localhost.localdomain
[main] [ 2015-04-03 15:39:06.945 MSK ] [ConfigureListener.isPortFree:1166]  IP Address: localhost.localdomain/127.0.0.1, Is IPv6 Address: false
[main] [ 2015-04-03 15:39:06.946 MSK ] [ConfigureListener.isPortFree:1169]  IP Address: localhost.localdomain/127.0.0.1, Is Link-Local Address: false
[main] [ 2015-04-03 15:39:06.946 MSK ] [ConfigureListener.isPortFree:1194]  Creating ServerSocket on Port:1521, IP Address: localhost.localdomain/127.0.0.1
[main] [ 2015-04-03 15:39:06.968 MSK ] [ConfigureListener.isPortFree:1197]  Created ServerSocket successfully.
[main] [ 2015-04-03 15:39:06.968 MSK ] [ConfigureListener.isPortFree:1166]  IP Address: localhost.localdomain/0:0:0:0:0:0:0:1, Is IPv6 Address: true
[main] [ 2015-04-03 15:39:06.968 MSK ] [ConfigureListener.isPortFree:1169]  IP Address: localhost.localdomain/0:0:0:0:0:0:0:1, Is Link-Local Address: false
[main] [ 2015-04-03 15:39:06.968 MSK ] [ConfigureListener.isPortFree:1194]  Creating ServerSocket on Port:1521, IP Address: localhost.localdomain/0:0:0:0:0:0:0:1
[main] [ 2015-04-03 15:39:06.969 MSK ] [ConfigureListener.isPortFree:1197]  Created ServerSocket successfully.
[main] [ 2015-04-03 15:39:06.969 MSK ] [ConfigureListener.isPortFree:1209]  Creating ServerSocket on Port:1521, Local IP Address: /127.0.0.1
[main] [ 2015-04-03 15:39:06.969 MSK ] [ConfigureListener.isPortFree:1213]  Created ServerSocket successfully.
[main] [ 2015-04-03 15:39:06.969 MSK ] [ConfigureListener.isPortFree:1219]  Creating ServerSocket on Port:1521
[main] [ 2015-04-03 15:39:06.970 MSK ] [ConfigureListener.isPortFree:1222]  Created ServerSocket successfully.
[main] [ 2015-04-03 15:39:06.970 MSK ] [ConfigureListener.isPortFree:1242]  Returning is Port 1521 free: true
[main] [ 2015-04-03 15:39:06.970 MSK ] [ConfigureListener.validateEndPoint:1114]  Validation...Complete for TCP/TCPS.
[main] [ 2015-04-03 15:39:06.970 MSK ] [ConfigureListener.typicalConfigure:274]  Using port: 1521
[main] [ 2015-04-03 15:39:08.684 MSK ] [ConfigureListener.isPortFree:1131]  Checking if port 1521 is free on local machine...
[main] [ 2015-04-03 15:39:08.685 MSK ] [ConfigureListener.isPortFree:1146]  InetAddress.getByName(127.0.0.1): /127.0.0.1
[main] [ 2015-04-03 15:39:08.686 MSK ] [ConfigureListener.isPortFree:1148]  Local host IP address: localhost.localdomain/127.0.0.1
[main] [ 2015-04-03 15:39:08.686 MSK ] [ConfigureListener.isPortFree:1150]  Local host name: localhost.localdomain
[main] [ 2015-04-03 15:39:08.687 MSK ] [ConfigureListener.isPortFree:1166]  IP Address: localhost.localdomain/127.0.0.1, Is IPv6 Address: false
[main] [ 2015-04-03 15:39:08.687 MSK ] [ConfigureListener.isPortFree:1169]  IP Address: localhost.localdomain/127.0.0.1, Is Link-Local Address: false
[main] [ 2015-04-03 15:39:08.687 MSK ] [ConfigureListener.isPortFree:1194]  Creating ServerSocket on Port:1521, IP Address: localhost.localdomain/127.0.0.1
[main] [ 2015-04-03 15:39:08.688 MSK ] [ConfigureListener.isPortFree:1197]  Created ServerSocket successfully.
[main] [ 2015-04-03 15:39:08.688 MSK ] [ConfigureListener.isPortFree:1166]  IP Address: localhost.localdomain/0:0:0:0:0:0:0:1, Is IPv6 Address: true
[main] [ 2015-04-03 15:39:08.689 MSK ] [ConfigureListener.isPortFree:1169]  IP Address: localhost.localdomain/0:0:0:0:0:0:0:1, Is Link-Local Address: false
[main] [ 2015-04-03 15:39:08.689 MSK ] [ConfigureListener.isPortFree:1194]  Creating ServerSocket on Port:1521, IP Address: localhost.localdomain/0:0:0:0:0:0:0:1
[main] [ 2015-04-03 15:39:08.689 MSK ] [ConfigureListener.isPortFree:1197]  Created ServerSocket successfully.
[main] [ 2015-04-03 15:39:08.690 MSK ] [ConfigureListener.isPortFree:1209]  Creating ServerSocket on Port:1521, Local IP Address: /127.0.0.1
[main] [ 2015-04-03 15:39:08.690 MSK ] [ConfigureListener.isPortFree:1213]  Created ServerSocket successfully.
[main] [ 2015-04-03 15:39:08.691 MSK ] [ConfigureListener.isPortFree:1219]  Creating ServerSocket on Port:1521
[main] [ 2015-04-03 15:39:08.691 MSK ] [ConfigureListener.isPortFree:1222]  Created ServerSocket successfully.
[main] [ 2015-04-03 15:39:08.692 MSK ] [ConfigureListener.isPortFree:1242]  Returning is Port 1521 free: true
</code>```

Maybe problem is because:

```<code>PRCI-1144 : Failed to retrieve Oracle Grid Infrastructure home path
PRKC-1144 : File "/etc/oracle/olr.loc" not found.
</code>```

Any ideas what I am dooing wrong and how finally install the Oracle?

答: For me in Windows 10 the solution was to install Microsoft Visual C++ 2010 Redistributable Package (x86)</p>

Body:
Hello I am trying to folow the manual for installing the Oracle 12c. Actually it was already installed on the machine, and then deinstalled.

During installiation I get the "[ins-20802] oracle net configuration assistant failed during installation" error window. And proposed detail log file, where I can see:

INFO: ... GenericInternalPlugIn: starting read loop.
INFO: Read:
WARNING: Skipping line:
INFO: End of argument passing to stdin
INFO: Read: Parsing command line arguments:
WARNING: Skipping line: Parsing command line arguments:
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "orahome" = /u01/app/oracle/product/12.1.0/db_1
WARNING: Skipping line:     Parameter "orahome" = /u01/app/oracle/product/12.1.0/db_1
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "orahnam" = OraDB12Home1
WARNING: Skipping line:     Parameter "orahnam" = OraDB12Home1
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "instype" = typical
WARNING: Skipping line:     Parameter "instype" = typical
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "inscomp" = client,oraclenet,javavm,server,ano
WARNING: Skipping line:     Parameter "inscomp" = client,oraclenet,javavm,server,ano
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "insprtcl" = tcp
WARNING: Skipping line:     Parameter "insprtcl" = tcp
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "cfg" = local
WARNING: Skipping line:     Parameter "cfg" = local
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "authadp" = NO_VALUE
WARNING: Skipping line:     Parameter "authadp" = NO_VALUE
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "responsefile" = /u01/app/oracle/product/12.1.0/db_1/network/install/netca_typ.rsp
WARNING: Skipping line:     Parameter "responsefile" = /u01/app/oracle/product/12.1.0/db_1/network/install/netca_typ.rsp
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "silent" = true
WARNING: Skipping line:     Parameter "silent" = true
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Parameter "ouiinternal" = true
WARNING: Skipping line:     Parameter "ouiinternal" = true
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read: Done parsing command line arguments.
WARNING: Skipping line: Done parsing command line arguments.
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read: Oracle Net Services Configuration:
WARNING: Skipping line: Oracle Net Services Configuration:
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read: Profile configuration complete.
WARNING: Skipping line: Profile configuration complete.
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read: Oracle Net Listener Startup:
WARNING: Skipping line: Oracle Net Listener Startup:
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Running Listener Control:
WARNING: Skipping line:     Running Listener Control:
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:       /u01/app/oracle/product/12.1.0/db_1/bin/lsnrctl start LISTENER
WARNING: Skipping line:       /u01/app/oracle/product/12.1.0/db_1/bin/lsnrctl start LISTENER
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Listener Control complete.
WARNING: Skipping line:     Listener Control complete.
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read:     Listener start failed.
WARNING: Skipping line:     Listener start failed.
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read: Check the trace file for details: /u01/app/oracle/cfgtoollogs/netca/trace_OraDB12Home1-1504033PM3901.log
WARNING: Skipping line: Check the trace file for details: /u01/app/oracle/cfgtoollogs/netca/trace_OraDB12Home1-1504033PM3901.log
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Read: Oracle Net Services configuration failed.  The exit code is 1
WARNING: Skipping line: Oracle Net Services configuration failed.  The exit code is 1
INFO: Exceeded the number of arguments passed to stdin. CurrentCount:1 Total args:0
INFO: Completed Plugin named: Oracle Net Configuration Assistant

Ans the corresponding trace_OraDB12Home1-1504033PM3901.log:

[main] [ 2015-04-03 15:39:06.329 MSK ] [OracleHome.getVersion:1059]  Current Version From Inventory: 12.1.0.2.0
[main] [ 2015-04-03 15:39:06.329 MSK ] [InitialSetup.<init>:4151]  Admin location is: /u01/app/oracle/product/12.1.0/db_1/network/admin
[main] [ 2015-04-03 15:39:06.718 MSK ] [ConfigureProfile.setProfileParam:140]  Setting NAMES.DIRECTORY_PATH: (TNSNAMES, EZCONNECT)
[main] [ 2015-04-03 15:39:06.735 MSK ] [HAUtils.getCurrentOracleHome:593]  Oracle home from system property: /u01/app/oracle/product/12.1.0/db_1
[main] [ 2015-04-03 15:39:06.735 MSK ] [HAUtils.getConfiguredGridHome:1343]  ----- Getting CRS HOME ----
[main] [ 2015-04-03 15:39:06.737 MSK ] [UnixSystem.getCRSHome:2878]  olrFileName = /etc/oracle/olr.loc
[main] [ 2015-04-03 15:39:06.795 MSK ] [HAUtils.getHASHome:1500]  Failed to get HAS home.
PRCI-1144 : Failed to retrieve Oracle Grid Infrastructure home path
PRKC-1144 : File "/etc/oracle/olr.loc" not found.
[main] [ 2015-04-03 15:39:06.795 MSK ] [InitialSetup.checkHAConfiguration:4808]  HA Server is NOT configured.
[main] [ 2015-04-03 15:39:06.797 MSK ] [NetCAResponseFile.<init>:75]  Response file initialized: /u01/app/oracle/product/12.1.0/db_1/network/install/netca_typ.rsp
[main] [ 2015-04-03 15:39:06.798 MSK ] [NetCAResponseFile.getInstalledComponents:114]  Installed components from response file: server, net8, javavm
[main] [ 2015-04-03 15:39:06.798 MSK ] [NetCAResponseFile.getVirtualHost:171]  Virtual Host from response file: null
[main] [ 2015-04-03 15:39:06.799 MSK ] [SilentConfigure.performSilentConfigure:198]  Typical profile configuration.
[main] [ 2015-04-03 15:39:06.801 MSK ] [ConfigureProfile.setProfileParam:140]  Setting NAMES.DIRECTORY_PATH: (TNSNAMES, EZCONNECT)
[main] [ 2015-04-03 15:39:06.802 MSK ] [SilentConfigure.performSilentConfigure:206]  Typical listener configuration.
[main] [ 2015-04-03 15:39:06.839 MSK ] [ConfigureListener.isHASConfigured:1596]  Calling SRVM api to check if Oracle Restart is configured ...
[main] [ 2015-04-03 15:39:06.840 MSK ] [HAUtils.getCurrentOracleHome:593]  Oracle home from system property: /u01/app/oracle/product/12.1.0/db_1
[main] [ 2015-04-03 15:39:06.840 MSK ] [HAUtils.getConfiguredGridHome:1343]  ----- Getting CRS HOME ----
[main] [ 2015-04-03 15:39:06.840 MSK ] [UnixSystem.getCRSHome:2878]  olrFileName = /etc/oracle/olr.loc
[main] [ 2015-04-03 15:39:06.841 MSK ] [HAUtils.getHASHome:1500]  Failed to get HAS home.
PRCI-1144 : Failed to retrieve Oracle Grid Infrastructure home path
PRKC-1144 : File "/etc/oracle/olr.loc" not found.
[main] [ 2015-04-03 15:39:06.841 MSK ] [ConfigureListener.isHASConfigured:1607]  Is Oracle Restart configured: false
[main] [ 2015-04-03 15:39:06.841 MSK ] [ConfigureListener.isHASRunning:1636]  Is Oracle Restart running: false
[main] [ 2015-04-03 15:39:06.842 MSK ] [ConfigureListener.listenerExists:396]  Is listener "LISTENER" already exists: false
[main] [ 2015-04-03 15:39:06.842 MSK ] [ConfigureListener.typicalConfigure:257]  Checking for free port in range: 1521-1540
[main] [ 2015-04-03 15:39:06.842 MSK ] [ConfigureListener.validateEndPoint:1059]  Validating end-point: TCP:1521
[main] [ 2015-04-03 15:39:06.944 MSK ] [ConfigureListener.isPortFree:1131]  Checking if port 1521 is free on local machine...
[main] [ 2015-04-03 15:39:06.945 MSK ] [ConfigureListener.isPortFree:1146]  InetAddress.getByName(127.0.0.1): /127.0.0.1
[main] [ 2015-04-03 15:39:06.945 MSK ] [ConfigureListener.isPortFree:1148]  Local host IP address: localhost.localdomain/127.0.0.1
[main] [ 2015-04-03 15:39:06.945 MSK ] [ConfigureListener.isPortFree:1150]  Local host name: localhost.localdomain
[main] [ 2015-04-03 15:39:06.945 MSK ] [ConfigureListener.isPortFree:1166]  IP Address: localhost.localdomain/127.0.0.1, Is IPv6 Address: false
[main] [ 2015-04-03 15:39:06.946 MSK ] [ConfigureListener.isPortFree:1169]  IP Address: localhost.localdomain/127.0.0.1, Is Link-Local Address: false
[main] [ 2015-04-03 15:39:06.946 MSK ] [ConfigureListener.isPortFree:1194]  Creating ServerSocket on Port:1521, IP Address: localhost.localdomain/127.0.0.1
[main] [ 2015-04-03 15:39:06.968 MSK ] [ConfigureListener.isPortFree:1197]  Created ServerSocket successfully.
[main] [ 2015-04-03 15:39:06.968 MSK ] [ConfigureListener.isPortFree:1166]  IP Address: localhost.localdomain/0:0:0:0:0:0:0:1, Is IPv6 Address: true
[main] [ 2015-04-03 15:39:06.968 MSK ] [ConfigureListener.isPortFree:1169]  IP Address: localhost.localdomain/0:0:0:0:0:0:0:1, Is Link-Local Address: false
[main] [ 2015-04-03 15:39:06.968 MSK ] [ConfigureListener.isPortFree:1194]  Creating ServerSocket on Port:1521, IP Address: localhost.localdomain/0:0:0:0:0:0:0:1
[main] [ 2015-04-03 15:39:06.969 MSK ] [ConfigureListener.isPortFree:1197]  Created ServerSocket successfully.
[main] [ 2015-04-03 15:39:06.969 MSK ] [ConfigureListener.isPortFree:1209]  Creating ServerSocket on Port:1521, Local IP Address: /127.0.0.1
[main] [ 2015-04-03 15:39:06.969 MSK ] [ConfigureListener.isPortFree:1213]  Created ServerSocket successfully.
[main] [ 2015-04-03 15:39:06.969 MSK ] [ConfigureListener.isPortFree:1219]  Creating ServerSocket on Port:1521
[main] [ 2015-04-03 15:39:06.970 MSK ] [ConfigureListener.isPortFree:1222]  Created ServerSocket successfully.
[main] [ 2015-04-03 15:39:06.970 MSK ] [ConfigureListener.isPortFree:1242]  Returning is Port 1521 free: true
[main] [ 2015-04-03 15:39:06.970 MSK ] [ConfigureListener.validateEndPoint:1114]  Validation...Complete for TCP/TCPS.
[main] [ 2015-04-03 15:39:06.970 MSK ] [ConfigureListener.typicalConfigure:274]  Using port: 1521
[main] [ 2015-04-03 15:39:08.684 MSK ] [ConfigureListener.isPortFree:1131]  Checking if port 1521 is free on local machine...
[main] [ 2015-04-03 15:39:08.685 MSK ] [ConfigureListener.isPortFree:1146]  InetAddress.getByName(127.0.0.1): /127.0.0.1
[main] [ 2015-04-03 15:39:08.686 MSK ] [ConfigureListener.isPortFree:1148]  Local host IP address: localhost.localdomain/127.0.0.1
[main] [ 2015-04-03 15:39:08.686 MSK ] [ConfigureListener.isPortFree:1150]  Local host name: localhost.localdomain
[main] [ 2015-04-03 15:39:08.687 MSK ] [ConfigureListener.isPortFree:1166]  IP Address: localhost.localdomain/127.0.0.1, Is IPv6 Address: false
[main] [ 2015-04-03 15:39:08.687 MSK ] [ConfigureListener.isPortFree:1169]  IP Address: localhost.localdomain/127.0.0.1, Is Link-Local Address: false
[main] [ 2015-04-03 15:39:08.687 MSK ] [ConfigureListener.isPortFree:1194]  Creating ServerSocket on Port:1521, IP Address: localhost.localdomain/127.0.0.1
[main] [ 2015-04-03 15:39:08.688 MSK ] [ConfigureListener.isPortFree:1197]  Created ServerSocket successfully.
[main] [ 2015-04-03 15:39:08.688 MSK ] [ConfigureListener.isPortFree:1166]  IP Address: localhost.localdomain/0:0:0:0:0:0:0:1, Is IPv6 Address: true
[main] [ 2015-04-03 15:39:08.689 MSK ] [ConfigureListener.isPortFree:1169]  IP Address: localhost.localdomain/0:0:0:0:0:0:0:1, Is Link-Local Address: false
[main] [ 2015-04-03 15:39:08.689 MSK ] [ConfigureListener.isPortFree:1194]  Creating ServerSocket on Port:1521, IP Address: localhost.localdomain/0:0:0:0:0:0:0:1
[main] [ 2015-04-03 15:39:08.689 MSK ] [ConfigureListener.isPortFree:1197]  Created ServerSocket successfully.
[main] [ 2015-04-03 15:39:08.690 MSK ] [ConfigureListener.isPortFree:1209]  Creating ServerSocket on Port:1521, Local IP Address: /127.0.0.1
[main] [ 2015-04-03 15:39:08.690 MSK ] [ConfigureListener.isPortFree:1213]  Created ServerSocket successfully.
[main] [ 2015-04-03 15:39:08.691 MSK ] [ConfigureListener.isPortFree:1219]  Creating ServerSocket on Port:1521
[main] [ 2015-04-03 15:39:08.691 MSK ] [ConfigureListener.isPortFree:1222]  Created ServerSocket successfully.
[main] [ 2015-04-03 15:39:08.692 MSK ] [ConfigureListener.isPortFree:1242]  Returning is Port 1521 free: true

Maybe problem is because:

PRCI-1144 : Failed to retrieve Oracle Grid Infrastructure home path
PRKC-1144 : File "/etc/oracle/olr.loc" not found.

Any ideas what I am dooing wrong and how finally install the Oracle?


答:
In the first example you did not call the log() function you created.
setTimeout function works because it executes the callback after given time.

```<code>function x() {
  function log() {
    console.log(message)
  }
  const message = "hello"

  log();
}

x()
</code>```

Title: Does setTimeout delay the creation of the function?

Body:
In the first example you did not call the log() function you created.
setTimeout function works because it executes the callback after given time.

function x() {
  function log() {
    console.log(message)
  }
  const message = "hello"

  log();
}

x()


问:
Python: How to Create chucks of data contain X byte for each time
I am trying to write a simple function that take a data in hex format. However, the idea is I want to use for loop with round() so that each time the loop will print only 2KB (2048) of data (only 2048 byte for each time),

This is what I did, but did not work.

```<code>data = "4d5a90000300000004000000fff........"

def function_x(x):
    for i in range(0,int(round(len(data)/2048))):
        data_chunk = data[i*2047:(i+1)*2047]
        ....
        ....
        ....
        ....
</code>```

UPDATE: To make my question clear for you, I will provide some details. I am using Postgresql, Large objects specifically, However, to update this object or insert any new data on it, you must keep this note in you mind, which is mentioned in their documentation

The amount of data per page is defined to be LOBLKSIZE (which is currently BLCKSZ/4, or typically 2 kB "2048").

so I wrote this simple code to fit with their requirements, just do not know what is the the right numbers must be written instead of (?) marks that i put

for i in range(0,int(round(len(data)/??))):  > to divide the code into x number of pages, each page must contain 2048 byte only > data[i*??:(i+1)*??]

NOTE: if i == 0 because the first page must be updated not inserted according to their docs

here is the full code

```<code>data = "4d5a90000300000004000000fff........"
loid = 14697

def function_x(x):
        for i in range(0,int(round(len(data)/??))):
    data_chunk = data[i*??:(i+1)*??]
    if i == 0:
        sql = "UPDATE PG_LARGEOBJECT SET data=decode('%s', 'hex') where loid=%d and pageno=%d" % (data_chunk, loid, i)
    else:
        sql = "INSERT PG_LARGEOBJECT SET data=decode('%s', 'hex') where loid=%d and pageno=%d" % (data_chunk, loid, i)
        ....
        ....
        ....
        ....
</code>```

答:
This Solved my problem too.</p>

```<code>    # divide the length by 2048 to create pages on that range (PostGresql things)
    for i in range(0,int(round(len(data)/2048))):
    # Here will guarantee to take only 2048 byte without any repeat in the data
    data_chunk = data[i*2048:(i+1)*2048]
</code>```

Body:
I am trying to write a simple function that take a data in hex format. However, the idea is I want to use for loop with round() so that each time the loop will print only 2KB (2048) of data (only 2048 byte for each time),

This is what I did, but did not work.

data = "4d5a90000300000004000000fff........"

def function_x(x):
    for i in range(0,int(round(len(data)/2048))):
        data_chunk = data[i*2047:(i+1)*2047]
        ....
        ....
        ....
        ....

UPDATE: To make my question clear for you, I will provide some details. I am using Postgresql, Large objects specifically, However, to update this object or insert any new data on it, you must keep this note in you mind, which is mentioned in their documentation

The amount of data per page is defined to be LOBLKSIZE (which is currently BLCKSZ/4, or typically 2 kB "2048").

so I wrote this simple code to fit with their requirements, just do not know what is the the right numbers must be written instead of (?) marks that i put

for i in range(0,int(round(len(data)/??))):  > to divide the code into x number of pages, each page must contain 2048 byte only > data[i*??:(i+1)*??]

NOTE: if i == 0 because the first page must be updated not inserted according to their docs

here is the full code

data = "4d5a90000300000004000000fff........"
loid = 14697

def function_x(x):
        for i in range(0,int(round(len(data)/??))):
    data_chunk = data[i*??:(i+1)*??]
    if i == 0:
        sql = "UPDATE PG_LARGEOBJECT SET data=decode('%s', 'hex') where loid=%d and pageno=%d" % (data_chunk, loid, i)
    else:
        sql = "INSERT PG_LARGEOBJECT SET data=decode('%s', 'hex') where loid=%d and pageno=%d" % (data_chunk, loid, i)
        ....
        ....
        ....
        ....

Body:
This Solved my problem too.

    # divide the length by 2048 to create pages on that range (PostGresql things)
    for i in range(0,int(round(len(data)/2048))):
    # Here will guarantee to take only 2048 byte without any repeat in the data
    data_chunk = data[i*2048:(i+1)*2048]


问:
enter special characters (accents) in a windows form application
I am working on a MS Paint like application and we allow the user to enter text as well. Now a requirement is to allow the user to enter accents and other special characters.

I understand that we can show the charmap.exe from within the application and allow the user to copy the character and the paste it in the text box used to enter the text. However, we would like the ability where user selects the character and it is entered in the text box.

So is implementing a dialog with the character set the only option ? And if it is the only option, is there a standard way to implement this.

Thanks,
Gaurav

答:
In general, you don't need to do anything. The user's operating system and keyboard will be configured to allow him to enter all the necessary characters, possibly via IME.

As a last resort, one can use numeric codes by typing ALT+[code].


问:
Sign Out button to Present Login View Controller - Swift 5
Hi I'm kind of new to Swift and I can't figure this out. I am trying to create a sign out button that would take user to the login page. I used the following two methods but the first one doesn't do anything and the second one is throwing Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value and it refers to the code with the customButton:

```<code>//this one doesn't do anything
@objc func SignOut(){

    let vc = self.storyboard?.instantiateViewController(identifier: "LoginViewController") as! LoginViewController
    let appDelegate = UIApplication.shared.delegate
    appDelegate?.window??.rootViewController = vc
}

//this one is throwing an error
let vc = CustomViewController()
self.present(vc, animated: true, completion: nil)

//the Fatal error refers to this code
override func viewDidLoad() {
    super.viewDidLoad()
    self.customButton.addTarget(self, action: #selector(customButtonPressed), for: .touchUpInside)
}
</code>```

Also, I was wondering if AppDelegate is the right approach or if I should use SceneDelegate. Any help would be greatly appreciated.

答:
```<code>let vc = self.storyboard?.instantiateViewController(identifier: "LoginViewController") as! LoginViewController
vc.modalPresentationStyle = .fullScreen
self.present(vc, animated: true, completion: nil)
</code>```

Please make sure the identifier is matching the one inside storyboard for this viewController

Body:
Hi I'm kind of new to Swift and I can't figure this out. I am trying to create a sign out button that would take user to the login page. I used the following two methods but the first one doesn't do anything and the second one is throwing Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value and it refers to the code with the customButton:

//this one doesn't do anything
@objc func SignOut(){

    let vc = self.storyboard?.instantiateViewController(identifier: "LoginViewController") as! LoginViewController
    let appDelegate = UIApplication.shared.delegate
    appDelegate?.window??.rootViewController = vc
}

//this one is throwing an error
let vc = CustomViewController()
self.present(vc, animated: true, completion: nil)

//the Fatal error refers to this code
override func viewDidLoad() {
    super.viewDidLoad()
    self.customButton.addTarget(self, action: #selector(customButtonPressed), for: .touchUpInside)
}

Also, I was wondering if AppDelegate is the right approach or if I should use SceneDelegate. Any help would be greatly appreciated.

Body:
let vc = self.storyboard?.instantiateViewController(identifier: "LoginViewController") as! LoginViewController
vc.modalPresentationStyle = .fullScreen
self.present(vc, animated: true, completion: nil)

Please make sure the identifier is matching the one inside storyboard for this viewController


问:
org.springframework.http.converter.HttpMessageNotWritableException: in corda
Getting exception while retrieving node info through method in java using spring web server.

This is the code written in custom controller:

```<code>@RequestMapping(value="/me", produces = MediaType.APPLICATION_JSON)

    public Party me() throws Exception

    {
        CordaRPCOps proxy = rpc.proxy;
        Party id = proxy.nodeInfo().getLegalIdentities().get(0);
        return id;
    }
</code>```

Even I tried by making parameter as:

```<code>spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false in gradlew.properties
</code>```

And also by adding dependency cordaCompile "net.corda:corda-jackson:3.1-corda" in java-source.

PFA, error screenshot

答:
It's not exactly clear what happened to solve the issue or if you solved it at all, but the recommendation definitely would have been to try that gradle setting to make sure spring gets all the environment-like variables it needs.

there are new sample cordapps in newer corda releases that use spring webservers, you can find an example here: https://github.com/corda/samples-java/tree/master/Advanced/obligation-cordapp

Body:
Getting exception while retrieving node info through method in java using spring web server.

This is the code written in custom controller:

@RequestMapping(value="/me", produces = MediaType.APPLICATION_JSON)

    public Party me() throws Exception

    {
        CordaRPCOps proxy = rpc.proxy;
        Party id = proxy.nodeInfo().getLegalIdentities().get(0);
        return id;
    }

Even I tried by making parameter as:

spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false in gradlew.properties

And also by adding dependency cordaCompile "net.corda:corda-jackson:3.1-corda" in java-source.

PFA, error screenshot


答:
I am not sure as per your little drawing that you made if the h1 is needed to be inside of the inner div like your code suggests, but your drawing does not.  If its not needed inside that inner div You can simply move the header text outside of the child div like this example.  But otherwise if you want the text at the bottom of the inner div, and not outside of it then you can follow the answer provided by @thenomadicmann

     .grey_box {
            background-color: grey;
            width: 680px;
            height: 500px;
        }
        .yellow_box {
            background-color: yellow;
            width: 450px;
            height: 300px;
        }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="grey_box">
        <div class="yellow_box">
        </div>
        <h1>when I say div</h1>
    </div></code>```

Title: how to put text at bottom of div that is inside another div

Body:
I have the following layout:

and I want to put some text at bottom of div2 just like in the pic.

I have the following code:

when I say div

Body:
I am not sure as per your little drawing that you made if the h1 is needed to be inside of the inner div like your code suggests, but your drawing does not.  If its not needed inside that inner div You can simply move the header text outside of the child div like this example.  But otherwise if you want the text at the bottom of the inner div, and not outside of it then you can follow the answer provided by @thenomadicmann

     .grey_box {
            background-color: grey;
            width: 680px;
            height: 500px;
        }
        .yellow_box {
            background-color: yellow;
            width: 450px;
            height: 300px;
        }

<div class="grey_box">
        <div class="yellow_box">
        </div>
        <h1>when I say div</h1>
    </div>


问:
XLA-able dynamic slicing
Is there any way to dynamically slice a tensor according to a random number generator in an XLA-compiled function?  For example:

@tf.function(experimental_compile=True)
def random_slice(input, max_slice_size):
    offset = tf.squeeze(tf.random.uniform([1], minval=0, maxval=input.shape[0]-max_slice_size, dtype=tf.int32))
    sz = tf.squeeze(tf.random.uniform([1], minval=1, maxval=max_slice_size, dtype=tf.int32))

    indices = tf.range(offset, offset+sz)  # Non-XLA-able due to non-static bounds

    return tf.gather(input, indices)

x = tf.ones([50, 50])
y = random_slice(x, 4)
```

This code fails to compile because XLA requires that the arguments to tf.range are known at compile time.  Is there a recommended workaround?

答: The underlying issue here is that XLA needs to know, statically, the shapes of all Tensors in the program. In this case it complains about tf.range because its output is not knowable given the random inputs. You might instead be able to get away with generating a masked version (zeroing out the elements you don't need, using something like tensor_scatter_nd_update) and using that masked version downstream (hard to say exactly how, without seeing more context on how y is to be used).

Title: XLA-able dynamic slicing

Body:
Is there any way to dynamically slice a tensor according to a random number generator in an XLA-compiled function?  For example:

@tf.function(experimental_compile=True)
def random_slice(input, max_slice_size):
    offset = tf.squeeze(tf.random.uniform([1], minval=0, maxval=input.shape[0]-max_slice_size, dtype=tf.int32))
    sz = tf.squeeze(tf.random.uniform([1], minval=1, maxval=max_slice_size, dtype=tf.int32))

    indices = tf.range(offset, offset+sz)  # Non-XLA-able due to non-static bounds

    return tf.gather(input, indices)

x = tf.ones([50, 50])
y = random_slice(x, 4)

This code fails to compile because XLA requires that the arguments to tf.range are known at compile time.  Is there a recommended workaround?


问:
What is the best way to write to a file in a parallel thread in Java?
I have a program that performs lots of calculations and reports them to a file frequently. I know that frequent write operations can slow a program down a lot, so to avoid it I'd like to have a second thread dedicated to the writing operations.

Right now I'm doing it with this class I wrote (the impatient can skip to the end of the question):

```<code>public class ParallelWriter implements Runnable {

    private File file;
    private BlockingQueue<Item> q;
    private int indentation;

    public ParallelWriter( File f ){
        file = f;
        q = new LinkedBlockingQueue<Item>();
        indentation = 0;
    }

    public ParallelWriter append( CharSequence str ){
        try {
            CharSeqItem item = new CharSeqItem();
            item.content = str;
            item.type = ItemType.CHARSEQ;
            q.put(item);
            return this;
        } catch (InterruptedException ex) {
            throw new RuntimeException( ex );
        }
    }

    public ParallelWriter newLine(){
        try {
            Item item = new Item();
            item.type = ItemType.NEWLINE;
            q.put(item);
            return this;
        } catch (InterruptedException ex) {
            throw new RuntimeException( ex );
        }
    }

    public void setIndent(int indentation) {
        try{
            IndentCommand item = new IndentCommand();
            item.type = ItemType.INDENT;
            item.indent = indentation;
            q.put(item);
        } catch (InterruptedException ex) {
            throw new RuntimeException( ex );
        }
    }

    public void end(){
        try {
            Item item = new Item();
            item.type = ItemType.POISON;
            q.put(item);
        } catch (InterruptedException ex) {
            throw new RuntimeException( ex );
        }
    }

    public void run() {

        BufferedWriter out = null;
        Item item = null;

        try{
            out = new BufferedWriter( new FileWriter( file ) );
            while( (item = q.take()).type != ItemType.POISON ){
                switch( item.type ){
                    case NEWLINE:
                        out.newLine();
                        for( int i = 0; i < indentation; i++ )
                            out.append("   ");
                        break;
                    case INDENT:
                        indentation = ((IndentCommand)item).indent;
                        break;
                    case CHARSEQ:
                        out.append( ((CharSeqItem)item).content );
                }
            }
        } catch (InterruptedException ex){
            throw new RuntimeException( ex );
        } catch  (IOException ex) {
            throw new RuntimeException( ex );
        } finally {
            if( out != null ) try {
                out.close();
            } catch (IOException ex) {
                throw new RuntimeException( ex );
            }
        }
    }

    private enum ItemType {
        CHARSEQ, NEWLINE, INDENT, POISON;
    }
    private static class Item {
        ItemType type;
    }
    private static class CharSeqItem extends Item {
        CharSequence content;
    }
    private static class IndentCommand extends Item {
        int indent;
    }
}
</code>```

And then I use it by doing:

```<code>ParallelWriter w = new ParallelWriter( myFile );
new Thread(w).start();

/// Lots of
w.append(" things ").newLine();
w.setIndent(2);
w.newLine().append(" more things ");

/// and finally
w.end();
</code>```

While this works perfectly well, I'm wondering:
Is there a better way to accomplish this?

答:
I know that frequent write operations
  can slow a program down a lot

Probably not as much as you think, provided you use buffering.

Body:
I have a program that performs lots of calculations and reports them to a file frequently. I know that frequent write operations can slow a program down a lot, so to avoid it I'd like to have a second thread dedicated to the writing operations.

Right now I'm doing it with this class I wrote (the impatient can skip to the end of the question):

public class ParallelWriter implements Runnable {

    private File file;
    private BlockingQueue<Item> q;
    private int indentation;

    public ParallelWriter( File f ){
        file = f;
        q = new LinkedBlockingQueue<Item>();
        indentation = 0;
    }

    public ParallelWriter append( CharSequence str ){
        try {
            CharSeqItem item = new CharSeqItem();
            item.content = str;
            item.type = ItemType.CHARSEQ;
            q.put(item);
            return this;
        } catch (InterruptedException ex) {
            throw new RuntimeException( ex );
        }
    }

    public ParallelWriter newLine(){
        try {
            Item item = new Item();
            item.type = ItemType.NEWLINE;
            q.put(item);
            return this;
        } catch (InterruptedException ex) {
            throw new RuntimeException( ex );
        }
    }

    public void setIndent(int indentation) {
        try{
            IndentCommand item = new IndentCommand();
            item.type = ItemType.INDENT;
            item.indent = indentation;
            q.put(item);
        } catch (InterruptedException ex) {
            throw new RuntimeException( ex );
        }
    }

    public void end(){
        try {
            Item item = new Item();
            item.type = ItemType.POISON;
            q.put(item);
        } catch (InterruptedException ex) {
            throw new RuntimeException( ex );
        }
    }

    public void run() {

        BufferedWriter out = null;
        Item item = null;

        try{
            out = new BufferedWriter( new FileWriter( file ) );
            while( (item = q.take()).type != ItemType.POISON ){
                switch( item.type ){
                    case NEWLINE:
                        out.newLine();
                        for( int i = 0; i < indentation; i++ )
                            out.append("   ");
                        break;
                    case INDENT:
                        indentation = ((IndentCommand)item).indent;
                        break;
                    case CHARSEQ:
                        out.append( ((CharSeqItem)item).content );
                }
            }
        } catch (InterruptedException ex){
            throw new RuntimeException( ex );
        } catch  (IOException ex) {
            throw new RuntimeException( ex );
        } finally {
            if( out != null ) try {
                out.close();
            } catch (IOException ex) {
                throw new RuntimeException( ex );
            }
        }
    }

    private enum ItemType {
        CHARSEQ, NEWLINE, INDENT, POISON;
    }
    private static class Item {
        ItemType type;
    }
    private static class CharSeqItem extends Item {
        CharSequence content;
    }
    private static class IndentCommand extends Item {
        int indent;
    }
}

And then I use it by doing:

ParallelWriter w = new ParallelWriter( myFile );
new Thread(w).start();

/// Lots of
w.append(" things ").newLine();
w.setIndent(2);
w.newLine().append(" more things ");

/// and finally
w.end();

While this works perfectly well, I'm wondering:
Is there a better way to accomplish this?


问:
How do I print this collection in a formatted way?
I have stored a cart in the database and want to associate it with an order number so that I can view order items. I have stored the cart using Cart::store($identifier) and retrived using $d = DB::table('shoppingcart')->get();. How do I print out this content?

I have tried using foreach loop but is not helping

```<code>+"content": "O:29:"Illuminate\Support\Collection":1:{s:8:"\x00*\x00items";a:2:{s:32:"07cca15168b1a5e48e0f89d878fbf6ea";O:32:"Gloudemans\Shoppingcart\CartItem":9:{s:5:"rowId";s:32:"07cca15168b1a5e48e0f89d878fbf6ea";s:2:"id";s:2:"16";s:3:"qty";i:1;s:4:"name";s:19:"Dr. Granville Braun";s:5:"price";d:515;s:7:"options";O:39:"Gloudemans\Shoppingcart\CartItemOptions":1:{s:8:"\x00*\x00items";a:0:{}}s:49:"\x00Gloudemans\Shoppingcart\CartItem\x00associatedModel";s:11:"App\Product";s:41:"\x00Gloudemans\Shoppingcart\CartItem\x00taxRate";i:21;s:41:"\x00Gloudemans\Shoppingcart\CartItem\x00isSaved";b:0;}s:32:"027c91341fd5cf4d2579b49c4b6a90da";O:32:"Gloudemans\Shoppingcart\CartItem":9:{s:5:"rowId";s:32:"027c91341fd5cf4d2579b49c4b6a90da";s:2:"id";s:1:"1";s:3:"qty";i:1;s:4:"name";s:17:"Double Wall Glass";s:5:"price";d:547;s:7:"options";O:39:"Gloudemans\Shoppingcart\CartItemOptions":1:{s:8:"\x00*\x00items";a:0:{}}s:49:"\x00Gloudemans\Shoppingcart\CartItem\x00associatedModel";s:11:"App\Product";s:41:"\x00Gloudemans\Shoppingcart\CartItem\x00taxRate";i:21;s:41:"\x00Gloudemans\Shoppingcart\CartItem\x00isSaved";b:0;}}} ◀"
</code>```

答:
You can get the data in the array format like this :</p>

```<code>$d = DB::table('shoppingcart')->get()->toArray();
</code>```

Body:
I have stored a cart in the database and want to associate it with an order number so that I can view order items. I have stored the cart using Cart::store($identifier) and retrived using $d = DB::table('shoppingcart')->get();. How do I print out this content?

I have tried using foreach loop but is not helping

+"content": "O:29:"Illuminate\Support\Collection":1:{s:8:"\x00*\x00items";a:2:{s:32:"07cca15168b1a5e48e0f89d878fbf6ea";O:32:"Gloudemans\Shoppingcart\CartItem":9:{s:5:"rowId";s:32:"07cca15168b1a5e48e0f89d878fbf6ea";s:2:"id";s:2:"16";s:3:"qty";i:1;s:4:"name";s:19:"Dr. Granville Braun";s:5:"price";d:515;s:7:"options";O:39:"Gloudemans\Shoppingcart\CartItemOptions":1:{s:8:"\x00*\x00items";a:0:{}}s:49:"\x00Gloudemans\Shoppingcart\CartItem\x00associatedModel";s:11:"App\Product";s:41:"\x00Gloudemans\Shoppingcart\CartItem\x00taxRate";i:21;s:41:"\x00Gloudemans\Shoppingcart\CartItem\x00isSaved";b:0;}s:32:"027c91341fd5cf4d2579b49c4b6a90da";O:32:"Gloudemans\Shoppingcart\CartItem":9:{s:5:"rowId";s:32:"027c91341fd5cf4d2579b49c4b6a90da";s:2:"id";s:1:"1";s:3:"qty";i:1;s:4:"name";s:17:"Double Wall Glass";s:5:"price";d:547;s:7:"options";O:39:"Gloudemans\Shoppingcart\CartItemOptions":1:{s:8:"\x00*\x00items";a:0:{}}s:49:"\x00Gloudemans\Shoppingcart\CartItem\x00associatedModel";s:11:"App\Product";s:41:"\x00Gloudemans\Shoppingcart\CartItem\x00taxRate";i:21;s:41:"\x00Gloudemans\Shoppingcart\CartItem\x00isSaved";b:0;}}} ◀"

Body:
You can get the data in the array format like this :

$d = DB::table('shoppingcart')->get()->toArray();


问:
Pythonic way of loading files with similar filename
I am using pathlib.Path() to check whether a file exists, and open it as an image using rasterio.

```<code>filename = pathlib.Path("./my_file-name.tif")
</code>```

However, some of the files in the directory I am loading from have a slightly different filename, e.g. my_filename.tif (without a hyphen) or my_file_name.tif (with an underscore instead of a hyphen).

All file names have the same basic structure. Is there a better way to call pathlib.Path() with all possible variations in filename.tif than just checking if they all exist? e.g.,

```<code>filename = pathlib.Path("./my_file-name.tif")
if not file.is_file():
    file = Path("./my_file_name.tif")
if not file.is_file():
    file = Path("./my_filename.tif")
</code>```

答:
You could use a regular expression (or expressions) to see if any files in your directory match. But you could also just check to see if a filename has all the necessary components. Here's an example you can adapt:

```<code>dir = pathlib.Path("./")
must_contain = ['my', 'file', 'name', '.tif']
true_filepath = None
for filepath in os.listdir(dir):
    if all([item in filepath for item in must_contain]):
        true_filepath = filepath
        break
</code>```

This will select the first item that contains all the necessary components. If you have specific requirements for the form that the components must take, then I'd suggest the regular expression route, where you use a regular expression(s) that match what you need. here's the documentation for the regular expression package re in python 3.

Hope this helps, Happy Coding!

Body:
I am using pathlib.Path() to check whether a file exists, and open it as an image using rasterio.

filename = pathlib.Path("./my_file-name.tif")

However, some of the files in the directory I am loading from have a slightly different filename, e.g. my_filename.tif (without a hyphen) or my_file_name.tif (with an underscore instead of a hyphen).

All file names have the same basic structure. Is there a better way to call pathlib.Path() with all possible variations in filename.tif than just checking if they all exist? e.g.,

filename = pathlib.Path("./my_file-name.tif")
if not file.is_file():
    file = Path("./my_file_name.tif")
if not file.is_file():
    file = Path("./my_filename.tif")

Body:
You could use a regular expression (or expressions) to see if any files in your directory match. But you could also just check to see if a filename has all the necessary components. Here's an example you can adapt:

dir = pathlib.Path("./")
must_contain = ['my', 'file', 'name', '.tif']
true_filepath = None
for filepath in os.listdir(dir):
    if all([item in filepath for item in must_contain]):
        true_filepath = filepath
        break

This will select the first item that contains all the necessary components. If you have specific requirements for the form that the components must take, then I'd suggest the regular expression route, where you use a regular expression(s) that match what you need. here's the documentation for the regular expression package re in python 3.

Hope this helps, Happy Coding!


问:
How to migrate data from dolphindb to python numpy?
I have some data in dolphindb, such as：

```<code>a = 1                // int
st  = "stringx"      // string
m1=1..9$3:3          // matrix
vec = 1 2 3 4 5 6    // vector
</code>```

I want to use them in numpy, what should I do? What kind of numpy object they will be convert to?

答:
when you download these data using DolphinDB Python API, it will be automatically converted into numpy  </p>

```<code>    import dolphindb as ddb
    s = ddb.session()
    s.connect("localhost",8848, "admin","123456")
    s.run("vec=1..6")
    vec=s.run("vec")

    >>> vec
    array([1, 2, 3, 4, 5, 6], dtype=int32)
</code>```

Body:
I have some data in dolphindb, such as：

a = 1                // int
st  = "stringx"      // string
m1=1..9$3:3          // matrix
vec = 1 2 3 4 5 6    // vector

I want to use them in numpy, what should I do? What kind of numpy object they will be convert to?

Body:
when you download these data using DolphinDB Python API, it will be automatically converted into numpy

    import dolphindb as ddb
    s = ddb.session()
    s.connect("localhost",8848, "admin","123456")
    s.run("vec=1..6")
    vec=s.run("vec")

    >>> vec
    array([1, 2, 3, 4, 5, 6], dtype=int32)


问:
Delaying opening of sub-menus in a menustrip
Our environment: Visual Studio 2010, c#, .net 4 client profile.

We have a Winforms application that contains a menustrip in its main form. The items of the menustrip contain both an image (64x64) and text. The main form also has a TabControl which contains 5 tabs. In the OnLoad() method of the main form, we hide the TabControl headers so that they are not visible and therefore not clickable. Instead, when the user clicks on an item in the menustrip, we switch the active tab.

However, our menus have many sub-menu items, and since we use the main menustrip to select the active tab, we would like the sub-menu items to appear only after the user clicks the menu item for a period of time, not instantaneously. Otherwise, whenever the user changes his/her active view (by selecting a tabPage), the sub-menus appear on the screen since he/she clicked a menustrip item that contains sub menus.

Is this possible?

答:
I don't completely understand the rationale, but you can delay the display of a submenu using the MouseDown handler and sleep function, like this:

```<code>Private Sub FileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FileToolStripMenuItem.MouseDown
System.Threading.Thread.Sleep(2000) ' wait two seconds
End Sub
</code>```

======================

(Edit: Added second solution)

You can do this with a timer control and ShowDropDown/HideDropDown:

```<code>Private Sub FileToolStripMenuItem_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles FileToolStripMenuItem.MouseDown
' show tab here'
FileToolStripMenuItem.HideDropDown()
Timer1.Interval = 500
Timer1.Start()
End Sub

Private Sub FileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FileToolStripMenuItem.Click
FileToolStripMenuItem.HideDropDown()
End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Stop()
FileToolStripMenuItem.ShowDropDown()
End Sub
</code>```

Body:
I don't completely understand the rationale, but you can delay the display of a submenu using the MouseDown handler and sleep function, like this:

Private Sub FileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FileToolStripMenuItem.MouseDown
System.Threading.Thread.Sleep(2000) ' wait two seconds
End Sub

======================

(Edit: Added second solution)

You can do this with a timer control and ShowDropDown/HideDropDown:

Private Sub FileToolStripMenuItem_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles FileToolStripMenuItem.MouseDown
' show tab here'
FileToolStripMenuItem.HideDropDown()
Timer1.Interval = 500
Timer1.Start()
End Sub

Private Sub FileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FileToolStripMenuItem.Click
FileToolStripMenuItem.HideDropDown()
End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Stop()
FileToolStripMenuItem.ShowDropDown()
End Sub


问:
Is there a way to compare CSVs in Python while ignoring row ordering?
I'm setting up an automatic job that needs to parse csv files from an ftp site, each file contains several 10 thousand lines. I want to pre-process the directory to eliminate duplicate files before parsing the remaining files. The problem is that duplicate files are being pushed to the ftp but with different row ordering (i.e. same data, different order). That results in "duplicate files" having different hashes and byte-by-byte comparisons. with minimal processing.

I want to keep file manipulation to the minimum so I tried sorting the CSVs using the csvsort module but this is giving me an index error: IndexError: list index out of range. Here is the relevant code:

```<code>from csvsort import csvsort
csvsort(input_filename=file_path,columns=[1,2])
</code>```

I tried finding and eliminating empty rows but this didn't seem to be the problem and, like I said, I want to keep file manipulation to the minimum to retain file integrity. Moreover, I have no control over the creation of files or pushing of the files to the ftp

I can think of a number of ways to work around this issue but they would all involve opening the CSVs and reading the contents, manipulating it, etc. Is there anyway I can do a lightweight file comparison that ignores row ordering or will I have to go for heavier processing?

答:
You do not specify how much data you have. My take on this would differ depending on size. Are we talking 100's of lines ? Or multi-million lines ?

If you have "few" lines you can easily sort the lines. But if the data gets longer, you can use other strategies.

I have previously solved the problem of "weeding out lines from file A that appear in file B" using AWK, since AWK is able to do this with just 1 run through the long file (A), making the process extremely fast. However you may need to call an external program. Not sure if this is ideal for you.

If your lines are not completely identical - let's say you need to compare just one of several fields - AWK can do that as well. Just extract fields into variables.

If you choose to go this way, the script is something along:

```<code>FNR==NR{
a[$0]++;cnt[1]+=1;next
}

!a[$0]
</code>```

Use with

```<code>c:\path\to\awk.exe  -f awkscript.awk   SMALL_LIST   FULL_LIST  > DIFF_LIST
</code>```

DIFF_LIST is items from FULL that are NOT in SMALL.

Body:
I'm setting up an automatic job that needs to parse csv files from an ftp site, each file contains several 10 thousand lines. I want to pre-process the directory to eliminate duplicate files before parsing the remaining files. The problem is that duplicate files are being pushed to the ftp but with different row ordering (i.e. same data, different order). That results in "duplicate files" having different hashes and byte-by-byte comparisons. with minimal processing.

I want to keep file manipulation to the minimum so I tried sorting the CSVs using the csvsort module but this is giving me an index error: IndexError: list index out of range. Here is the relevant code:

from csvsort import csvsort
csvsort(input_filename=file_path,columns=[1,2])

I tried finding and eliminating empty rows but this didn't seem to be the problem and, like I said, I want to keep file manipulation to the minimum to retain file integrity. Moreover, I have no control over the creation of files or pushing of the files to the ftp

I can think of a number of ways to work around this issue but they would all involve opening the CSVs and reading the contents, manipulating it, etc. Is there anyway I can do a lightweight file comparison that ignores row ordering or will I have to go for heavier processing?

Body:
You do not specify how much data you have. My take on this would differ depending on size. Are we talking 100's of lines ? Or multi-million lines ?

If you have "few" lines you can easily sort the lines. But if the data gets longer, you can use other strategies.

I have previously solved the problem of "weeding out lines from file A that appear in file B" using AWK, since AWK is able to do this with just 1 run through the long file (A), making the process extremely fast. However you may need to call an external program. Not sure if this is ideal for you.

If your lines are not completely identical - let's say you need to compare just one of several fields - AWK can do that as well. Just extract fields into variables.

If you choose to go this way, the script is something along:

FNR==NR{
a[$0]++;cnt[1]+=1;next
}

!a[$0]

Use with

c:\path\to\awk.exe  -f awkscript.awk   SMALL_LIST   FULL_LIST  > DIFF_LIST

DIFF_LIST is items from FULL that are NOT in SMALL.


问:
Opening terminal in current directory
I am attempting to set up the behavior described in the title. For reference, there is an answer which solve this for emacs. I however use DWM/ST and Zsh.

The solutions I have clumsily tried to come um with include modifying the .zshrc file in the with the following lined:

```<code>cd $pwd
</code>```

I have realized this does not make sense as the path displayed by this instance of pwd will in fact be the path in which the terminal itself is opened, which is $HOME. Maybe the solution is messing with ST, but I have not had any ideas of how to do do so. Any help would be appreciated.

答:
it depends on the terminal emulator that you're using: for instance

```<code> $lxterminal --working-directory=./
</code>```

Works for zsh in my manjaro distribution.

in Ubuntu i might use:

```<code> $x-terminal-emulator ./
</code>```

Title: Opening terminal in current directory

Body:
I am attempting to set up the behavior described in the title. For reference, there is an answer which solve this for emacs. I however use DWM/ST and Zsh.

The solutions I have clumsily tried to come um with include modifying the .zshrc file in the with the following lined:

cd $pwd

I have realized this does not make sense as the path displayed by this instance of pwd will in fact be the path in which the terminal itself is opened, which is $HOME. Maybe the solution is messing with ST, but I have not had any ideas of how to do do so. Any help would be appreciated.

Body:
it depends on the terminal emulator that you're using: for instance

 $lxterminal --working-directory=./

Works for zsh in my manjaro distribution.

in Ubuntu i might use:

 $x-terminal-emulator ./