问:
Highlight Listbox Function
Im looking for assistance in my code in regards to my listbox highlighting and actively changing the highlighted choice based off active sheet.

my listbox auto populates based off the sheets within the workbook and can change active worksheet based off selection but does not auto highlight the initial loaded active sheet as the selection and when manually selected on the workbook does not reflect the changes.

```<code>Public ActiveSheetChoice As String

    Private Sub ActiveSheetDisplay_AfterUpdate()

        ActiveSheetChoice = ActiveSheetDisplay.Text

    ' Change sheet based on choice
        Worksheets(ActiveSheetChoice).Activate

    End Sub
Private Sub ActiveSheetDisplayRefresh_Click()

' Declaration
    Dim N As Long

' Clear exsisting entries
    ActiveSheetDisplay.Clear

' Function
    For N = 1 To ActiveWorkbook.Sheets.Count
        ActiveSheetDisplay.AddItem ActiveWorkbook.Sheets(N).Name
    Next N

End Sub

Private Sub UserForm_Initialize()

    ' Declaration
        Dim N As Long

    ' Initalization of active sheet display
        For N = 1 To ActiveWorkbook.Sheets.Count
            ActiveSheetDisplay.AddItem ActiveWorkbook.Sheets(N).Name
        Next N

End Sub

Private Sub ImportButton_Click()

' Declare Variables
    Dim TargetBook As Workbook
    Dim SourceBook As Workbook

' Set Active Workbook
    Set SourceBook = ThisWorkbook

' Display a Dialog Box that allows to select a single file.
    'The path for the file picked will be stored in fullpath variable
        With Application.FileDialog(msoFileDialogFilePicker)

        ' Makes sure the user can select only one file
            .AllowMultiSelect = False

        ' Filter to just the following types of files to narrow down selection options
            .Filters.Add "Excel Files", "*.xlsx; *.xlsm; *.xls; *.xlsb", 1

        ' Show the dialog box
            .Show

        ' Opening selected file
            For Each Book In .SelectedItems
                Set TargetBook = Workbooks.Open(Book)
                CopyAllSheets SourceBook, TargetBook
                TargetBook.Close SaveChanges:=False
            Next Book

        ' Refresh Active Sheets
            Call ActiveSheetDisplayRefresh_Click

        ' Inform User of completion
            MsgBox "Data import complete"

        End With

End Sub

' Copy Sheet Function
    Sub CopyAllSheets(Source As Workbook, Target As Workbook)

    ' Determine Number of sheets to copy
        totalSheets = Target.Sheets.Count

    ' Copy
        For Each sh In Target.Sheets
          sh.Copy after:=Source.Sheets(Source.Sheets.Count)
        Next sh

    End Sub

    Private Sub SaveOptionButton_Click()

        ' Save workbook Function
            ThisWorkbook.Save
            MsgBox "Workbook saved!"

    End Sub

' Using Query Close event of Userform
    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

' Display information message dialog box
        If CloseMode = vbFormControlMenu Then

            'Changing Cancel variable value to True
                Cancel = True
                MsgBox "Main Options cannot be closed"

        End If

    End Sub
</code>```

答:
The ListBox won't show any highlight because no selection has been made. When no selection was made the ListBox has no Value (Text). If you assign a Value programmatically it will be highlighted automatically. If you assign a value not in the list an error will occur.

Consider using the Worksheet_Activate event to set a value.

```<code>Private Sub Worksheet_Activate()
    On Error Resume Next
    ActiveSheetDisplay.Text = ActiveSheet.Name
End Sub
</code>```

The On Error statement has the function of preventing a crash if the ActiveSheet isn't in the list for whatever reason.

The above idea has been implemented in the solution presented below. You will need to adapt parts of it to use the variable names you are already familiar with.

You should have a userform. I have named mine MyForm. Replace the name in my code with one you like better wherever it appears.

My MyForm has a ListBox called ListBox1. Replace the name in my code with one you like better wherever it appears.

Install the following 3 procedures in a standard code module.

Sub ShowMyForm()
    ' Variatus @STO 21 Feb 2020

```<code>Dim UForm As MyForm

If FormIndex = True Then             ' prevents creation of several instances
    Debug.Print "New form"
    Set UForm = New MyForm
    UForm.Show vbModeless
End If
</code>```

End Sub

Sub RefreshMyForm()
    ' Variatus @STO 21 Feb 2020

```<code>Dim i As Integer

i = FormIndex
If i > -1 Then
    UserForms(i).ListBox1.Text = ActiveSheet.Name
End If
</code>```

End Sub

Private Function FormIndex() As Integer
    ' Variatus @STO 21 Feb 2020

```<code>Dim i As Integer

For i = UserForms.Count To 1 Step -1
    If UserForms(i - 1).Name = "MyForm" Then Exit For
Next i

FormIndex = i - 1
</code>```

End Function

This procedure goes into the ThisWorkbook code module.

Private Sub Workbook_Open()
    ' Variatus @STO 21 Feb 2020
    ShowMyForm
End Sub

The procedure below goes into the userform's code module. You can adjust the way the list box is filled to exclude some sheets but it's important that you set the V variable to indicate the currently active sheet.

Private Sub UserForm_Initialize()
    ' Variatus @STO 21 Feb 2020

```<code>Dim Ws As Worksheet
Dim Arr() As String
Dim V As Integer
Dim i As Integer

With Worksheets
    ReDim Arr(1 To .Count)
    For i = 1 To .Count
        Arr(i) = .Item(i).Name
        If .Item(i) Is ActiveSheet Then V = i
    Next i
End With

With ListBox1
    .List = Arr
    .ListIndex = V - 1
End With
</code>```

End Sub

Finally, this is the procedure you need to install in the code sheet of every worksheet listed in the listbox.

Private Sub Worksheet_Activate()
    ' Variatus @STO 21 Feb 2020

```<code>RefreshMyForm
</code>```

End Sub

Now, to put it all together: When the workbook is opened the procedure ShowMyForm is called. If the form gets deleted accidentally thereafter you can reinstate it by calling the same procedure or the Workbook_Open event procedure (which can also be called with F5). If ShowMyForm is called repeatedly it will refuse to open more than one instance of the form.

When the form is shown its Initialize event procedure runs. This procedure lists the sheets in the listbox and sets the current ActiveSheet.

When you change sheets a new sheet gets activated and the Worksheet_Activate event occurs. The relative event procedure calls the ListBox's Initialize event, resetting the list.

When you select another sheet from the listbox it gets activate by this procedure in the UserForm's code sheet. However, I think you have this already.

```<code>Private Sub ListBox1_Click()
    ' Variatus @STO 21 Feb 2020
    Worksheets(ListBox1.Value).Activate
End Sub
</code>```

Title: Highlight Listbox Function

Body:
Im looking for assistance in my code in regards to my listbox highlighting and actively changing the highlighted choice based off active sheet.

my listbox auto populates based off the sheets within the workbook and can change active worksheet based off selection but does not auto highlight the initial loaded active sheet as the selection and when manually selected on the workbook does not reflect the changes.

Public ActiveSheetChoice As String

    Private Sub ActiveSheetDisplay_AfterUpdate()

        ActiveSheetChoice = ActiveSheetDisplay.Text

    ' Change sheet based on choice
        Worksheets(ActiveSheetChoice).Activate

    End Sub
Private Sub ActiveSheetDisplayRefresh_Click()

' Declaration
    Dim N As Long

' Clear exsisting entries
    ActiveSheetDisplay.Clear

' Function
    For N = 1 To ActiveWorkbook.Sheets.Count
        ActiveSheetDisplay.AddItem ActiveWorkbook.Sheets(N).Name
    Next N

End Sub

Private Sub UserForm_Initialize()

    ' Declaration
        Dim N As Long

    ' Initalization of active sheet display
        For N = 1 To ActiveWorkbook.Sheets.Count
            ActiveSheetDisplay.AddItem ActiveWorkbook.Sheets(N).Name
        Next N

End Sub

Private Sub ImportButton_Click()

' Declare Variables
    Dim TargetBook As Workbook
    Dim SourceBook As Workbook

' Set Active Workbook
    Set SourceBook = ThisWorkbook

' Display a Dialog Box that allows to select a single file.
    'The path for the file picked will be stored in fullpath variable
        With Application.FileDialog(msoFileDialogFilePicker)

        ' Makes sure the user can select only one file
            .AllowMultiSelect = False

        ' Filter to just the following types of files to narrow down selection options
            .Filters.Add "Excel Files", "*.xlsx; *.xlsm; *.xls; *.xlsb", 1

        ' Show the dialog box
            .Show

        ' Opening selected file
            For Each Book In .SelectedItems
                Set TargetBook = Workbooks.Open(Book)
                CopyAllSheets SourceBook, TargetBook
                TargetBook.Close SaveChanges:=False
            Next Book

        ' Refresh Active Sheets
            Call ActiveSheetDisplayRefresh_Click

        ' Inform User of completion
            MsgBox "Data import complete"

        End With

End Sub

' Copy Sheet Function
    Sub CopyAllSheets(Source As Workbook, Target As Workbook)

    ' Determine Number of sheets to copy
        totalSheets = Target.Sheets.Count

    ' Copy
        For Each sh In Target.Sheets
          sh.Copy after:=Source.Sheets(Source.Sheets.Count)
        Next sh

    End Sub

    Private Sub SaveOptionButton_Click()

        ' Save workbook Function
            ThisWorkbook.Save
            MsgBox "Workbook saved!"

    End Sub

' Using Query Close event of Userform
    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

' Display information message dialog box
        If CloseMode = vbFormControlMenu Then

            'Changing Cancel variable value to True
                Cancel = True
                MsgBox "Main Options cannot be closed"

        End If

    End Sub

Body:
The ListBox won't show any highlight because no selection has been made. When no selection was made the ListBox has no Value (Text). If you assign a Value programmatically it will be highlighted automatically. If you assign a value not in the list an error will occur.

Consider using the Worksheet_Activate event to set a value.

Private Sub Worksheet_Activate()
    On Error Resume Next
    ActiveSheetDisplay.Text = ActiveSheet.Name
End Sub

The On Error statement has the function of preventing a crash if the ActiveSheet isn't in the list for whatever reason.

The above idea has been implemented in the solution presented below. You will need to adapt parts of it to use the variable names you are already familiar with.

You should have a userform. I have named mine MyForm. Replace the name in my code with one you like better wherever it appears.

