问:
Error while changing hard coded file to user prompted file
I'm trying to import data from a CSV file to an Excel sheet.

I recorded a macro. The macro uses a hard coded file.

```<code>Sub ImportData()
    ActiveWorkbook.Queries.Add Name:="XX", Formula:= _
        "let" & Chr(13) & "" & Chr(10) & "    Source = Csv.Document(File.Contents(""N:\Operations\Workshop\04 Turbine Testing\01 Engine Test Data\SN140\Build01\Data\Raw\OPC data\SN140-01-07 250kW test.csv""),[Delimiter="","", Columns=104, Encoding=1252, QuoteStyle=QuoteStyle.None])," & Chr(13) & "" & Chr(10) & "    #""Promoted Headers"" = Table.PromoteHeaders(Source, [PromoteAllScalars=true])," & Chr(13) & "" & Chr(10) & "    #""Changed Type"" = Table.Tra" & _
        "nsformColumnTypes(#""Promoted Headers"",{{""Timestamp"", type datetime}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.Engine_Shaft_Power"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.HT80"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PT80"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99" & _
        "_Signals.TE80"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]SE210A"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]SE210B"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]SE210C"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]SY210"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.Engine_Inlet_Mass_Flow"", type number}, {""[I00001" & _
        "9_Testcell_Heng_Rev_0_12]Program:TB99_Signals.FT912"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PDT110"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PT925"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PT931"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PT980A" & _
        """, type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PT980B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE130A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE130B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE970"", type number}, {""[I000019_Testcell_Heng_Rev_0" & _
        "_12]Program:TB99_Signals.TE971"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE972"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE973"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]PT364A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]PT364B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]PT375"", " & _
        "type number}, {""[I000019_Testcell_Heng_Rev_0_12]PT376"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]PY364"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE141A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE141B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE142A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE142B"", type number}, {" & _
        """[I000019_Testcell_Heng_Rev_0_12]TE143A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE143B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE144A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE144B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]ZT370"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]FV370"", Int64.Type}, {""[I000019_Testce" & _
        "ll_Heng_Rev_0_12]FV370B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TT371"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]PT360"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]ZT361"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]FV361"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]FV361B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]ZT" & _
        "366"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]FV366"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]FV366B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.FT933A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE940"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE941"", type nu" & _
        "mber}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE942"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE943"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE944"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE945"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB" & _
        "99_Signals.TE946"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE947"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE948"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE949"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE950"", type number}, {""[I000019_Testce" & _
        "ll_Heng_Rev_0_12]Program:TB99_Signals.PDT953"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PDT954"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PDT955"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PDT956"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE161"", type number}, {""[I000" & _
        "019_Testcell_Heng_Rev_0_12]TE162"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE163"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE164"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE165"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE166"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TY160"", type number}, {""[I000019_Testcell_Heng_Re" & _
        "v_0_12]PT160"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.Turbine_Entry_Temperature"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]VY210"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]VY215"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]VY220"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]PT240"", type number}, {""[I00" & _
        "0019_Testcell_Heng_Rev_0_12]TE231"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]PT231"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE233"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]PT381"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:Flame_Monitoring.BT_DERV01.Out"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signa" & _
        "ls.PT130A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PT130B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE951"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE952"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE110A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE110B""," & _
        " type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE362"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB88_Signals.VY218"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB88_Signals.VY219"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB88_Signals.VY221"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB88_Signals.VY222" & _
        """, Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB88_Signals.VY223"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB88_Signals.VY224"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]FT234"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]FT235"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:Combustor_Vibration_Signals.VY141A"", " & _
        "Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:Combustor_Vibration_Signals.VY141B"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:Combustor_Vibration_Signals.VY142A"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:Combustor_Vibration_Signals.VY142B"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB88_Signals.VY2161"", Int64.T" & _
        "ype}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB88_Signals.VY2171"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.Gas_Fuel_Mass_Flow"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE929"", type number}, {"""", type text}})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & "    #""Changed Type"""
    ActiveWorkbook.Worksheets.Add

    With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
        "OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location= ""XX""" _
        , Destination:=Range("$A$1")).QueryTable
        .CommandType = xlCmdSql
        .CommandText = Array("SELECT * FROM [XX]")
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .PreserveColumnInfo = True
        .ListObject.DisplayName = "XX"
        .Refresh BackgroundQuery:=False
     End With

    Range("A1").Select

End Sub
</code>```

I want to replace the hard coded file in the code with a user prompted file, hence added the following code to the above.

```<code>Dim path As String

With Application.FileDialog(msoFileDialogOpen)
    .Show
    If .SelectedItems.Count = 1 Then
        path = .SelectedItems(1)
    End If
End With

ActiveWorkbook.Queries.Add Name:="XX", Formula:= _
        "let" & Chr(13) & "" & Chr(10) & "    Source = Csv.Document(File.Contents (path).... remaining code as it was
</code>```

This gives an error in the line .Refresh BackgroundQuery:=False.

答:
Not enough rep to ask for clarification so here goes...

When I want to get a user-selected file I use something like this. I'll modify the context to refer to a CSV for this case:

```<code>    Dim importFile as String

    'Displays an open file dialog box for selecting the target file.
    importFile = Application.GetOpenFilename( _
    FileFilter:="CSV Files, *.csv; Title:="Select a CSV file")

    'Handles no sheet selection.
    If importFile = "False" Then
        MsgBox "No File Selected!"
        Exit Sub
    End If
</code>```

From there you can use importFile as the path. Try this

```<code>    Source = Csv.Document(File.Contents(importFile)...
</code>```

Body:
I'm trying to import data from a CSV file to an Excel sheet.

I recorded a macro. The macro uses a hard coded file.

Sub ImportData()
    ActiveWorkbook.Queries.Add Name:="XX", Formula:= _
        "let" & Chr(13) & "" & Chr(10) & "    Source = Csv.Document(File.Contents(""N:\Operations\Workshop\04 Turbine Testing\01 Engine Test Data\SN140\Build01\Data\Raw\OPC data\SN140-01-07 250kW test.csv""),[Delimiter="","", Columns=104, Encoding=1252, QuoteStyle=QuoteStyle.None])," & Chr(13) & "" & Chr(10) & "    #""Promoted Headers"" = Table.PromoteHeaders(Source, [PromoteAllScalars=true])," & Chr(13) & "" & Chr(10) & "    #""Changed Type"" = Table.Tra" & _
        "nsformColumnTypes(#""Promoted Headers"",{{""Timestamp"", type datetime}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.Engine_Shaft_Power"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.HT80"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PT80"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99" & _
        "_Signals.TE80"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]SE210A"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]SE210B"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]SE210C"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]SY210"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.Engine_Inlet_Mass_Flow"", type number}, {""[I00001" & _
        "9_Testcell_Heng_Rev_0_12]Program:TB99_Signals.FT912"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PDT110"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PT925"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PT931"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PT980A" & _
        """, type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PT980B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE130A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE130B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE970"", type number}, {""[I000019_Testcell_Heng_Rev_0" & _
        "_12]Program:TB99_Signals.TE971"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE972"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE973"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]PT364A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]PT364B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]PT375"", " & _
        "type number}, {""[I000019_Testcell_Heng_Rev_0_12]PT376"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]PY364"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE141A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE141B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE142A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE142B"", type number}, {" & _
        """[I000019_Testcell_Heng_Rev_0_12]TE143A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE143B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE144A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE144B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]ZT370"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]FV370"", Int64.Type}, {""[I000019_Testce" & _
        "ll_Heng_Rev_0_12]FV370B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TT371"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]PT360"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]ZT361"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]FV361"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]FV361B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]ZT" & _
        "366"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]FV366"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]FV366B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.FT933A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE940"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE941"", type nu" & _
        "mber}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE942"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE943"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE944"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE945"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB" & _
        "99_Signals.TE946"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE947"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE948"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE949"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE950"", type number}, {""[I000019_Testce" & _
        "ll_Heng_Rev_0_12]Program:TB99_Signals.PDT953"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PDT954"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PDT955"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PDT956"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE161"", type number}, {""[I000" & _
        "019_Testcell_Heng_Rev_0_12]TE162"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE163"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE164"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE165"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE166"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TY160"", type number}, {""[I000019_Testcell_Heng_Re" & _
        "v_0_12]PT160"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.Turbine_Entry_Temperature"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]VY210"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]VY215"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]VY220"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]PT240"", type number}, {""[I00" & _
        "0019_Testcell_Heng_Rev_0_12]TE231"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]PT231"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE233"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]PT381"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:Flame_Monitoring.BT_DERV01.Out"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signa" & _
        "ls.PT130A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.PT130B"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE951"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE952"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE110A"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE110B""," & _
        " type number}, {""[I000019_Testcell_Heng_Rev_0_12]TE362"", type number}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB88_Signals.VY218"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB88_Signals.VY219"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB88_Signals.VY221"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB88_Signals.VY222" & _
        """, Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB88_Signals.VY223"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB88_Signals.VY224"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]FT234"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]FT235"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:Combustor_Vibration_Signals.VY141A"", " & _
        "Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:Combustor_Vibration_Signals.VY141B"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:Combustor_Vibration_Signals.VY142A"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:Combustor_Vibration_Signals.VY142B"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB88_Signals.VY2161"", Int64.T" & _
        "ype}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB88_Signals.VY2171"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.Gas_Fuel_Mass_Flow"", Int64.Type}, {""[I000019_Testcell_Heng_Rev_0_12]Program:TB99_Signals.TE929"", type number}, {"""", type text}})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & "    #""Changed Type"""
    ActiveWorkbook.Worksheets.Add

    With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
        "OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location= ""XX""" _
        , Destination:=Range("$A$1")).QueryTable
        .CommandType = xlCmdSql
        .CommandText = Array("SELECT * FROM [XX]")
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .PreserveColumnInfo = True
        .ListObject.DisplayName = "XX"
        .Refresh BackgroundQuery:=False
     End With

    Range("A1").Select

End Sub

I want to replace the hard coded file in the code with a user prompted file, hence added the following code to the above.

