问:
Primefaces: How can I create a popup list?
I want to make a button that when is pressed will show a popup with a list of objects, from which I can select one to see it's details. How can I do this?</p>

答:
Use
 to show a dialog by a button click. Then to select one of the items, use
 (or any other
 component).

Just peek through their showcase to see what's all available. It comes along with good code examples.

Body:
Use <p:dialog> to show a dialog by a button click. Then to select one of the items, use <p:dataTable> (or any other <p:dataXXX> component).

Just peek through their showcase to see what's all available. It comes along with good code examples.


来源: stackexchange

问:
Why is a ScrolledPanel inside a Treebook not resized automatically?
As I need scrollbars I changed the default Panel by a ScrolledPanel, but the content I inserted inside ScrolledPanel does not make it auto-size according to the size of the window.

I then tried to create a default Panel and insert all the widgets in it through a BoxSizer and finally through another BoxSizer insert this Panel inside the ScrolledPanel, but the content continues without doing the autoresize.

I also tried the opposite, that is, I created a standard Panel and inserted inside my ScrolledPanel using the BoxSizers, but also did not work.

Another detail is that this ScrolledPanels must be inside a TreeBook, because I have a tree that manages the call of each ScrolledPanel.

My code:

```<code>import wx
import wx.lib.scrolledpanel as scrolled

from gettext import gettext as _

class MyMainView(wx.Frame):

    instance = None
    init = 0

    def __init__(self, app):
        if self.init:
            return

        self.frameWidth = 850
        self.frameHeight = 600
        self.init = 1

        no_sys_menu = wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX | wx.CAPTION | wx.CLIP_CHILDREN | wx.CLOSE_BOX
        wx.Frame.__init__(self, None, title=_("Title"), style=no_sys_menu)
        self.SetSize(wx.Size(self.frameWidth, self.frameHeight))

        self.SetBackgroundColour('white')
        self.Centre()

        treeBook = Treebook(self)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(treeBook, 1, wx.ALL | wx.EXPAND, 10)

        self.SetSizer(sizer)
        self.Show()
        self.Layout()

    def __new__(self, *args, **kwargs):
        if self.instance is None:
            self.instance = wx.Frame.__new__(self)
        elif not self.instance:
            self.instance = wx.Frame.__new__(self)

        return self.instance

class Treebook(wx.Treebook):

    def __init__(self, parent):
        wx.Treebook.__init__(self, parent, wx.ID_ANY, style=wx.BK_DEFAULT)

        self.AddPage(MainPanel(self), _("AppTitle"))
        self.AddSubPage(MenuPanel(self), _("SubNodeTitle1"))
        self.ExpandNode(0)

class MainPanel(wx.Panel): # This Panel is OK

    def __init__(self, parent):
        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)

        self.font1 = wx.Font(18, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)
        self.font2 = wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)

        self.SetBackgroundColour("white")

        pngIcon = wx.Image("foo.ico", wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        icon = wx.StaticBitmap(self, -1, pngIcon, pos=(25, 15), size=(pngIcon.GetWidth(), pngIcon.GetHeight()))

        titleHelp = wx.StaticText(self, -1, _("HelpTitle"))
        titleHelp.SetFont(self.font1)

        titleApp = wx.StaticText(self, -1, _("AppTitle"), pos=(25, 85))
        titleApp.SetFont(self.font1)

        description = wx.StaticText(self, -1, _("App description."), pos=(25, 170))
        description.SetFont(self.font2)

        features = wx.StaticText(self, -1, _("App features."), pos=(25, 210))
        features.SetFont(self.font2)

        pngLogo = wx.Image("foo.png", wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        logo = wx.StaticBitmap(self, -1, pngLogo, pos=(25, 390), size=(pngLogo.GetWidth(), pngLogo.GetHeight()))

        sliLine = wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL)
        sliLine.SetSize(wx.Size(625, 1))

        steCopy = wx.StaticText(self, -1, _("Copyright text."))
        steCopy.SetFont(self.font2)

        heigthSpacer = 20

        hSizer = wx.BoxSizer(wx.HORIZONTAL)
        hSizer.Add(icon, 0, wx.LEFT, 0)
        hSizer.Add(titleHelp, 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 10)

        vSizer = wx.BoxSizer(wx.VERTICAL)
        vSizer.AddSpacer(heigthSpacer)
        vSizer.Add(hSizer, 0, wx.LEFT, 10)
        vSizer.AddSpacer(heigthSpacer + 10)
        vSizer.Add(titleApp, 0, wx.LEFT, 15)
        vSizer.AddSpacer(10)
        vSizer.Add(description, 0, wx.LEFT, 15)
        vSizer.AddSpacer(heigthSpacer)
        vSizer.Add(features, 0, wx.LEFT, 15)
        vSizer.AddSpacer(115)
        vSizer.Add(logo, 0, wx.LEFT, 15)
        vSizer.Add(sliLine, 0, wx.TOP | wx.LEFT | wx.RIGHT | wx.EXPAND, 15)
        vSizer.Add(steCopy, 0, wx.LEFT | wx.RIGHT | wx.ALIGN_RIGHT, 15)

        self.SetSizer(vSizer)

class MenuPanel(scrolled.ScrolledPanel): # This panel does not fit content within the size of the Treebook panel

    def __init__(self, parent):
        scrolled.ScrolledPanel.__init__(self, parent, -1)
        self.SetBackgroundColour("white")

        self.font1 = wx.Font(18, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)
        self.font2 = wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
        self.font3 = wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)

        strTitlePage = wx.StaticText(self, -1, _("TitlePanel"))
        strTitlePage.SetFont(self.font1)

        strIntroPage = wx.StaticText(self, -1, _("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."))
        strIntroPage.SetFont(self.font2)

        png = wx.Image("foo.png", wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        bitmap1 = wx.StaticBitmap(self, -1, png, pos=(240, 100), size=(png.GetWidth(), png.GetHeight()))

        steMainTitle = wx.StaticText(self, -1, _("MainMenu"))
        steMainTitle.SetFont(self.font3)

        steMainMenu = wx.StaticText(self, -1, _("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."))
        steMainMenu.SetFont(self.font2)

        png = wx.Image("foo.png", wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        bitmap2 = wx.StaticBitmap(self, -1, png, pos=(240, 100), size=(png.GetWidth(), png.GetHeight()))

        steLangTitle = wx.StaticText(self, -1, _("Config Menu"))
        steLangTitle.SetFont(self.font3)

        steLangMenu = wx.StaticText(self, -1, _("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."))
        steLangMenu.SetFont(self.font2)

        png = wx.Image("foo.png", wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        bitmap3 = wx.StaticBitmap(self, -1, png, pos=(240, 100), size=(png.GetWidth(), png.GetHeight()))

        stePortMenu = wx.StaticText(self, -1, _("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."))
        stePortMenu.SetFont(self.font2)

        png = wx.Image("foo.png", wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        bitmap4 = wx.StaticBitmap(self, -1, png, pos=(240, 100), size=(png.GetWidth(), png.GetHeight()))

        steHelpTitle = wx.StaticText(self, -1, _("Menu Help"))
        steHelpTitle.SetFont(self.font3)

        steHelpMenu = wx.StaticText(self, -1, _("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."))
        steHelpMenu.SetFont(self.font2)

        sliLine = wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL)

        steCopy = wx.StaticText(self, -1, _("Copyright text."))
        steCopy.SetFont(self.font2)

        heigthSpacer = 20

        vSizer = wx.BoxSizer(wx.VERTICAL)
        vSizer.AddSpacer(heigthSpacer)
        vSizer.Add(strTitlePage, 0, wx.ALL, 5)
        vSizer.Add(strIntroPage, 0, wx.EXPAND, 5)
        vSizer.AddSpacer(heigthSpacer)
        vSizer.Add(steMainTitle, 0, wx.ALL, 5)
        vSizer.Add(bitmap1, 0, wx.ALIGN_CENTRE_HORIZONTAL, 5)
        vSizer.Add(steMainMenu, 0, wx.EXPAND, 5)
        vSizer.AddSpacer(heigthSpacer)
        vSizer.Add(steLangTitle, 0, wx.ALL, 5)
        vSizer.Add(bitmap2, 0, wx.ALIGN_CENTRE_HORIZONTAL, 5)
        vSizer.Add(steLangMenu, 0, wx.EXPAND, 5)
        vSizer.AddSpacer(heigthSpacer)
        vSizer.Add(bitmap3, 0, wx.ALIGN_CENTRE_HORIZONTAL, 5)
        vSizer.Add(stePortMenu, 0, wx.EXPAND, 5)
        vSizer.AddSpacer(heigthSpacer)
        vSizer.Add(steHelpTitle, 0, wx.ALL, 5)
        vSizer.Add(bitmap4, 0, wx.ALIGN_CENTRE_HORIZONTAL, 5)
        vSizer.Add(steHelpMenu, 0, wx.EXPAND, 5)
        vSizer.AddSpacer(heigthSpacer)
        vSizer.Add(sliLine, 0, wx.ALL | wx.EXPAND, 5)
        vSizer.Add(steCopy, 0, wx.ALIGN_RIGHT, 5)

        self.SetSizer(vSizer)
        self.Layout()
        self.SetAutoLayout(1)
        self.SetupScrolling()

def main():
    app = wx.App(False)
    main = MyMainView(app)
    app.MainLoop()

if __name__ == '__main__':
    main()
</code>```

What I want is to click on an item in the tree and open next to a Panel with the content being resized according to the size of my window (statictexts, staticlines).

答:
I am not sure if I understand correctly but:

StaticText won't automatically break lines, so even if the "inner panel" resized correctly, the texts would not be visible. You might want to use TextCtrl of some kind, possibly a rich-text ctrl.

If you have a scrolled panel, then the inside of the panel has whatever size it needs, and scrolled panel just adds scroll bars.

So, what you need is: Make another panel inside the MenuPanel, and make all the widgets in the MenuPanel children of this new panel. Then add an on-size handler for the MenuPanel

```<code>    self.Bind(wx.EVT_SIZE, self.OnSize)

def OnSize(self, evt):
    evt.Skip(False)
    self.p.SetSize(evt.GetSize())
</code>```

(self.p is the new panel inside the MenuPanel). But this sets the size of the panel so no scroll bars will ever be needed.  You probably want only the vertical scrollbar and only when it is needed, right? Then I would probably try to set the width of the window only if it is possible, or set the width and very big height, measure, and set the size again.

ContentLicense: CC BY-SA 4.0

Body:
As I need scrollbars I changed the default Panel by a ScrolledPanel, but the content I inserted inside ScrolledPanel does not make it auto-size according to the size of the window.

I then tried to create a default Panel and insert all the widgets in it through a BoxSizer and finally through another BoxSizer insert this Panel inside the ScrolledPanel, but the content continues without doing the autoresize.

I also tried the opposite, that is, I created a standard Panel and inserted inside my ScrolledPanel using the BoxSizers, but also did not work.