My MyForm has a ListBox called ListBox1. Replace the name in my code with one you like better wherever it appears.

Install the following 3 procedures in a standard code module.

Sub ShowMyForm()
    ' Variatus @STO 21 Feb 2020

Dim UForm As MyForm

If FormIndex = True Then             ' prevents creation of several instances
    Debug.Print "New form"
    Set UForm = New MyForm
    UForm.Show vbModeless
End If

End Sub

Sub RefreshMyForm()
    ' Variatus @STO 21 Feb 2020

Dim i As Integer

i = FormIndex
If i > -1 Then
    UserForms(i).ListBox1.Text = ActiveSheet.Name
End If

End Sub

Private Function FormIndex() As Integer
    ' Variatus @STO 21 Feb 2020

Dim i As Integer

For i = UserForms.Count To 1 Step -1
    If UserForms(i - 1).Name = "MyForm" Then Exit For
Next i

FormIndex = i - 1

End Function

This procedure goes into the ThisWorkbook code module.

Private Sub Workbook_Open()
    ' Variatus @STO 21 Feb 2020
    ShowMyForm
End Sub

The procedure below goes into the userform's code module. You can adjust the way the list box is filled to exclude some sheets but it's important that you set the V variable to indicate the currently active sheet.

Private Sub UserForm_Initialize()
    ' Variatus @STO 21 Feb 2020

Dim Ws As Worksheet
Dim Arr() As String
Dim V As Integer
Dim i As Integer

With Worksheets
    ReDim Arr(1 To .Count)
    For i = 1 To .Count
        Arr(i) = .Item(i).Name
        If .Item(i) Is ActiveSheet Then V = i
    Next i
End With

With ListBox1
    .List = Arr
    .ListIndex = V - 1
End With

End Sub

Finally, this is the procedure you need to install in the code sheet of every worksheet listed in the listbox.

Private Sub Worksheet_Activate()
    ' Variatus @STO 21 Feb 2020

RefreshMyForm

End Sub

Now, to put it all together: When the workbook is opened the procedure ShowMyForm is called. If the form gets deleted accidentally thereafter you can reinstate it by calling the same procedure or the Workbook_Open event procedure (which can also be called with F5). If ShowMyForm is called repeatedly it will refuse to open more than one instance of the form.

When the form is shown its Initialize event procedure runs. This procedure lists the sheets in the listbox and sets the current ActiveSheet.

When you change sheets a new sheet gets activated and the Worksheet_Activate event occurs. The relative event procedure calls the ListBox's Initialize event, resetting the list.

When you select another sheet from the listbox it gets activate by this procedure in the UserForm's code sheet. However, I think you have this already.

Private Sub ListBox1_Click()
    ' Variatus @STO 21 Feb 2020
    Worksheets(ListBox1.Value).Activate
End Sub


来源: stackexchange

问:
File version different between Azure Portal and Azure Portal Kudu for the same file
Currently my Azure Function shows a different file version in the portal as compared to Kudu.

I am using Azure App Service /w Azure Functions V2 and Python 3.7.

I publish my function app using:

```<code>func azure functionapp publish <functionappname>
</code>```

It successfully performs a remote build.
Now if I look at my Function App in the portal I can see the updated version of my init.py. However, when I use Kudu (Platform features > Advanced tools (Kudu)) to look into the file /home/site/wwwroot//init.py I still see the old version. Shouldn't these versions be identical?

I hope some experienced user can shed light on this.

答:
I test it in my side, when I create a new azure function app(python) and deploy the python code from VS Code to azure portal. It will not create a "init.py" under the directory /home/site/wwwroot. In this directory, it just exists a "host.json"(shown as below).

So you can see the new version of your "init.py" after your deployment on azure portal, but it seems the old version "init.py" in the directory /home/site/wwwroot may be created by a deployment in the past or created because some other reasons in the past. I think it has nothing to do with your new deployment.

ContentLicense: CC BY-SA 4.0

Body:
Currently my Azure Function shows a different file version in the portal as compared to Kudu.

I am using Azure App Service /w Azure Functions V2 and Python 3.7.

I publish my function app using:

func azure functionapp publish <functionappname>

It successfully performs a remote build.
Now if I look at my Function App in the portal I can see the updated version of my init.py. However, when I use Kudu (Platform features > Advanced tools (Kudu)) to look into the file /home/site/wwwroot//init.py I still see the old version. Shouldn't these versions be identical?

I hope some experienced user can shed light on this.


问:
Why is my Forge Design Automation Activity iLogic Failing?
I'm running a DA job based on a code sample, and some of my ilogic rules seem to be causing it to fail. Originally, these were running fine, but when I translated the results on the MD API, some components were still visible despite being suppressed in the result output. I went through the top level rules and solved this by setting components to visible=false, which solved the problem for the most part. After I went through my sub assemblies, I tested the ilogic, then uploaded the latest version.

Now I'm getting errors in the ilogic processing portion of the DA (If I run the logic manually with my activity, I don't get an error until the DA's iLogic processor). I tried adding try catches to the visibility lines within the ilogic to no avail. I also can't identify which rules or components are causing the issue.

Furthermore, it seems like the ilogic is trying to run at the end of the activity execution, after the results are zipped - is this right?

This is the log output:

```<code>[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : Setting BridgeConfig to "3 Station"
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : Ending HeartBeat
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 :  params: TunnelVisibility, false
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : HeartBeating every 50000ms.
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : Setting TunnelVisibility to false
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : Ending HeartBeat
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : Getting full file name of assembly
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : ** Saving SVF
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : HeartBeating every 50000ms.
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : SVF Translator addin is available
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : SVF Translator addin is available
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : SVF save
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : SVF files are oputput to: T:\Aces\Jobs\bcc3160360d84b849acae7443caaf428\inputFile\Playset\SvfOutput
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : SVF can be exported.
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : ** Saved SVF as T:\Aces\Jobs\bcc3160360d84b849acae7443caaf428\inputFile\Playset\SvfOutput\result.collaboration
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : Ending HeartBeat
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : Zipping up T:\Aces\Jobs\bcc3160360d84b849acae7443caaf428\viewable.zip
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : Zipping the following files:
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : HeartBeating every 50000ms.
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : Ending HeartBeat
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : Saved as T:\Aces\Jobs\bcc3160360d84b849acae7443caaf428\viewable.zip
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : Saving updated assembly
[02/18/2020 19:38:08]     InventorCoreConsole.exe Information: 0 : Zip path: T:\Aces\Jobs\bcc3160360d84b849acae7443caaf428\inputFile\Playset
[02/18/2020 19:38:08]     InventorCoreConsole.exe Information: 0 : Zipping up T:\Aces\Jobs\bcc3160360d84b849acae7443caaf428\result.zip
[02/18/2020 19:38:08]     InventorCoreConsole.exe Information: 0 : Zipping the following files:
[02/18/2020 19:38:08]     InventorCoreConsole.exe Information: 0 : HeartBeating every 50000ms.
[02/18/2020 19:38:09]     InventorCoreConsole.exe Information: 0 : Ending HeartBeat
[02/18/2020 19:38:09]     InventorCoreConsole.exe Information: 0 : Saved as T:\Aces\Jobs\bcc3160360d84b849acae7443caaf428\result.zip
[02/18/2020 19:38:09]     InventorCoreConsole.exe Information: 0 : Ending HeartBeat
[02/18/2020 19:38:09]     InventorCoreConsole.exe Information: 0 : Performing iLogic diagnostics...
[02/18/2020 19:38:09]     InventorCoreConsole.exe Error: 0 : iLogic error
[02/18/2020 19:38:09]  Context: RuleRunning
[02/18/2020 19:38:09]  Details: System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
[02/18/2020 19:38:09]    at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
[02/18/2020 19:38:09]    at Inventor.ComponentOccurrence.set_Visible(Boolean )
[02/18/2020 19:38:09]    at iLogic.ComponentInRule.set_Visible(Object componentName, Boolean value)
[02/18/2020 19:38:09]    at ThisRule.Main()
[02/18/2020 19:38:09]    at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
[02/18/2020 19:38:09]    at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
[02/18/2020 19:38:09]     InventorCoreConsole.exe Error: 0 : iLogic error
[02/18/2020 19:38:09]  Context: RuleRunning
[02/18/2020 19:38:09]  Details: System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
[02/18/2020 19:38:09]    at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
[02/18/2020 19:38:09]    at Inventor.ComponentOccurrence.set_Visible(Boolean )
[02/18/2020 19:38:09]    at iLogic.ComponentInRule.set_Visible(Object componentName, Boolean value)
[02/18/2020 19:38:09] P r o c e s s i n g   f a i l e d
[02/18/2020 19:38:09]
[02/18/2020 19:38:09]    at ThisRule.Main()
[02/18/2020 19:38:09]    at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
[02/18/2020 19:38:09]    at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
[02/18/2020 19:38:09]     InventorCoreConsole.exe Information: 0 : End of iLogic diagnostics...
[02/18/2020 19:38:09]     InventorCoreConsole.exe Information: 0 : Deactivating plug-in: UpdateUserParametersPlugin
[02/18/2020 19:38:09]     InventorCoreConsole.exe Information: 0 : : UpdateUserParametersPlugin: deactivating...
[02/18/2020 19:38:09] [SBXMSG] The process 2184 ended.
[02/18/2020 19:38:09] [SBXMSG] Process exit code: -1
[02/18/2020 19:38:10]
[02/18/2020 19:38:10] End Inventor Core Engine standard output dump.
[02/18/2020 19:38:10] Error: InventorCoreConsole.exe exits with code -1 which indicates an error.
[02/18/2020 19:38:10] End script phase.
[02/18/2020 19:38:10] Error: An unexpected error happened during phase CoreEngineExecution of job.
[02/18/2020 19:38:10] Job finished with result FailedExecution
[02/18/2020 19:38:10] Job Status:
</code>```

答:
I tried an alternative of setting visibility to off in the in the activity rather than via iLogic and found this failed as well. The work around I landed on was deleting the suppressed components, which isn't a long term solution, but at least my models look right in the viewer.

I would love to know if there's something else I'm missing or if this is the entire cause of the issue, re: the model derivative API translating/exporting suppressed components.

Body:
I'm running a DA job based on a code sample, and some of my ilogic rules seem to be causing it to fail. Originally, these were running fine, but when I translated the results on the MD API, some components were still visible despite being suppressed in the result output. I went through the top level rules and solved this by setting components to visible=false, which solved the problem for the most part. After I went through my sub assemblies, I tested the ilogic, then uploaded the latest version.