Dim path As String

With Application.FileDialog(msoFileDialogOpen)
    .Show
    If .SelectedItems.Count = 1 Then
        path = .SelectedItems(1)
    End If
End With

ActiveWorkbook.Queries.Add Name:="XX", Formula:= _
        "let" & Chr(13) & "" & Chr(10) & "    Source = Csv.Document(File.Contents (path).... remaining code as it was

This gives an error in the line .Refresh BackgroundQuery:=False.

Body:
Not enough rep to ask for clarification so here goes...

When I want to get a user-selected file I use something like this. I'll modify the context to refer to a CSV for this case:

    Dim importFile as String

    'Displays an open file dialog box for selecting the target file.
    importFile = Application.GetOpenFilename( _
    FileFilter:="CSV Files, *.csv; Title:="Select a CSV file")

    'Handles no sheet selection.
    If importFile = "False" Then
        MsgBox "No File Selected!"
        Exit Sub
    End If

From there you can use importFile as the path. Try this

    Source = Csv.Document(File.Contents(importFile)...


来源: stackexchange

问:
How to replace a string with the array and index of an array as a string?
Consider

```<code>var arr = ["a","b","c"];
var string = "Hello {1} is a friend of {2} and {3}";
</code>```

so replacing {1} with "a", {2} with "b", and {3} with "c"

How do we do using JavaScript?

答:
You can do this with a regex and the string .replace method:

var arr = ["a","b","c"];
var str = "Hello {1} is a friend of {2} and {3}"

var newstr = str.replace(/\{(\d)\}/gm, (_m, i) => {
  const index = Number(i) - 1;
  return arr[index]
});

console.log(newstr)```

ContentLicense: CC BY-SA 4.0

Body:
Consider

var arr = ["a","b","c"];
var string = "Hello {1} is a friend of {2} and {3}";

so replacing {1} with "a", {2} with "b", and {3} with "c"

How do we do using JavaScript?

ContentLicense: CC BY-SA 3.0


问:
Working with embedded resources in external dll, without visual studios
Okay, so I've ran into a problem that I am having trouble finding a solution. There are plenty of solutions using visual studios properties. The issue is that I'm not using visual studios, I'm using csc.exe to compile my code.

Here's what I have so far.

exe.cmd

dll.cmd

Resource.dll

Main.csx

Rsc.csx

a.png

This is all of the code for the .cmd files and .csx files

exe.cmd

```<code>@echo off
csc.exe /target:winexe /reference:Resource.dll /out:Main.exe Main.csx
pause
</code>```

dll.cmd

```<code>@echo off
csc.exe /target:library /resource:a.png /out:Resource.dll Rsc.csx
pause
</code>```

Rsc.csx

```<code>using System;
using System.IO;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;

namespace EmIm
{
    public static class Bck
    {
        public static Image GetBck()
        {
            Bitmap bmp = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("a.png"));
            Image rtn = bmp;
            return rtn;
        }
    }
}
</code>```

Main.csx

```<code>using System;
using System.IO;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;

using EmIm;

namespace prg
{
    class class_m
    {
        public static void Main()
        {
            Form f1 = new Form();
            try
            {
                f1.BackgroundImage = Bck.GetBck();
            }
            catch(Exception e)
            {
                MessageBox.Show(e.Message);
            }
            f1.ShowDialog();
        }
    }
}
</code>```

When I run this, I get a messagebox that displays value of 'null' is not valid for 'stream'

What steps do I need to take to be able to access a.png with reflection, I have checked to make sure a.png is the correct name in the assembly. Any help would be greatly appreciated. Thanks :)

答:
A large thanks to Hans Passant for providing the simple solution to this problem. I had no idea even where to look to find out how to answer this problem, but he summed it up in a single comment.

only one file had to be altered in order for the program to work

new Rsc.csx file

```<code>using System;
using System.IO;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using System.Runtime.CompilerServices;

namespace EmIm
{
    public static class Bck
    {
        [MethodImpl(MethodImplOptions.NoInlining)]
        public static Image GetBck()
        {
            Bitmap bmp = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("a.png"));
            Image rtn = bmp;
            return rtn;
        }
    }
}
</code>```

Once again, thanks Hans Passant for that quick fix to my problem, hopefully any other programmers stubborn enough to avoid Visual Studios could possibly look to this to find a solution that works without it. Have fun programming :)

Body:
Okay, so I've ran into a problem that I am having trouble finding a solution. There are plenty of solutions using visual studios properties. The issue is that I'm not using visual studios, I'm using csc.exe to compile my code.

Here's what I have so far.

exe.cmd

dll.cmd

Resource.dll

Main.csx

Rsc.csx

a.png

This is all of the code for the .cmd files and .csx files

exe.cmd

@echo off
csc.exe /target:winexe /reference:Resource.dll /out:Main.exe Main.csx
pause

dll.cmd

@echo off
csc.exe /target:library /resource:a.png /out:Resource.dll Rsc.csx
pause

Rsc.csx

using System;
using System.IO;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;

namespace EmIm
{
    public static class Bck
    {
        public static Image GetBck()
        {
            Bitmap bmp = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("a.png"));
            Image rtn = bmp;
            return rtn;
        }
    }
}

Main.csx

using System;
using System.IO;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;

using EmIm;

namespace prg
{
    class class_m
    {
        public static void Main()
        {
            Form f1 = new Form();
            try
            {
                f1.BackgroundImage = Bck.GetBck();
            }
            catch(Exception e)
            {
                MessageBox.Show(e.Message);
            }
            f1.ShowDialog();
        }
    }
}

When I run this, I get a messagebox that displays value of 'null' is not valid for 'stream'

What steps do I need to take to be able to access a.png with reflection, I have checked to make sure a.png is the correct name in the assembly. Any help would be greatly appreciated. Thanks :)

Body:
A large thanks to Hans Passant for providing the simple solution to this problem. I had no idea even where to look to find out how to answer this problem, but he summed it up in a single comment.

only one file had to be altered in order for the program to work

new Rsc.csx file

using System;
using System.IO;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using System.Runtime.CompilerServices;

namespace EmIm
{
    public static class Bck
    {
        [MethodImpl(MethodImplOptions.NoInlining)]
        public static Image GetBck()
        {
            Bitmap bmp = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("a.png"));
            Image rtn = bmp;
            return rtn;
        }
    }
}

Once again, thanks Hans Passant for that quick fix to my problem, hopefully any other programmers stubborn enough to avoid Visual Studios could possibly look to this to find a solution that works without it. Have fun programming :)


问:
setTimeout() executed more times?
I am trying to add functionality to a html/js stopwatch, but i have a problem with setTimeout() function. Why is it only executed once for me, but in this video:

https://www.youtube.com/watch?annotation_id=annotation_3059475893&feature=iv&src_vid=iSLWtGAw1Ic&v=gpFPppFU8s8

it is executed until someone stops it. Yeah I know I can use setInterval, but I'm just curious.

here is my code:

```<code>let running = false;
let time = 0;

function start() {
    running = true;
    timer();
}

function stop() {
    running = false;
}

function reset() {
    running = false;
    time = 0;
    document.getElementById("stw").innerHTML = "00:00:00";
}
function timer() {
    if (running) {
        setTimeout(function() {
            time++;
            let min = Math.floor(time / 100 / 60);
            let sec = Math.floor(time / 100) % 60;
            let mSec = time % 100;

            if (min < 10) {
                min = "0" + min;
            }
            if (sec < 10) {
                sec = "0" + sec;
            }
            if (mSec < 10) {
                mSec = "0" + mSec;
            }
            document.getElementById("stw").innerHTML =
                min + ":" + sec + ":" + mSec;
        }, 10);
    }
}
</code>```

答: In the video (around 2 minutes in), timer() calls itself recursively. Your code does not.

Title: setTimeout() executed more times?

Body:
I am trying to add functionality to a html/js stopwatch, but i have a problem with setTimeout() function. Why is it only executed once for me, but in this video:

https://www.youtube.com/watch?annotation_id=annotation_3059475893&feature=iv&src_vid=iSLWtGAw1Ic&v=gpFPppFU8s8

it is executed until someone stops it. Yeah I know I can use setInterval, but I'm just curious.

here is my code:

let running = false;
let time = 0;

function start() {
    running = true;
    timer();
}

function stop() {
    running = false;
}

function reset() {
    running = false;
    time = 0;
    document.getElementById("stw").innerHTML = "00:00:00";
}
function timer() {
    if (running) {
        setTimeout(function() {
            time++;
            let min = Math.floor(time / 100 / 60);
            let sec = Math.floor(time / 100) % 60;
            let mSec = time % 100;

            if (min < 10) {
                min = "0" + min;
            }
            if (sec < 10) {
                sec = "0" + sec;
            }
            if (mSec < 10) {
                mSec = "0" + mSec;
            }
            document.getElementById("stw").innerHTML =
                min + ":" + sec + ":" + mSec;
        }, 10);
    }
}


答:
setTimeout() only calls its callback function once.

There are two ways to to have it call multiple times:

Use setInterval()

Use a recursive function to restart setTimeout() over and over again.

Example:

```<code>function timer() {
  // do something

  // call this function again in 10 milliseconds
  setTimeout(timer, 10);
}
</code>```

Title: setTimeout() executed more times?

Body:
setTimeout() only calls its callback function once.

There are two ways to to have it call multiple times:

Use setInterval()

Use a recursive function to restart setTimeout() over and over again.

Example:

function timer() {
  // do something

  // call this function again in 10 milliseconds
  setTimeout(timer, 10);
}


问:
C++ How to break a while find loop?
In this loop I want to add new line (\n) behind evert dot(.).

How to break the loop when new line has been added after each dot?

```<code>while (alltxt.find(".") != string::npos)
    alltxt.replace(alltxt.find("."), 1, ".\n");
</code>```

答:
You can use a different overload of std::string::find that accepts a starting position. Then you start each search ahead of the '.' that you found.

Something like this:

```<code>std::string::size_type pos = 0;