Another detail is that this ScrolledPanels must be inside a TreeBook, because I have a tree that manages the call of each ScrolledPanel.

My code:

import wx
import wx.lib.scrolledpanel as scrolled

from gettext import gettext as _

class MyMainView(wx.Frame):

    instance = None
    init = 0

    def __init__(self, app):
        if self.init:
            return

        self.frameWidth = 850
        self.frameHeight = 600
        self.init = 1

        no_sys_menu = wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX | wx.CAPTION | wx.CLIP_CHILDREN | wx.CLOSE_BOX
        wx.Frame.__init__(self, None, title=_("Title"), style=no_sys_menu)
        self.SetSize(wx.Size(self.frameWidth, self.frameHeight))

        self.SetBackgroundColour('white')
        self.Centre()

        treeBook = Treebook(self)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(treeBook, 1, wx.ALL | wx.EXPAND, 10)

        self.SetSizer(sizer)
        self.Show()
        self.Layout()

    def __new__(self, *args, **kwargs):
        if self.instance is None:
            self.instance = wx.Frame.__new__(self)
        elif not self.instance:
            self.instance = wx.Frame.__new__(self)

        return self.instance

class Treebook(wx.Treebook):

    def __init__(self, parent):
        wx.Treebook.__init__(self, parent, wx.ID_ANY, style=wx.BK_DEFAULT)

        self.AddPage(MainPanel(self), _("AppTitle"))
        self.AddSubPage(MenuPanel(self), _("SubNodeTitle1"))
        self.ExpandNode(0)