Now I'm getting errors in the ilogic processing portion of the DA (If I run the logic manually with my activity, I don't get an error until the DA's iLogic processor). I tried adding try catches to the visibility lines within the ilogic to no avail. I also can't identify which rules or components are causing the issue.

Furthermore, it seems like the ilogic is trying to run at the end of the activity execution, after the results are zipped - is this right?

This is the log output:

[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : Setting BridgeConfig to "3 Station"
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : Ending HeartBeat
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 :  params: TunnelVisibility, false
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : HeartBeating every 50000ms.
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : Setting TunnelVisibility to false
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : Ending HeartBeat
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : Getting full file name of assembly
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : ** Saving SVF
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : HeartBeating every 50000ms.
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : SVF Translator addin is available
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : SVF Translator addin is available
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : SVF save
[02/18/2020 19:38:02]     InventorCoreConsole.exe Information: 0 : SVF files are oputput to: T:\Aces\Jobs\bcc3160360d84b849acae7443caaf428\inputFile\Playset\SvfOutput
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : SVF can be exported.
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : ** Saved SVF as T:\Aces\Jobs\bcc3160360d84b849acae7443caaf428\inputFile\Playset\SvfOutput\result.collaboration
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : Ending HeartBeat
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : Zipping up T:\Aces\Jobs\bcc3160360d84b849acae7443caaf428\viewable.zip
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : Zipping the following files:
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : HeartBeating every 50000ms.
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : Ending HeartBeat
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : Saved as T:\Aces\Jobs\bcc3160360d84b849acae7443caaf428\viewable.zip
[02/18/2020 19:38:05]     InventorCoreConsole.exe Information: 0 : Saving updated assembly
[02/18/2020 19:38:08]     InventorCoreConsole.exe Information: 0 : Zip path: T:\Aces\Jobs\bcc3160360d84b849acae7443caaf428\inputFile\Playset
[02/18/2020 19:38:08]     InventorCoreConsole.exe Information: 0 : Zipping up T:\Aces\Jobs\bcc3160360d84b849acae7443caaf428\result.zip
[02/18/2020 19:38:08]     InventorCoreConsole.exe Information: 0 : Zipping the following files:
[02/18/2020 19:38:08]     InventorCoreConsole.exe Information: 0 : HeartBeating every 50000ms.
[02/18/2020 19:38:09]     InventorCoreConsole.exe Information: 0 : Ending HeartBeat
[02/18/2020 19:38:09]     InventorCoreConsole.exe Information: 0 : Saved as T:\Aces\Jobs\bcc3160360d84b849acae7443caaf428\result.zip
[02/18/2020 19:38:09]     InventorCoreConsole.exe Information: 0 : Ending HeartBeat
[02/18/2020 19:38:09]     InventorCoreConsole.exe Information: 0 : Performing iLogic diagnostics...
[02/18/2020 19:38:09]     InventorCoreConsole.exe Error: 0 : iLogic error
[02/18/2020 19:38:09]  Context: RuleRunning
[02/18/2020 19:38:09]  Details: System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
[02/18/2020 19:38:09]    at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
[02/18/2020 19:38:09]    at Inventor.ComponentOccurrence.set_Visible(Boolean )
[02/18/2020 19:38:09]    at iLogic.ComponentInRule.set_Visible(Object componentName, Boolean value)
[02/18/2020 19:38:09]    at ThisRule.Main()
[02/18/2020 19:38:09]    at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
[02/18/2020 19:38:09]    at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
[02/18/2020 19:38:09]     InventorCoreConsole.exe Error: 0 : iLogic error
[02/18/2020 19:38:09]  Context: RuleRunning
[02/18/2020 19:38:09]  Details: System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
[02/18/2020 19:38:09]    at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
[02/18/2020 19:38:09]    at Inventor.ComponentOccurrence.set_Visible(Boolean )
[02/18/2020 19:38:09]    at iLogic.ComponentInRule.set_Visible(Object componentName, Boolean value)
[02/18/2020 19:38:09] P r o c e s s i n g   f a i l e d
[02/18/2020 19:38:09]
[02/18/2020 19:38:09]    at ThisRule.Main()
[02/18/2020 19:38:09]    at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
[02/18/2020 19:38:09]    at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
[02/18/2020 19:38:09]     InventorCoreConsole.exe Information: 0 : End of iLogic diagnostics...
[02/18/2020 19:38:09]     InventorCoreConsole.exe Information: 0 : Deactivating plug-in: UpdateUserParametersPlugin
[02/18/2020 19:38:09]     InventorCoreConsole.exe Information: 0 : : UpdateUserParametersPlugin: deactivating...
[02/18/2020 19:38:09] [SBXMSG] The process 2184 ended.
[02/18/2020 19:38:09] [SBXMSG] Process exit code: -1
[02/18/2020 19:38:10]
[02/18/2020 19:38:10] End Inventor Core Engine standard output dump.
[02/18/2020 19:38:10] Error: InventorCoreConsole.exe exits with code -1 which indicates an error.
[02/18/2020 19:38:10] End script phase.
[02/18/2020 19:38:10] Error: An unexpected error happened during phase CoreEngineExecution of job.
[02/18/2020 19:38:10] Job finished with result FailedExecution
[02/18/2020 19:38:10] Job Status:


问:
Session vs URI multi language identifier
I am working on a multilingual website (php/mysql) and my question is what would be the best solution for language identification - sessions/cookies or URI identification.  I mean in terms of SEO, what would be more accurate.

Thanks

答:
Using only sessions/cookies, it wouldn't really be possible for someone to link straight to the 'Swahili' version of your content.  Instead, you would have a default language (English?) which all incoming links would point to.  Once there, if a user wanted your content in Mandarin then they could choose that option, but they won't get it straight out of the gate so using URI identification is my personal pick.

There are a couple of ways to tag what language to use in the URI, either by setting up some sort of directory structure, such as: http://domain.tld/localized/fr/ for the main page of the french content, or you can abstract it out in your database and identify the language through GET variables: http://domain.tld/?l=4 for the main page of language with ID of 4

Or, as Wesley van Opdorp pointed out, you can set up a separate domain or sub-domain for each language: http://domain.fr or http://fr.domain.tld

As far as SEO goes, I believe the best way would be to adhere to the Top Level Domain Standards and set up a separate domain for each language you want to host the site in (http://domain.fr, http://domain.ru, etc).  This of course would mean purchasing more domains, so if that isn't an option my second choice would be to set up sub-domains for each langauge such as in: http://fr.domain.tld and http://ru.domain.tld

ContentLicense: CC BY-SA 3.0


问:
Asp net core 3.1 webapp doesn't refresh on modify razor template
i'm using visual studio code on mac osx for running a simply web app in asp net core 3.1.
I run application with command dotnet run in visual studio code terminal.
Now, if i modify a .cshtml template and refresh my browser, modify don't show.

Why? How can i resolve?

Thanks

答:
To enable runtime compilation in vs code, you need to follow below steps:

1.Add a reference to the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation package,run the command in the terminal

```<code>dotnet add package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation -v 3.1.0
</code>```

2.Update the project's Startup.ConfigureServices method to include a call to AddRazorRuntimeCompilation.

```<code>services.AddControllersWithViews().AddRazorRuntimeCompilation();//for MVC

//services.AddRazorPages().AddRazorRuntimeCompilation();//for Razor Pages
</code>```

Refer to https://learn.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-3.1#runtime-compilation

Body:
To enable runtime compilation in vs code, you need to follow below steps:

1.Add a reference to the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation package,run the command in the terminal

dotnet add package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation -v 3.1.0

2.Update the project's Startup.ConfigureServices method to include a call to AddRazorRuntimeCompilation.

services.AddControllersWithViews().AddRazorRuntimeCompilation();//for MVC

//services.AddRazorPages().AddRazorRuntimeCompilation();//for Razor Pages

Refer to https://learn.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-3.1#runtime-compilation


问:
Is it possible to trigger share menu on smartphones (via HTML/JS)?
Is there an existing possibility to trigger the share functionality in local browsers on smartphones via HTML or JavaScript?

Of course there are many services which provide a share button. But when I e.g. want to share a website on facebook, I need to be logged in to facebook in the browser I am currently using.

Almost all browsers got an own share functionality build in, which triggers a system menu to choose which app you want to use to share:

This question is about: How to trigger this menu?

I know it is possible to trigger a phone call with a specified prefix in href attribute of links, like tel: or callto:. Maybe such a shortcut for this share menu is also existing? Or some javascript code? Or a totally different way how to do it?

Thanks in advance.

答:
It is possible and I wrote a function to have pretty content to share and observe the asynchronous side effects:</p>

```<code>const shareContact = async (title, content) => {
  const text = `${title}

${content}`;

  try {
    await navigator.share({
      text,
    });
  } catch (e) {
    console.log(e);
  }
};
</code>```

Body:
It is possible and I wrote a function to have pretty content to share and observe the asynchronous side effects:

const shareContact = async (title, content) => {
  const text = `${title}

${content}`;

  try {
    await navigator.share({
      text,
    });
  } catch (e) {
    console.log(e);
  }
};


问:
Read S3 Files That Meet Last Modified Window Into DataFrame
I have an S3 bucket with objects where the Last Modified ranges from very old to current.  I need to be able to find the files with a last modified stamp within a window, and then read those files (which are JSON) into some sort of Data Frame (pandas, spark, etc.).

I have attempted to gather the files, read them in individually and append via the following code but it is painfully slow:

```<code>session = boto3.session.Session(region_name=region)

#Gather all keys that have a modified stamp between max_previous_data_extracted_timestamp and start_time_proper
s3 = session.resource('s3', region_name=region)
bucket = s3.Bucket(args.sourceBucket)
app_body = []
for obj in bucket.objects.all():
    obj_datetime = obj.last_modified.replace(tzinfo=None)
    if args.accountId + '/Patient' in obj.key and obj_datetime > max_previous_data_extracted_timestamp_datetime and obj_datetime <= start_time_datetime:
        obj_df = pd.read_csv(obj.get()['Body'])
        app_body.append(obj_df)

merged_dataframe = pd.concat(app_body)
</code>```

The logic is functional in that I only get objects that have been modified within the window, however, the next part where it gets the body and appends to the list runs for 30-45 minutes on ~10K files.  There has to be a better way to do this that I am just not thinking of.

答:
Spark is a way to go on this one.

When talking to S3 bucket with a large number of files, we always need to keep in mind that listing all objects in a bucket is expensive since it returns 1000 object at a time and a pointer to fetch the next set. This makes it very hard to parallelise unless you know the structure and use it to optimize those calls.

I'm sorry if the code doesn't work, I use scala but this should be almost in a working state.

Knowing that your structure is bucket/account_identifier/Patient/patient_identifier:

```<code># account_identifiers -- provided from DB
accounts_df = sc.parallelize(account_identifiers, number_of_partitions)
paths = accounts_df.mapPartitions(fetch_files_for_account).collect()
df = spark.read.json(paths)

def fetch_files_for_account(accounts):
    s3 = boto3.client('s3')
    result = []
    for a in accounts:
        marker = ''
        while True:
            request_result = s3.list_objects(Bucket=args.sourceBucket, Prefix=a)
            items = request_result['Contents']
            for i in items:
                obj_datetime = i['LastModified'].replace(tzinfo=None)
                if obj_datetime > max_previous_data_extracted_timestamp_datetime and obj_datetime <= start_time_datetime:
                    result.append('s3://' + args.sourceBucket +'/' + i['Key'])
            if not request_result['IsTruncated']:
                break
            else:
                marker = request_result['Marker']
    return iter(result)
</code>```

Map partitions will make sure you do not have too many clients instantiated. You can control that number using the number_of_partitions.

Another optimisation you can do is to manually load contents after mapPartitions call instead of using collect(). After that stage you'd have Strings that are JSON contents and then you'd call spark.createDataFrame(records, schema). Note: you have to provide schema.

If you do not have account_identifiers or number of files will not get into 100k territory, you would have to list all object in a bucket, filter by last_modified and basically do the same call:

```<code>spark.read.json(paths)
</code>```

Body:
I have an S3 bucket with objects where the Last Modified ranges from very old to current.  I need to be able to find the files with a last modified stamp within a window, and then read those files (which are JSON) into some sort of Data Frame (pandas, spark, etc.).

I have attempted to gather the files, read them in individually and append via the following code but it is painfully slow:

session = boto3.session.Session(region_name=region)

#Gather all keys that have a modified stamp between max_previous_data_extracted_timestamp and start_time_proper
s3 = session.resource('s3', region_name=region)
bucket = s3.Bucket(args.sourceBucket)
app_body = []
for obj in bucket.objects.all():
    obj_datetime = obj.last_modified.replace(tzinfo=None)
    if args.accountId + '/Patient' in obj.key and obj_datetime > max_previous_data_extracted_timestamp_datetime and obj_datetime <= start_time_datetime:
        obj_df = pd.read_csv(obj.get()['Body'])
        app_body.append(obj_df)

merged_dataframe = pd.concat(app_body)

The logic is functional in that I only get objects that have been modified within the window, however, the next part where it gets the body and appends to the list runs for 30-45 minutes on ~10K files.  There has to be a better way to do this that I am just not thinking of.

Body:
Spark is a way to go on this one.

When talking to S3 bucket with a large number of files, we always need to keep in mind that listing all objects in a bucket is expensive since it returns 1000 object at a time and a pointer to fetch the next set. This makes it very hard to parallelise unless you know the structure and use it to optimize those calls.

I'm sorry if the code doesn't work, I use scala but this should be almost in a working state.

Knowing that your structure is bucket/account_identifier/Patient/patient_identifier:

# account_identifiers -- provided from DB
accounts_df = sc.parallelize(account_identifiers, number_of_partitions)
paths = accounts_df.mapPartitions(fetch_files_for_account).collect()
df = spark.read.json(paths)

def fetch_files_for_account(accounts):
    s3 = boto3.client('s3')
    result = []
    for a in accounts:
        marker = ''
        while True:
            request_result = s3.list_objects(Bucket=args.sourceBucket, Prefix=a)
            items = request_result['Contents']
            for i in items:
                obj_datetime = i['LastModified'].replace(tzinfo=None)
                if obj_datetime > max_previous_data_extracted_timestamp_datetime and obj_datetime <= start_time_datetime:
                    result.append('s3://' + args.sourceBucket +'/' + i['Key'])
            if not request_result['IsTruncated']:
                break
            else:
                marker = request_result['Marker']
    return iter(result)

Map partitions will make sure you do not have too many clients instantiated. You can control that number using the number_of_partitions.

Another optimisation you can do is to manually load contents after mapPartitions call instead of using collect(). After that stage you'd have Strings that are JSON contents and then you'd call spark.createDataFrame(records, schema). Note: you have to provide schema.

If you do not have account_identifiers or number of files will not get into 100k territory, you would have to list all object in a bucket, filter by last_modified and basically do the same call:

spark.read.json(paths)


问:
How to use qt-gstreamer with qtquick2videosink on Qt5 on Raspberry Pi3
I built qt-gstreamer from source code on GitHub (version 1.2.0). Then I tried to run qmlplayer2 application (built from qt-gstreamer and use qtquick2videosink) on qt5 on Raspberry Pi3 but I got the following error at runtime:

(gst-plugin-scanner:3749): GStreamer-WARNING **: Failed to load plugin
  '/usr/lib/gstreamer-0.10/libgstqt5videosink.so':
  /usr/lib/gstreamer-0.10/libgstqt5videosink.so: undefined symbol:
  _Z33gst_qt_quick2_video_sink_get_typev    Failed to create qtquick2videosink. Make sure it is installed correctly

(qmlplayer2:8517): GStreamer-CRITICAL **: gst_bin_add: assertion
  'GST_IS_ELEMENT (element)' failed

(qmlplayer2:8517): GStreamer-CRITICAL **:
  gst_element_link_pads_filtered: assertion 'GST_IS_ELEMENT (dest)'
  failed

答:
Look at source code of qt-gstreamer, i found that the function gst_qt_quick2_video_sink_get_type() is implemented in gstqtquick2videosink.cpp but this file was not compiled due to missing configuration in cmake related to OpenGL.

I config cmake as below :

then rebuild and deploy new file libgstqt5videosink.so to /usr/lib/gstreamer-0.10/libgstqt5videosink.so on target device. After that qmlplayer2 application work fine.


问:
I am unable to filter by 'Name' in SharePoint picture library
I am rendering to a page blog posts.  Unfortunately, when the blog was initially set up, the pictures corresponding to each blog post was kept in a picture library for some odd reason. Now I need to dynamically display the appropriate picture with the correct blog post but I am having a hard time.  I am using SharePoint 2016 and using REST API to query the picture library.  I am able to query the library but I am not able to filter for a specific picture.

So, here's what I have,
the below works and shows the field that I need, Name

/blog/_api/web/lists/getbyTitle('blogPics')/items?$select=File/Name&$expand=File

the below filtering doesn't work

/blog/_api/web/lists/getbyTitle('blogPics')/items?$select=File/Name&$expand=File&$filter=Name eq 'imgName.jpg'

Any ideas why?

Thanks!

答:
We can use FileLeafRef to filter the specific picture.</p>

```<code>/_api/web/lists/getbytitle('blogPics')/items?$select=FileRef,FileLeafRef&$filter=FileLeafRef eq 'imgName.jpg'
</code>```

Body:
We can use FileLeafRef to filter the specific picture.

/_api/web/lists/getbytitle('blogPics')/items?$select=FileRef,FileLeafRef&$filter=FileLeafRef eq 'imgName.jpg'


问:
mongoose recursive nesting
in my project a user can create products. each user have a reference to all of its products and each product have a reference to its user.

both the user and the product have a 'name' field.

i need to get all of the users products array, and in that array i want to have the product name and the
user name that created it (and only those fields and no others).

for example:

Users:

```<code>{ _id: 1, name: 'josh', productIds: [1,3]}
{ _id: 2, name: 'sheldon', productIds: [2]}
</code>```

Products:

```<code>{ _id: 1, name: 'table', price: 45, userId: 1}
{ _id: 2, name: 'television', price: 25 userId: 2}
{ _id: 3, name: 'chair', price: 14 userId: 1}
</code>```

i want to get the following result:

```<code>{ _id: 1, name: 'josh',
    products: {
        { _id: 1, name: 'table', user: { _id: 1, name: 'josh' },
        { _id: 3, name: 'chair', user: { _id: 1, name: 'josh' },
    }
}
{ _id: 2, name: 'sheldon',
    products: {
        { _id: 2, name: 'television', userId: { _id: 2, name: 'sheldon' }
    }
}
</code>```

i tried the following query that didn't fill the inner userId and left it with only the id (no name):

```<code>User.aggregate([
  {
    $lookup:
      {
        from: 'products',
        localField: 'productIds',
        foreignField: '_id',
        as: 'products'
      }
  }
</code>```

i also tried the following, which did the same as the first query except it only retried the first product for each user:

```<code>User.aggregate([
  {
    $lookup:
      {
        from: 'products',
        localField: 'productIds',
        foreignField: '_id',
        as: 'products'
      }
  },
  {
    $unwind: {
      path: "$products",
      preserveNullAndEmptyArrays: true
    }
  },
  {
    $lookup: {
      from: "user",
      localField: "products.userId",
      foreignField: "_id",
      as: "prodUsr",
    }
  },
  {
    $group: {
      _id : "$_id",
      products: { $push: "$products" },
      "doc": { "$first": "$$ROOT" }
    }
  },
  {
    "$replaceRoot": {
    "newRoot": "$doc"
    }
}
</code>```

Product:

```<code>const schema = new Schema(
  {
    name: {
      type: String,
      required: true
    },
    price: {
      type: Number,
      required: true
    },
    userId: {
      type: Schema.Types.ObjectId,
      ref: 'User',
      required: true
    },
  }
);

module.exports = mongoose.model('Product', schema);
</code>```

User:

```<code>const schema = new Schema(
  {
    name: {
      type: String,
      required: true,
      unique: true
    },
    productIds: [{
      type: Schema.Types.ObjectId,
      ref: 'Product',
      require: false
    }],
  { timestamps: true }
);

module.exports = mongoose.model('User', schema);

</code>```

any help will be highly appreciated

答:
It looks like a perfect scenario for $lookup with custom pipeline and another nested $lookup. The inner one allows you to  handle product-> user relationship while the outer one handles user -> product one:

```<code>db.Users.aggregate([
    {
        $project: {
            productIds: 0
        }
    },
    {
        $lookup: {
            from: "Products",
            let: { user_id: "$_id" },
            pipeline: [
                {
                    $match: {
                        $expr: {
                            $eq: [ "$userId", "$$user_id" ]
                        }
                    }
                },
                {
                    $lookup: {
                        from: "Users",
                        localField: "userId",
                        foreignField: "_id",
                        as: "user"
                    }
                },
                {
                    $unwind: "$user"
                },
                {
                    $project: {
                        "user.productIds": 0,
                        "price": 0,
                        "userId": 0
                    }
                }
            ],
            as: "products"
        }
    }
])
</code>```

Mongo Playground

Title: mongoose recursive nesting

Body:
in my project a user can create products. each user have a reference to all of its products and each product have a reference to its user.

both the user and the product have a 'name' field.

i need to get all of the users products array, and in that array i want to have the product name and the
user name that created it (and only those fields and no others).

for example:

Users:

{ _id: 1, name: 'josh', productIds: [1,3]}
{ _id: 2, name: 'sheldon', productIds: [2]}

Products:

{ _id: 1, name: 'table', price: 45, userId: 1}
{ _id: 2, name: 'television', price: 25 userId: 2}
{ _id: 3, name: 'chair', price: 14 userId: 1}

i want to get the following result:

{ _id: 1, name: 'josh',
    products: {
        { _id: 1, name: 'table', user: { _id: 1, name: 'josh' },
        { _id: 3, name: 'chair', user: { _id: 1, name: 'josh' },
    }
}
{ _id: 2, name: 'sheldon',
    products: {
        { _id: 2, name: 'television', userId: { _id: 2, name: 'sheldon' }
    }
}

i tried the following query that didn't fill the inner userId and left it with only the id (no name):

User.aggregate([
  {
    $lookup:
      {
        from: 'products',
        localField: 'productIds',
        foreignField: '_id',
        as: 'products'
      }
  }

i also tried the following, which did the same as the first query except it only retried the first product for each user:

User.aggregate([
  {
    $lookup:
      {
        from: 'products',
        localField: 'productIds',
        foreignField: '_id',
        as: 'products'
      }
  },
  {
    $unwind: {
      path: "$products",
      preserveNullAndEmptyArrays: true
    }
  },
  {
    $lookup: {
      from: "user",
      localField: "products.userId",
      foreignField: "_id",
      as: "prodUsr",
    }
  },
  {
    $group: {
      _id : "$_id",
      products: { $push: "$products" },
      "doc": { "$first": "$$ROOT" }
    }
  },
  {
    "$replaceRoot": {
    "newRoot": "$doc"
    }
}

Product:

const schema = new Schema(
  {
    name: {
      type: String,
      required: true
    },
    price: {
      type: Number,
      required: true
    },
    userId: {
      type: Schema.Types.ObjectId,
      ref: 'User',
      required: true
    },
  }
);

module.exports = mongoose.model('Product', schema);

User:

const schema = new Schema(
  {
    name: {
      type: String,
      required: true,
      unique: true
    },
    productIds: [{
      type: Schema.Types.ObjectId,
      ref: 'Product',
      require: false
    }],
  { timestamps: true }
);

module.exports = mongoose.model('User', schema);

any help will be highly appreciated

Body:
It looks like a perfect scenario for $lookup with custom pipeline and another nested $lookup. The inner one allows you to  handle product-> user relationship while the outer one handles user -> product one:

db.Users.aggregate([
    {
        $project: {
            productIds: 0
        }
    },
    {
        $lookup: {
            from: "Products",
            let: { user_id: "$_id" },
            pipeline: [
                {
                    $match: {
                        $expr: {
                            $eq: [ "$userId", "$$user_id" ]
                        }
                    }
                },
                {
                    $lookup: {
                        from: "Users",
                        localField: "userId",
                        foreignField: "_id",
                        as: "user"
                    }
                },
                {
                    $unwind: "$user"
                },
                {
                    $project: {
                        "user.productIds": 0,
                        "price": 0,
                        "userId": 0
                    }
                }
            ],
            as: "products"
        }
    }
])

Mongo Playground


问:
WSO2 API Manager authorization issue when logging in
I have been experiencing the issue when installing WSO2 API Manager 3.0.0 with analytics and identity server on ubuntu server using docker-compose.

I have managed to set up docker containers on UBUNTU 18.04 server, but I am experiencing the issue. I have created roles and users  (apicreator, apipublisher, webuser) with the same permissions as in the self-paced training. Even though users appear in the list of users, I can't login into WSO2 publisher, or devportal.

It gives me below error message:

Error 403 : Forbidden The server could not verify that you are
  authorized to access the requested resource.

Please advise.

答:
If you have assigned only the roles which you have created to the users, also assign the following internal roles to the respective users as well.

apicreator : Internal/creator

apipublisher: Internal/publisher

If web user is the one who creates applications by logging in to the Developer Portal, assign the Internal/subscriber role to the user.


问:
How to number consecutive signals
I have a script that can plot many sell signals in a row and I want to number them if there is no buy signal in between the sell signals, so the first signal is p1sell, second is p2sell etc... if there is a buy signal then the count restarts....
any idea how to tackle this?

This is what I have so far, p1sell is correct but the other ones aren't-

```<code>//first sellsignal since buysignal
p1sell=barssince(SellSignal)<barssince(BuySignal) and barssince(SellSignal[1])>barssince(BuySignal)

//second sellsignal since first sellsignal without buysignal
p2sell=barssince(SellSignal)<barssince(BuySignal) and barssince(SellSignal[1])<barssince(BuySignal)

//third sellsignal since second sell signal without buysignal
p3sell=barssince(SellSignal)<barssince(BuySignal) and barssince(SellSignal[1])<barssince(BuySignal)
</code>```

答:
```<code>//@version=4
study("", "", true)
condA = rising(close, 3)
condB = falling(close, 3)
var countB = 0
countB := condA ? 0 : condB ? countB + 1 : countB
plotchar(condA, "condA", "▲", location.top)
plotchar(condB, "condB", "▼", location.top)
plotchar(countB, "countB", "", location.top)
</code>```

Title: How to number consecutive signals

Body:
I have a script that can plot many sell signals in a row and I want to number them if there is no buy signal in between the sell signals, so the first signal is p1sell, second is p2sell etc... if there is a buy signal then the count restarts....
any idea how to tackle this?

This is what I have so far, p1sell is correct but the other ones aren't-

//first sellsignal since buysignal
p1sell=barssince(SellSignal)<barssince(BuySignal) and barssince(SellSignal[1])>barssince(BuySignal)

//second sellsignal since first sellsignal without buysignal
p2sell=barssince(SellSignal)<barssince(BuySignal) and barssince(SellSignal[1])<barssince(BuySignal)

//third sellsignal since second sell signal without buysignal
p3sell=barssince(SellSignal)<barssince(BuySignal) and barssince(SellSignal[1])<barssince(BuySignal)


问:
How to call a method only after another method completes in ViewDidLoad
I'm trying to make an app where at the start Object A begins to fades.

Immediately after Object A completely fades, I'd like Object B to begin to fade.

I tried putting the below code in the ViewDidLoad method but they both run at the same time. Any idea on how to make one run after the other starting after the initial load?

```<code>ObjectA.isHidden = false
    UIView.animate(withDuration: 5.0, animations: { () -> Void in
         self.Fader.alpha = 0
        })

ObjectB.isHidden = false
    UIView.animate(withDuration: 1.0, animations: { () -> Void in
         self.Intro.alpha = 0
        })
</code>```

答:
Nesting an animation within the first animation's completion block is perfectly fine.
But for grouping multiple animations, it's worthwhile to consider CAAnimation Groups.

here's a ray wenderlich tutorial that goes through a simple CAAnimationGroup

Apple's documentation has a great example, but you MUST specify the beginTime for each animation (otherwise each animation will run at the same time):

```<code>let fadeOut = CABasicAnimation(keyPath: "opacity")
fadeOut.fromValue = 1
fadeOut.toValue = 0
fadeOut.duration = 1
fadeOut.beginTime = 0.0

let expandScale = CABasicAnimation()
expandScale.keyPath = "transform"
expandScale.valueFunction = CAValueFunction(name: kCAValueFunctionScale)
expandScale.fromValue = [1, 1, 1]
expandScale.toValue = [3, 3, 3]
expandScale.beginTime = fadeOut.beginTime + fadeOut.duration

let fadeAndScale = CAAnimationGroup()
fadeAndScale.animations = [fadeOut, expandScale]
fadeAndScale.duration = fadeOut.duration + expandScale.duration
</code>```

Body:
I'm trying to make an app where at the start Object A begins to fades.

Immediately after Object A completely fades, I'd like Object B to begin to fade.

I tried putting the below code in the ViewDidLoad method but they both run at the same time. Any idea on how to make one run after the other starting after the initial load?

ObjectA.isHidden = false
    UIView.animate(withDuration: 5.0, animations: { () -> Void in
         self.Fader.alpha = 0
        })

ObjectB.isHidden = false
    UIView.animate(withDuration: 1.0, animations: { () -> Void in
         self.Intro.alpha = 0
        })

Body:
Nesting an animation within the first animation's completion block is perfectly fine.
But for grouping multiple animations, it's worthwhile to consider CAAnimation Groups.

here's a ray wenderlich tutorial that goes through a simple CAAnimationGroup

Apple's documentation has a great example, but you MUST specify the beginTime for each animation (otherwise each animation will run at the same time):

let fadeOut = CABasicAnimation(keyPath: "opacity")
fadeOut.fromValue = 1
fadeOut.toValue = 0
fadeOut.duration = 1
fadeOut.beginTime = 0.0

let expandScale = CABasicAnimation()
expandScale.keyPath = "transform"
expandScale.valueFunction = CAValueFunction(name: kCAValueFunctionScale)
expandScale.fromValue = [1, 1, 1]
expandScale.toValue = [3, 3, 3]
expandScale.beginTime = fadeOut.beginTime + fadeOut.duration

let fadeAndScale = CAAnimationGroup()
fadeAndScale.animations = [fadeOut, expandScale]
fadeAndScale.duration = fadeOut.duration + expandScale.duration


问:
ASP.NET Core MVC and 2 Web API projects
There are a web app and two web api services + two projects in one solution. In the production server there are two web applications: one web and one service. In the service application I found the two web api service and I do not understand why and how can I build, or deploy these to api into onr web application.
I am new in the Core business so please help.</p>

答:
According to your description, I suggest you could create a new web application on the production server to hosted the web api project or create nested two web application in the service web sites in the web server.

After doing this , you will have three web application on the production server.

One Core MVC application and two web api application.

Then you could post these three application to each IIS web application. Notice: You need to modify the MVC web api's url since there are not the same.

More details about how to build and publish the web application to the server, you could refer to below article.

https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-3.1&tabs=visual-studio

Title: ASP.NET Core MVC and 2 Web API projects


问:
java dyn parser
Im a novice java-programer, whos trying to create a small java app.

In the program im working on, I want to load the configurations from different ini-files.
The basic idea is, that I would have a library containing all the config files, the parser should read all of them and make configurations named after their filenames.
The parser should be created to work dynamicly, so it can read different types of configs.
example

```<code>House.ini
 -> type0
 -> id  name  height  witdh  length   price_based_on_dimensions
 -> id1  name1  height  witdh  length   price_based_on_dimensions
</code>```

These data should be saved to a config object named config.house. The tricky part is that a different config file, can have its type = type0 but with a different number of attributtes.

I realise that there is no simply solution to this, but any help and or guides to create a dynamic parser is welcome

答: I'm not really clear on the output you want to produce, but a Java INI parsing library might be a good place to start. For that, you should use ini4j.</p>

Title: java dyn parser

Body:
Im a novice java-programer, whos trying to create a small java app.

In the program im working on, I want to load the configurations from different ini-files.
The basic idea is, that I would have a library containing all the config files, the parser should read all of them and make configurations named after their filenames.
The parser should be created to work dynamicly, so it can read different types of configs.
example

House.ini
 -> type0
 -> id  name  height  witdh  length   price_based_on_dimensions
 -> id1  name1  height  witdh  length   price_based_on_dimensions

These data should be saved to a config object named config.house. The tricky part is that a different config file, can have its type = type0 but with a different number of attributtes.

I realise that there is no simply solution to this, but any help and or guides to create a dynamic parser is welcome


问:
Show different files between local and remote
I have a local folder which is linked to a remote git repository.

Sometimes, We have instructions to check the difference between local and remote.

But their difference could be big and long. Sometimes, I just want to see which files are different/added/removed, and don't need to go into details.

Does anyone know how could I quickly get that information?

Edit 1:

Additionally, I just realised that I need to eventually git add new local files, and locally make a new git commit before git fetch and git diff. Am I correct?

答:
Your question mentions folders and files.  Git doesn't store folders, and doesn't really work with files either—not at the level of talking to another Git on a different machine, anyway.  Git works, instead, with commits.  When you have your Git call up some other Git, on some other machine, your Git gets from that Git any commits they have, that you don't, that you should have.  That's a git fetch operation.  (Or, your Git gives to that Git any commits that you have, that they don't, that you want them to have: that's a git push operation.  But it sounds like the one you care about here is "get from them", i.e., fetch.)

So, having had your Git call up their Git and get commits from them, your job is now to compare these commits.  Each commit contains files.  It only has files, not folders, but the files often have names that may force your OS to create folders.  For instance, the file named dir/sub/file.ext probably requires your OS to first create the folder dir, then within dir, the folder sub.  (That's your OS's problem, not Git's: as far as Git is concerned, it's just a file with a long name.  Git will work around your OS's fixation on "folders" as needed here.)

Every commit has a full, complete snapshot of all of that commit's files.  So if you compare commit C123 with commit C456, for instance, you can see what files are common to both, which ones are unique to each, and what the differences are between any common-to-both files.  The git diff command does just that, with a lot of options:

```<code>git diff --name-only <commit#1> <commit#2>
</code>```

tells you which files (by full names like a/b/c.ext) are different in the two commits, or are only in one of the two.  Or:

```<code>git diff --name-status <commit#1> <commit#2>
</code>```

tells you which files are different, and in what way: for instance, a file might need to be Added to commit#1 for commit#1 to start coming closer to commit#2.  Another file might just need to be Modified to change its content a bit.  What git diff prints here are, in effect, instructions: if you make these changes to the left-side commit, you'll get the right-side commit.  The default for git diff is to provided complete instructions: everything you must do.

Regarding your edit

Additionally, I just realised that I need to eventually git add new local files, and locally make a new git commit before git fetch and git diff. Am I correct?

That might be wisest, but it's probably not necessary.

I mentioned above about Git working with commits, and the diffs shown above all use commits.  Commits contain frozen snapshots of all of your (committed) files.  All commits are completely read-only: once made, no part of any commit can ever be changed.  The files stored inside commits are in a special, read-only, Git-only frozen format that only Git can use.  (This format makes comparing the commits faster and easier, and likewise for other things that Git does.  It also makes the storage of commits more compact, because once a file is frozen forever, each new commit can just re-use the old commits' files, if they match.  It's impossible to change them, so if you make a new commit, and 97 out of 100 files are the same, Git can just re-use those 97 files.  The "copy" in the new commit is really just a reference to the existing, shared, already-frozen copy.)

Stuff that's frozen for all time is great for archival.  But Git isn't just an archiver.  Its data is in this Git-only format: nothing else on your computer can use the files.  So it's totally useless for getting any actual work done.  What this means is that Git must, to let you get work done, copy the frozen files out of some commit, into some sort of working area.  The files in this work area—the area Git calls a working tree or work-tree or similar—are just ordinary everyday files.  They're not frozen, and they're in the ordinary everyday format that your computer uses, whatever that is.  (They're in folders and everything!)

This process, of copying out the frozen files into your work-tree, also copies the frozen files to Git's index.  When you git add and git commit, what you are doing is copying the work-tree files back into the index (git add) and then making a new commit from whatever is in the index (git commit).

The index can get complicated (during merges), but it can be described pretty simply: it's where you build up your next commit.  The files that are in it1 are in the frozen format, ready to go into a new commit, but unlike a commit, aren't frozen.  You can overwrite them, and you can put all-new files in, and you can delete files from the index.  So you can copy each work-tree file into the index to make it ready to be committed.  This process, of copying a work-tree file back into the index—replacing the old copy if there was one, creating an all-new file if not—is called staging the file, and hence the index is also called the staging area.

So: to work with files, you have them copied out from commits to the index and the work-tree.  You can view and modify files in your work-tree, and you can re-copy files from the work-tree back into the index, staging them for committing.

1Technically, what's in the index is a reference to a frozen-format file, just like in commits.  This shows up if you start looking at the internal details of the index, using git ls-files --stage or git update-index.  But for the most part, you can just think of the index as having its own separate copy of each file: that mental model works fine until you get into this low level.

git status

The git status command runs two git diffs: one compares the current commit (frozen, remember) to the index.  Whatever is different here is staged for commit.  That is, if you ran git commit right now, Git would make the new commit from whatever is in the index.  All the files that match the HEAD (current) commit are not very interesting: they're exactly the same.  So git status says nothing about them.  For any file that's new, or deleted, or different, though, git status lists that file's name.

That's what git diff --name-only does, and that's what git status does for this step: it compares, and whatever is different, prints out the file's name.  Instead of comparing two commits, though, it compares one commit—specifically, the one that is HEAD right now—and the index.

But git status then goes on to run a second git diff.  This time, it compares the files in the index to the files in your work-tree.  For everything that is the same, it says nothing.  For everything that is different, it prints the file names.

Again, this is the same thing that git diff --name-only would do, except that instead of comparing two commits, it's comparing the index and your work-tree.

Because your work-tree is an ordinary set of folders, you can create files (and subfolders) that aren't in the index.  These are your untracked files.  Since they are not in the index, they will not be in the next commit.  If you run git add on them, Git copies them from the work-tree into the index, and now they are in the index and will be in the next commit.

If you don't copy these into the index, they'll just remain untracked files.  They won't participate in git diff.  Git will just whine about them: I found these untracked files, what should I do with them?  A .gitignore file tells Git to shut up about untracked files.  It has no effect on tracked files—files that are in the index—because those files are in the index.  But you can put files into the index, and take them out of the index, any time you like.

How all this goes with your original problem

If you wish to compare two commits, you'll need to make a commit.  That lets you adjust the index contents as needed, and then you have two commits, where the comparison is easy: you just give git diff both hash IDs, or names for the two hash IDs.

But, if you're willing to use the index or the work-tree as the source of one of the two sets of files, you can do that too.  When using the work-tree as one set of files, Git will only believe that those files that are also in the index are part of that work-tree: the other files are all untracked and hence do not take part in the git diff.  And now you have one other problem: git diff --cached <hash> compares with the index on the right, and the given commit on the left, for instance.  But there's a -R (reverse the sides) flag, if you want the comparison to go the other way.

If, after getting a diff, you decide you'd like to send a commit to the other Git, you'll probably want to just make a commit.  Making a commit is generally quite cheap: it's just a matter of packaging up whatever is already in the index, and adding the metadata that goes with a new commit.

Body:
Your question mentions folders and files.  Git doesn't store folders, and doesn't really work with files either—not at the level of talking to another Git on a different machine, anyway.  Git works, instead, with commits.  When you have your Git call up some other Git, on some other machine, your Git gets from that Git any commits they have, that you don't, that you should have.  That's a git fetch operation.  (Or, your Git gives to that Git any commits that you have, that they don't, that you want them to have: that's a git push operation.  But it sounds like the one you care about here is "get from them", i.e., fetch.)

So, having had your Git call up their Git and get commits from them, your job is now to compare these commits.  Each commit contains files.  It only has files, not folders, but the files often have names that may force your OS to create folders.  For instance, the file named dir/sub/file.ext probably requires your OS to first create the folder dir, then within dir, the folder sub.  (That's your OS's problem, not Git's: as far as Git is concerned, it's just a file with a long name.  Git will work around your OS's fixation on "folders" as needed here.)

Every commit has a full, complete snapshot of all of that commit's files.  So if you compare commit C123 with commit C456, for instance, you can see what files are common to both, which ones are unique to each, and what the differences are between any common-to-both files.  The git diff command does just that, with a lot of options:

git diff --name-only <commit#1> <commit#2>

tells you which files (by full names like a/b/c.ext) are different in the two commits, or are only in one of the two.  Or:

git diff --name-status <commit#1> <commit#2>

tells you which files are different, and in what way: for instance, a file might need to be Added to commit#1 for commit#1 to start coming closer to commit#2.  Another file might just need to be Modified to change its content a bit.  What git diff prints here are, in effect, instructions: if you make these changes to the left-side commit, you'll get the right-side commit.  The default for git diff is to provided complete instructions: everything you must do.

Regarding your edit

Additionally, I just realised that I need to eventually git add new local files, and locally make a new git commit before git fetch and git diff. Am I correct?

That might be wisest, but it's probably not necessary.

I mentioned above about Git working with commits, and the diffs shown above all use commits.  Commits contain frozen snapshots of all of your (committed) files.  All commits are completely read-only: once made, no part of any commit can ever be changed.  The files stored inside commits are in a special, read-only, Git-only frozen format that only Git can use.  (This format makes comparing the commits faster and easier, and likewise for other things that Git does.  It also makes the storage of commits more compact, because once a file is frozen forever, each new commit can just re-use the old commits' files, if they match.  It's impossible to change them, so if you make a new commit, and 97 out of 100 files are the same, Git can just re-use those 97 files.  The "copy" in the new commit is really just a reference to the existing, shared, already-frozen copy.)

Stuff that's frozen for all time is great for archival.  But Git isn't just an archiver.  Its data is in this Git-only format: nothing else on your computer can use the files.  So it's totally useless for getting any actual work done.  What this means is that Git must, to let you get work done, copy the frozen files out of some commit, into some sort of working area.  The files in this work area—the area Git calls a working tree or work-tree or similar—are just ordinary everyday files.  They're not frozen, and they're in the ordinary everyday format that your computer uses, whatever that is.  (They're in folders and everything!)

This process, of copying out the frozen files into your work-tree, also copies the frozen files to Git's index.  When you git add and git commit, what you are doing is copying the work-tree files back into the index (git add) and then making a new commit from whatever is in the index (git commit).

The index can get complicated (during merges), but it can be described pretty simply: it's where you build up your next commit.  The files that are in it1 are in the frozen format, ready to go into a new commit, but unlike a commit, aren't frozen.  You can overwrite them, and you can put all-new files in, and you can delete files from the index.  So you can copy each work-tree file into the index to make it ready to be committed.  This process, of copying a work-tree file back into the index—replacing the old copy if there was one, creating an all-new file if not—is called staging the file, and hence the index is also called the staging area.

So: to work with files, you have them copied out from commits to the index and the work-tree.  You can view and modify files in your work-tree, and you can re-copy files from the work-tree back into the index, staging them for committing.

1Technically, what's in the index is a reference to a frozen-format file, just like in commits.  This shows up if you start looking at the internal details of the index, using git ls-files --stage or git update-index.  But for the most part, you can just think of the index as having its own separate copy of each file: that mental model works fine until you get into this low level.

git status

The git status command runs two git diffs: one compares the current commit (frozen, remember) to the index.  Whatever is different here is staged for commit.  That is, if you ran git commit right now, Git would make the new commit from whatever is in the index.  All the files that match the HEAD (current) commit are not very interesting: they're exactly the same.  So git status says nothing about them.  For any file that's new, or deleted, or different, though, git status lists that file's name.

That's what git diff --name-only does, and that's what git status does for this step: it compares, and whatever is different, prints out the file's name.  Instead of comparing two commits, though, it compares one commit—specifically, the one that is HEAD right now—and the index.

But git status then goes on to run a second git diff.  This time, it compares the files in the index to the files in your work-tree.  For everything that is the same, it says nothing.  For everything that is different, it prints the file names.

Again, this is the same thing that git diff --name-only would do, except that instead of comparing two commits, it's comparing the index and your work-tree.

Because your work-tree is an ordinary set of folders, you can create files (and subfolders) that aren't in the index.  These are your untracked files.  Since they are not in the index, they will not be in the next commit.  If you run git add on them, Git copies them from the work-tree into the index, and now they are in the index and will be in the next commit.

If you don't copy these into the index, they'll just remain untracked files.  They won't participate in git diff.  Git will just whine about them: I found these untracked files, what should I do with them?  A .gitignore file tells Git to shut up about untracked files.  It has no effect on tracked files—files that are in the index—because those files are in the index.  But you can put files into the index, and take them out of the index, any time you like.

How all this goes with your original problem

If you wish to compare two commits, you'll need to make a commit.  That lets you adjust the index contents as needed, and then you have two commits, where the comparison is easy: you just give git diff both hash IDs, or names for the two hash IDs.

But, if you're willing to use the index or the work-tree as the source of one of the two sets of files, you can do that too.  When using the work-tree as one set of files, Git will only believe that those files that are also in the index are part of that work-tree: the other files are all untracked and hence do not take part in the git diff.  And now you have one other problem: git diff --cached <hash> compares with the index on the right, and the given commit on the left, for instance.  But there's a -R (reverse the sides) flag, if you want the comparison to go the other way.

If, after getting a diff, you decide you'd like to send a commit to the other Git, you'll probably want to just make a commit.  Making a commit is generally quite cheap: it's just a matter of packaging up whatever is already in the index, and adding the metadata that goes with a new commit.


问:
How to add Azure Powershell module to Visual Code Intellisense
Does anyone know how to add the intellisense for the Azure module in visual code? I installed the Azure Powershell module recently, and want to write some powershell script using visual code, but the editor doesn't give me any intellisense for the az functions, like Get-AzResourceGroup</p>

答:
There is a difference between Azure PowerShell and Azure CLI. Azure PowerShell is strictly for Windows PowerShell and PowerShell Core, whereas Azure CLI has cross-platform support for Windows, Mac and Linux. This also means if you have PowerShell Core on Mac or Linux, you can still use Azure PowerShell.

You can usually tell the syntactic difference between the two e.g. Get-AzResourceGroup vs az group list. It seems like you want the latter(Azure CLI), since you mention:

intellisense for the az functions

Furthermore, using the default PowerShell extension provided by Microsoft will be good enough to provide intellisense for Azure PowerShell CmdLets. However, for Azure CLI, you can install the Azure CLI Tools extension provided by Microsoft. This will provide intellisense on any .azcli files where you write your az commands.


问:
Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead
I'm getting this error when I run the script npm run watch

cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress  --config=node_modules/laravel-mix/setup/webpack.config.js

i ｢webpack｣: Watching enabled \ Building Modules
  (16%)C:\xampp\htdocs\VidhiStage\node_modules\webpack\lib\Chunk.js:824
                  throw new Error(
                  ^

Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by
  instanceof Entrypoint instead
      at Chunk.get (C:\xampp\htdocs\VidhiStage\node_modules\webpack\lib\Chunk.js:824:9)
      at C:\xampp\htdocs\VidhiStage\node_modules\laravel-mix\node_modules\extract-text-webpack-plugin\dist\index.js:176:48
      at Array.forEach ()
      at C:\xampp\htdocs\VidhiStage\node_modules\laravel-mix\node_modules\extract-text-webpack-plugin\dist\index.js:171:18
      at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\xampp\htdocs\VidhiStage\node_modules\tapable\lib\HookCodeFactory.js:24:12),
  :12:1)
      at AsyncSeriesHook.lazyCompileHook [as _callAsync] (C:\xampp\htdocs\VidhiStage\node_modules\tapable\lib\Hook.js:35:21)
      at Compilation.seal (C:\xampp\htdocs\VidhiStage\node_modules\webpack\lib\Compilation.js:1203:27)
      at hooks.make.callAsync.err (C:\xampp\htdocs\VidhiStage\node_modules\webpack\lib\Compiler.js:547:17)
      at _err0 (eval at create (C:\xampp\htdocs\VidhiStage\node_modules\tapable\lib\HookCodeFactory.js:24:12),
  :11:1)
      at _addModuleChain (C:\xampp\htdocs\VidhiStage\node_modules\webpack\lib\Compilation.js:1054:12)
      at processModuleDependencies.err (C:\xampp\htdocs\VidhiStage\node_modules\webpack\lib\Compilation.js:980:9)
      at process._tickCallback (internal/process/next_tick.js:172:11) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! VidhiStage@1.0.0
  watch: cross-env NODE_ENV=development
  node_modules/webpack/bin/webpack.js --watch --progress
  --config=node_modules/laravel-mix/setup/webpack.config.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the VidhiStage@1.0.0 watch
  script. npm ERR! This is probably not a problem with npm. There is
  likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR!

  C:\Users\BIKI
  MALLIK\AppData\Roaming\npm-cache_logs\2018-08-02T08_45_14_967Z-debug.log

Following is the Webpack.config.js:

```<code>const webpack = require('webpack');
module.exports = {
  watch : true,
  context: __dirname,
  entry: {
    main : "./Components/Admin/Admin.js",
  },
  output: {
    path: __dirname+'/public/js/build',
    filename : "Admin.js",
    chunkFilename: 'chunk/[name].[chunkhash].js',
    publicPath:'./js/build/'
  },
  resolve: {
    alias: {
      vue: 'vue/dist/vue.js',
      lolly : 'quill/dist/quill.min.js'
    }
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
      },
      {
        test: /\.styl$/,
        loader: 'css-loader!stylus-loader?paths=node_modules/bootstrap-stylus/stylus/',
      },
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      }
    ]
  },
  plugins: [
  ]
}
</code>```

答:
You could also upgrade the plugin:</p>

```<code>npm install extract-text-webpack-plugin@next --save-dev
</code>```

Body:
I'm getting this error when I run the script npm run watch

cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress  --config=node_modules/laravel-mix/setup/webpack.config.js

i ｢webpack｣: Watching enabled \ Building Modules
  (16%)C:\xampp\htdocs\VidhiStage\node_modules\webpack\lib\Chunk.js:824
                  throw new Error(
                  ^

Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by
  instanceof Entrypoint instead
      at Chunk.get (C:\xampp\htdocs\VidhiStage\node_modules\webpack\lib\Chunk.js:824:9)
      at C:\xampp\htdocs\VidhiStage\node_modules\laravel-mix\node_modules\extract-text-webpack-plugin\dist\index.js:176:48
      at Array.forEach ()
      at C:\xampp\htdocs\VidhiStage\node_modules\laravel-mix\node_modules\extract-text-webpack-plugin\dist\index.js:171:18
      at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\xampp\htdocs\VidhiStage\node_modules\tapable\lib\HookCodeFactory.js:24:12),
  :12:1)
      at AsyncSeriesHook.lazyCompileHook [as _callAsync] (C:\xampp\htdocs\VidhiStage\node_modules\tapable\lib\Hook.js:35:21)
      at Compilation.seal (C:\xampp\htdocs\VidhiStage\node_modules\webpack\lib\Compilation.js:1203:27)
      at hooks.make.callAsync.err (C:\xampp\htdocs\VidhiStage\node_modules\webpack\lib\Compiler.js:547:17)
      at _err0 (eval at create (C:\xampp\htdocs\VidhiStage\node_modules\tapable\lib\HookCodeFactory.js:24:12),
  :11:1)
      at _addModuleChain (C:\xampp\htdocs\VidhiStage\node_modules\webpack\lib\Compilation.js:1054:12)
      at processModuleDependencies.err (C:\xampp\htdocs\VidhiStage\node_modules\webpack\lib\Compilation.js:980:9)
      at process._tickCallback (internal/process/next_tick.js:172:11) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! VidhiStage@1.0.0
  watch: cross-env NODE_ENV=development
  node_modules/webpack/bin/webpack.js --watch --progress
  --config=node_modules/laravel-mix/setup/webpack.config.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the VidhiStage@1.0.0 watch
  script. npm ERR! This is probably not a problem with npm. There is
  likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR!

  C:\Users\BIKI
  MALLIK\AppData\Roaming\npm-cache_logs\2018-08-02T08_45_14_967Z-debug.log

Following is the Webpack.config.js:

const webpack = require('webpack');
module.exports = {
  watch : true,
  context: __dirname,
  entry: {
    main : "./Components/Admin/Admin.js",
  },
  output: {
    path: __dirname+'/public/js/build',
    filename : "Admin.js",
    chunkFilename: 'chunk/[name].[chunkhash].js',
    publicPath:'./js/build/'
  },
  resolve: {
    alias: {
      vue: 'vue/dist/vue.js',
      lolly : 'quill/dist/quill.min.js'
    }
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
      },
      {
        test: /\.styl$/,
        loader: 'css-loader!stylus-loader?paths=node_modules/bootstrap-stylus/stylus/',
      },
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      }
    ]
  },
  plugins: [
  ]
}

Body:
You could also upgrade the plugin:

npm install extract-text-webpack-plugin@next --save-dev


问:
Find Whether the clipboard has text or image?
I am using Html5 and Jquery.
I have paste image/text from clipboard into html canvas.

Is it possible to detect whether clipboard has text or image?

```<code>$(document).on('paste','[contenteditable]',function(e) {
    e.preventDefault();

    //Here is it possible to detect whether clipboard has text or image?

    var text = (e.originalEvent || e).clipboardData.getData('text/plain');
});
</code>```

Thanks!

答:
This is what I have on my page, it works for me:

```<code>if (e.clipboardData.files.length > 0) {
// Image
} else {
// Text
};
</code>```

Also I see that this question was posted 6 years ago but hopefully it can help some other people.

Body:
I am using Html5 and Jquery.
I have paste image/text from clipboard into html canvas.

Is it possible to detect whether clipboard has text or image?

$(document).on('paste','[contenteditable]',function(e) {
    e.preventDefault();

    //Here is it possible to detect whether clipboard has text or image?

    var text = (e.originalEvent || e).clipboardData.getData('text/plain');
});

Thanks!

Body:
This is what I have on my page, it works for me:

if (e.clipboardData.files.length > 0) {
// Image
} else {
// Text
};

Also I see that this question was posted 6 years ago but hopefully it can help some other people.


问:
South doesn't create default permissions on new models in time for latter migrations to use them
I'm not 100% sure I'm doing this right, but I think I've found an issue where auth.Permission objects aren't being created soon enough for migrations to use them when you initialize a DB from scratch.

The important details:

I'm trying to initialize a Django DB from scratch using ./manage.py syncdb --migrate --noinput

I have 11 migrations in my chain

The 1st migration creates a new model called myapp.CompanyAccount

The 9th migration tries to fetch the permission myapp.change_companyaccount with:

p = orm[ "auth.Permission" ].objects.get( codename = "change_companyaccount" )

At that point, an exception is raised:

django.contrib.auth.models.DoesNotExist: Permission matching query does not exist

I had assumed that the default permissions that are defined for every object (as per http://docs.djangoproject.com/en/dev/topics/auth/#default-permissions) would have been created by the time the 1st migration finished, but it doesn't appear that they are.  If I re-run the migration after the exception, it works the second time because apparently the permission now exists and the 9th migration can execute without error.

Is there anything that can be done to "flush" everything sometime before the 9th migration runs so that the whole thing can run in a single pass without bailing out?

Thanks for any help / advice.

EDIT: In response to John's comment below, I found out that the following command-line sequence will work:

./manage.py syncdb (this initializes the default Django tables)

./manage.py migrate myapp 0001 (this causes the CompanyAccount table to be created)

./manage.py migrate myapp (this migrates all the way to the end without error)

Unfortunately, skipping step #2 above means that you get the same exception in the 0009 migration, which tells me that my original suspicion was correct that default permissions on new models are not created by South immediately, and are somehow only pushed into the database when the entire migration chain finishes.

This is better than where I was (I'm at least avoiding exceptions now) but I still need to manually segment the migration around the creation of new models that latter migrations might need to touch the permissions of, so this isn't a complete solution.

答:
As it turns out, the answer is to manually call db.send_pending_create_signals() at some point before you try to access the default permission since South only does this "flushing" step quite late in the process.  Thanks to Andrew Godwin from South for replying to this on the South mailing list here:

http://groups.google.com/group/south-users/browse_thread/thread/1de2219fe4f35959


问:
can't make links active when scrolling to a specific section in page
I'm doing a landing page functionality with pure JavaScript and not allowed to use any libraries. I want to make a link on scroll to a specific section to be active. so I did a helper function IsInViewPort() to sense the position when I'm scrolling the page.

I'm trying to make a function that is on scrolling, Looping inside the sections in the page to add the specified section to the classList and make its link from navbar active. when I added this function there was an error says "unexpected identifier" and the navbar disappeared. How to fix it?
global variables:

```<code>const sections = document.getElementsByTagName('section');
const addToNav = document.querySelector('ul');
const myLinks = document.getElementById("navbar__list");
</code>```

The helper function:

```<code>    const isInViewport = elem => {
  let distance = elem.getBoundingClientRect();
  return (
    distance.top >= 0 &&
    distance.left >= 0 &&
    distance.bottom <=
      (window.innerHeight || document.documentElement.clientHeight) &&
    distance.right <=
      (window.innerWidth || document.documentElement.clientWidth)
  );
};
</code>```

The function:

```<code>window.addEventListener("scroll" , e=>{
  for(let i=0 ; i<sections.length;i++){
    if(isInViewport(sections[i])){
      sections[i].classList.add("your-active-class");
      var activateLink = document.getElementsByClassName(''+[i]+'')[0];
      activateLink.classList.add("active");
    }
    else{
      sections[i].classList.remove("your-active-class");
      var activateLink = document.getElementsByClassName(''+[i]+'')[0];
      activateLink.classList.remove("active");
    }
  }
});
</code>```

This is my project so far: https://jsfiddle.net/dode2/yqne0orj/1/
my issue in //Set sections as active.

答:
The "unexpected identifier" is caused by your "int i=0" which should be let i=0

The following code:

```<code>window.addEventListener("scroll" , e=>{
for(int i=0 ; i<=sections.length;i++){
    if(isInViewport(sections[i])){
        sections[i].classList.add("your-active-class");
        document.getElementsByClassName(`${sections[i].id}`)[0].classList.add("active");
    }
    else{
        section.classList.remove("your-active-class");
        document.getElementsByClassName(`${sections[i].id}`)[0].classList.remove("active");
    }
}
</code>```

Should be:

```<code>window.addEventListener("scroll" , e=>{
for(let i=0 ; i<=sections.length;i++){
    if(isInViewport(sections[i])){
        sections[i].classList.add("your-active-class");
        document.getElementsByClassName(`${sections[i].id}`)[0].classList.add("active");
    }
    else{
        section.classList.remove("your-active-class");
        document.getElementsByClassName(`${sections[i].id}`)[0].classList.remove("active");
    }
}
</code>```

That will fix your error.

Body:
I'm doing a landing page functionality with pure JavaScript and not allowed to use any libraries. I want to make a link on scroll to a specific section to be active. so I did a helper function IsInViewPort() to sense the position when I'm scrolling the page.

I'm trying to make a function that is on scrolling, Looping inside the sections in the page to add the specified section to the classList and make its link from navbar active. when I added this function there was an error says "unexpected identifier" and the navbar disappeared. How to fix it?
global variables:

const sections = document.getElementsByTagName('section');
const addToNav = document.querySelector('ul');
const myLinks = document.getElementById("navbar__list");

The helper function:

    const isInViewport = elem => {
  let distance = elem.getBoundingClientRect();
  return (
    distance.top >= 0 &&
    distance.left >= 0 &&
    distance.bottom <=
      (window.innerHeight || document.documentElement.clientHeight) &&
    distance.right <=
      (window.innerWidth || document.documentElement.clientWidth)
  );
};

The function:

window.addEventListener("scroll" , e=>{
  for(let i=0 ; i<sections.length;i++){
    if(isInViewport(sections[i])){
      sections[i].classList.add("your-active-class");
      var activateLink = document.getElementsByClassName(''+[i]+'')[0];
      activateLink.classList.add("active");
    }
    else{
      sections[i].classList.remove("your-active-class");
      var activateLink = document.getElementsByClassName(''+[i]+'')[0];
      activateLink.classList.remove("active");
    }
  }
});

This is my project so far: https://jsfiddle.net/dode2/yqne0orj/1/
my issue in //Set sections as active.

Body:
The "unexpected identifier" is caused by your "int i=0" which should be let i=0

The following code:

window.addEventListener("scroll" , e=>{
for(int i=0 ; i<=sections.length;i++){
    if(isInViewport(sections[i])){
        sections[i].classList.add("your-active-class");
        document.getElementsByClassName(`${sections[i].id}`)[0].classList.add("active");
    }
    else{
        section.classList.remove("your-active-class");
        document.getElementsByClassName(`${sections[i].id}`)[0].classList.remove("active");
    }
}

Should be:

window.addEventListener("scroll" , e=>{
for(let i=0 ; i<=sections.length;i++){
    if(isInViewport(sections[i])){
        sections[i].classList.add("your-active-class");
        document.getElementsByClassName(`${sections[i].id}`)[0].classList.add("active");
    }
    else{
        section.classList.remove("your-active-class");
        document.getElementsByClassName(`${sections[i].id}`)[0].classList.remove("active");
    }
}

That will fix your error.