while((pos = s.find(".", pos)) != std::string::npos)
{
    s.replace(pos, 1, ".\n");
    pos += 2; // move past the dot (and the extra '\n')
}
</code>```

This relies on an idiomatic assign & test which performs an assignment and then tests the result:

```<code>// do the assignment and then test the results
(pos = s.find(".", pos)) != std::string::npos
</code>```

Also note that it is legal with std::string::find for pos to be equal to (but not greater than) s.size().

Title: C++ How to break a while find loop?

Body:
In this loop I want to add new line (\n) behind evert dot(.).

How to break the loop when new line has been added after each dot?

while (alltxt.find(".") != string::npos)
    alltxt.replace(alltxt.find("."), 1, ".\n");

Body:
You can use a different overload of std::string::find that accepts a starting position. Then you start each search ahead of the '.' that you found.

Something like this:

std::string::size_type pos = 0;

while((pos = s.find(".", pos)) != std::string::npos)
{
    s.replace(pos, 1, ".\n");
    pos += 2; // move past the dot (and the extra '\n')
}

This relies on an idiomatic assign & test which performs an assignment and then tests the result:

// do the assignment and then test the results
(pos = s.find(".", pos)) != std::string::npos

Also note that it is legal with std::string::find for pos to be equal to (but not greater than) s.size().


问:
In Rails how do I have a user click to share a specific image with specific text to Facebook?
I'm struggling with this bit of code. What I'd like is for when a user is looking at an image and they want to share it on Facebook they click on the Share option and click Facebook. Then Facebook opens up to share that image with the text that is defined for that image.

I've been working with the following:

```<code><%= link_to ""http://www.facebook.com/sharer.php?u={url}", target: :_blank do %>
        <%= image_tag("/specific image.jpg", class: :facebook_icon, alt: "Facebook") %>
      <% end %>
</code>```

This clearly isn't working. I know I need to have a place to do the text. I've also tried:

```<code><%= link_to "https://www.facebook.com/sharer/sharer.php?u={url}",  title: 'Share Me!' do %><i class="huge facebook icon" data-content="Share Me!">
<%= image_tag('specific image.jpg') %></i><% end %>
</code>```

Which doesn't work. Really all I want on the dropdown is the Facebook icon. Then the link itself should carry that image with text. So shouldn't it be something like:

```<code><%= link_to image_tag('/images/specific_image.jpg'), "https://www.facebook.com/sharer/sharer.php?u={url}", :target => "_blank", title: "Some text goes here for description" %>
</code>```

But that's not right either because it's trying to display the image not sharing the image. Any feedback?

答:
```<code><a href="https://www.facebook.com/sharer/sharer.php?u=<%= asset_url('image.jpg') %>" target="_blank" title="Click to share on Facebook"><span></span>Click to share on Facebook (Opens in new window)</a>
</code>```

This works but...doesn't offer adding in a caption.

Body:
I'm struggling with this bit of code. What I'd like is for when a user is looking at an image and they want to share it on Facebook they click on the Share option and click Facebook. Then Facebook opens up to share that image with the text that is defined for that image.

I've been working with the following:

<%= link_to ""http://www.facebook.com/sharer.php?u={url}", target: :_blank do %>
        <%= image_tag("/specific image.jpg", class: :facebook_icon, alt: "Facebook") %>
      <% end %>

This clearly isn't working. I know I need to have a place to do the text. I've also tried:

<%= link_to "https://www.facebook.com/sharer/sharer.php?u={url}",  title: 'Share Me!' do %>
<%= image_tag('specific image.jpg') %><% end %>

Which doesn't work. Really all I want on the dropdown is the Facebook icon. Then the link itself should carry that image with text. So shouldn't it be something like:

<%= link_to image_tag('/images/specific_image.jpg'), "https://www.facebook.com/sharer/sharer.php?u={url}", :target => "_blank", title: "Some text goes here for description" %>

But that's not right either because it's trying to display the image not sharing the image. Any feedback?

Body:
<a href="https://www.facebook.com/sharer/sharer.php?u=<%= asset_url('image.jpg') %>" target="_blank" title="Click to share on Facebook"><span></span>Click to share on Facebook (Opens in new window)</a>

This works but...doesn't offer adding in a caption.


问:
How to extract only parameter value from URL using ONLY Regular Expressions
Extract the value of the u2 parameter from this URL using a regular expression. http://www.example.com?u1=US&u2=HA853&u3=HPA

```<code><?php
$subject="http://www.example.com?u1=US&u2=HA853&u3=HPA"; //my url
$pattern='/u2=[0-9A-Za-z]*/'; //R.E that url value is only digit/Alphabet
preg_match($pattern,$subject,$match);
print_r($match[0]);
?>
</code>```

Output:-
u2=HA853

How can i retrieve only HA853?

答:
Other way is to use parse_url,http://php.net/manual/en/function.parse-url.php</p>

```<code>  $subject="http://www.example.com?u1=US&u2=HA853&u3=HPA";
  $query_string  = parse_url($subject, PHP_URL_QUERY); // get query string
  $parameters  = explode('&', $query_string); //Explode with &
  $array  = array();  // define an empty array
  foreach($parameters  as $val)
   {
    $param= explode('=', $val);
    $array[$param[0]] = $param[1];
   }
  echo $array['u2']; // outputs HA853

print_r($array);