class MainPanel(wx.Panel): # This Panel is OK

    def __init__(self, parent):
        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)

        self.font1 = wx.Font(18, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)
        self.font2 = wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)

        self.SetBackgroundColour("white")

        pngIcon = wx.Image("foo.ico", wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        icon = wx.StaticBitmap(self, -1, pngIcon, pos=(25, 15), size=(pngIcon.GetWidth(), pngIcon.GetHeight()))

        titleHelp = wx.StaticText(self, -1, _("HelpTitle"))
        titleHelp.SetFont(self.font1)

        titleApp = wx.StaticText(self, -1, _("AppTitle"), pos=(25, 85))
        titleApp.SetFont(self.font1)

        description = wx.StaticText(self, -1, _("App description."), pos=(25, 170))
        description.SetFont(self.font2)

        features = wx.StaticText(self, -1, _("App features."), pos=(25, 210))
        features.SetFont(self.font2)

        pngLogo = wx.Image("foo.png", wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        logo = wx.StaticBitmap(self, -1, pngLogo, pos=(25, 390), size=(pngLogo.GetWidth(), pngLogo.GetHeight()))

        sliLine = wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL)
        sliLine.SetSize(wx.Size(625, 1))

        steCopy = wx.StaticText(self, -1, _("Copyright text."))
        steCopy.SetFont(self.font2)

        heigthSpacer = 20

        hSizer = wx.BoxSizer(wx.HORIZONTAL)
        hSizer.Add(icon, 0, wx.LEFT, 0)
        hSizer.Add(titleHelp, 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 10)

        vSizer = wx.BoxSizer(wx.VERTICAL)
        vSizer.AddSpacer(heigthSpacer)
        vSizer.Add(hSizer, 0, wx.LEFT, 10)
        vSizer.AddSpacer(heigthSpacer + 10)
        vSizer.Add(titleApp, 0, wx.LEFT, 15)
        vSizer.AddSpacer(10)
        vSizer.Add(description, 0, wx.LEFT, 15)
        vSizer.AddSpacer(heigthSpacer)
        vSizer.Add(features, 0, wx.LEFT, 15)
        vSizer.AddSpacer(115)
        vSizer.Add(logo, 0, wx.LEFT, 15)
        vSizer.Add(sliLine, 0, wx.TOP | wx.LEFT | wx.RIGHT | wx.EXPAND, 15)
        vSizer.Add(steCopy, 0, wx.LEFT | wx.RIGHT | wx.ALIGN_RIGHT, 15)

        self.SetSizer(vSizer)

class MenuPanel(scrolled.ScrolledPanel): # This panel does not fit content within the size of the Treebook panel

    def __init__(self, parent):
        scrolled.ScrolledPanel.__init__(self, parent, -1)
        self.SetBackgroundColour("white")

        self.font1 = wx.Font(18, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)
        self.font2 = wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
        self.font3 = wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)

        strTitlePage = wx.StaticText(self, -1, _("TitlePanel"))
        strTitlePage.SetFont(self.font1)

        strIntroPage = wx.StaticText(self, -1, _("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."))
        strIntroPage.SetFont(self.font2)

        png = wx.Image("foo.png", wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        bitmap1 = wx.StaticBitmap(self, -1, png, pos=(240, 100), size=(png.GetWidth(), png.GetHeight()))

        steMainTitle = wx.StaticText(self, -1, _("MainMenu"))
        steMainTitle.SetFont(self.font3)

        steMainMenu = wx.StaticText(self, -1, _("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."))
        steMainMenu.SetFont(self.font2)

        png = wx.Image("foo.png", wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        bitmap2 = wx.StaticBitmap(self, -1, png, pos=(240, 100), size=(png.GetWidth(), png.GetHeight()))

        steLangTitle = wx.StaticText(self, -1, _("Config Menu"))
        steLangTitle.SetFont(self.font3)

        steLangMenu = wx.StaticText(self, -1, _("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."))
        steLangMenu.SetFont(self.font2)

        png = wx.Image("foo.png", wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        bitmap3 = wx.StaticBitmap(self, -1, png, pos=(240, 100), size=(png.GetWidth(), png.GetHeight()))

        stePortMenu = wx.StaticText(self, -1, _("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."))
        stePortMenu.SetFont(self.font2)

        png = wx.Image("foo.png", wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        bitmap4 = wx.StaticBitmap(self, -1, png, pos=(240, 100), size=(png.GetWidth(), png.GetHeight()))

        steHelpTitle = wx.StaticText(self, -1, _("Menu Help"))
        steHelpTitle.SetFont(self.font3)

        steHelpMenu = wx.StaticText(self, -1, _("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."))
        steHelpMenu.SetFont(self.font2)

        sliLine = wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL)

        steCopy = wx.StaticText(self, -1, _("Copyright text."))
        steCopy.SetFont(self.font2)

        heigthSpacer = 20

        vSizer = wx.BoxSizer(wx.VERTICAL)
        vSizer.AddSpacer(heigthSpacer)
        vSizer.Add(strTitlePage, 0, wx.ALL, 5)
        vSizer.Add(strIntroPage, 0, wx.EXPAND, 5)
        vSizer.AddSpacer(heigthSpacer)
        vSizer.Add(steMainTitle, 0, wx.ALL, 5)
        vSizer.Add(bitmap1, 0, wx.ALIGN_CENTRE_HORIZONTAL, 5)
        vSizer.Add(steMainMenu, 0, wx.EXPAND, 5)
        vSizer.AddSpacer(heigthSpacer)
        vSizer.Add(steLangTitle, 0, wx.ALL, 5)
        vSizer.Add(bitmap2, 0, wx.ALIGN_CENTRE_HORIZONTAL, 5)
        vSizer.Add(steLangMenu, 0, wx.EXPAND, 5)
        vSizer.AddSpacer(heigthSpacer)
        vSizer.Add(bitmap3, 0, wx.ALIGN_CENTRE_HORIZONTAL, 5)
        vSizer.Add(stePortMenu, 0, wx.EXPAND, 5)
        vSizer.AddSpacer(heigthSpacer)
        vSizer.Add(steHelpTitle, 0, wx.ALL, 5)
        vSizer.Add(bitmap4, 0, wx.ALIGN_CENTRE_HORIZONTAL, 5)
        vSizer.Add(steHelpMenu, 0, wx.EXPAND, 5)
        vSizer.AddSpacer(heigthSpacer)
        vSizer.Add(sliLine, 0, wx.ALL | wx.EXPAND, 5)
        vSizer.Add(steCopy, 0, wx.ALIGN_RIGHT, 5)

        self.SetSizer(vSizer)
        self.Layout()
        self.SetAutoLayout(1)
        self.SetupScrolling()

def main():
    app = wx.App(False)
    main = MyMainView(app)
    app.MainLoop()

if __name__ == '__main__':
    main()

What I want is to click on an item in the tree and open next to a Panel with the content being resized according to the size of my window (statictexts, staticlines).

Body:
I am not sure if I understand correctly but:

StaticText won't automatically break lines, so even if the "inner panel" resized correctly, the texts would not be visible. You might want to use TextCtrl of some kind, possibly a rich-text ctrl.

If you have a scrolled panel, then the inside of the panel has whatever size it needs, and scrolled panel just adds scroll bars.

So, what you need is: Make another panel inside the MenuPanel, and make all the widgets in the MenuPanel children of this new panel. Then add an on-size handler for the MenuPanel

    self.Bind(wx.EVT_SIZE, self.OnSize)

def OnSize(self, evt):
    evt.Skip(False)
    self.p.SetSize(evt.GetSize())

(self.p is the new panel inside the MenuPanel). But this sets the size of the panel so no scroll bars will ever be needed.  You probably want only the vertical scrollbar and only when it is needed, right? Then I would probably try to set the width of the window only if it is possible, or set the width and very big height, measure, and set the size again.

ContentLicense: CC BY-SA 3.0


问:
Issues creating a Multi list for mobile dropdown menu
I am playing around with this tutorial to create a mobile dropdown menu.

https://osvaldas.info/drop-down-navigation-responsive-and-touch-friendly

Everything works fine but once I add a new  with extra lists inside a previous  tag. The dropdown menu tends to not work as it should. I tried changing the css but had no luck.

Its displaying all the list without user having to click on it. If i add a new multi list to the previous  tag.

```<code><nav id="nav" role="navigation">
<a href="#nav">Show navigation</a>
<a href="#">Hide navigation</a>
<ul class="clearfix">
    <li class="active"><a href="?home">Home</a></li>
    <li>
        <a href="?blog" aria-haspopup="true"><span>Blog</span></a>
        <ul>
            <li><a href="?javascript">JavaScript</a></li>
            <li>
                <a href="?blog" aria-haspopup="true"><span>Test</span></a>
                <ul>
                <li><a href="?design">One</a></li>
                </ul>
            </li>
        </ul>
    </li>
    <li>
        <a href="?work" aria-haspopup="true"><span>Work</span></a>
        <ul>
            <li><a href="?webdesign">Web Design</a></li>
        </ul>
    </li>
    <li><a href="?about">About</a></li>
</ul>
</code>```

I will not post the entire code here as there is too many css elements. please have a look at the code below.

Running example.

https://jsfiddle.net/cys670Lh/1/

答:
You should use when hover > to snipe the current child and not all descendents, then add a new hover rule for the next submenu...

```<code> #nav > ul > li:hover > ul
    {
        display: block;
        left: 0;
        right: 0;
    }
#nav > ul > li > ul > li:hover ul
    {
        display: block;
        left: 0;
        right: 0;
    }
</code>```

FIDDLE

Anyway, as a humble suggestion, I would not use hover to show the menu subcategories... specially if you aim at mobile device. I would use event on click insteed with javascript.

Body:
I am playing around with this tutorial to create a mobile dropdown menu.

https://osvaldas.info/drop-down-navigation-responsive-and-touch-friendly

Everything works fine but once I add a new  with extra lists inside a previous  tag. The dropdown menu tends to not work as it should. I tried changing the css but had no luck.

Its displaying all the list without user having to click on it. If i add a new multi list to the previous  tag.

Show navigation
Hide navigation

Home

        Blog

JavaScript

                Test

One

        Work

Web Design

About

I will not post the entire code here as there is too many css elements. please have a look at the code below.

Running example.

https://jsfiddle.net/cys670Lh/1/

Body:
You should use when hover > to snipe the current child and not all descendents, then add a new hover rule for the next submenu...

 #nav > ul > li:hover > ul
    {
        display: block;
        left: 0;
        right: 0;
    }
#nav > ul > li > ul > li:hover ul
    {
        display: block;
        left: 0;
        right: 0;
    }

FIDDLE

Anyway, as a humble suggestion, I would not use hover to show the menu subcategories... specially if you aim at mobile device. I would use event on click insteed with javascript.


问:
Swrve in app messages
I have swrve SDK implemented in my app. Push notifications, events, everything. And all that works fine except in-app-messages (https://docs.swrve.com/user-documentation/in-app-messaging/intro-to-in-app-messages/).

Did anyone had any experience with Swrve in app messages? The documentation doesn`t say anything about this, only about console configuration which is fine since I recieve the message when I need to do and the buttons respond to user input.

When I click on any button that does some action in the app, the app restarts... Swrve simply restarts my activity. Does anybody have a clue why ?

Cheers

答:
After all I have created another activity where I added the intent filter for receiving this kind of intents (deep link). When you receive deep link in game, it simply opens that new activity on the top of the MAinActivity and you get the URL from Swrve like this onCreate SwrveActivity:

```<code>if (getIntent().getAction() == Intent.ACTION_VIEW) {
        Uri data = getIntent().getData();
        MainActivity.processDeepLink(data.toString());
}
</code>```

After that you must call finish() onResume of that activity so it should close that temporary activity so your app could continue normally.

Title: Swrve in app messages

Body:
After all I have created another activity where I added the intent filter for receiving this kind of intents (deep link). When you receive deep link in game, it simply opens that new activity on the top of the MAinActivity and you get the URL from Swrve like this onCreate SwrveActivity:

if (getIntent().getAction() == Intent.ACTION_VIEW) {
        Uri data = getIntent().getData();
        MainActivity.processDeepLink(data.toString());
}

After that you must call finish() onResume of that activity so it should close that temporary activity so your app could continue normally.


问:
Retrieving TABLE OF VARCHAR2(4000) from stored procedure output in C#
I would need your help at retrieving an Oracle table of varchar2(4000) as output parameter in C#.

I have this Stored Procedure:

```<code>Type TTABSelectResult IS TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER;
PROCEDURE FOO_Procedure(i_nIndex          IN NUMBER,
                        i_nAnzahl         IN NUMBER,
                        o_tabSelectResult OUT TTABSelectResult);
</code>```

And this would be the code I tried:

```<code>using (var cmd = new OracleCommand
                {
                    Connection = Conn,
                    CommandType = CommandType.StoredProcedure,
                    CommandText = "FOO_Package.FOO_Procedure",
                    BindByName = true
                })
{
    cmd.Parameters.Add(new OracleParameter("i_Index", index));
    cmd.Parameters.Add(new OracleParameter("i_Cnt", maxCnt));
    cmd.Parameters.Add("o_tabSelectResult", ???).Direction = ParameterDirection.Output;

    cmd.ExecuteNonQuery();

    var obj = (???)cmd.Parameters["o_tabSelectResult"].Value;
}
</code>```

Could you kindly tell me which types I have to use? Because OracleDbType doesn't support something like string[].

PS: I edited for further information.

PPS: Looking for a posibility to get the data out of the o_tabSelectResult table.

答:
I changed the output to an ref cursor, which can be used to populate an List in c#.

Works like a charm.

Thank you all for your input!

Body:
I would need your help at retrieving an Oracle table of varchar2(4000) as output parameter in C#.

I have this Stored Procedure:

Type TTABSelectResult IS TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER;
PROCEDURE FOO_Procedure(i_nIndex          IN NUMBER,
                        i_nAnzahl         IN NUMBER,
                        o_tabSelectResult OUT TTABSelectResult);

And this would be the code I tried:

using (var cmd = new OracleCommand
                {
                    Connection = Conn,
                    CommandType = CommandType.StoredProcedure,
                    CommandText = "FOO_Package.FOO_Procedure",
                    BindByName = true
                })
{
    cmd.Parameters.Add(new OracleParameter("i_Index", index));
    cmd.Parameters.Add(new OracleParameter("i_Cnt", maxCnt));
    cmd.Parameters.Add("o_tabSelectResult", ???).Direction = ParameterDirection.Output;

    cmd.ExecuteNonQuery();

    var obj = (???)cmd.Parameters["o_tabSelectResult"].Value;
}

Could you kindly tell me which types I have to use? Because OracleDbType doesn't support something like string[].

PS: I edited for further information.

PPS: Looking for a posibility to get the data out of the o_tabSelectResult table.


问:
Push into object with specific key
I'm trying to push some values into one object with a specific key index, something like this:

```<code>var array = [];
array.push({
  name: "toto",
  function: "Dev"
})
</code>```

My final object I want to look like this:

```<code>array = {'user'=>[name:"toto",function:"Dev"]};
</code>```

Thank you.

答:
```<code>var myArry = [];
myArry['user'] = [];
myArry['user'].push({
  name: "toto",
  function: "Dev"
});
</code>```

<p>I think you are looking for that </p>

Title: Push into object with specific key

Body:
I'm trying to push some values into one object with a specific key index, something like this:

var array = [];
array.push({
  name: "toto",
  function: "Dev"
})

My final object I want to look like this:

array = {'user'=>[name:"toto",function:"Dev"]};

Thank you.

Body:
var myArry = [];
myArry['user'] = [];
myArry['user'].push({
  name: "toto",
  function: "Dev"
});

I think you are looking for that


问:
manipulate data set using R
I have a data set which has for example the following column entries

```<code>Data: 05.12.2017   |   Acceleration: 0,0042414...

Data: 05.12.2017   |   Acceleration: 0,004235235...

Data: 05.12.2017   |   Acceleration: 0,04235235...

Data: 05.12.2017   |   Acceleration: 0,0023414...
</code>```

I want to manipulate the data, such that the name before the ":" is the name of the column.

In other words I want this:

```<code>Data         |  Acceleration

05.12.2017   |  0,0042414...

05.12.2017   |  0,004235235...

05.12.2017   |  0,04235235...

05.12.2017   |  0,0023414...
</code>```

Is there a possibility to do that?

答:
A solution using some reshaping from the tidyr package:

```<code># example dataset
df = data.frame(x = c("Data: 05.12.2017", "Data: 05.12.2017"),
                y = c("Acceleration: 0.0042414", "Acceleration: 0.0042243"),
                stringsAsFactors = F)

df

#                  x                       y
# 1 Data: 05.12.2017 Acceleration: 0.0042414
# 2 Data: 05.12.2017 Acceleration: 0.0042243

library(dplyr)
library(tidyr)

df %>%
  gather() %>%
  select(value) %>%
  separate(value,c("v1","v2"), sep = ":") %>%
  group_by(v1) %>%
  mutate(row_num = row_number()) %>%
  spread(v1,v2) %>%
  select(-row_num)

# # A tibble: 2 x 2
#   Acceleration        Data
# *        <chr>       <chr>
# 1    0.0042414  05.12.2017
# 2    0.0042243  05.12.2017
</code>```

Title: manipulate data set using R

Body:
I have a data set which has for example the following column entries

Data: 05.12.2017   |   Acceleration: 0,0042414...

Data: 05.12.2017   |   Acceleration: 0,004235235...

Data: 05.12.2017   |   Acceleration: 0,04235235...

Data: 05.12.2017   |   Acceleration: 0,0023414...

I want to manipulate the data, such that the name before the ":" is the name of the column.

In other words I want this:

Data         |  Acceleration

05.12.2017   |  0,0042414...

05.12.2017   |  0,004235235...

05.12.2017   |  0,04235235...

05.12.2017   |  0,0023414...

Is there a possibility to do that?

Body:
A solution using some reshaping from the tidyr package:

# example dataset
df = data.frame(x = c("Data: 05.12.2017", "Data: 05.12.2017"),
                y = c("Acceleration: 0.0042414", "Acceleration: 0.0042243"),
                stringsAsFactors = F)

df

#                  x                       y
# 1 Data: 05.12.2017 Acceleration: 0.0042414
# 2 Data: 05.12.2017 Acceleration: 0.0042243

library(dplyr)
library(tidyr)

df %>%
  gather() %>%
  select(value) %>%
  separate(value,c("v1","v2"), sep = ":") %>%
  group_by(v1) %>%
  mutate(row_num = row_number()) %>%
  spread(v1,v2) %>%
  select(-row_num)

# # A tibble: 2 x 2
#   Acceleration        Data
# *        <chr>       <chr>
# 1    0.0042414  05.12.2017
# 2    0.0042243  05.12.2017


问:
Specify source ip using fsockopen
On a server with multiple IPs routed to it, I'd like to use PHP's fsockopen to open from a non-primary-interface ip (or a comparable method to be able to make fread and fwrites from a different ip)</p>

答:
With the standard arguments offered, it may not be possible.

This article (see: http://bytes.com/topic/php/answers/568317-specify-source-address-interface-use-when-using-fsockopen) suggests that you have to go down a level and use socket_bind().

ContentLicense: CC BY-SA 2.5

Title: Specify source ip using fsockopen


问:
Maven scope provided and transitive dependencies
I have a dependency with one of the jar and i have marked it as provided in pom xml. It seems only some of the transitive dependency jar are marked as provided and not packaged with the war but others are still scope as compile and  packaged with war libs.Do i need to explicitly mark the scope as provided for all the transitive dependencies.

Dependency in pom xml:

```<code><dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-ftp</artifactId>
            <scope>provided</scope>
</dependency>
</code>```

Dependency tree:

```<code>[INFO] +- org.apache.camel:camel-ftp:jar:2.17.0.redhat-630262:provided
[INFO] |  +- com.jcraft:jsch:jar:0.1.54:provided
[INFO] |  +- commons-net:commons-net:jar:3.3.0.redhat-3:provided
[INFO] |  +- com.sun.xml.bind:jaxb-core:jar:2.2.11:compile
[INFO] |  \- com.sun.xml.bind:jaxb-impl:jar:2.2.11.redhat-2:compile
[INFO] +- org.apache.camel:camel-csv:jar:2.17.0.redhat-630262:provided
</code>```

plugin version Details:

```<code><maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <cdi.api.version>1.2.0.redhat-2</cdi.api.version>
        <javax.inject.version>1.0.0.redhat-6</javax.inject.version>
        <sonar.host.url>http://vfrde2srta0401.agcs.biz:9000</sonar.host.url>
        <xerces.version>2.11.0-22</xerces.version>
        <xmlunit.version>1.6</xmlunit.version>
        <maven.compilerplugin.version>3.7.0</maven.compilerplugin.version>
        <maven.releaseplugin.version>2.5.3</maven.releaseplugin.version>
        <maven.warplugin.version>3.2.0</maven.warplugin.version>
        <maven.jarplugin.version>3.0.2</maven.jarplugin.version>
        <maven.surefireplugin.version>2.20.1</maven.surefireplugin.version>
        <maven.coberturaplugin.version>2.7</maven.coberturaplugin.version>
</code>```

答:
According to Maven documentation (see table), if you define a dependency with provided scope, transitive dependencies will have the following final scopes depending on their original scope:

compile > provided

provided > omitted

runtime > provided

test > omitted

A compile transitive dependency of your provided dependency should then be considered provided.

Body:
I have a dependency with one of the jar and i have marked it as provided in pom xml. It seems only some of the transitive dependency jar are marked as provided and not packaged with the war but others are still scope as compile and  packaged with war libs.Do i need to explicitly mark the scope as provided for all the transitive dependencies.

Dependency in pom xml:

<dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-ftp</artifactId>
            <scope>provided</scope>
</dependency>

Dependency tree:

[INFO] +- org.apache.camel:camel-ftp:jar:2.17.0.redhat-630262:provided
[INFO] |  +- com.jcraft:jsch:jar:0.1.54:provided
[INFO] |  +- commons-net:commons-net:jar:3.3.0.redhat-3:provided
[INFO] |  +- com.sun.xml.bind:jaxb-core:jar:2.2.11:compile
[INFO] |  \- com.sun.xml.bind:jaxb-impl:jar:2.2.11.redhat-2:compile
[INFO] +- org.apache.camel:camel-csv:jar:2.17.0.redhat-630262:provided

plugin version Details:

<maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <cdi.api.version>1.2.0.redhat-2</cdi.api.version>
        <javax.inject.version>1.0.0.redhat-6</javax.inject.version>
        <sonar.host.url>http://vfrde2srta0401.agcs.biz:9000</sonar.host.url>
        <xerces.version>2.11.0-22</xerces.version>
        <xmlunit.version>1.6</xmlunit.version>
        <maven.compilerplugin.version>3.7.0</maven.compilerplugin.version>
        <maven.releaseplugin.version>2.5.3</maven.releaseplugin.version>
        <maven.warplugin.version>3.2.0</maven.warplugin.version>
        <maven.jarplugin.version>3.0.2</maven.jarplugin.version>
        <maven.surefireplugin.version>2.20.1</maven.surefireplugin.version>
        <maven.coberturaplugin.version>2.7</maven.coberturaplugin.version>


问:
How to do XML POST with FlUrl
FlUrl does a great job in dealing with Json/UrlEncoded requests. However, the documentation doesn't really point out how to handle other request types such as text/xml.

What's the best way to do an XML POST using FlUrl?

This (accessing underlying HttpClient) kinda defeats the purpose of using FlUrl since you need to build the URI and content again:

```<code>var result = await "http://someUrl"
                   .AppendPathSegment(pathSegment)
                   .SetQueryParam("name", name)
                   .WithBasicAuth(_userName, _apiToken)
                   .HttpClient
                   .PostAsync(<uri>, <content>);
</code>```

答:
I am a little late to this, however, I have manged to use Flurl nativly, with Xml (had trouble with the xml extension)

First, take your xml data string, convert it to Html content

```<code>var httpContent = new StringContent(xmlDateString, Encoding.UTF8, "text/xml");
</code>```

then, use that content in a normal postasync call.

```<code>var response = await "http://localhost/Notices/webservices/importer.asmx"
        .WithHeader("Authorization", "Basic ssssserrrrr")
        .WithHeader("Content-Type", "text/xml")
        .WithHeader("SOAPAction", "\"http://tempuri.org/ImportData\"")
        .PostAsync(httpContent);
</code>```

In this call, I am setting the content type.  I am also setting the soap action (this is the web method I am calling).

Then it works as normal.

Title: How to do XML POST with FlUrl

Body:
FlUrl does a great job in dealing with Json/UrlEncoded requests. However, the documentation doesn't really point out how to handle other request types such as text/xml.

What's the best way to do an XML POST using FlUrl?

This (accessing underlying HttpClient) kinda defeats the purpose of using FlUrl since you need to build the URI and content again:

var result = await "http://someUrl"
                   .AppendPathSegment(pathSegment)
                   .SetQueryParam("name", name)
                   .WithBasicAuth(_userName, _apiToken)
                   .HttpClient
                   .PostAsync(<uri>, <content>);

Body:
I am a little late to this, however, I have manged to use Flurl nativly, with Xml (had trouble with the xml extension)

First, take your xml data string, convert it to Html content

var httpContent = new StringContent(xmlDateString, Encoding.UTF8, "text/xml");

then, use that content in a normal postasync call.

var response = await "http://localhost/Notices/webservices/importer.asmx"
        .WithHeader("Authorization", "Basic ssssserrrrr")
        .WithHeader("Content-Type", "text/xml")
        .WithHeader("SOAPAction", "\"http://tempuri.org/ImportData\"")
        .PostAsync(httpContent);

In this call, I am setting the content type.  I am also setting the soap action (this is the web method I am calling).

Then it works as normal.


问:
How to get a number of same character and their position in a string in Python?
I have a string, list and start position:

```<code>s = "NNDRJGLDFDNJASNJBSA82NNNNNDHDWUEB3J4JJX"
l = [0, ""]
start = 0
</code>```

Now I want to extract all the N's and their positions in the string. What I have tried so far is:

```<code>for i in range(len(s)):
    if s[i] == "N":
        l[0] = i+start
        l[1] = s[i]
</code>```

But I only get the last "N" character from the string. Any suggestions?

答:
If you enumerate the list, you can retrieve all the indices where there is a N:

```<code>    s = "NNDRJGLDFDNJASNJBSA82NNNNNDHDWUEB3J4JJX"
    indices = []
    start = 0

    for idx, c in enumerate(s):
        if c == "N":
            indices.append(idx)
    indices
</code>```

output:

```<code>[0, 1, 10, 14, 21, 22, 23, 24, 25]
</code>```

Body:
I have a string, list and start position:

s = "NNDRJGLDFDNJASNJBSA82NNNNNDHDWUEB3J4JJX"
l = [0, ""]
start = 0

Now I want to extract all the N's and their positions in the string. What I have tried so far is:

for i in range(len(s)):
    if s[i] == "N":
        l[0] = i+start
        l[1] = s[i]

But I only get the last "N" character from the string. Any suggestions?

Body:
If you enumerate the list, you can retrieve all the indices where there is a N:

    s = "NNDRJGLDFDNJASNJBSA82NNNNNDHDWUEB3J4JJX"
    indices = []
    start = 0

    for idx, c in enumerate(s):
        if c == "N":
            indices.append(idx)
    indices

output:

[0, 1, 10, 14, 21, 22, 23, 24, 25]


问:
primeng p-datatable two way binding issue in angular 4
i have a data table as shown below(using primeng datatable)

```<code><p-dataTable   [value]="gridData" [editable]="true"   >
<p-header>Extraction Fields Setup</p-header>
<p-column *ngFor="let col of cols" [field]="col.field" [header]="col.header"
[sortable]="true" [editable]="col.edit" [style]="{'overflow':
'visible','width':''}">
</p-column>
<p-footer>
<div class="ui-helper-clearfix" style="width:100%"><button type="button"
pButton icon="fa-plus" style="float:left" label="Add"
(click)="showDialogToAdd()">Add</button>
</div>
</p-footer>
</p-dataTable>
</code>```

when click on Add in Footer i fired an event showDialogToAdd() code as shown below.

```<code>    let newBatchObj = {};
    newBatchObj['extractionType'] = '11';
    newBatchObj['fieldname'] = '1';
    newBatchObj['fielddata'] = '1';
    newBatchObj['Anchor'] = '1';
    newBatchObj['bRules'] = '1';
    this.gridData.push(newBatchObj);
</code>```

but p-datatable was not showing the newly added value

答:
you can resolve your problem changing the attribute immutable to false. So your HTML should be like following:

```<code><p-dataTable [immutable]="false" [value]="gridData" [editable]="true">
// your code...
</p-dataTable>
</code>```

I've found the solution on: StackOverflow question

More details on: PrimeNG documentations

Body:
i have a data table as shown below(using primeng datatable)

Extraction Fields Setup

<button type="button"
pButton icon="fa-plus" style="float:left" label="Add"
(click)="showDialogToAdd()">Add</button>

when click on Add in Footer i fired an event showDialogToAdd() code as shown below.

    let newBatchObj = {};
    newBatchObj['extractionType'] = '11';
    newBatchObj['fieldname'] = '1';
    newBatchObj['fielddata'] = '1';
    newBatchObj['Anchor'] = '1';
    newBatchObj['bRules'] = '1';
    this.gridData.push(newBatchObj);

but p-datatable was not showing the newly added value

Body:
you can resolve your problem changing the attribute immutable to false. So your HTML should be like following:

<p-dataTable [immutable]="false" [value]="gridData" [editable]="true">
// your code...
</p-dataTable>

I've found the solution on: StackOverflow question

More details on: PrimeNG documentations


问:
How can i connect Luis to Node.js
This is my first time working with node.js and i have to connect it to Luis, what i tried to do so far is a simple example available in the docs where the bot repeats what the user says and it gave an error as i seemingly am linking LUIS to node.js badly although I referred to the docs https://learn.microsoft.com/en-us/azure/cognitive-services/luis/luis-nodejs-tutorial-build-bot-framework-sample
precisely

```<code>// app.js - register LUIS endpoint API
var recognizer = new builder.LuisRecognizer(process.env.LUIS_MODEL_URL);
bot.recognizer(recognizer)
</code>```

;

My code

```<code>var restify = require('restify');
var builder = require('botbuilder');
var http = require('http');
var recognizer = new builder.LuisRecognizer(MY_PATH_TO_LUIS_HTTP);
bot.recognizer(recognizer);
// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
   console.log('%s listening to %s', server.name, server.url);
});

// Create chat connector for communicating with the Bot Framework Service
var connector = new builder.ChatConnector({
    appId: MY_ID,
    appPassword:MY_PASS
});

// Listen for messages from users
server.post('/api/messages', connector.listen());

// Receive messages from the user and respond by echoing each message back (prefixed with 'You said:')
var bot = new builder.UniversalBot(connector, function (session) {
    session.send("You said: %s", session.message.text);
});
</code>```

So again what i'm trying to do is connect the Luis successfully to node.js then run the output in the cmd and test it in the bot framework channel emulator.
Kindly note that i have tested the code without adding

```<code>var http = require('http');
    var recognizer = new builder.LuisRecognizer(MY_PATH_TO_LUIS_HTTP);
    bot.recognizer(recognizer);
</code>```

at first and it worked fine and i know that what i set in LuiS is different than what this node.js should do(repeat my words) but I'm just still getting a feel of how to link things.

Edit : I got this error

so i went to the command line and used this command npm install --save recognizer then imported to my code above by adding var recognizer = require ('recognizer');
still not working.

答:
You are going in the right direction. The main issue is that you are doing
bot.recognizer before bot is declared :) (you are doing it at the bottom of the code)

Also, I believe that what it's missing is defining the intents methods that will handle the responses from LUIS.

You might want to check the following resources:

Recognize intents and entities with LUIS

The intelligence-LUIS Node.js sample

Title: How can i connect Luis to Node.js

Body:
This is my first time working with node.js and i have to connect it to Luis, what i tried to do so far is a simple example available in the docs where the bot repeats what the user says and it gave an error as i seemingly am linking LUIS to node.js badly although I referred to the docs https://learn.microsoft.com/en-us/azure/cognitive-services/luis/luis-nodejs-tutorial-build-bot-framework-sample
precisely

// app.js - register LUIS endpoint API
var recognizer = new builder.LuisRecognizer(process.env.LUIS_MODEL_URL);
bot.recognizer(recognizer)

;

My code

var restify = require('restify');
var builder = require('botbuilder');
var http = require('http');
var recognizer = new builder.LuisRecognizer(MY_PATH_TO_LUIS_HTTP);
bot.recognizer(recognizer);
// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
   console.log('%s listening to %s', server.name, server.url);
});

// Create chat connector for communicating with the Bot Framework Service
var connector = new builder.ChatConnector({
    appId: MY_ID,
    appPassword:MY_PASS
});

// Listen for messages from users
server.post('/api/messages', connector.listen());

// Receive messages from the user and respond by echoing each message back (prefixed with 'You said:')
var bot = new builder.UniversalBot(connector, function (session) {
    session.send("You said: %s", session.message.text);
});

So again what i'm trying to do is connect the Luis successfully to node.js then run the output in the cmd and test it in the bot framework channel emulator.
Kindly note that i have tested the code without adding

var http = require('http');
    var recognizer = new builder.LuisRecognizer(MY_PATH_TO_LUIS_HTTP);
    bot.recognizer(recognizer);

at first and it worked fine and i know that what i set in LuiS is different than what this node.js should do(repeat my words) but I'm just still getting a feel of how to link things.

Edit : I got this error

so i went to the command line and used this command npm install --save recognizer then imported to my code above by adding var recognizer = require ('recognizer');
still not working.


问:
Android filename with white space cannot be opened
My code works correctly while opening a file in sdcard. However, if I open a filename with white space then error occurs (example: Path - "/sdcard/download/hello hi.jpg").

I tried string.replace(" ","%20"); it doesn't work

```<code>try {
    File file = new File(paths);
    if (file.exists()) {
        Uri path = Uri.fromFile(file);
        Intent intent = new Intent(Intent.ACTION_VIEW);
        String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(paths));

        if (!mimeType.equals("")) {
            intent.setDataAndType(path, mimeType);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
        } else {
            Toast.makeText(this, "Unsupported Format to Open", Toast.LENGTH_SHORT).show();
        }
    }
} catch (ActivityNotFoundException e) {
    Toast.makeText(this, "No Application Available to View this File", Toast.LENGTH_SHORT).show();
} catch(Exception e) {
    Toast.makeText(this, "Error Occurred", Toast.LENGTH_SHORT).show();
}
</code>```

Please help

答:
Replace %20 with space like below

```<code>filePath =  filePath.replaceAll("%20"," ");
</code>```

This worked for me

Body:
My code works correctly while opening a file in sdcard. However, if I open a filename with white space then error occurs (example: Path - "/sdcard/download/hello hi.jpg").

I tried string.replace(" ","%20"); it doesn't work

try {
    File file = new File(paths);
    if (file.exists()) {
        Uri path = Uri.fromFile(file);
        Intent intent = new Intent(Intent.ACTION_VIEW);
        String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(paths));

        if (!mimeType.equals("")) {
            intent.setDataAndType(path, mimeType);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
        } else {
            Toast.makeText(this, "Unsupported Format to Open", Toast.LENGTH_SHORT).show();
        }
    }
} catch (ActivityNotFoundException e) {
    Toast.makeText(this, "No Application Available to View this File", Toast.LENGTH_SHORT).show();
} catch(Exception e) {
    Toast.makeText(this, "Error Occurred", Toast.LENGTH_SHORT).show();
}

Please help

Body:
Replace %20 with space like below

filePath =  filePath.replaceAll("%20"," ");

This worked for me


问:
Realm - results.remove() is deprecated in realm
Now that results.remove(0) is deprecated in realm, what is the best way to remove the realm element in an android application?

I have tried to delete particular element and I have used following code :

using result.deleteAllFromRealm(); it's delete all element but need to delete particular position.

```<code>RealmResults<PersonDetailsModel> results = myRealm.where(PersonDetailsModel.class).equalTo("id", personId).findAll();
        myRealm.beginTransaction();
        results.remove(0);     // App crash
        myRealm.commitTransaction();
</code>```

But it's app crash on that line and I am getting this error :

```<code>java.lang.UnsupportedOperationException: This method is not supported by 'RealmResults' or 'OrderedRealmCollectionSnapshot'.
</code>```

Suggest some way to solved this issue.

答:
Use deleteFromRealm method</p>

```<code>result.deleteFromRealm(index);
</code>```

Body:
Now that results.remove(0) is deprecated in realm, what is the best way to remove the realm element in an android application?

I have tried to delete particular element and I have used following code :

using result.deleteAllFromRealm(); it's delete all element but need to delete particular position.

RealmResults<PersonDetailsModel> results = myRealm.where(PersonDetailsModel.class).equalTo("id", personId).findAll();
        myRealm.beginTransaction();
        results.remove(0);     // App crash
        myRealm.commitTransaction();

But it's app crash on that line and I am getting this error :

java.lang.UnsupportedOperationException: This method is not supported by 'RealmResults' or 'OrderedRealmCollectionSnapshot'.

Suggest some way to solved this issue.

Body:
Use deleteFromRealm method

result.deleteFromRealm(index);


问:
is there an url for photo gallery so that we could jump to in ios
I want user jump to their photo gallery after pressing a button.

Is there a URL for that? I am using objective-c if it matters.

答:
Short answer NO.

You can not open photos app using URL because Photos app does not register and URL schema.

About Apple URL Schemes

photos-redirect:// is the URL Scheme for Photo App. However, it is undocumented, thus you shouldn't use it.


问:
Getting unread count from gmail using C#
I've been trying to get the count of unread emails in Gmail but I'm encountering some problems. I did a search and I found ImapX library that should help me achieve this, but the code I found here on StackOverFlow on previews questions doesn't work. This is my code right now:

```<code>namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string username = "my_email@gmail.com";
            string passwd = "my_pass";
            int unread = 0;

            ImapClient client = new ImapClient("imap.gmail.com", 993, true);
            bool result = client.IsConnected;

            if (result)
                Console.WriteLine("Connection Established");

            result = client.Login(username, passwd); // <-- Error here
            if (result)
            {
                Console.WriteLine("Logged in");
                FolderCollection folders = client.Folders;
               // Message messages = client.Folders["INBOX"].Messages;
                foreach (ImapX.Message m in client.Folders["INBOX"].Messages)
                {
                    if (m.Seen == false)
                        unread++;
                }
                Console.WriteLine(unread);
            }
        }
    }
}
</code>```

The Error is:

The selected authentication mechanism is not supported" on line 26

which is result = client.Login(username, passwd);

答:
You have to make the connection.

```<code>        ImapClient client = new ImapClient("imap.gmail.com", 993, true);
        client.Connect();
        bool result = client.IsConnected;