Array
(
    [u1] => US
    [u2] => HA853
    [u3] => HPA
)
</code>```

Body:
Extract the value of the u2 parameter from this URL using a regular expression. http://www.example.com?u1=US&u2=HA853&u3=HPA

<?php
$subject="http://www.example.com?u1=US&u2=HA853&u3=HPA"; //my url
$pattern='/u2=[0-9A-Za-z]*/'; //R.E that url value is only digit/Alphabet
preg_match($pattern,$subject,$match);
print_r($match[0]);
?>

Output:-
u2=HA853

How can i retrieve only HA853?

Body:
Other way is to use parse_url,http://php.net/manual/en/function.parse-url.php

  $subject="http://www.example.com?u1=US&u2=HA853&u3=HPA";
  $query_string  = parse_url($subject, PHP_URL_QUERY); // get query string
  $parameters  = explode('&', $query_string); //Explode with &
  $array  = array();  // define an empty array
  foreach($parameters  as $val)
   {
    $param= explode('=', $val);
    $array[$param[0]] = $param[1];
   }
  echo $array['u2']; // outputs HA853

print_r($array);

Array
(
    [u1] => US
    [u2] => HA853
    [u3] => HPA
)


问:
Move a div using keypresses and jquery?
Alright, so I'm trying to make a simple script that moves down a div when I press 's' but it's not firing at all. I got Jquery installed, and the error-console in FF isn't saying anything. Can someone tell me what I'm doing wrong?

http://prime.programming-designs.com/designs/map/

答:
Here's your code:

```<code>$('#map').keydown(function(event) {
    switch (event.keycode) {
        case 83: // left arrow key
            markX = markX + markSpeed;
            mark.style.top  = markX + 'px';
            break;
    }
});
</code>```

The issues are that keycode needs to be camelCase keyCode and that the case should be 37 for the left arrow or 40 for the down arrow.

ContentLicense: CC BY-SA 2.5

Title: Move a div using keypresses and jquery?

Body:
Here's your code:

$('#map').keydown(function(event) {
    switch (event.keycode) {
        case 83: // left arrow key
            markX = markX + markSpeed;
            mark.style.top  = markX + 'px';
            break;
    }
});

The issues are that keycode needs to be camelCase keyCode and that the case should be 37 for the left arrow or 40 for the down arrow.


答:
You can try:

```<code>df.loc[df['Date'] == 'Nov 20, 2017', 'Close']
</code>```

if your data frame is called tescoin.history replace that name by df in the code

Title: Python: Finding the value of a position in a dataframe in Pandas, knowing the value in one column

Body:
I have a pandas dataframe in python:

              Date    Open    High     Low   Close     Volume  Market Cap  \
0     Nov 21, 2017  136.10  142.21  131.37  141.74   72701500  2093010000
1     Nov 20, 2017  129.50  140.55  128.49  135.76   59945400  1990900000
2     Nov 19, 2017  130.72  133.62  127.21  129.48   42133000  2009180000
3     Nov 18, 2017  126.59  135.01  123.53  130.80   62156400  1945200000
4     Nov 17, 2017  120.02  126.70  119.25  126.70   47127700  1843600000
5     Nov 16, 2017  121.24  128.09  118.50  120.31   74944100  1861940000
6     Nov 15, 2017  122.24  124.72  119.19  121.37   49976700  1876740000
7     Nov 14, 2017  123.62  124.20  118.63  122.35   53544800  1896990000
8     Nov 13, 2017  128.96  136.53  120.92  123.40  116200000  1978840000
9     Nov 12, 2017  119.60  133.68  110.62  123.86  144948000  1834630000
10    Nov 11, 2017  105.75  127.11  103.88  119.62  107708000  1621800000

This is stored as test.history. I need to get the value of the column Close for the date 20 of November 2017. How do I do it?

I tried:

print testcoin.history.loc['Date'=='Nov 20, 2017','Close']

and

print testcoin.history.loc('Nov 20, 2017','Close')

and many other possibility but I obviously do not understand dataframes well.

P.S. I tried searching for this answer here and looking for the answer online and in tutorials but I always seem to be missing some basic elements to make it work.

Body:
You can try:

df.loc[df['Date'] == 'Nov 20, 2017', 'Close']

if your data frame is called tescoin.history replace that name by df in the code


问:
Continuously loop through CSS style in Angular 4
I am trying to continuously loop through an array of background URLs, with a delay, to create a 'screensaver' for a website's background.

Currently, I have the array in my .ts file, and am using the NgFor directive in my HTML. The issues are that there is no delay between the switch in images (so the one that ends up being displayed is the last one), and that it is not a continuous loop through the array.

In .ts:

```<code>  bgImgs = [
`url("/assets/img/friendship.jpeg")`,
`url("/assets/img/family.jpeg")`,
`url("/assets/img/health.jpeg")`,
`url("/assets/img/fatherson2.jpeg")`
</code>```

]

In .html:

```<code><div *ngFor="let bgImg of bgImgs">
  <div [style.backgroundImage]="bgImg" id="home" class="pt-5">
</code>```

答:
There might be a more "rxjs" way of doing this, but here's one way:

```<code>export class App implements OnInit {
  private imageUrls: string[];
  private current: number = 0;
  currentImage: string;
  constructor() {
    this.imageUrls = [
      '//placehold.it/1280x720.jpg',
      '//placehold.it/1280x721.jpg',
      '//placehold.it/1280x722.jpg',
      '//placehold.it/1280x723.jpg'
    ];
    this.currentImage = this.imageUrls[0]
  }
  ngOnInit() {

    // Every second...
    Observable.interval(1000)
    .subscribe(x => {
      this.currentImage = `url(${this.imageUrls[this.current]})`;

      // Reset current to 0 if we're at the end of the array
      this.current == this.imageUrls.length - 1 ? (this.current = 0) : ++this.current;
    })
  }
}
</code>```

If you want to get into fading or other transitions a bit more legwork is needed.

Plunk

Body:
I am trying to continuously loop through an array of background URLs, with a delay, to create a 'screensaver' for a website's background.

Currently, I have the array in my .ts file, and am using the NgFor directive in my HTML. The issues are that there is no delay between the switch in images (so the one that ends up being displayed is the last one), and that it is not a continuous loop through the array.

In .ts:

  bgImgs = [
`url("/assets/img/friendship.jpeg")`,
`url("/assets/img/family.jpeg")`,
`url("/assets/img/health.jpeg")`,
`url("/assets/img/fatherson2.jpeg")`

]

In .html:

Body:
There might be a more "rxjs" way of doing this, but here's one way:

export class App implements OnInit {
  private imageUrls: string[];
  private current: number = 0;
  currentImage: string;
  constructor() {
    this.imageUrls = [
      '//placehold.it/1280x720.jpg',
      '//placehold.it/1280x721.jpg',
      '//placehold.it/1280x722.jpg',
      '//placehold.it/1280x723.jpg'
    ];
    this.currentImage = this.imageUrls[0]
  }
  ngOnInit() {

    // Every second...
    Observable.interval(1000)
    .subscribe(x => {
      this.currentImage = `url(${this.imageUrls[this.current]})`;

      // Reset current to 0 if we're at the end of the array
      this.current == this.imageUrls.length - 1 ? (this.current = 0) : ++this.current;
    })
  }
}

If you want to get into fading or other transitions a bit more legwork is needed.

Plunk


问:
Cookies in IIS web farm with InProc sessionState
We got two applications, one a legacy application that uses Asp.Net webforms and a new application which uses MVC. Right now we are leaving links on the old application to navigate to certain pages on MVC and were using "Cookies" to maintain state while redirecting to the new application. When we deploy it on lower environments, the navigation between old and new application is working fine but when I deploy my web site to Production, it will be in a web farm on that environment with a load balancer, will there be any issues in terms of accessing cookies between the applications? If so can anyone point me in the right direction with a good example or resource to handle the possible issues?

We are using IIS 7.5

Thanks in advance.

答:
Cookies will be sent to any node in the web farm without issue, assuming the following are all true:

The ASP web forms site and the MVC site are under the same domain.

The cookie is created with a path that includes both sites.

The load balancer is not configured with any rewrite rules that would interfere with the transmission of the cookie (not very likely)

Also, if the cookie is encrypted with the site's machine key, make sure that the machine key is hardcoded on all web servers' web.config (MVC and web forms) with the same value.


答:
When you use setTimeout() to create a loop, inside the function setTimeout() calls, you have to call setTimeout() again.

Here is a basic loop function that does it:

const loopFunc = () => {
  console.log('loop');
  setTimeout(loopFunc, 1000);
};

loopFunc(); // kick it off```

Title: setTimeout() executed more times?


问:
C Language Standard Collections Where Are They?
I have committed to learning C now, I'm good with Python/PHP/Bash but I've decided I'm limited by not being fluent in C.  However I cannot imagine working in a language without lists and hashes, maybe I'm just jumping a gun, but surely there are 'standard' collection libraries.  I do not see any in the GNU standard lib though, any suggestions?</p>

答: Depending on your system, you may find what you're looking for in sys/queue.h, which includes "implementations of singly-linked lists, doubly-linked lists, simple queues, and tail queues".</p>


问:
How do I use CultureInfo to get the 12-hour or 24-hour time (without the date)

I would like to use C# to format a time of day in the proper cultural format.

For example, if the current culture is en-US I would like to show 1:00 PM, and if the current culture is fr-FR I would like to show 13:00. I just want the time of day, I do not want the date.

```<code>//timeOfDay is a DateTime object.

//This will return the 12 hour clock regardless of culture:
time = timeOfDay.ToString("h:mm tt", CultureInfo.CurrentCulture);
//This will return the 24 hour clock regardless of culture
time = timeOfDay.ToString("H:mm tt", CultureInfo.CurrentCulture);
//This will return the correct clock for the culture, but the date will also be present
time = timeOfDay.ToString(CultureInfo.CurrentCulture);
</code>```

Note that the "tt" is for AM/PM, and it is culturally sensitive (in France it is blank, as it should be).

How do I acquire the appropriate clock format for the current culture, without the date?

答:
If you don't need to be explicit you could use .ToShortTimeString() and let the system determine the format.

https://msdn.microsoft.com/en-us/library/system.datetime.toshorttimestring(v=vs.110).aspx

The string returned by the ToShortTimeString method is culture-sensitive. It reflects the pattern defined by the current culture's DateTimeFormatInfo object. For example, for the en-US culture, the standard short time pattern is "h:mm tt"; for the de-DE culture, it is "HH:mm"; for the ja-JP culture, it is "H:mm". The specific format string on a particular computer can also be customized so that it differs from the standard short time format string.

The emphasis is mine.

Edit to demonstrate for this use case:

```<code>//ToShortTimeString automatically uses current culture to show hour:minute
string time = timeOfDay.ToShortTimeString();
</code>```

Body:
I would like to use C# to format a time of day in the proper cultural format.

For example, if the current culture is en-US I would like to show 1:00 PM, and if the current culture is fr-FR I would like to show 13:00. I just want the time of day, I do not want the date.

//timeOfDay is a DateTime object.

//This will return the 12 hour clock regardless of culture:
time = timeOfDay.ToString("h:mm tt", CultureInfo.CurrentCulture);
//This will return the 24 hour clock regardless of culture
time = timeOfDay.ToString("H:mm tt", CultureInfo.CurrentCulture);
//This will return the correct clock for the culture, but the date will also be present
time = timeOfDay.ToString(CultureInfo.CurrentCulture);

Note that the "tt" is for AM/PM, and it is culturally sensitive (in France it is blank, as it should be).

How do I acquire the appropriate clock format for the current culture, without the date?

Body:
If you don't need to be explicit you could use .ToShortTimeString() and let the system determine the format.

https://msdn.microsoft.com/en-us/library/system.datetime.toshorttimestring(v=vs.110).aspx

The string returned by the ToShortTimeString method is culture-sensitive. It reflects the pattern defined by the current culture's DateTimeFormatInfo object. For example, for the en-US culture, the standard short time pattern is "h:mm tt"; for the de-DE culture, it is "HH:mm"; for the ja-JP culture, it is "H:mm". The specific format string on a particular computer can also be customized so that it differs from the standard short time format string.

The emphasis is mine.

Edit to demonstrate for this use case:

//ToShortTimeString automatically uses current culture to show hour:minute
string time = timeOfDay.ToShortTimeString();


问:
Bash: how to automatically insert spacing characters according to indent?
I've got lots of debug statements making for unreadable stacktraces (not my call) like this:

```<code> 00:53:59,906  - j.util.indexing.FileBasedIndex - START INDEX SHUTDOWN
 00:53:09,192  - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/macros.xml
 00:53:09,195  - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/quicklists.xml file is null
 00:53:09,195  - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/quicklists.xml
 00:53:09,696  - ij.openapi.wm.impl.IdeRootPane - App initialization took 5584 ms
 00:53:11,677  -                  TestNG Runner - Create TestNG Template Configuration
 00:53:13,628  - indexing.UnindexedFilesUpdater - Unindexed files update started
 00:53:15,370  - indexing.UnindexedFilesUpdater - Unindexed files update done
 00:53:20,873  - tor.impl.FileEditorManagerImpl - Project opening took 10569 ms
 00:53:31,862  - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/intentionSettings.xml file is null
 00:53:31,862  - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/intentionSettings.xml
 00:54:00,723  - j.util.indexing.FileBasedIndex - END INDEX SHUTDOWN
</code>```

And I want them to look like this:

```<code> 00:53:59,906  - j.util.indexing.FileBasedIndex - START INDEX SHUTDOWN
 00:53:09,192  - .impl.stores.XmlElementStorage -   Document was not loaded for $APP_CONFIG$/macros.xml
 00:53:09,195  - s.impl.stores.FileBasedStorage -   Document was not loaded for $APP_CONFIG$/quicklists.xml file is null
 00:53:09,195  - .impl.stores.XmlElementStorage -   Document was not loaded for $APP_CONFIG$/quicklists.xml
 00:53:09,696  - ij.openapi.wm.impl.IdeRootPane -     App initialization took 5584 ms
 00:53:11,677  -                  TestNG Runner -       Create TestNG Template Configuration
 00:53:13,628  - indexing.UnindexedFilesUpdater -        Unindexed files update started
 00:53:15,370  - indexing.UnindexedFilesUpdater -        Unindexed files update done
 00:53:20,873  - tor.impl.FileEditorManagerImpl -     Project opening took 10569 ms
 00:53:31,862  - s.impl.stores.FileBasedStorage -    Document was not loaded for $APP_CONFIG$/intentionSettings.xml file is null
 00:53:31,862  - .impl.stores.XmlElementStorage -   Document was not loaded for $APP_CONFIG$/intentionSettings.xml
 00:54:00,723  - j.util.indexing.FileBasedIndex - END INDEX SHUTDOWN
</code>```

Now my code is formatted automatically so I know exactly how many characters there are in my source code for indent level.

What I want to do is replace automatically every line in my code looking like:

```<code>log.debug("some silly debug line");
</code>```

with:

```<code>log.debug(" " + "some silly debug line");
</code>```

or:

```<code>log.debug("  " + "some silly debug line");
</code>```

depending on the number of indents before the log.debug line.

I'm pretty sure some Bash/shell magic can do this automatically.

Basically I'd start with a:

```<code>find . -iname "*java" -exec ...
</code>```

then I'd like to insert " " on lines starting with log.debug depending on the indent level of these lines.

How would I go about it?

EDIT

Damn: it needs to be able to run several times, without re-shifting the lines already containing log.debug(" " +).  It gets more complicated but now thanks to the good answer I've got something to start from :)

Note: before yelling and shooting as to why this ain't a good idea, read my comment(s)

答:
Try sed string replacement:

```<code>find . -type f -iname "*.java" -exec sed -i 's/\(\(\s\+\)log.debug(\)\(.*)\)/\1"\2" + \3/' {} \;
</code>```

Let's take a closer look at the regex patterns in sed -i 's/\(\(\s\+\)log.debug(\)\(.*)\)/\1"\2" + \3/...

Group 1 is the original leading text, including whitespace and "log.debug(" (with the open parenthesis).

\(\(\s\+\)log.debug(\)

Group 2, which is inside Group 1 shown above, captures only the leading whitespace:

\(\s\+\)

Group 3 is the original remaining text after "log.debug(":

\(.*)\)

sed uses these capture groups to form a replacement string, which begins with the original leading text, following the original leading whitespace surrounded by quotes, then a plus symbol (for Java string concatenation), and finally the remaining original text:

\1"\2" + \3

Body:
I've got lots of debug statements making for unreadable stacktraces (not my call) like this:

 00:53:59,906  - j.util.indexing.FileBasedIndex - START INDEX SHUTDOWN
 00:53:09,192  - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/macros.xml
 00:53:09,195  - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/quicklists.xml file is null
 00:53:09,195  - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/quicklists.xml
 00:53:09,696  - ij.openapi.wm.impl.IdeRootPane - App initialization took 5584 ms
 00:53:11,677  -                  TestNG Runner - Create TestNG Template Configuration
 00:53:13,628  - indexing.UnindexedFilesUpdater - Unindexed files update started
 00:53:15,370  - indexing.UnindexedFilesUpdater - Unindexed files update done
 00:53:20,873  - tor.impl.FileEditorManagerImpl - Project opening took 10569 ms
 00:53:31,862  - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/intentionSettings.xml file is null
 00:53:31,862  - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/intentionSettings.xml
 00:54:00,723  - j.util.indexing.FileBasedIndex - END INDEX SHUTDOWN

And I want them to look like this:

 00:53:59,906  - j.util.indexing.FileBasedIndex - START INDEX SHUTDOWN
 00:53:09,192  - .impl.stores.XmlElementStorage -   Document was not loaded for $APP_CONFIG$/macros.xml
 00:53:09,195  - s.impl.stores.FileBasedStorage -   Document was not loaded for $APP_CONFIG$/quicklists.xml file is null
 00:53:09,195  - .impl.stores.XmlElementStorage -   Document was not loaded for $APP_CONFIG$/quicklists.xml
 00:53:09,696  - ij.openapi.wm.impl.IdeRootPane -     App initialization took 5584 ms
 00:53:11,677  -                  TestNG Runner -       Create TestNG Template Configuration
 00:53:13,628  - indexing.UnindexedFilesUpdater -        Unindexed files update started
 00:53:15,370  - indexing.UnindexedFilesUpdater -        Unindexed files update done
 00:53:20,873  - tor.impl.FileEditorManagerImpl -     Project opening took 10569 ms
 00:53:31,862  - s.impl.stores.FileBasedStorage -    Document was not loaded for $APP_CONFIG$/intentionSettings.xml file is null
 00:53:31,862  - .impl.stores.XmlElementStorage -   Document was not loaded for $APP_CONFIG$/intentionSettings.xml
 00:54:00,723  - j.util.indexing.FileBasedIndex - END INDEX SHUTDOWN

Now my code is formatted automatically so I know exactly how many characters there are in my source code for indent level.

What I want to do is replace automatically every line in my code looking like:

log.debug("some silly debug line");

with:

log.debug(" " + "some silly debug line");

or:

log.debug("  " + "some silly debug line");

depending on the number of indents before the log.debug line.

I'm pretty sure some Bash/shell magic can do this automatically.

Basically I'd start with a:

find . -iname "*java" -exec ...

then I'd like to insert " " on lines starting with log.debug depending on the indent level of these lines.

How would I go about it?

EDIT

Damn: it needs to be able to run several times, without re-shifting the lines already containing log.debug(" " +).  It gets more complicated but now thanks to the good answer I've got something to start from :)

Note: before yelling and shooting as to why this ain't a good idea, read my comment(s)

Body:
Try sed string replacement:

find . -type f -iname "*.java" -exec sed -i 's/\(\(\s\+\)log.debug(\)\(.*)\)/\1"\2" + \3/' {} \;

Let's take a closer look at the regex patterns in sed -i 's/\(\(\s\+\)log.debug(\)\(.*)\)/\1"\2" + \3/...

Group 1 is the original leading text, including whitespace and "log.debug(" (with the open parenthesis).

\(\(\s\+\)log.debug(\)

Group 2, which is inside Group 1 shown above, captures only the leading whitespace:

\(\s\+\)

Group 3 is the original remaining text after "log.debug(":

\(.*)\)

sed uses these capture groups to form a replacement string, which begins with the original leading text, following the original leading whitespace surrounded by quotes, then a plus symbol (for Java string concatenation), and finally the remaining original text:

\1"\2" + \3


问:
How to extract numbers from a dataframe with html tags in R?
I need to clean my dataframe to take of the HTML tags from columns 2-4.

Does anyone knows a simple way to do that?

答:
```<code>df$col <- gsub("<[^>]+>", "", df$col)
</code>```

Or

```<code>df$col <- gsub("<.*?>","",df$col)
</code>```

This uses regex to strip all html tags which usually enclosed in <>.

Note: using regex to strip HTML is not advised at all times however in your case it seems like your data set will have numbers which is why regex would be the best and simple option for you to go about it.

Body:
df$col <- gsub("<[^>]+>", "", df$col)

Or

df$col <- gsub("<.*?>","",df$col)

This uses regex to strip all html tags which usually enclosed in <>.

Note: using regex to strip HTML is not advised at all times however in your case it seems like your data set will have numbers which is why regex would be the best and simple option for you to go about it.


问:
Problems using MongoDB's $graphLookup
I have two collections. sources:

```<code>[
  {
    "_id": "0001",
    "name": "John Doe"
  },
  {
    "_id": "0002",
    "address": "123 Some Place"
  },
  {
    "_id": "0003",
    "phone": "5555555555"
  }
]
</code>```

and connections:

```<code>[
  {
    "_id": "0001.0002",
    "_from": "0001",
    "_to": "0002",
    "probability": 0.8
  },
  {
    "_id": "0002.0003",
    "_from": "0002",
    "_to": "0003",
    "probability": 0.6
  }
]
</code>```

I'm attempting to do graph traversal with $graphLookup to get a list of all the sources connections. This is the code I have:

db.sources.aggregate([
    {
      $match: {
        '_id': '0001'
      }
    },
    {
      $graphLookup: {
        from: 'connections',
        startWith: '_id',
        connectFromField: '_from',
        connectToField: '_to',
        maxDepth: 2,
        depthField: 'numConnections',
        as: 'destinations'
      }
    }
])
```

This returns the destinations array that is empty. I would expect it to contain two records (0002 and 0003).

I'd like additionally to multiply probabilities during traversal so that 0001 -> 0002 = 0.8 and 0001 -> 0003 = 0.48 (0.8 * 0.6). I must be missing something simple here as I've tried to follow exactly how it's represented in the documentation (https://docs.mongodb.com/manual/reference/operator/aggregation/graphLookup/).

答:
You can try the below query.

You will need two $graphlookup, one for connections for each sources and the other for calculating the probability for each connection.

$unwind with $graphlookup to get all the probability for each connection.

$reduce to $multiply all the array elements for each collection.

$group to group source documents with respective connections and its probability.

```<code>db.sources.aggregate([
  {
    "$match": {
      "_id": "0001"
    }
  },
  {
    "$graphLookup": {
      "from": "connections",
      "startWith": "$_id",
      "connectFromField": "_to",
      "connectToField": "_from",
      "maxDepth": 2,
      "depthField": "numConnections",
      "as": "destinations"
    }
  },
  {
    "$unwind": "$destinations"
  },
  {
    "$graphLookup": {
      "from": "connections",
      "startWith": "$destinations._to",
      "connectFromField": "_from",
      "connectToField": "_to",
      "maxDepth": 2,
      "as": "destinations.probabilities"
    }
  },
  {
    "$addFields": {
      "destinations.probabilities": {
        "$reduce": {
          "input": "$destinations.probabilities.probability",
          "initialValue": 1,
          "in": {
            "$multiply": [
              "$$value",
              "$$this"
            ]
          }
        }
      }
    }
  },
  {
    "$group": {
      "_id": "$_id",
      "name": {
        "$first": "$name"
      },
      "destinations": {
        "$push": "$destinations"
      }
    }
  }
])
</code>```

Title: Problems using MongoDB's $graphLookup

Body:
I have two collections. sources:

[
  {
    "_id": "0001",
    "name": "John Doe"
  },
  {
    "_id": "0002",
    "address": "123 Some Place"
  },
  {
    "_id": "0003",
    "phone": "5555555555"
  }
]

and connections:

[
  {
    "_id": "0001.0002",
    "_from": "0001",
    "_to": "0002",
    "probability": 0.8
  },
  {
    "_id": "0002.0003",
    "_from": "0002",
    "_to": "0003",
    "probability": 0.6
  }
]

I'm attempting to do graph traversal with $graphLookup to get a list of all the sources connections. This is the code I have:

db.sources.aggregate([
    {
      $match: {
        '_id': '0001'
      }
    },
    {
      $graphLookup: {
        from: 'connections',
        startWith: '_id',
        connectFromField: '_from',
        connectToField: '_to',
        maxDepth: 2,
        depthField: 'numConnections',
        as: 'destinations'
      }
    }
])

This returns the destinations array that is empty. I would expect it to contain two records (0002 and 0003).

I'd like additionally to multiply probabilities during traversal so that 0001 -> 0002 = 0.8 and 0001 -> 0003 = 0.48 (0.8 * 0.6). I must be missing something simple here as I've tried to follow exactly how it's represented in the documentation (https://docs.mongodb.com/manual/reference/operator/aggregation/graphLookup/).

Body:
You can try the below query.

You will need two $graphlookup, one for connections for each sources and the other for calculating the probability for each connection.

$unwind with $graphlookup to get all the probability for each connection.

$reduce to $multiply all the array elements for each collection.

$group to group source documents with respective connections and its probability.

db.sources.aggregate([
  {
    "$match": {
      "_id": "0001"
    }
  },
  {
    "$graphLookup": {
      "from": "connections",
      "startWith": "$_id",
      "connectFromField": "_to",
      "connectToField": "_from",
      "maxDepth": 2,
      "depthField": "numConnections",
      "as": "destinations"
    }
  },
  {
    "$unwind": "$destinations"
  },
  {
    "$graphLookup": {
      "from": "connections",
      "startWith": "$destinations._to",
      "connectFromField": "_from",
      "connectToField": "_to",
      "maxDepth": 2,
      "as": "destinations.probabilities"
    }
  },
  {
    "$addFields": {
      "destinations.probabilities": {
        "$reduce": {
          "input": "$destinations.probabilities.probability",
          "initialValue": 1,
          "in": {
            "$multiply": [
              "$$value",
              "$$this"
            ]
          }
        }
      }
    }
  },
  {
    "$group": {
      "_id": "$_id",
      "name": {
        "$first": "$name"
      },
      "destinations": {
        "$push": "$destinations"
      }
    }
  }
])


问:
SQL Query : IF exist delete ELSE update
Good Day,

Right now Im having a hard time figuring if is it possible to have an IF ELSE function inside an sql query. I want to DELETE a row with same location and name, then UPDATE if not exist.

```<code>      $sql = "IF EXISTS (SELECT * FROM location_tbl WHERE name = '$a' && location = 'Drawing Room')
                            DELETE FROM location_tbl WHERE name = '$a'
                                ELSE
                                INSERT INTO location_tbl (id, name, datetime, location) VALUES ('', '$a' , NOW(),'Drawing Room')";
</code>```

Thank you so much for your KIND HELP

答:
One suggestion would be to run the if statement using php:</p>

```<code>$result = $mysqli->query("SELECT * FROM location_tbl WHERE name = '".$a."' AND location = 'Drawing Room'");
if($result->num_rows > 0 ){
    $mysqli->query("DELETE FROM location_tbl WHERE name = '".$a."'");
} else {
    $mysqli->query("INSERT INTO location_tbl (id, name, datetime, location) VALUES ('', '".$a."' , NOW(),'Drawing Room')");
}
</code>```

Title: SQL Query : IF exist delete ELSE update

Body:
Good Day,

Right now Im having a hard time figuring if is it possible to have an IF ELSE function inside an sql query. I want to DELETE a row with same location and name, then UPDATE if not exist.

      $sql = "IF EXISTS (SELECT * FROM location_tbl WHERE name = '$a' && location = 'Drawing Room')
                            DELETE FROM location_tbl WHERE name = '$a'
                                ELSE
                                INSERT INTO location_tbl (id, name, datetime, location) VALUES ('', '$a' , NOW(),'Drawing Room')";

Thank you so much for your KIND HELP

Body:
One suggestion would be to run the if statement using php:

$result = $mysqli->query("SELECT * FROM location_tbl WHERE name = '".$a."' AND location = 'Drawing Room'");
if($result->num_rows > 0 ){
    $mysqli->query("DELETE FROM location_tbl WHERE name = '".$a."'");
} else {
    $mysqli->query("INSERT INTO location_tbl (id, name, datetime, location) VALUES ('', '".$a."' , NOW(),'Drawing Room')");
}


问:
how to remove spaces in a list that has a specific character
how do you get a list to fix the spaces in the list m.

```<code>m = ['m, a \n', 'l, n \n', 'c, l\n']
for i in m:
    if (' ') in i:
        i.strip(' ')
</code>```

I got:

```<code>'m, a \n'
'l, n \n'
'c, l\n'
</code>```

and I want it to return:

```<code>['m, a\n', 'l, n\n', 'c, l\n']
</code>```

答:
Quick and dirty:

m = [x.replace(' \n', '\n') for x in m]

If you know that only one space goes before the '\n'

Body:
how do you get a list to fix the spaces in the list m.

m = ['m, a \n', 'l, n \n', 'c, l\n']
for i in m:
    if (' ') in i:
        i.strip(' ')

I got:

'm, a \n'
'l, n \n'
'c, l\n'

and I want it to return:

['m, a\n', 'l, n\n', 'c, l\n']


问:
How to dynamically switch theme with vmware clarity
Vmware Clarity 0.10.16 just released the new dark theme. This is great!

They described how to add that new theme, but nothing about the possibility to dynamically change it inside the page. Is it because it is not doable?

If it is, how can I do it with Angular 4+? Any site that could help me explaining how to realize that?

Thanks in advance!

答:
I've built a proof of concept how you could do this, but it does have some limitations. Since you can only include one theme file at a time, there can be some lag for the correct theme to render since it happens later in the Angular rendering cycle. It would only big a big deal when the cache is empty for a browser, as subsequent visits would render quickly, but that is a major consideration here. Its a start that you might be able to build something more robust upon.

https://stackblitz.com/edit/clarity-theme-switcher?file=app%2Fapp.component.ts


问:
python: applying ** operator on user-defined class
I have created a custom class, and I want to use the ** operator on a instance for passing it to a function. I have already defined __getitem__ and __iter__, but when I try f(**my_object), I'm getting

```<code>`TypeError: argument must be a mapping, not 'MyClass'`
</code>```

What are the minimum required methods so that the custom class qualifies as a mapping?

答:
** is not an operator, it is part of the call syntax:

If the syntax **expression appears in the function call, expression must evaluate to a mapping, the contents of which are treated as additional keyword arguments.

So if your class implements the Mapping methods, then you should be good to go. You'll need more than just __getitem__ and __iter__ here.

A Mapping is a Collection, so must define at least __getitem__, __iter__, and __len__; in addition most of __contains__, keys, items, values, get, __eq__, and __ne__ would be expected. If your custom class directly inherits from collections.abc.Mapping, you only need to implement the first three.

Demo:

```<code>>>> from collections.abc import Mapping
>>> class DemoMapping(Mapping):
...     def __init__(self, a=None, b=None, c=None):
...         self.a, self.b, self.c = a, b, c
...     def __len__(self): return 3
...     def __getitem__(self, name): return vars(self)[name]
...     def __iter__(self): return iter('abc')
...
>>> def foo(a, b, c):
...     print(a, b, c)
...
>>> foo(**DemoMapping(42, 'spam', 'eggs'))
42 spam eggs
</code>```

If you run this under a debugger, you'll see that Python calls the .keys() method, which returns a dictionary view, which then delegates to the custom class __iter__ method when the view is iterated over. The values are then retrieved with a series of __getitem__ calls. So for your specific case, what was missing was the .keys() method.

In addition, note that Python may enforce that the keys are strings!

```<code>>>> class Numeric(Mapping):
...     def __getitem__(self, name): return {1: 42, 7: 'spam', 11: 'eggs'}[name]
...     def __len__(self): return 3
...     def __iter__(self): return iter((1, 7, 11))
...
>>> dict(Numeric())
{1: 42, 7: 'spam', 11: 'eggs'}
>>> def foo(**kwargs): print(kwargs)
...
>>> foo(**Numeric())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: foo() keywords must be strings
</code>```

Body:
I have created a custom class, and I want to use the ** operator on a instance for passing it to a function. I have already defined __getitem__ and __iter__, but when I try f(**my_object), I'm getting

`TypeError: argument must be a mapping, not 'MyClass'`

What are the minimum required methods so that the custom class qualifies as a mapping?

Body:
** is not an operator, it is part of the call syntax:

If the syntax **expression appears in the function call, expression must evaluate to a mapping, the contents of which are treated as additional keyword arguments.

So if your class implements the Mapping methods, then you should be good to go. You'll need more than just __getitem__ and __iter__ here.

A Mapping is a Collection, so must define at least __getitem__, __iter__, and __len__; in addition most of __contains__, keys, items, values, get, __eq__, and __ne__ would be expected. If your custom class directly inherits from collections.abc.Mapping, you only need to implement the first three.

Demo:

>>> from collections.abc import Mapping
>>> class DemoMapping(Mapping):
...     def __init__(self, a=None, b=None, c=None):
...         self.a, self.b, self.c = a, b, c
...     def __len__(self): return 3
...     def __getitem__(self, name): return vars(self)[name]
...     def __iter__(self): return iter('abc')
...
>>> def foo(a, b, c):
...     print(a, b, c)
...
>>> foo(**DemoMapping(42, 'spam', 'eggs'))
42 spam eggs

If you run this under a debugger, you'll see that Python calls the .keys() method, which returns a dictionary view, which then delegates to the custom class __iter__ method when the view is iterated over. The values are then retrieved with a series of __getitem__ calls. So for your specific case, what was missing was the .keys() method.

In addition, note that Python may enforce that the keys are strings!

>>> class Numeric(Mapping):
...     def __getitem__(self, name): return {1: 42, 7: 'spam', 11: 'eggs'}[name]
...     def __len__(self): return 3
...     def __iter__(self): return iter((1, 7, 11))
...
>>> dict(Numeric())
{1: 42, 7: 'spam', 11: 'eggs'}
>>> def foo(**kwargs): print(kwargs)
...
>>> foo(**Numeric())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: foo() keywords must be strings


问:
Replace far left breadcrumbs with ellipsis or dropdown at mobile breakpoints
I am working on a bootstrap web page where we want to use breadcrumbs for users to track where they are at. I have the breadcrumb html and css where I want it, but I need to make them responsive for mobile devices. I would like to have it automatically show maybe the last 2 or 3 breadcrumbs, depending on the length of them so they fit in mobile devices, then replace the remaining left breadcrumbs with either an ellipsis that users can click on to go back further or a dropdown menu for them to click and select the hidden breadcrumbs.

I am not skilled with javascript/jQuery (I am trying to learn this now). Is there a way to easily do this using js/jQuery or possibly even with pure css?

Below is my HTML and CSS as well as jsfiddle link.

https://jsfiddle.net/htrrbmu5/

HTML:

```<code><div class="cont_principal">
    <div class="cont_breadcrumbs">
        <div class="cont_breadcrumbs" id="navBread">

            <ul>
                <li><a href="#">Dr Know</a></li>
                <li><a href="#">Customers</a></li>
                <li><a href="#">ABC Electric</a></li>
                <li><a href="#">IT</a></li>
                <li><a href="#">ANDY_ASUS</a></li>
                <li><a href="#">Scan</a></li>
                <li><a href="#">2017/12/02 14:03:02</a></li>
            </ul>
        </div>
    </div>
</div>
</code>```

CSS:

```<code>.cont_principal {
  width: 100%;
  height: 100%;
    margin-left: -35px;
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d4e4ef', endColorstr='#86aecc',GradientType=0 );

}

.cont_breadcrumbs {
  width: auto;
}

.cont_breadcrumbs {
  position: relative;
  width: 100%;
  float: left;
}

.cont_breadcrumbs > ul > li {
  position: relative;
  float: left;
  transform: skewX(-15deg);
  background-color: #06bd0a;
  z-index: 1;
  transition: all 0.5s;
  margin-left: 5px;
  list-style: none;

}

.cont_breadcrumbs > ul > li:hover {
 background-color: #3e496a;
}

.cont_breadcrumbs > ul > li  > a {
  display: block;
  padding: 10px;
  font-size: 16px;
  transform: skewX(15deg);
  text-decoration:none;
  color: #fff;
  font-weight: 300;
}
.cont_breadcrumbs > ul > li:last-child {
  background-color: #252d44;
}

.cont_breadcrumbs > ul > li:last-child > a {
  color: #fff;

}
</code>```

答:
Personally I'd just hide the breadcrumbs on mobile, I'm not convinced they're that useful to be honest.

Anyway, if you want to go the dropdown method I wouldn't display any of the breadcrumbs, just take advantage of Bootstrap's hidden responsive utilities. Hide the breadcrumbs on xl and sm, and hide the dropdown on md, lg and xl.

Below is a partially fleshed out solution using jQuery for the select bits and the hidden utilities.

HTML

```<code><div class="cont_principal">
  <div class="cont_breadcrumbs">
    <div class="cont_breadcrumbs" id="navBread">
      <ul class="hidden-xs hidden-sm">
        <li><a href="#">Dr Know</a></li>
        <li><a href="#">Customers</a></li>
        <li><a href="#">ABC Electric</a></li>
        <li><a href="#">IT</a></li>
        <li><a href="#">ANDY_ASUS</a></li>
        <li><a href="#">Scan</a></li>
        <li><a href="#">2017/12/02 14:03:02</a></li>
      </ul>
      <select id="mobile-breadcrumbs" class="hidden-md hidden-lg hidden-xl">
        <option value="dr_know">Dr Know</option>
        <option value="customers">Customers</option>
        <option value="abc_electric">ABC Electric</option>
        <option value="it">IT</option>
        <option value="andy_asus">ANDY_ASUS</option>
        <option value="scan">Scan</option>
        <option value="date">2017/12/02 14:03:02</option>
      </select>
    </div>
  </div>
</div>
</code>```

jQuery

```<code>$(document).ready(function(){
    //change dropdown to last value in breadcrumbs
     var lastone = $("#mobile-breadcrumbs option:last-child").val()
   $('#mobile-breadcrumbs option[value="' + lastone + '"]').attr('selected', 'selected')

   //get value of your dropdown option, that value should be the link to the page.
   $("#mobile-breadcrumbs").change(function() {
     var newpage = $(this).find(":selected").val()
     // code to change pages here.
   })
})
</code>```

Fiddle: https://jsfiddle.net/htrrbmu5/2/ Change the size of the output portion of the page to see the effect.

Body:
I am working on a bootstrap web page where we want to use breadcrumbs for users to track where they are at. I have the breadcrumb html and css where I want it, but I need to make them responsive for mobile devices. I would like to have it automatically show maybe the last 2 or 3 breadcrumbs, depending on the length of them so they fit in mobile devices, then replace the remaining left breadcrumbs with either an ellipsis that users can click on to go back further or a dropdown menu for them to click and select the hidden breadcrumbs.

I am not skilled with javascript/jQuery (I am trying to learn this now). Is there a way to easily do this using js/jQuery or possibly even with pure css?

Below is my HTML and CSS as well as jsfiddle link.

https://jsfiddle.net/htrrbmu5/

HTML:

Dr Know

Customers

ABC Electric

IT

ANDY_ASUS

Scan

2017/12/02 14:03:02

CSS:

.cont_principal {
  width: 100%;
  height: 100%;
    margin-left: -35px;
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d4e4ef', endColorstr='#86aecc',GradientType=0 );

}

.cont_breadcrumbs {
  width: auto;
}

.cont_breadcrumbs {
  position: relative;
  width: 100%;
  float: left;
}

.cont_breadcrumbs > ul > li {
  position: relative;
  float: left;
  transform: skewX(-15deg);
  background-color: #06bd0a;
  z-index: 1;
  transition: all 0.5s;
  margin-left: 5px;
  list-style: none;

}

.cont_breadcrumbs > ul > li:hover {
 background-color: #3e496a;
}

.cont_breadcrumbs > ul > li  > a {
  display: block;
  padding: 10px;
  font-size: 16px;
  transform: skewX(15deg);
  text-decoration:none;
  color: #fff;
  font-weight: 300;
}
.cont_breadcrumbs > ul > li:last-child {
  background-color: #252d44;
}

.cont_breadcrumbs > ul > li:last-child > a {
  color: #fff;

}

Body:
Personally I'd just hide the breadcrumbs on mobile, I'm not convinced they're that useful to be honest.

Anyway, if you want to go the dropdown method I wouldn't display any of the breadcrumbs, just take advantage of Bootstrap's hidden responsive utilities. Hide the breadcrumbs on xl and sm, and hide the dropdown on md, lg and xl.

Below is a partially fleshed out solution using jQuery for the select bits and the hidden utilities.

HTML

<div class="cont_principal">
  <div class="cont_breadcrumbs">
    <div class="cont_breadcrumbs" id="navBread">
      <ul class="hidden-xs hidden-sm">
        <li><a href="#">Dr Know</a></li>
        <li><a href="#">Customers</a></li>
        <li><a href="#">ABC Electric</a></li>
        <li><a href="#">IT</a></li>
        <li><a href="#">ANDY_ASUS</a></li>
        <li><a href="#">Scan</a></li>
        <li><a href="#">2017/12/02 14:03:02</a></li>
      </ul>
      <select id="mobile-breadcrumbs" class="hidden-md hidden-lg hidden-xl">
        <option value="dr_know">Dr Know</option>
        <option value="customers">Customers</option>
        <option value="abc_electric">ABC Electric</option>
        <option value="it">IT</option>
        <option value="andy_asus">ANDY_ASUS</option>
        <option value="scan">Scan</option>
        <option value="date">2017/12/02 14:03:02</option>
      </select>
    </div>
  </div>
</div>

jQuery

$(document).ready(function(){
    //change dropdown to last value in breadcrumbs
     var lastone = $("#mobile-breadcrumbs option:last-child").val()
   $('#mobile-breadcrumbs option[value="' + lastone + '"]').attr('selected', 'selected')

   //get value of your dropdown option, that value should be the link to the page.
   $("#mobile-breadcrumbs").change(function() {
     var newpage = $(this).find(":selected").val()
     // code to change pages here.
   })
})

Fiddle: https://jsfiddle.net/htrrbmu5/2/ Change the size of the output portion of the page to see the effect.


问:
Very Advanced Javascript WYSIWYG editor
I need a solution where a user could enter the URL of a web page in my system. The page would load, and then the user could click a certain section that he wants to change. So basically what I need is, a way to display a web page inside my app (could possibly be done with frames but I'd prefer not to have a horizontal scroll bar), and then another way to let users select a block of text or a page element.

I.e if a block of text is in a div, hovering above the text would outline that div using a faint green color (hovering away would remove this border/outline), and clicking the text would draw a solid green border around it to show that its been selected, and then some content on my page will show the id of the div, and let the user specify some other info that i need.

So I probably need a way to get all the
s,
s, s,
s and any other 'container' tags, and then have the ability to cause hovering/clicking of them to change their style.border property, and the ability to retrieve their id/name,

For a block of text the border could probably work, but what about images and such? Also, what if a
 doesn't have an ID/Name, how could it be specified?

答:
If they fit your context, you might consider doing this with either Adobe Flex or Microsoft Silverlight. Both provide the functionality and granularity of control that's more difficult to accomplish in javascript or with a framework, especially if you need to to work consistently with several browsers, across Windows, Mac, and Linux.

Flex uses an enhanced version of javascript for its programming language. Silverlight did similarly with version 1, although with version 2 they only support the .NET languages (which may be better, worse, or indifferent depending on your needs.)

Both describe themselves as tools for RIAs (Rich Internet Applications).

OwnerDisplayName: Click Upvote

Title: Very Advanced Javascript WYSIWYG editor

LastEditorDisplayName: Tom

OwnerDisplayName: le dorfier

LastEditorDisplayName: le dorfier


问:
Directly setting values for an ArrayList in Java
Setting a list of values for a Java ArrayList works:

```<code>Integer[] a = {1,2,3,4,5,6,7,8,9};
ArrayList<Integer> possibleValues2 = new ArrayList<Integer>(Arrays.asList(a));
</code>```

However, the following doesn't work and has the error "Illegal start of type" as well as other. Why not? Since the first line in the first code block is simply assignment, shouldn't it not have an effect?

```<code>ArrayList<Integer> possibleValues2 = new ArrayList<Integer>(Arrays.asList({1,2,3,4,5,6,7,8,9}));
</code>```

答:
Another option is to use Guava ("Google collections"), which has a Lists.newArrayList(...) method.

Your code would be something like

```<code>ArrayList<Integer> possibleValues2 = Lists.newArrayList(1,2,3,4,...);
</code>```

Body:
Setting a list of values for a Java ArrayList works:

Integer[] a = {1,2,3,4,5,6,7,8,9};
ArrayList<Integer> possibleValues2 = new ArrayList<Integer>(Arrays.asList(a));

However, the following doesn't work and has the error "Illegal start of type" as well as other. Why not? Since the first line in the first code block is simply assignment, shouldn't it not have an effect?

ArrayList<Integer> possibleValues2 = new ArrayList<Integer>(Arrays.asList({1,2,3,4,5,6,7,8,9}));

Body:
Another option is to use Guava ("Google collections"), which has a Lists.newArrayList(...) method.

Your code would be something like

ArrayList<Integer> possibleValues2 = Lists.newArrayList(1,2,3,4,...);


问:
Install hadoop plugin for eclipse oxygen
I am trying to install hadoop plugin for eclipse oxygen ... but am not able to make it work properly.. i am not getting any option to create a map reduce project .. can some one please let me know how to go abt installing the hadoop eclipse plugin ? I am unable to use the install new software feature - I have downloaded the hadoop-eclipse-plugin-2.6.0.jar but am not able to install the same as that is giving me an error sayin no site exists that this location. Also, copying the plugin at the eclipse/plugin folder doesn't work either  ?

Please help!

答:
Copy it to the dropins folder of your Eclipse installation directory.

See also: Eclipse help - The dropins folder and supported file layouts


问:
how to make a value between parentheses in a text file
How can i get value contained in a text file in parentheses?

Example Input:

```<code>Today is a beautiful {day}
</code>```

I want to get the value of day.

答: if you wanted to get the day, you could do %day%, which would print the variable day instead of writing day

Body:
How can i get value contained in a text file in parentheses?

Example Input:

Today is a beautiful {day}

I want to get the value of day.


问:
position sticky for complex table header
I'm trying to get a sticky table header to work with a complex header. It works fine for standard tables. The table will stick at the top row and not the second causing the header to look "out of whack" or sort of staggered.  I tried putting the position sticky on the thead and that didn't seem to do anything.

Here is my table:

table {
  border: 1px solid black;
  font-size: 14px;
  margin: 10px 0;
  position: relative;
}

thead tr th {
  background-color: gray;
  position: sticky;
  top: -2px;
}

thead {
  border: 1px solid black;
  line-height: 1.25;
  overflow: hidden;
}

td {
  border: 1px solid black;
  line-height: 1.25;
  overflow: hidden;
  padding: 4px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table class='sticky-table'>
  <thead>
    <tr>
      <th rowspan="2">First column</th>
      <th colspan="3">Top of second column</th>
    </tr>
    <tr>
      <th>One</th>
      <th>Two</th>
      <th>Three</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
  </tbody>
</table></code>```

答:
I believe the js below will solve the problem. There is some weirdness with the borders, but the ths stick properly.

var tableHeaderTop = document.querySelector('.sticky-table thead').getBoundingClientRect().top;
var ths = document.querySelectorAll('.sticky-table thead th')

for(var i = 0; i < ths.length; i++) {
  var th = ths[i];
  th.style.top = th.getBoundingClientRect().top - tableHeaderTop + "px";
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>table {
  border: 1px solid black;
  font-size: 14px;
  margin: 10px 0;
  position: relative;
}

thead tr th {
  background-color: gray;
  position: sticky;
  top: -2px;
}

thead {
  border: 1px solid black;
  line-height: 1.25;
  overflow: hidden;
}

td {
  border: 1px solid black;
  line-height: 1.25;
  overflow: hidden;
  padding: 4px;
}</code>```

      First column
      Top of second column

      One
      Two
      Three

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

```

Body:
I'm trying to get a sticky table header to work with a complex header. It works fine for standard tables. The table will stick at the top row and not the second causing the header to look "out of whack" or sort of staggered.  I tried putting the position sticky on the thead and that didn't seem to do anything.

Here is my table:

table {
  border: 1px solid black;
  font-size: 14px;
  margin: 10px 0;
  position: relative;
}

thead tr th {
  background-color: gray;
  position: sticky;
  top: -2px;
}

thead {
  border: 1px solid black;
  line-height: 1.25;
  overflow: hidden;
}

td {
  border: 1px solid black;
  line-height: 1.25;
  overflow: hidden;
  padding: 4px;
}

      First column
      Top of second column

      One
      Two
      Three

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

      First cell
      Second cell
      Third cell
      Fourth cell

Body:
I believe the js below will solve the problem. There is some weirdness with the borders, but the ths stick properly.

var tableHeaderTop = document.querySelector('.sticky-table thead').getBoundingClientRect().top;
var ths = document.querySelectorAll('.sticky-table thead th')

for(var i = 0; i < ths.length; i++) {
  var th = ths[i];
  th.style.top = th.getBoundingClientRect().top - tableHeaderTop + "px";
}

table {
  border: 1px solid black;
  font-size: 14px;
  margin: 10px 0;
  position: relative;
}

thead tr th {
  background-color: gray;
  position: sticky;
  top: -2px;
}

thead {
  border: 1px solid black;
  line-height: 1.25;
  overflow: hidden;
}

td {
  border: 1px solid black;
  line-height: 1.25;
  overflow: hidden;
  padding: 4px;
}

<table class='sticky-table'>
  <thead>
    <tr>
      <th rowspan="2">First column</th>
      <th colspan="3">Top of second column</th>
    </tr>
    <tr>
      <th>One</th>
      <th>Two</th>
      <th>Three</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
    <tr>
      <td>First cell</td>
      <td>Second cell</td>
      <td>Third cell</td>
      <td>Fourth cell</td>
    </tr>
  </tbody>
</table>


问:
Recovering a deleted git branch
I was working on a project. Now a few weeks later the client asked me about a branch I had called feature/zomato

It's gone, It can't checkout to it anymore, I don't see it my list of branches in phpstorm either.

I looked online for some solutions

Reflog Solution

This solution required you to know that latest commit on that branch, but the only rows I see in reflog are switching to and away to that branch, I don't see any commits being made on it.

Do you know other solutions to restore a deleted branch? **Or the proof that I deleted it? Is it possible to see that in logs somewhere?

Thank you!

答: If you've deleted (or moved) the ref but haven't GC'd it, you can use git fsck --lost-found to get a list of dangling commits. If one (or more) show up, you can then recreate the branch from the SHA (git branch feature/zomato SHA).

Title: Recovering a deleted git branch


问:
How to start with mobile testing with Appium
Can anyone suggest to startup way with Appium mobile testing. Already have knowledge of Automation testing using Selenium.</p>

答:
start with android automation as you automate basically any app. Use your phone if you have android and if not install genny motion as virtual machine

try this
https://www.guru99.com/introduction-to-appium.html


问:
Mysql Joining data from 3 tables
I can't seem to figure out what join I need to do. I have 3 tables which have all the information. I've map out the steps but I'm unsure what to do now, I need to display all the books listed from a specific author.

There is 3 tables I need to use

Author - which contains author_code, fname & lname.

Book - which contains book_code, title, publisher_code, type, price and paperback

Wrote - which contains book_code, author_number and sequence

Here's the code so far, really I know I should use author name but i can't figure it out.

```<code>SELECT BOOK_CODE
FROM WROTE
WHERE AUTHOR_NUM = 20
LEFT JOIN AUTHOR
ON WROTE.AUTHOR_NUM = AUTHOR.AUTHOR_NUM;
</code>```

答:
You need list of book, so start with book table then join it with wrote to get specific author and then join to author to get author data</p>

```<code>SELECT BOOK_CODE
FROM BOOK
INNER JOIN  WROTE
   ON WROTE.BOOK_CODE = BOOK.BOOK_CODE
   AND WROTE.AUTHOR_NUM = 20
INNER JOIN AUTHOR
   ON AUTHOR.AUTHOR_NUM  = WROTE.AUTHOR_NUM
</code>```

Title: Mysql Joining data from 3 tables

Body:
I can't seem to figure out what join I need to do. I have 3 tables which have all the information. I've map out the steps but I'm unsure what to do now, I need to display all the books listed from a specific author.

There is 3 tables I need to use

Author - which contains author_code, fname & lname.

Book - which contains book_code, title, publisher_code, type, price and paperback

Wrote - which contains book_code, author_number and sequence

Here's the code so far, really I know I should use author name but i can't figure it out.

SELECT BOOK_CODE
FROM WROTE
WHERE AUTHOR_NUM = 20
LEFT JOIN AUTHOR
ON WROTE.AUTHOR_NUM = AUTHOR.AUTHOR_NUM;

Body:
You need list of book, so start with book table then join it with wrote to get specific author and then join to author to get author data

SELECT BOOK_CODE
FROM BOOK
INNER JOIN  WROTE
   ON WROTE.BOOK_CODE = BOOK.BOOK_CODE
   AND WROTE.AUTHOR_NUM = 20
INNER JOIN AUTHOR
   ON AUTHOR.AUTHOR_NUM  = WROTE.AUTHOR_NUM