</code>```

So if you added the line client.Connect(), I think it solves your problem.

Body:
I've been trying to get the count of unread emails in Gmail but I'm encountering some problems. I did a search and I found ImapX library that should help me achieve this, but the code I found here on StackOverFlow on previews questions doesn't work. This is my code right now:

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string username = "my_email@gmail.com";
            string passwd = "my_pass";
            int unread = 0;

            ImapClient client = new ImapClient("imap.gmail.com", 993, true);
            bool result = client.IsConnected;

            if (result)
                Console.WriteLine("Connection Established");

            result = client.Login(username, passwd); // <-- Error here
            if (result)
            {
                Console.WriteLine("Logged in");
                FolderCollection folders = client.Folders;
               // Message messages = client.Folders["INBOX"].Messages;
                foreach (ImapX.Message m in client.Folders["INBOX"].Messages)
                {
                    if (m.Seen == false)
                        unread++;
                }
                Console.WriteLine(unread);
            }
        }
    }
}

The Error is:

The selected authentication mechanism is not supported" on line 26

which is result = client.Login(username, passwd);

Body:
You have to make the connection.

        ImapClient client = new ImapClient("imap.gmail.com", 993, true);
        client.Connect();
        bool result = client.IsConnected;

So if you added the line client.Connect(), I think it solves your problem.


问:
Wrong path searched when running c++ program

Hi. I am using a machine remotely which has an g++ version too old to compile a c++ program. I installed gcc-5.4.0 using  http://luiarthur.github.io/gccinstall. The code complies but when running it I get the following error:

./run_with_config: /usr/lib64/libstdc++.so.6: version GLIBCXX_3.4.20' not found (required by ./run_with_config)
  ./run_with_config: /usr/lib64/libstdc++.so.6: versionCXXABI_1.3.9' not found (required by ./run_with_config)
  ./run_with_config: /usr/lib64/libstdc++.so.6: version GLIBCXX_3.4.18' not found (required by ./run_with_config)
  ./run_with_config: /usr/lib64/libstdc++.so.6: versionCXXABI_1.3.5' not found (required by ./run_with_config)
  ./run_with_config: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./run_with_config)

So the path that is searched

/usr/lib64/

is the incorrect one. I am not sure what I would have to adjust so that the correct path is the one searched.

Help would be appreciated.

答: Compile with -static-libstdc++ flag (probably you'll need -static-libgcc as well) - that will include newer runtime library inside binary, so outdated /usr/lib64/libstdc++.so.6 library would not be used.


问:
Why does changing the type lead to different usage of members?
So I was testing with some code snippets to wrap my head around the concept of inheritance, when I came across this - for me - strange phenomenon.

So first I was testing this simple code:

```<code>public class Main{
    public static void main(String[] args) {
        Bar bar = new Bar();

        System.out.println("age = " + bar.age);

        bar.test();
    }
}

class Foo{
    int age = 2;

    void test(){
        System.out.println("TEST FOO");
    }
}

class Bar extends Foo{
    int age = 4;

    void test(){
        System.out.println("TEST BAR");
    }
}
</code>```

And the output was as I expected:

```<code>age = 4
TEST BAR
</code>```

Then I made a small change to line 3, where I changed the type Bar to Foo like this:

```<code>Foo bar = new Bar();
</code>```

Now when I run the code, it gives me an output I believe is weird:

```<code>age = 2
TEST BAR
</code>```

How does it happen that the code bar.age is now using the age member of the Foo class (which makes sense), while bar.test(); still uses the method of the Bar class (and not from Foo as that is what the type is)?

答:
The age in Bar shadows the age in Foo.

Furthermore, fields are not polymorphic (cf. functions).

So when you write Foo bar = new Bar();, the static type of bar is used when accessing the field age, to return 2. And the dynamic type of bar is used when deciding which override of test() to call, and that's a Bar type.

Body:
So I was testing with some code snippets to wrap my head around the concept of inheritance, when I came across this - for me - strange phenomenon.

So first I was testing this simple code:

public class Main{
    public static void main(String[] args) {
        Bar bar = new Bar();

        System.out.println("age = " + bar.age);

        bar.test();
    }
}

class Foo{
    int age = 2;

    void test(){
        System.out.println("TEST FOO");
    }
}

class Bar extends Foo{
    int age = 4;

    void test(){
        System.out.println("TEST BAR");
    }
}

And the output was as I expected:

age = 4
TEST BAR

Then I made a small change to line 3, where I changed the type Bar to Foo like this:

Foo bar = new Bar();

Now when I run the code, it gives me an output I believe is weird:

age = 2
TEST BAR

How does it happen that the code bar.age is now using the age member of the Foo class (which makes sense), while bar.test(); still uses the method of the Bar class (and not from Foo as that is what the type is)?


问:
Sorting 20 newsgroup dataset in python
in the code below I tried to sort the 20 newsgroup datasets. But it provides error. The wondering part is the dimensionality of this array (11314, 130107). Anyone knows why?</p>

```<code>import numpy as np

import tensorflow as tf

from pprint import pprint

from sklearn.datasets import fetch_20newsgroups_vectorized

data_train= fetch_20newsgroups_vectorized(subset='train')

temp= np.sort(data_train.data, axis=1)
</code>```

答:
As fetch_20newsgroup_vectorized described, it returns a csr_matrix other than np.matrix:

Returns bunch : Bunch object
  bunch.data: sparse matrix, shape [n_samples, n_features] bunch.target: array, shape [n_samples] bunch.target_names: list, length [n_classes]

You need to transfer it into np.matrix with todense:

```<code>np.sort(data_train.data.todense(), axis=1)
</code>```

Title: Sorting 20 newsgroup dataset in python

Body:
in the code below I tried to sort the 20 newsgroup datasets. But it provides error. The wondering part is the dimensionality of this array (11314, 130107). Anyone knows why?

import numpy as np

import tensorflow as tf

from pprint import pprint

from sklearn.datasets import fetch_20newsgroups_vectorized

data_train= fetch_20newsgroups_vectorized(subset='train')

temp= np.sort(data_train.data, axis=1)

Body:
As fetch_20newsgroup_vectorized described, it returns a csr_matrix other than np.matrix:

Returns bunch : Bunch object
  bunch.data: sparse matrix, shape [n_samples, n_features] bunch.target: array, shape [n_samples] bunch.target_names: list, length [n_classes]

You need to transfer it into np.matrix with todense:

np.sort(data_train.data.todense(), axis=1)


问:
Notification from subscription does not notify specific domains
We are migrating from one pre-production platform on the cloud to another server. We have successfully migrated everything but something strange is happening with the subscriptions of Orion Context Broker, since our instance of Orion is successfully notifying different endpoints, but not the one from our platform.

Both of the subscriptions are done from the same instance and implementing HTTPS, and the security groups are equally configured. The Orion context broker logs doesnt show any useful information about what is happening with the cURL request that internally is doing.

Here is an example of a right subscription from this Orion:

```<code>time=Tuesday 14 Nov 12:54:03 2017.102Z | lvl=INFO | corr=e42533b2-c93a-11e7-b333-0242ac110003 | trans=1510663280-019-00000000009 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=logMsg.h[1832]:lmTransactionStart | msg=Starting transaction from 54.194.53.34:48920/v1/updateContext
time=Tuesday 14 Nov 12:54:03 2017.102Z | lvl=INFO | corr=e42533b2-c93a-11e7-b333-0242ac110003 | trans=1510663280-019-00000000009 | from=54.194.53.34 | srv=pending | subsrv=/howto | comp=Orion | op=rest.cpp[882]:servicePathSplit | msg=Service Path 0: '/howto'
time=Tuesday 14 Nov 12:54:03 2017.103Z | lvl=INFO | corr=e42533b2-c93a-11e7-b333-0242ac110003 | trans=1510663280-019-00000000009 | from=54.194.53.34 | srv=howtoservice | subsrv=/howto | comp=Orion | op=connectionOperations.cpp[92]:collectionQuery | msg=Database Operation Successful (query: { _id.id: "M1111", _id.type: "Thing", _id.servicePath: { $in: [ /^/howto$/ ] } })
time=Tuesday 14 Nov 12:54:03 2017.104Z | lvl=INFO | corr=e42533b2-c93a-11e7-b333-0242ac110003 | trans=1510663280-019-00000000009 | from=54.194.53.34 | srv=howtoservice | subsrv=/howto | comp=Orion | op=connectionOperations.cpp[447]:collectionUpdate | msg=Database Operation Successful (update: <{ _id.id: "M1111", _id.type: "Thing", _id.servicePath: { $in: [ /^/howto$/ ] } }, { $set: { attrs.local: { value: "1.1.1.1,50", type: "string", md: { TimeInstant: { type: "ISO8601", value: "2017-11-14T12:54:03.090Z" } }, mdNames: [ "TimeInstant" ], creDate: 1510662361, modDate: 1510664043 }, attrs.serial_number: { value: "M1111", type: "string", md: { TimeInstant: { type: "ISO8601", value: "2017-11-14T12:54:03.090Z" } }, mdNames: [ "TimeInstant" ], creDate: 1510662361, modDate: 1510664043 }, attrs.TimeInstant: { value: "2017-11-14T12:54:03.090Z", type: "ISO8601", mdNames: [], creDate: 1510662361, modDate: 1510664043 }, modDate: 1510664043, lastCorrelator: "e42533b2-c93a-11e7-b333-0242ac110003" }, $unset: { location: 1 } }>)
time=Tuesday 14 Nov 12:54:03 2017.104Z | lvl=INFO | corr=e42533b2-c93a-11e7-b333-0242ac110003 | trans=1510663280-019-00000000009 | from=54.194.53.34 | srv=howtoservice | subsrv=/howto | comp=Orion | op=logMsg.h[1916]:lmTransactionEnd | msg=Transaction ended
time=Tuesday 14 Nov 12:54:03 2017.105Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000010 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=logMsg.h[1832]:lmTransactionStart | msg=Starting transaction to https://visualfy.secmotic.com:443/api/v1/devices/orion/local
time=Tuesday 14 Nov 12:54:03 2017.105Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000010 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=httpRequestSend.cpp[599]:httpRequestSendWithCurl | msg=Sending message 2 to HTTP server: sending message of 540 bytes to HTTP server
time=Tuesday 14 Nov 12:54:03 2017.238Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000010 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=httpRequestSend.cpp[620]:httpRequestSendWithCurl | msg=Notification Successfully Sent to https://visualfy.secmotic.com:443/api/v1/devices/orion/local
time=Tuesday 14 Nov 12:54:03 2017.239Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000010 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=logMsg.h[1916]:lmTransactionEnd | msg=Transaction ended
</code>```

And here is an example of a failed notification.

```<code>time=Tuesday 14 Nov 12:55:13 2017.809Z | lvl=INFO | corr=0e4a4e20-c93b-11e7-957f-0242ac110003 | trans=1510663280-019-00000000012 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=logMsg.h[1832]:lmTransactionStart | msg=Starting transaction from 54.194.53.34:48922/v1/updateContext
time=Tuesday 14 Nov 12:55:13 2017.810Z | lvl=INFO | corr=0e4a4e20-c93b-11e7-957f-0242ac110003 | trans=1510663280-019-00000000012 | from=54.194.53.34 | srv=pending | subsrv=/howto | comp=Orion | op=rest.cpp[882]:servicePathSplit | msg=Service Path 0: '/howto'
time=Tuesday 14 Nov 12:55:13 2017.810Z | lvl=INFO | corr=0e4a4e20-c93b-11e7-957f-0242ac110003 | trans=1510663280-019-00000000012 | from=54.194.53.34 | srv=howtoservice | subsrv=/howto | comp=Orion | op=connectionOperations.cpp[92]:collectionQuery | msg=Database Operation Successful (query: { _id.id: "M1111", _id.type: "Thing", _id.servicePath: { $in: [ /^/howto$/ ] } })
time=Tuesday 14 Nov 12:55:13 2017.811Z | lvl=INFO | corr=0e4a4e20-c93b-11e7-957f-0242ac110003 | trans=1510663280-019-00000000012 | from=54.194.53.34 | srv=howtoservice | subsrv=/howto | comp=Orion | op=connectionOperations.cpp[447]:collectionUpdate | msg=Database Operation Successful (update: <{ _id.id: "M1111", _id.type: "Thing", _id.servicePath: { $in: [ /^/howto$/ ] } }, { $set: { attrs.local: { value: "1.1.1.1,50", type: "string", md: { TimeInstant: { type: "ISO8601", value: "2017-11-14T12:55:13.800Z" } }, mdNames: [ "TimeInstant" ], creDate: 1510662361, modDate: 1510664113 }, attrs.serial_number: { value: "M1111", type: "string", md: { TimeInstant: { type: "ISO8601", value: "2017-11-14T12:55:13.800Z" } }, mdNames: [ "TimeInstant" ], creDate: 1510662361, modDate: 1510664113 }, attrs.TimeInstant: { value: "2017-11-14T12:55:13.800Z", type: "ISO8601", mdNames: [], creDate: 1510662361, modDate: 1510664113 }, modDate: 1510664113, lastCorrelator: "0e4a4e20-c93b-11e7-957f-0242ac110003" }, $unset: { location: 1 } }>)
time=Tuesday 14 Nov 12:55:13 2017.812Z | lvl=INFO | corr=0e4a4e20-c93b-11e7-957f-0242ac110003 | trans=1510663280-019-00000000012 | from=54.194.53.34 | srv=howtoservice | subsrv=/howto | comp=Orion | op=logMsg.h[1916]:lmTransactionEnd | msg=Transaction ended
time=Tuesday 14 Nov 12:55:13 2017.812Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000013 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=logMsg.h[1832]:lmTransactionStart | msg=Starting transaction to https://iot.visualfy.com:443/api/v1/devices/orion/local
time=Tuesday 14 Nov 12:55:13 2017.812Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000013 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=httpRequestSend.cpp[599]:httpRequestSendWithCurl | msg=Sending message 3 to HTTP server: sending message of 535 bytes to HTTP server
time=Tuesday 14 Nov 12:55:13 2017.891Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000013 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=logMsg.h[1916]:lmTransactionEnd | msg=Transaction ended
</code>```

The subscription is the same with the http attribute changed to the endpoint.

Any help would be appreciated and if you need further information don't hesitate asking.

UPDATE 1

After shutting down the process in the 443 port and adding a listener, performing a netcat like: nc -l 443 has resulted in a notification arriving to netcat with a non readable data stream.
The orion context broker logs shows some interesting information:

```<code>    time=Friday 17 Nov 11:05:56 2017.587Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000090 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=logMsg.h[1832]:lmTransactionStart | msg=Starting transaction to https://34.240.0.113:443/api/v1/devices/orion/local
time=Friday 17 Nov 11:05:56 2017.587Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000090 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=httpRequestSend.cpp[599]:httpRequestSendWithCurl | msg=Sending message 22 to HTTP server: sending message of 531 bytes to HTTP server
time=Friday 17 Nov 11:06:04 2017.153Z | lvl=INFO | corr=4da159ee-cb87-11e7-97f4-0242ac110003 | trans=1510663280-019-00000000091 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=logMsg.h[1832]:lmTransactionStart | msg=Starting transaction from 37.11.95.120:60933/v2/subscriptions
time=Friday 17 Nov 11:06:04 2017.154Z | lvl=INFO | corr=4da159ee-cb87-11e7-97f4-0242ac110003 | trans=1510663280-019-00000000091 | from=37.11.95.120 | srv=pending | subsrv=/howto | comp=Orion | op=rest.cpp[882]:servicePathSplit | msg=Service Path 0: '/howto'
time=Friday 17 Nov 11:06:04 2017.154Z | lvl=INFO | corr=4da159ee-cb87-11e7-97f4-0242ac110003 | trans=1510663280-019-00000000091 | from=37.11.95.120 | srv=howtoservice | subsrv=/howto | comp=Orion | op=connectionOperations.cpp[175]:collectionRangedQuery | msg=Database Operation Successful (query: { query: { servicePath: "/howto" }, orderby: { _id: 1 } })
time=Friday 17 Nov 11:06:04 2017.155Z | lvl=INFO | corr=4da159ee-cb87-11e7-97f4-0242ac110003 | trans=1510663280-019-00000000091 | from=37.11.95.120 | srv=howtoservice | subsrv=/howto | comp=Orion | op=logMsg.h[1916]:lmTransactionEnd | msg=Transaction ended
time=Friday 17 Nov 11:06:04 2017.556Z | lvl=WARN | corr=N/A | trans=1510663280-019-00000000090 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=AlarmManager.cpp[328]:notificationError | msg=Raising alarm NotificationError https://34.240.0.113:443/api/v1/devices/orion/local: (curl_easy_perform failed: SSL connect error)
</code>```

Which has the same looking than the failed notification instead of the one that ended OK.

The same process to the service that is working, when the notification reachs netcat has more characters notifying. In other words, this is what I receive in the netcat that doesnt receive notifications correctly:

```<code>HD?#

    ?\?s???s0?^0M
                 c1\6?QSb?J3298/5
?
</code>```

And this is what I receive in the netcat that receive the notifications OK:

```<code>?_????=?)>B??w??{?d?O?އ?$V? ?bG??B?>?????
                                         ????O???[06?gZZ̨̩?+?/?,?0????/5
? ?&???ualfy.secmotic.com#?ۻ????f??s??? ir????b???;?!~?"-$?}?G?A?Ӎ8????ؽV???%2ߨ??B&?
       ?Wr?n?<=T?h?A{R?Ϛ?y??'L1??1??????w"m?kY?oKl??5??%'?["?X9??h?f?`???Hj?%mZ?{???I?ʤx??v???m??H?9?????Ƥf%
hhttp/1.1uP

????@^C
</code>```

UPDATE 2
It is clear now that it is an HTTPS error with the notifications.
I have gone in the docker container where Orion Context Broker is and tried to perform a curl to the HTTPS domain, having the following output:

```<code>* About to connect() to iot.visualfy.com port 443 (#0)
*   Trying 34.240.0.113... connected
* Connected to iot.visualfy.com (34.240.0.113) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* NSS error -5961
* Closing connection #0
* SSL connect error
curl: (35) SSL connect error
</code>```

I actually tried to configure Orion as the documentation says with the -insecureNotif option, but the result is the same.

答: Finally I found the solution in this new scenario: yum update . The container wasn't updated, just the same as the image I launched. After doing an update, it installed the new CA certificates, recognizing letsencrypt as a valid Certificate Authorization. Thank you very much for your support @fgalan

Body:
We are migrating from one pre-production platform on the cloud to another server. We have successfully migrated everything but something strange is happening with the subscriptions of Orion Context Broker, since our instance of Orion is successfully notifying different endpoints, but not the one from our platform.

Both of the subscriptions are done from the same instance and implementing HTTPS, and the security groups are equally configured. The Orion context broker logs doesnt show any useful information about what is happening with the cURL request that internally is doing.

Here is an example of a right subscription from this Orion:

time=Tuesday 14 Nov 12:54:03 2017.102Z | lvl=INFO | corr=e42533b2-c93a-11e7-b333-0242ac110003 | trans=1510663280-019-00000000009 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=logMsg.h[1832]:lmTransactionStart | msg=Starting transaction from 54.194.53.34:48920/v1/updateContext
time=Tuesday 14 Nov 12:54:03 2017.102Z | lvl=INFO | corr=e42533b2-c93a-11e7-b333-0242ac110003 | trans=1510663280-019-00000000009 | from=54.194.53.34 | srv=pending | subsrv=/howto | comp=Orion | op=rest.cpp[882]:servicePathSplit | msg=Service Path 0: '/howto'
time=Tuesday 14 Nov 12:54:03 2017.103Z | lvl=INFO | corr=e42533b2-c93a-11e7-b333-0242ac110003 | trans=1510663280-019-00000000009 | from=54.194.53.34 | srv=howtoservice | subsrv=/howto | comp=Orion | op=connectionOperations.cpp[92]:collectionQuery | msg=Database Operation Successful (query: { _id.id: "M1111", _id.type: "Thing", _id.servicePath: { $in: [ /^/howto$/ ] } })
time=Tuesday 14 Nov 12:54:03 2017.104Z | lvl=INFO | corr=e42533b2-c93a-11e7-b333-0242ac110003 | trans=1510663280-019-00000000009 | from=54.194.53.34 | srv=howtoservice | subsrv=/howto | comp=Orion | op=connectionOperations.cpp[447]:collectionUpdate | msg=Database Operation Successful (update: <{ _id.id: "M1111", _id.type: "Thing", _id.servicePath: { $in: [ /^/howto$/ ] } }, { $set: { attrs.local: { value: "1.1.1.1,50", type: "string", md: { TimeInstant: { type: "ISO8601", value: "2017-11-14T12:54:03.090Z" } }, mdNames: [ "TimeInstant" ], creDate: 1510662361, modDate: 1510664043 }, attrs.serial_number: { value: "M1111", type: "string", md: { TimeInstant: { type: "ISO8601", value: "2017-11-14T12:54:03.090Z" } }, mdNames: [ "TimeInstant" ], creDate: 1510662361, modDate: 1510664043 }, attrs.TimeInstant: { value: "2017-11-14T12:54:03.090Z", type: "ISO8601", mdNames: [], creDate: 1510662361, modDate: 1510664043 }, modDate: 1510664043, lastCorrelator: "e42533b2-c93a-11e7-b333-0242ac110003" }, $unset: { location: 1 } }>)
time=Tuesday 14 Nov 12:54:03 2017.104Z | lvl=INFO | corr=e42533b2-c93a-11e7-b333-0242ac110003 | trans=1510663280-019-00000000009 | from=54.194.53.34 | srv=howtoservice | subsrv=/howto | comp=Orion | op=logMsg.h[1916]:lmTransactionEnd | msg=Transaction ended
time=Tuesday 14 Nov 12:54:03 2017.105Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000010 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=logMsg.h[1832]:lmTransactionStart | msg=Starting transaction to https://visualfy.secmotic.com:443/api/v1/devices/orion/local
time=Tuesday 14 Nov 12:54:03 2017.105Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000010 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=httpRequestSend.cpp[599]:httpRequestSendWithCurl | msg=Sending message 2 to HTTP server: sending message of 540 bytes to HTTP server
time=Tuesday 14 Nov 12:54:03 2017.238Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000010 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=httpRequestSend.cpp[620]:httpRequestSendWithCurl | msg=Notification Successfully Sent to https://visualfy.secmotic.com:443/api/v1/devices/orion/local
time=Tuesday 14 Nov 12:54:03 2017.239Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000010 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=logMsg.h[1916]:lmTransactionEnd | msg=Transaction ended

And here is an example of a failed notification.

time=Tuesday 14 Nov 12:55:13 2017.809Z | lvl=INFO | corr=0e4a4e20-c93b-11e7-957f-0242ac110003 | trans=1510663280-019-00000000012 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=logMsg.h[1832]:lmTransactionStart | msg=Starting transaction from 54.194.53.34:48922/v1/updateContext
time=Tuesday 14 Nov 12:55:13 2017.810Z | lvl=INFO | corr=0e4a4e20-c93b-11e7-957f-0242ac110003 | trans=1510663280-019-00000000012 | from=54.194.53.34 | srv=pending | subsrv=/howto | comp=Orion | op=rest.cpp[882]:servicePathSplit | msg=Service Path 0: '/howto'
time=Tuesday 14 Nov 12:55:13 2017.810Z | lvl=INFO | corr=0e4a4e20-c93b-11e7-957f-0242ac110003 | trans=1510663280-019-00000000012 | from=54.194.53.34 | srv=howtoservice | subsrv=/howto | comp=Orion | op=connectionOperations.cpp[92]:collectionQuery | msg=Database Operation Successful (query: { _id.id: "M1111", _id.type: "Thing", _id.servicePath: { $in: [ /^/howto$/ ] } })
time=Tuesday 14 Nov 12:55:13 2017.811Z | lvl=INFO | corr=0e4a4e20-c93b-11e7-957f-0242ac110003 | trans=1510663280-019-00000000012 | from=54.194.53.34 | srv=howtoservice | subsrv=/howto | comp=Orion | op=connectionOperations.cpp[447]:collectionUpdate | msg=Database Operation Successful (update: <{ _id.id: "M1111", _id.type: "Thing", _id.servicePath: { $in: [ /^/howto$/ ] } }, { $set: { attrs.local: { value: "1.1.1.1,50", type: "string", md: { TimeInstant: { type: "ISO8601", value: "2017-11-14T12:55:13.800Z" } }, mdNames: [ "TimeInstant" ], creDate: 1510662361, modDate: 1510664113 }, attrs.serial_number: { value: "M1111", type: "string", md: { TimeInstant: { type: "ISO8601", value: "2017-11-14T12:55:13.800Z" } }, mdNames: [ "TimeInstant" ], creDate: 1510662361, modDate: 1510664113 }, attrs.TimeInstant: { value: "2017-11-14T12:55:13.800Z", type: "ISO8601", mdNames: [], creDate: 1510662361, modDate: 1510664113 }, modDate: 1510664113, lastCorrelator: "0e4a4e20-c93b-11e7-957f-0242ac110003" }, $unset: { location: 1 } }>)
time=Tuesday 14 Nov 12:55:13 2017.812Z | lvl=INFO | corr=0e4a4e20-c93b-11e7-957f-0242ac110003 | trans=1510663280-019-00000000012 | from=54.194.53.34 | srv=howtoservice | subsrv=/howto | comp=Orion | op=logMsg.h[1916]:lmTransactionEnd | msg=Transaction ended
time=Tuesday 14 Nov 12:55:13 2017.812Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000013 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=logMsg.h[1832]:lmTransactionStart | msg=Starting transaction to https://iot.visualfy.com:443/api/v1/devices/orion/local
time=Tuesday 14 Nov 12:55:13 2017.812Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000013 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=httpRequestSend.cpp[599]:httpRequestSendWithCurl | msg=Sending message 3 to HTTP server: sending message of 535 bytes to HTTP server
time=Tuesday 14 Nov 12:55:13 2017.891Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000013 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=logMsg.h[1916]:lmTransactionEnd | msg=Transaction ended

The subscription is the same with the http attribute changed to the endpoint.

Any help would be appreciated and if you need further information don't hesitate asking.

UPDATE 1

After shutting down the process in the 443 port and adding a listener, performing a netcat like: nc -l 443 has resulted in a notification arriving to netcat with a non readable data stream.
The orion context broker logs shows some interesting information:

    time=Friday 17 Nov 11:05:56 2017.587Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000090 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=logMsg.h[1832]:lmTransactionStart | msg=Starting transaction to https://34.240.0.113:443/api/v1/devices/orion/local
time=Friday 17 Nov 11:05:56 2017.587Z | lvl=INFO | corr=N/A | trans=1510663280-019-00000000090 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=httpRequestSend.cpp[599]:httpRequestSendWithCurl | msg=Sending message 22 to HTTP server: sending message of 531 bytes to HTTP server
time=Friday 17 Nov 11:06:04 2017.153Z | lvl=INFO | corr=4da159ee-cb87-11e7-97f4-0242ac110003 | trans=1510663280-019-00000000091 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=logMsg.h[1832]:lmTransactionStart | msg=Starting transaction from 37.11.95.120:60933/v2/subscriptions
time=Friday 17 Nov 11:06:04 2017.154Z | lvl=INFO | corr=4da159ee-cb87-11e7-97f4-0242ac110003 | trans=1510663280-019-00000000091 | from=37.11.95.120 | srv=pending | subsrv=/howto | comp=Orion | op=rest.cpp[882]:servicePathSplit | msg=Service Path 0: '/howto'
time=Friday 17 Nov 11:06:04 2017.154Z | lvl=INFO | corr=4da159ee-cb87-11e7-97f4-0242ac110003 | trans=1510663280-019-00000000091 | from=37.11.95.120 | srv=howtoservice | subsrv=/howto | comp=Orion | op=connectionOperations.cpp[175]:collectionRangedQuery | msg=Database Operation Successful (query: { query: { servicePath: "/howto" }, orderby: { _id: 1 } })
time=Friday 17 Nov 11:06:04 2017.155Z | lvl=INFO | corr=4da159ee-cb87-11e7-97f4-0242ac110003 | trans=1510663280-019-00000000091 | from=37.11.95.120 | srv=howtoservice | subsrv=/howto | comp=Orion | op=logMsg.h[1916]:lmTransactionEnd | msg=Transaction ended
time=Friday 17 Nov 11:06:04 2017.556Z | lvl=WARN | corr=N/A | trans=1510663280-019-00000000090 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=AlarmManager.cpp[328]:notificationError | msg=Raising alarm NotificationError https://34.240.0.113:443/api/v1/devices/orion/local: (curl_easy_perform failed: SSL connect error)

Which has the same looking than the failed notification instead of the one that ended OK.

The same process to the service that is working, when the notification reachs netcat has more characters notifying. In other words, this is what I receive in the netcat that doesnt receive notifications correctly:

HD?#

    ?\?s???s0?^0M
                 c1\6?QSb?J3298/5
?

And this is what I receive in the netcat that receive the notifications OK:

?_????=?)>B??w??{?d?O?އ?$V? ?bG??B?>?????
                                         ????O???[06?gZZ̨̩?+?/?,?0????/5
? ?&???ualfy.secmotic.com#?ۻ????f??s??? ir????b???;?!~?"-$?}?G?A?Ӎ8????ؽV???%2ߨ??B&?
       ?Wr?n?<=T?h?A{R?Ϛ?y??'L1??1??????w"m?kY?oKl??5??%'?["?X9??h?f?`???Hj?%mZ?{???I?ʤx??v???m??H?9?????Ƥf%
hhttp/1.1uP

????@^C

UPDATE 2
It is clear now that it is an HTTPS error with the notifications.
I have gone in the docker container where Orion Context Broker is and tried to perform a curl to the HTTPS domain, having the following output:

* About to connect() to iot.visualfy.com port 443 (#0)
*   Trying 34.240.0.113... connected
* Connected to iot.visualfy.com (34.240.0.113) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* NSS error -5961
* Closing connection #0
* SSL connect error
curl: (35) SSL connect error

I actually tried to configure Orion as the documentation says with the -insecureNotif option, but the result is the same.


问:
Is there a difference between "throw" and "throw ex"?
There are some posts that asks what the difference between those two are already.
(why do I have to even mention this...)

But my question is different in a way that I am calling "throw ex" in another error god-like handling method.

```<code>public class Program {
    public static void Main(string[] args) {
        try {
            // something
        } catch (Exception ex) {
            HandleException(ex);
        }
    }

    private static void HandleException(Exception ex) {
        if (ex is ThreadAbortException) {
            // ignore then,
            return;
        }
        if (ex is ArgumentOutOfRangeException) {
            // Log then,
            throw ex;
        }
        if (ex is InvalidOperationException) {
            // Show message then,
            throw ex;
        }
        // and so on.
    }
}
</code>```

If try & catch were used in the Main, then I would use throw; to rethrow the error.
But in the above simplied code, all exceptions go through HandleException

Does throw ex; has the same effect as calling throw when called inside HandleException?

答:
let's understand the difference between throw and throw ex. I heard that in many .net interviews this common asked is being asked.

Just to give an overview of these two terms, throw and throw ex are both used to understand where the exception has occurred. Throw ex rewrites the stack trace of exception irrespective where actually has been thrown.

Let's understand with an example.

Let's understand first Throw.

```<code>static void Main(string[] args) {
    try {
        M1();
    } catch (Exception ex) {
        Console.WriteLine(" -----------------Stack Trace Hierarchy -----------------");
        Console.WriteLine(ex.StackTrace.ToString());
        Console.WriteLine(" ---------------- Method Name / Target Site -------------- ");
        Console.WriteLine(ex.TargetSite.ToString());
    }
    Console.ReadKey();
}

static void M1() {
    try {
        M2();
    } catch (Exception ex) {
        throw;
    };
}

static void M2() {
    throw new DivideByZeroException();
}
</code>```

output of the above is below.

shows complete hierarchy and method name where actually the exception has thrown.. it is M2 -> M2. along with line numbers

Secondly.. lets understand by throw ex. Just replace throw with throw ex in M2 method catch block. as below.

output of throw ex code is as below..

You can see the difference in the output.. throw ex just ignores all the previous hierarchy and resets stack trace with line/method where throw ex is written.

Body:
There are some posts that asks what the difference between those two are already.
(why do I have to even mention this...)

But my question is different in a way that I am calling "throw ex" in another error god-like handling method.

public class Program {
    public static void Main(string[] args) {
        try {
            // something
        } catch (Exception ex) {
            HandleException(ex);
        }
    }

    private static void HandleException(Exception ex) {
        if (ex is ThreadAbortException) {
            // ignore then,
            return;
        }
        if (ex is ArgumentOutOfRangeException) {
            // Log then,
            throw ex;
        }
        if (ex is InvalidOperationException) {
            // Show message then,
            throw ex;
        }
        // and so on.
    }
}

If try & catch were used in the Main, then I would use throw; to rethrow the error.
But in the above simplied code, all exceptions go through HandleException

Does throw ex; has the same effect as calling throw when called inside HandleException?

Body:
let's understand the difference between throw and throw ex. I heard that in many .net interviews this common asked is being asked.

Just to give an overview of these two terms, throw and throw ex are both used to understand where the exception has occurred. Throw ex rewrites the stack trace of exception irrespective where actually has been thrown.

Let's understand with an example.

Let's understand first Throw.

static void Main(string[] args) {
    try {
        M1();
    } catch (Exception ex) {
        Console.WriteLine(" -----------------Stack Trace Hierarchy -----------------");
        Console.WriteLine(ex.StackTrace.ToString());
        Console.WriteLine(" ---------------- Method Name / Target Site -------------- ");
        Console.WriteLine(ex.TargetSite.ToString());
    }
    Console.ReadKey();
}

static void M1() {
    try {
        M2();
    } catch (Exception ex) {
        throw;
    };
}

static void M2() {
    throw new DivideByZeroException();
}

output of the above is below.

shows complete hierarchy and method name where actually the exception has thrown.. it is M2 -> M2. along with line numbers

Secondly.. lets understand by throw ex. Just replace throw with throw ex in M2 method catch block. as below.

output of throw ex code is as below..

You can see the difference in the output.. throw ex just ignores all the previous hierarchy and resets stack trace with line/method where throw ex is written.


问:
Create installer for a Windows service written in Go
I'm using https://github.com/kardianos/service to implement service installation/start/stop into my Go project, as I want to run it as a daemon.

The sticking point here is that I want to use something like Wix to create an msi installer for my service. My issue is that the documentation and several articles online seem to contradict each other.

How would I go about using Wix (or any other provider) to create an installer for my service?

答:
Start by reading through this tutorial on windows services:

https://github.com/iswix-llc/iswix-tutorials

Now read this article to understand how any old script/EXE can be made a service using srvany.exe:

https://support.microsoft.com/en-us/help/137890/how-to-create-a-user-defined-service

Take a look at my answer to see how it all comes together:

Wix installer to replace INSTSRV and SRVANY for user defined service installation

If that still isn't enough, send me an email and I'll give you a complimentary 30-60 minute session to show you.


答: Because you have defined two different age fields, one in each class. Fields are not overridden.</p>

Title: Why does changing the type lead to different usage of members?