问:
SOH (Start of Heading) in XML / XSLT
I'm trying to create the SOH (Start Of Heading) character in XML 1.1 using XSLT.
I need this character to delimitter two strings.

I tried the following strings, but in most cases the parser dont't accept them.

```<code>
!
#x1
a
</code>```

Onlye the second one was accepted, but this is just a !.

Did anyone know how to add the SOH correctly to the XML?

Thanks alot...
SoniX

答:
SOH = ^A = Decimal 1 = Hex 01

Try &X01 or &01

IHTH

Title: SOH (Start of Heading) in XML / XSLT

Body:
I'm trying to create the SOH (Start Of Heading) character in XML 1.1 using XSLT.
I need this character to delimitter two strings.

I tried the following strings, but in most cases the parser dont't accept them.

!
#x1
a

Onlye the second one was accepted, but this is just a !.

Did anyone know how to add the SOH correctly to the XML?

Thanks alot...
SoniX


来源: stackexchange

问:
Material-UI Expansion Panel not obeying controled expansion
I want the first of the three expansion panels to be open but still only allow one panel at a time to be open. Currently I can either have the first panel open OR have the panels controlled to be open one a time, but not both. But this what I need.

I also need the jsx to be rendered with a loop. This loop seems to be be causing the issue because this works without a loop.

The 2nd and 3rd drawers works as they should here.

I've tried passing the the props directly like in the docs but this did not work. Currently I am trying to pass them in dynamically so only the proper props ones go with each panel, with each iteration of the loop. It looks like this:

```<code>function setAttributes(i) {
   return [
     { defaultExpanded: true },
     { expanded: expanded === `panel2` },
     { expanded: expanded === `panel3` }
   ]
  }

return (
<div className={`${classes.root} accordion`}>
  {Object.values(props.drawers).map((drawer, i) => {
    return (
      <ExpansionPanel
        key={i}
        //set attributes here
        {...setAttributes(i)[i]}
        onChange={handleChange(`panel${i + 1}`)}
        className="expansion-panel"
      >
        <ExpansionPanelSummary
          className="expansion-panel-inner"
          expandIcon={<ExpandMoreIcon />}
          aria-controls={`panel${i + 1}bh-content`}
          id={`panel${i + 1}bh-header`}
        >
          <Typography className={`${classes.heading} panel-heading`}>
            {' '}
            {drawer.heading}
          </Typography>
          <Typography className={classes.secondaryHeading} />
        </ExpansionPanelSummary>
        <ExpansionPanelDetails>
          <Typography>{drawer.text}</Typography>
        </ExpansionPanelDetails>
      </ExpansionPanel>
    )
  })}
</div>
</code>```

)

I've tried looking at what props are attached after render but its' not super clear; it's not as easy as looking for an added class. It's unclear to me if the proper props are getting added to each panel. I also tried making the first object inside setAttributes { defaultExpanded: true, expanded: expanded === "panel1" }, but this just disables the default expansion.

A demo shows the problem.

I want the first panel open on load, then after that only one panel, whichever is clicked, to be open, and only that one.

答:
If I'm understanding your issue, you should be able to just set the default value.

```<code>const [expanded, setExpanded] = React.useState("panel1");
</code>```

And if you want to make it so you can't collapse a panel by clicking it again:

```<code>const handleChange = panel => (event, isExpanded) => {
    setExpanded(panel);
};
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I want the first of the three expansion panels to be open but still only allow one panel at a time to be open. Currently I can either have the first panel open OR have the panels controlled to be open one a time, but not both. But this what I need.

I also need the jsx to be rendered with a loop. This loop seems to be be causing the issue because this works without a loop.

The 2nd and 3rd drawers works as they should here.

I've tried passing the the props directly like in the docs but this did not work. Currently I am trying to pass them in dynamically so only the proper props ones go with each panel, with each iteration of the loop. It looks like this:

function setAttributes(i) {
   return [
     { defaultExpanded: true },
     { expanded: expanded === `panel2` },
     { expanded: expanded === `panel3` }
   ]
  }

return (
<div className={`${classes.root} accordion`}>
  {Object.values(props.drawers).map((drawer, i) => {
    return (
      <ExpansionPanel
        key={i}
        //set attributes here
        {...setAttributes(i)[i]}
        onChange={handleChange(`panel${i + 1}`)}
        className="expansion-panel"
      >
        <ExpansionPanelSummary
          className="expansion-panel-inner"
          expandIcon={<ExpandMoreIcon />}
          aria-controls={`panel${i + 1}bh-content`}
          id={`panel${i + 1}bh-header`}
        >
          <Typography className={`${classes.heading} panel-heading`}>
            {' '}
            {drawer.heading}
          </Typography>
          <Typography className={classes.secondaryHeading} />
        </ExpansionPanelSummary>
        <ExpansionPanelDetails>
          <Typography>{drawer.text}</Typography>
        </ExpansionPanelDetails>
      </ExpansionPanel>
    )
  })}

)

I've tried looking at what props are attached after render but its' not super clear; it's not as easy as looking for an added class. It's unclear to me if the proper props are getting added to each panel. I also tried making the first object inside setAttributes { defaultExpanded: true, expanded: expanded === "panel1" }, but this just disables the default expansion.

A demo shows the problem.

I want the first panel open on load, then after that only one panel, whichever is clicked, to be open, and only that one.

Body:
If I'm understanding your issue, you should be able to just set the default value.

const [expanded, setExpanded] = React.useState("panel1");

And if you want to make it so you can't collapse a panel by clicking it again:

const handleChange = panel => (event, isExpanded) => {
    setExpanded(panel);
};


问:
How to read a single line out of a word document
The method I used was for text files and gives gibberish as expected.

```<code>In: John Smith
Out: PK!~8ìz‡[Content_Types].xml ¢( ´”ÏNÂ@Æï&¾C³WÓ.x0ÆP8•D|€a;…Õvw³;ü{{§´5@UôBRf¾ß÷Ív;½Áº,¢%ú IE7éˆ²™6³T¼Lâ[“Aa
¦bƒAú—½ÉÆaˆXmB*æDîNÊ æXBH¬CÃ•ÜúˆýL:Po0CyÝéÜHe
¡¡˜*†è÷†˜Ã¢ h´æ¿ë$SmDt_÷UV©ç
€¸,—&KÊÛ<×
</code>```

I'm a novice at VBA, and I'm trying to read a document line by line so that I can eventually have the macro automatically remove entire lines based on their content.

```<code>Sub ayaya()
Dim TextLine As String
Open ActiveDocument.Path & "\Doc1.docm" For Input As #1
    Do While Not EOF(1) ' Loop until end of file.
    Line Input #1, TextLine ' Read line into variable.
    Debug.Print TextLine
    Loop
    Close #1

End Sub
</code>```

Part of me hoped that it would give "John Smith". I've seen some solutions put the entire document into a text file. Is there any way where I can delimit the data somehow? I'd like to be able to isolate a single line and remove it.

答: You are trying to read a docx or docm file, which is a zip archive. Word files are not plain text files, so you won't get anything meaningful treating them as such. You need to open the file with Word or another app that can read such files.</p>

Body:
The method I used was for text files and gives gibberish as expected.

In: John Smith
Out: PK!~8ìz‡[Content_Types].xml ¢( ´”ÏNÂ@Æï&¾C³WÓ.x0ÆP8•D|€a;…Õvw³;ü{{§´5@UôBRf¾ß÷Ív;½Áº,¢%ú IE7éˆ²™6³T¼Lâ[“Aa
¦bƒAú—½ÉÆaˆXmB*æDîNÊ æXBH¬CÃ•ÜúˆýL:Po0CyÝéÜHe
¡¡˜*†è÷†˜Ã¢ h´æ¿ë$SmDt_÷UV©ç
€¸,—&KÊÛ<×

I'm a novice at VBA, and I'm trying to read a document line by line so that I can eventually have the macro automatically remove entire lines based on their content.

Sub ayaya()
Dim TextLine As String
Open ActiveDocument.Path & "\Doc1.docm" For Input As #1
    Do While Not EOF(1) ' Loop until end of file.
    Line Input #1, TextLine ' Read line into variable.
    Debug.Print TextLine
    Loop
    Close #1

End Sub

Part of me hoped that it would give "John Smith". I've seen some solutions put the entire document into a text file. Is there any way where I can delimit the data somehow? I'd like to be able to isolate a single line and remove it.


问:
Creating a nesting layout with a fixed column that's scroll able
I'll try my best to explain this as clearly as I can. I'm also using the Bulma CSS framework if it matters. So the layout I'm trying to create is this.

I created a working version that can be seen in action here

However, in the working example the vh/px of the scrollable box is fixed to a certain amount and I'm using tiles from the Bulma CSS framework. I tried using columns and the same outcome occurred. If I was to not make it a fixed amount, it'll just extend past the screen, but I want it to fit the entire screen regardless of the size and the only scrollable part should be the green box I've showed above. Also, the box may not even have enough content to become scrollable in some cases, and in that case I would still like it to fill up the rest of the height with the box even if it's going to be empty.

As you can see here, if the height isn't explicitly set, it'll keep going past the screen, but if it's properly set it will work as intended. I'm wondering how I can make this height fill the space properly no matter how it's resized and etc.

Any help would be appreciated!

答: It sounds like you should set the height property on the wrapper of the content and set the overflow: scroll; Then all of the contents will be the height you set and have scrollable content.


问:
Oculus Rift CV1 Black Display
I recently bough my brand new CV1. Even though My GTX 980M is not recommended VGA but it should display something. Now about the problem. It started with Oculus Home setup, seem to everything worked fine, even tracking is working, I listened audio from setup process but display was completely black. And LED is orange btw. However I managed to pass settings using audio only with my Oculus remote. Now i can see the Oculus Home, but when I try to run any app from there it simply stays black. I am also a Unity3D developer and when I tried to launch my own apps same happened. In unity HDM is working, gyro is ok (I can see on my laptop display when I'm turning around) but display is still black, with orange LED light. And here some Oculus server logs I've been captured maybe it can help! Please Help anybody!</p>

```<code>24/08 15:36:48.824 {INFO}    [LifeCycle] motionSensorEvent() Start
24/08 15:36:48.824 {INFO}    [LifeCycle] HMD Moving: true
24/08 15:36:48.824 {INFO}    [TrackingManager] Setting tracking mode to on
24/08 15:36:48.824 {INFO}    [Server] Tracking Enabled : true
24/08 15:36:48.824 {DEBUG}   [Server] UpdateFocusedVirtualHmd: ConfigureTracking On (112)
24/08 15:36:48.824 {DEBUG}   [Kernel:Default] [VirtualHMD] Applying client-specific caps
24/08 15:36:48.825 {WARNING} [Server] Setting connection focus to pid: 1336, file: oculus-overlays.exe, but no window handle exists
24/08 15:36:48.825 {INFO}    [LifeCycle] motionSensorEvent() End
24/08 15:36:49.118 {INFO}    [HW:Enumeration] HMDs: 1, Displays: 1
24/08 15:36:49.118 {DEBUG}   [HW:HmdSensor] IMU report rate = 500
24/08 15:36:49.118 {INFO}    [HW:HmdSensor] Leaving idle mode
24/08 15:36:49.118 {INFO}    [HW:Enumeration] Setting frameInterval = 19200, ledExposure = 399
24/08 15:36:49.118 {INFO}    [HW:HmdSensor] Setting LED state: true
24/08 15:36:49.320 {DEBUG}   [Server] Connection open for pid: 12020, file: Unity.exe
24/08 15:36:49.320 {DEBUG}   [Server] Accepted a client from pid: 12020(Unity.exe) running version (prod = 1).1.7.0(build = 262766) feature version = 0. Server is version (prod = 1).1.7.0(build = 262766) feature version = 0
24/08 15:36:49.321 {DEBUG}   [Server] UpdateFocusedVirtualHmd: ConfigureTracking On (112)
24/08 15:36:49.321 {DEBUG}   [Kernel:Default] [VirtualHMD] Applying client-specific caps
24/08 15:36:50.450 {WARNING} [Server] Setting connection focus to pid: 1336, file: oculus-overlays.exe, but no window handle exists
24/08 15:36:50.450 {DEBUG}   [Server] Hmd_Create
24/08 15:36:50.450 {DEBUG}   [Kernel:Default] [AppFocusObserver] AddProcess: Recognizing the newly added process as in-focus pid=12020
24/08 15:36:50.450 {INFO}    [LifeCycle] registerPid() Start
24/08 15:36:50.450 {INFO}    [LifeCycle] Register Pid: 12020 (Sideloaded)
24/08 15:36:50.450 {INFO}    [LifeCycle] Registering tracker: 12020 (Sideloaded)
24/08 15:36:50.450 {INFO}    [LifeCycle] App already added.
24/08 15:36:50.450 {INFO}    [LifeCycle] registerPid() End
24/08 15:36:50.450 {DEBUG}   [Server] Hmd_GetHmdInfo
24/08 15:36:50.454 {DEBUG}   [Kernel:Default] [AppFocusObserver] UpdateTextureSetActive: Setting rift window for pid=12020 textureset=1
24/08 15:36:50.454 {INFO}    [LifeCycle] requestFocus() Start
24/08 15:36:50.454 {INFO}    [LifeCycle] Request Focus: 12020 (Sideloaded)
24/08 15:36:50.454 {INFO}    [LifeCycle] Request Location: APP
24/08 15:36:50.454 {INFO}    [LifeCycle] Push Location: APP
24/08 15:36:50.454 {INFO}    [LifeCycle] Update Location: HSW
24/08 15:36:50.454 {INFO}    [LifeCycle] Inactive Focus: 3452 (oculus-home)
24/08 15:36:50.454 {INFO}    [LifeCycle] Already Focused: 0 (Unknown)
24/08 15:36:50.454 {INFO}    [LifeCycle] requestFocus() End
24/08 15:36:50.455 {INFO}    [Kernel:Default] WARNING: [CameraTimeSynchronizer] out of sync. Exposure Delta = 33830.2 ms, cameraDelta = -32430.4 ms.
24/08 15:36:50.455 {WARNING} [Tracking:Tracker] WMTD302S600Z3S: at 0, skipped 1 frames (37403 -> 37405)
24/08 15:36:50.569 {INFO}    [Kernel:Default] [CameraTimeSynchronizer] successfully synchronized.
24/08 15:36:50.667 {DEBUG}   [Tracking:Filter] HMD: Large change, resetting position filter
24/08 15:36:51.031 {INFO}    [DeviceEvent] SENSOR [WMTD302S600Z3S] TrackingChanged 0
24/08 15:36:51.031 {INFO}    [HardwareManager] Tracker WMTD302S600Z3S got tracking event with error code 0
24/08 15:36:51.518 {DEBUG}   [Kernel:Default] [AppFocusObserver] UpdateRenderingActive: pid=12020 active
24/08 15:36:51.518 {INFO}    [LifeCycle] enterVR() Start
24/08 15:36:51.518 {INFO}    [LifeCycle] Enter VR: 12020 (Sideloaded)
24/08 15:36:51.518 {INFO}    [AppTracker] VR Ready: 12020 (Sideloaded)
24/08 15:36:51.518 {INFO}    [LifeCycle] Request Focus: 12020 (Sideloaded)
24/08 15:36:51.518 {INFO}    [LifeCycle] Request Location: APP
24/08 15:36:51.518 {INFO}    [LifeCycle] Push Location: APP
24/08 15:36:51.518 {INFO}    [LifeCycle] Update Location: HSW
24/08 15:36:51.519 {INFO}    [LifeCycle] Inactive Focus: 3452 (oculus-home)
24/08 15:36:51.519 {INFO}    [LifeCycle] Already Focused: 0 (Unknown)
24/08 15:36:51.519 {INFO}    [LifeCycle] enterVR() End
24/08 15:36:54.815 {DEBUG}   [Tracking:Pnp] RansacMatch: Too many outliers: 1 outliers out of 5, allowed 0
24/08 15:36:58.592 {DEBUG}   [Kernel:Default] [AppFocusObserver] UpdateTextureSetActive: Active process pid=12020 dismantling its last texture set
24/08 15:36:58.592 {DEBUG}   [Kernel:Default] [AppFocusObserver] NextProcess: Switching active rift process to pid=1336 textureset=1 (not updating active render window)
24/08 15:36:58.592 {INFO}    [LifeCycle] requestFocus() Start
24/08 15:36:58.592 {INFO}    [LifeCycle] Request Focus: 1336 (oculus-overlays)
24/08 15:36:58.592 {INFO}    [LifeCycle] Setting focus to Overlays is not allowed.
24/08 15:36:58.592 {INFO}    [LifeCycle] requestFocus() End
24/08 15:36:58.594 {DEBUG}   [Server] UpdateFocusedVirtualHmd: ConfigureTracking On (112)
24/08 15:36:58.594 {DEBUG}   [Kernel:Default] [VirtualHMD] Applying client-specific caps
24/08 15:36:58.598 {WARNING} [Server] Setting connection focus to pid: 1336, file: oculus-overlays.exe, but no window handle exists
24/08 15:36:58.598 {INFO}    [Server] Connection closed for pid: 12020, file: Unity.exe
24/08 15:36:58.598 {DEBUG}   [Server] UpdateFocusedVirtualHmd: ConfigureTracking On (112)
24/08 15:36:58.598 {DEBUG}   [Kernel:Default] [VirtualHMD] Applying client-specific caps
24/08 15:36:58.616 {WARNING} [Server] Setting connection focus to pid: 1336, file: oculus-overlays.exe, but no window handle exists
24/08 15:36:58.616 {INFO}    [Server] Connection destroyed for pid: 12020, file: Unity.exe
24/08 15:37:01.456 {INFO}    [DeviceEvent] SENSOR [WMTD302S600Z3S] TrackingChanged 0
24/08 15:37:01.456 {INFO}    [HardwareManager] Tracker WMTD302S600Z3S got tracking event with error code 0
</code>```

答:
After doing some research I learned that my HDMI isnt giving a strong enough output and I have experimented with a couple different products that helps add power to the rift!

HTC Vive Link Box https://www.amazon.com/dp/B01LXR6DKV?ref=ppx_pop_mob_ap_share

AC to DC 12V Power Supply Adapter... https://www.amazon.com/dp/B01GPXNJPI?ref=ppx_pop_mob_ap_share

UGREEN USB 3.0 A to A Cable Type... https://www.amazon.com/dp/B00P0E3954?ref=ppx_pop_mob_ap_share

These three products allowed the oculus rift to run on a laptop when no display and only a orange light was on in the headset, Now everything is running fine! Thank you so much for your time and please suggest these products to people if they are having the same issue I am and if the troubleshooting isnt working.

ContentLicense: CC BY-SA 3.0

Title: Oculus Rift CV1 Black Display

Body:
I recently bough my brand new CV1. Even though My GTX 980M is not recommended VGA but it should display something. Now about the problem. It started with Oculus Home setup, seem to everything worked fine, even tracking is working, I listened audio from setup process but display was completely black. And LED is orange btw. However I managed to pass settings using audio only with my Oculus remote. Now i can see the Oculus Home, but when I try to run any app from there it simply stays black. I am also a Unity3D developer and when I tried to launch my own apps same happened. In unity HDM is working, gyro is ok (I can see on my laptop display when I'm turning around) but display is still black, with orange LED light. And here some Oculus server logs I've been captured maybe it can help! Please Help anybody!

24/08 15:36:48.824 {INFO}    [LifeCycle] motionSensorEvent() Start
24/08 15:36:48.824 {INFO}    [LifeCycle] HMD Moving: true
24/08 15:36:48.824 {INFO}    [TrackingManager] Setting tracking mode to on
24/08 15:36:48.824 {INFO}    [Server] Tracking Enabled : true
24/08 15:36:48.824 {DEBUG}   [Server] UpdateFocusedVirtualHmd: ConfigureTracking On (112)
24/08 15:36:48.824 {DEBUG}   [Kernel:Default] [VirtualHMD] Applying client-specific caps
24/08 15:36:48.825 {WARNING} [Server] Setting connection focus to pid: 1336, file: oculus-overlays.exe, but no window handle exists
24/08 15:36:48.825 {INFO}    [LifeCycle] motionSensorEvent() End
24/08 15:36:49.118 {INFO}    [HW:Enumeration] HMDs: 1, Displays: 1
24/08 15:36:49.118 {DEBUG}   [HW:HmdSensor] IMU report rate = 500
24/08 15:36:49.118 {INFO}    [HW:HmdSensor] Leaving idle mode
24/08 15:36:49.118 {INFO}    [HW:Enumeration] Setting frameInterval = 19200, ledExposure = 399
24/08 15:36:49.118 {INFO}    [HW:HmdSensor] Setting LED state: true
24/08 15:36:49.320 {DEBUG}   [Server] Connection open for pid: 12020, file: Unity.exe
24/08 15:36:49.320 {DEBUG}   [Server] Accepted a client from pid: 12020(Unity.exe) running version (prod = 1).1.7.0(build = 262766) feature version = 0. Server is version (prod = 1).1.7.0(build = 262766) feature version = 0
24/08 15:36:49.321 {DEBUG}   [Server] UpdateFocusedVirtualHmd: ConfigureTracking On (112)
24/08 15:36:49.321 {DEBUG}   [Kernel:Default] [VirtualHMD] Applying client-specific caps
24/08 15:36:50.450 {WARNING} [Server] Setting connection focus to pid: 1336, file: oculus-overlays.exe, but no window handle exists
24/08 15:36:50.450 {DEBUG}   [Server] Hmd_Create
24/08 15:36:50.450 {DEBUG}   [Kernel:Default] [AppFocusObserver] AddProcess: Recognizing the newly added process as in-focus pid=12020
24/08 15:36:50.450 {INFO}    [LifeCycle] registerPid() Start
24/08 15:36:50.450 {INFO}    [LifeCycle] Register Pid: 12020 (Sideloaded)
24/08 15:36:50.450 {INFO}    [LifeCycle] Registering tracker: 12020 (Sideloaded)
24/08 15:36:50.450 {INFO}    [LifeCycle] App already added.
24/08 15:36:50.450 {INFO}    [LifeCycle] registerPid() End
24/08 15:36:50.450 {DEBUG}   [Server] Hmd_GetHmdInfo
24/08 15:36:50.454 {DEBUG}   [Kernel:Default] [AppFocusObserver] UpdateTextureSetActive: Setting rift window for pid=12020 textureset=1
24/08 15:36:50.454 {INFO}    [LifeCycle] requestFocus() Start
24/08 15:36:50.454 {INFO}    [LifeCycle] Request Focus: 12020 (Sideloaded)
24/08 15:36:50.454 {INFO}    [LifeCycle] Request Location: APP
24/08 15:36:50.454 {INFO}    [LifeCycle] Push Location: APP
24/08 15:36:50.454 {INFO}    [LifeCycle] Update Location: HSW
24/08 15:36:50.454 {INFO}    [LifeCycle] Inactive Focus: 3452 (oculus-home)
24/08 15:36:50.454 {INFO}    [LifeCycle] Already Focused: 0 (Unknown)
24/08 15:36:50.454 {INFO}    [LifeCycle] requestFocus() End
24/08 15:36:50.455 {INFO}    [Kernel:Default] WARNING: [CameraTimeSynchronizer] out of sync. Exposure Delta = 33830.2 ms, cameraDelta = -32430.4 ms.
24/08 15:36:50.455 {WARNING} [Tracking:Tracker] WMTD302S600Z3S: at 0, skipped 1 frames (37403 -> 37405)
24/08 15:36:50.569 {INFO}    [Kernel:Default] [CameraTimeSynchronizer] successfully synchronized.
24/08 15:36:50.667 {DEBUG}   [Tracking:Filter] HMD: Large change, resetting position filter
24/08 15:36:51.031 {INFO}    [DeviceEvent] SENSOR [WMTD302S600Z3S] TrackingChanged 0
24/08 15:36:51.031 {INFO}    [HardwareManager] Tracker WMTD302S600Z3S got tracking event with error code 0
24/08 15:36:51.518 {DEBUG}   [Kernel:Default] [AppFocusObserver] UpdateRenderingActive: pid=12020 active
24/08 15:36:51.518 {INFO}    [LifeCycle] enterVR() Start
24/08 15:36:51.518 {INFO}    [LifeCycle] Enter VR: 12020 (Sideloaded)
24/08 15:36:51.518 {INFO}    [AppTracker] VR Ready: 12020 (Sideloaded)
24/08 15:36:51.518 {INFO}    [LifeCycle] Request Focus: 12020 (Sideloaded)
24/08 15:36:51.518 {INFO}    [LifeCycle] Request Location: APP
24/08 15:36:51.518 {INFO}    [LifeCycle] Push Location: APP
24/08 15:36:51.518 {INFO}    [LifeCycle] Update Location: HSW
24/08 15:36:51.519 {INFO}    [LifeCycle] Inactive Focus: 3452 (oculus-home)
24/08 15:36:51.519 {INFO}    [LifeCycle] Already Focused: 0 (Unknown)
24/08 15:36:51.519 {INFO}    [LifeCycle] enterVR() End
24/08 15:36:54.815 {DEBUG}   [Tracking:Pnp] RansacMatch: Too many outliers: 1 outliers out of 5, allowed 0
24/08 15:36:58.592 {DEBUG}   [Kernel:Default] [AppFocusObserver] UpdateTextureSetActive: Active process pid=12020 dismantling its last texture set
24/08 15:36:58.592 {DEBUG}   [Kernel:Default] [AppFocusObserver] NextProcess: Switching active rift process to pid=1336 textureset=1 (not updating active render window)
24/08 15:36:58.592 {INFO}    [LifeCycle] requestFocus() Start
24/08 15:36:58.592 {INFO}    [LifeCycle] Request Focus: 1336 (oculus-overlays)
24/08 15:36:58.592 {INFO}    [LifeCycle] Setting focus to Overlays is not allowed.
24/08 15:36:58.592 {INFO}    [LifeCycle] requestFocus() End
24/08 15:36:58.594 {DEBUG}   [Server] UpdateFocusedVirtualHmd: ConfigureTracking On (112)
24/08 15:36:58.594 {DEBUG}   [Kernel:Default] [VirtualHMD] Applying client-specific caps
24/08 15:36:58.598 {WARNING} [Server] Setting connection focus to pid: 1336, file: oculus-overlays.exe, but no window handle exists
24/08 15:36:58.598 {INFO}    [Server] Connection closed for pid: 12020, file: Unity.exe
24/08 15:36:58.598 {DEBUG}   [Server] UpdateFocusedVirtualHmd: ConfigureTracking On (112)
24/08 15:36:58.598 {DEBUG}   [Kernel:Default] [VirtualHMD] Applying client-specific caps
24/08 15:36:58.616 {WARNING} [Server] Setting connection focus to pid: 1336, file: oculus-overlays.exe, but no window handle exists
24/08 15:36:58.616 {INFO}    [Server] Connection destroyed for pid: 12020, file: Unity.exe
24/08 15:37:01.456 {INFO}    [DeviceEvent] SENSOR [WMTD302S600Z3S] TrackingChanged 0
24/08 15:37:01.456 {INFO}    [HardwareManager] Tracker WMTD302S600Z3S got tracking event with error code 0


问:
WSDOT Traveler Information API - Anybody know how to access the below url with parameters like limit, offset etc
API list: http://wsdot.wa.gov/traffic/api/

There are some class documentation, but they are not telling how to access those functions.

http://wsdot.wa.gov/traffic/api/Documentation/index.html

Get highway alerts: http://wsdot.wa.gov/traffic/api/Documentation/class_highway_alerts.html#a3b45c057c4cea9d8953d917d0a183e94

答:
Go to this page, it will list the different kinds of responses you can get and the URL to call with your parameters such as limit and offset. Then push GET to see an example response
http://wsdot.wa.gov/traffic/api/HighwayAlerts/HighwayAlertsREST.svc/Help</p>


问:
How to write unix regular expression to select for specific files in a cp for-loop
I've got a directory with a bunch of files. Instead of describing the filenames and extensions, I'll just show you what is in the directory:

```<code>P01_1.atag  P03_3.tgt   P05_6.src   P08_3.atag  P10_5.tgt
P01_1.src   P03_4.atag  P05_6.tgt   P08_3.src   P10_6.atag
P01_1.tgt   P03_4.src   P06_1.atag  P08_3.tgt   P10_6.src
P01_2.atag  P03_4.tgt   P06_1.src   P08_4.atag  P10_6.tgt
P01_2.src   P03_5.atag  P06_1.tgt   P08_4.src   P11_1.atag
P01_2.tgt   P03_5.src   P06_2.atag  P08_4.tgt   P11_1.src
P01_3.atag  P03_5.tgt   P06_2.src   P08_5.atag  P11_1.tgt
P01_3.src   P03_6.atag  P06_2.tgt   P08_5.src   P11_2.atag
P01_3.tgt   P03_6.src   P06_3.atag  P08_5.tgt   P11_2.src
P01_4.atag  P03_6.tgt   P06_3.src   P08_6.atag  P11_2.tgt
P01_4.src   P04_1.atag  P06_3.tgt   P08_6.src   P11_3.atag
P01_4.tgt   P04_1.src   P06_4.atag  P08_6.tgt   P11_3.src
P01_5.atag  P04_1.tgt   P06_4.src   P09_1.atag  P11_3.tgt
P01_5.src   P04_2.atag  P06_4.tgt   P09_1.src   P11_4.atag
P01_5.tgt   P04_2.src   P06_5.atag  P09_1.tgt   P11_4.src
P01_6.atag  P04_2.tgt   P06_5.src   P09_2.atag  P11_4.tgt
P01_6.src   P04_3.atag  P06_5.tgt   P09_2.src   P11_5.atag
P01_6.tgt   P04_3.src   P06_6.atag  P09_2.tgt   P11_5.src
P02_1.atag  P04_3.tgt   P06_6.src   P09_3.atag  P11_5.tgt
P02_1.src   P04_4.atag  P06_6.tgt   P09_3.src   P11_6.atag
P02_1.tgt   P04_4.src   P07_1.atag  P09_3.tgt   P11_6.src
P02_2.atag  P04_4.tgt   P07_1.src   P09_4.atag  P11_6.tgt
P02_2.src   P04_5.atag  P07_1.tgt   P09_4.src   P12_1.atag
P02_2.tgt   P04_5.src   P07_2.atag  P09_4.tgt   P12_1.src
P02_3.atag  P04_5.tgt   P07_2.src   P09_5.atag  P12_1.tgt
P02_3.src   P04_6.atag  P07_2.tgt   P09_5.src   P12_2.atag
P02_3.tgt   P04_6.src   P07_3.atag  P09_5.tgt   P12_2.src
P02_4.atag  P04_6.tgt   P07_3.src   P09_6.atag  P12_2.tgt
P02_4.src   P05_1.atag  P07_3.tgt   P09_6.src   P12_3.atag
P02_4.tgt   P05_1.src   P07_4.atag  P09_6.tgt   P12_3.src
P02_5.atag  P05_1.tgt   P07_4.src   P10_1.atag  P12_3.tgt
P02_5.src   P05_2.atag  P07_4.tgt   P10_1.src   P12_4.atag
P02_5.tgt   P05_2.src   P07_5.atag  P10_1.tgt   P12_4.src
P02_6.atag  P05_2.tgt   P07_5.src   P10_2.atag  P12_4.tgt
P02_6.src   P05_3.atag  P07_5.tgt   P10_2.src   P12_5.atag
P02_6.tgt   P05_3.src   P07_6.atag  P10_2.tgt   P12_5.src
P03_1.atag  P05_3.tgt   P07_6.src   P10_3.atag  P12_5.tgt
P03_1.src   P05_4.atag  P07_6.tgt   P10_3.src   P12_6.atag
P03_1.tgt   P05_4.src   P08_1.atag  P10_3.tgt   P12_6.src
P03_2.atag  P05_4.tgt   P08_1.src   P10_4.atag  P12_6.tgt
P03_2.src   P05_5.atag  P08_1.tgt   P10_4.src
P03_2.tgt   P05_5.src   P08_2.atag  P10_4.tgt
P03_3.atag  P05_5.tgt   P08_2.src   P10_5.atag
P03_3.src   P05_6.atag  P08_2.tgt   P10_5.src
</code>```

I have a file that is just outside of this directory that I need to copy to all of the files that end with "_1.src" inside the directory.

I'm working with unix in the Terminal app, so I tried writing this for loop, but it rejected my regular expression:

```<code>for .*1.src in ./
> do
> cp ../1.src
> done
</code>```

I've only written regular expressions in Python before and have minimal experience, but I was under the impression that .* would match any combination of characters. However, I got the following error message:

```<code>-bash: `.*1.src': not a valid identifier
</code>```

I then tried the same for loop with the following regular expression:

```<code>^[a-zA-Z0-9_]*1.src$
</code>```

But I got the same error message:

```<code>-bash: `^[a-zA-Z0-9_]*1.src$': not a valid identifier
</code>```

I tried the same regular expression with and without quotation marks, but it always gives the same 'not a valid identifier' error message.

答:
Thanks to everyone; this is what ended up working:

```<code>for x in `echo ./P[0-9]*_1.src`
> do
> cp ../1.src "$x"
> done
</code>```

This loop allowed me to copy the contents of the one file to all of the files in the subdirectory that ended with "_1.src"

Body:
I've got a directory with a bunch of files. Instead of describing the filenames and extensions, I'll just show you what is in the directory:

P01_1.atag  P03_3.tgt   P05_6.src   P08_3.atag  P10_5.tgt
P01_1.src   P03_4.atag  P05_6.tgt   P08_3.src   P10_6.atag
P01_1.tgt   P03_4.src   P06_1.atag  P08_3.tgt   P10_6.src
P01_2.atag  P03_4.tgt   P06_1.src   P08_4.atag  P10_6.tgt
P01_2.src   P03_5.atag  P06_1.tgt   P08_4.src   P11_1.atag
P01_2.tgt   P03_5.src   P06_2.atag  P08_4.tgt   P11_1.src
P01_3.atag  P03_5.tgt   P06_2.src   P08_5.atag  P11_1.tgt
P01_3.src   P03_6.atag  P06_2.tgt   P08_5.src   P11_2.atag
P01_3.tgt   P03_6.src   P06_3.atag  P08_5.tgt   P11_2.src
P01_4.atag  P03_6.tgt   P06_3.src   P08_6.atag  P11_2.tgt
P01_4.src   P04_1.atag  P06_3.tgt   P08_6.src   P11_3.atag
P01_4.tgt   P04_1.src   P06_4.atag  P08_6.tgt   P11_3.src
P01_5.atag  P04_1.tgt   P06_4.src   P09_1.atag  P11_3.tgt
P01_5.src   P04_2.atag  P06_4.tgt   P09_1.src   P11_4.atag
P01_5.tgt   P04_2.src   P06_5.atag  P09_1.tgt   P11_4.src
P01_6.atag  P04_2.tgt   P06_5.src   P09_2.atag  P11_4.tgt
P01_6.src   P04_3.atag  P06_5.tgt   P09_2.src   P11_5.atag
P01_6.tgt   P04_3.src   P06_6.atag  P09_2.tgt   P11_5.src
P02_1.atag  P04_3.tgt   P06_6.src   P09_3.atag  P11_5.tgt
P02_1.src   P04_4.atag  P06_6.tgt   P09_3.src   P11_6.atag
P02_1.tgt   P04_4.src   P07_1.atag  P09_3.tgt   P11_6.src
P02_2.atag  P04_4.tgt   P07_1.src   P09_4.atag  P11_6.tgt
P02_2.src   P04_5.atag  P07_1.tgt   P09_4.src   P12_1.atag
P02_2.tgt   P04_5.src   P07_2.atag  P09_4.tgt   P12_1.src
P02_3.atag  P04_5.tgt   P07_2.src   P09_5.atag  P12_1.tgt
P02_3.src   P04_6.atag  P07_2.tgt   P09_5.src   P12_2.atag
P02_3.tgt   P04_6.src   P07_3.atag  P09_5.tgt   P12_2.src
P02_4.atag  P04_6.tgt   P07_3.src   P09_6.atag  P12_2.tgt
P02_4.src   P05_1.atag  P07_3.tgt   P09_6.src   P12_3.atag
P02_4.tgt   P05_1.src   P07_4.atag  P09_6.tgt   P12_3.src
P02_5.atag  P05_1.tgt   P07_4.src   P10_1.atag  P12_3.tgt
P02_5.src   P05_2.atag  P07_4.tgt   P10_1.src   P12_4.atag
P02_5.tgt   P05_2.src   P07_5.atag  P10_1.tgt   P12_4.src
P02_6.atag  P05_2.tgt   P07_5.src   P10_2.atag  P12_4.tgt
P02_6.src   P05_3.atag  P07_5.tgt   P10_2.src   P12_5.atag
P02_6.tgt   P05_3.src   P07_6.atag  P10_2.tgt   P12_5.src
P03_1.atag  P05_3.tgt   P07_6.src   P10_3.atag  P12_5.tgt
P03_1.src   P05_4.atag  P07_6.tgt   P10_3.src   P12_6.atag
P03_1.tgt   P05_4.src   P08_1.atag  P10_3.tgt   P12_6.src
P03_2.atag  P05_4.tgt   P08_1.src   P10_4.atag  P12_6.tgt
P03_2.src   P05_5.atag  P08_1.tgt   P10_4.src
P03_2.tgt   P05_5.src   P08_2.atag  P10_4.tgt
P03_3.atag  P05_5.tgt   P08_2.src   P10_5.atag
P03_3.src   P05_6.atag  P08_2.tgt   P10_5.src

I have a file that is just outside of this directory that I need to copy to all of the files that end with "_1.src" inside the directory.

I'm working with unix in the Terminal app, so I tried writing this for loop, but it rejected my regular expression:

for .*1.src in ./
> do
> cp ../1.src
> done

I've only written regular expressions in Python before and have minimal experience, but I was under the impression that .* would match any combination of characters. However, I got the following error message:

-bash: `.*1.src': not a valid identifier

I then tried the same for loop with the following regular expression:

^[a-zA-Z0-9_]*1.src$

But I got the same error message:

-bash: `^[a-zA-Z0-9_]*1.src$': not a valid identifier

I tried the same regular expression with and without quotation marks, but it always gives the same 'not a valid identifier' error message.

Body:
Thanks to everyone; this is what ended up working:

for x in `echo ./P[0-9]*_1.src`
> do
> cp ../1.src "$x"
> done

This loop allowed me to copy the contents of the one file to all of the files in the subdirectory that ended with "_1.src"


问:
how to get textbox to show results
trying to get results in textbox18, but no results. Is there something wrong with this code?

```<code>Private Sub CommandButton4_Click()

Dim id As String
Dim finalrow As Integer
Dim i As Integer

id = Me.ComboBox17.Text
finalrow = Sheets("Sheet2").Range("B27").End(xlUp).Row

For i = 7 To finalrow
    If Sheets("Sheet2").Cells(i, 2).Text = id Then
        Me.TextBox18 = Sheets("Sheet2").Cells(i, 9).Text

        End If

    Next i

End Sub
</code>```

答:
Remember that the textbox itself is an object, in which the Text is a field. So if you want to change that field's value, you should try:

```<code>Me.TextBox18.Text = Sheets("Sheet2").Cells(i, 9).Text
</code>```

Title: how to get textbox to show results

Body:
trying to get results in textbox18, but no results. Is there something wrong with this code?

Private Sub CommandButton4_Click()

Dim id As String
Dim finalrow As Integer
Dim i As Integer

id = Me.ComboBox17.Text
finalrow = Sheets("Sheet2").Range("B27").End(xlUp).Row

For i = 7 To finalrow
    If Sheets("Sheet2").Cells(i, 2).Text = id Then
        Me.TextBox18 = Sheets("Sheet2").Cells(i, 9).Text

        End If

    Next i

End Sub

Body:
Remember that the textbox itself is an object, in which the Text is a field. So if you want to change that field's value, you should try:

Me.TextBox18.Text = Sheets("Sheet2").Cells(i, 9).Text


问:
Transposing and Concatenating strings
How do I transpose and concatenate a pandas dataframe without using a for loop?

Here is the input data:

```<code>input_data =  pandas.DataFrame({'a': ['fruit', 'fruit', 'fruit', 'food', 'food', 'food', 'food'],
                      'b': ['banana', '', 'apple', 'rice', '', 'yam', 'chicken']})
</code>```

Resulting output should look like this:

```<code>result = pandas.DataFrame({'a': ['fruit', 'food'],
                      'b': ['banana  apple', 'rice  yam  chicken']})
</code>```

Here is my for loop solution:

```<code>stuff_list = input_data.a.drop_duplicates().tolist()
result = pandas.DataFrame()

for s in stuff_list:
    step1 = input_data[input_data.a == s]
    step2 = ' '.join(step1.b.tolist())
    step3 = pandas.DataFrame({'a':[s], 'b':[step2]})
    result = result.append(step3)

print(result)
</code>```

答:
More like agg

```<code>df.groupby('a',sort=False,as_index=False).agg(' '.join)
Out[539]:
       a                  b
0  fruit      banana  apple
1   food  rice  yam chicken
</code>```

Title: Transposing and Concatenating strings

Body:
How do I transpose and concatenate a pandas dataframe without using a for loop?

Here is the input data:

input_data =  pandas.DataFrame({'a': ['fruit', 'fruit', 'fruit', 'food', 'food', 'food', 'food'],
                      'b': ['banana', '', 'apple', 'rice', '', 'yam', 'chicken']})

Resulting output should look like this:

result = pandas.DataFrame({'a': ['fruit', 'food'],
                      'b': ['banana  apple', 'rice  yam  chicken']})

Here is my for loop solution:

stuff_list = input_data.a.drop_duplicates().tolist()
result = pandas.DataFrame()

for s in stuff_list:
    step1 = input_data[input_data.a == s]
    step2 = ' '.join(step1.b.tolist())
    step3 = pandas.DataFrame({'a':[s], 'b':[step2]})
    result = result.append(step3)

print(result)

Body:
More like agg

df.groupby('a',sort=False,as_index=False).agg(' '.join)
Out[539]:
       a                  b
0  fruit      banana  apple
1   food  rice  yam chicken


问:
K8s: how to change the nameserver for pod when trying to visit some domain outside the cluster
For some reason, nameserver such as 4.2.2.1,208.67.220.220 is not the best option in China. When the pod tries to resolve the domain outside the cluster, daemon set nodelocaldns complains i/o timeout to resolve the domain name

```<code>[ERROR] plugin/errors: 2 checkpoint-api.hashicorp.com. A: read udp 192.168.1.15:35630->4.2.2.1:53: i/o timeout
[ERROR] plugin/errors: 2 checkpoint-api.hashicorp.com. AAAA: read udp 192.168.1.15:37137->4.2.2.2:53: i/o timeout
</code>```

I modified the corefile of coredns in the configmap to use another nameserver 114.114.114.114, but without effect.

```<code>---
kind: ConfigMap
apiVersion: v1
metadata:
  name: coredns
  namespace: kube-system
  selfLink: "/api/v1/namespaces/kube-system/configmaps/coredns"
  uid: 844355d4-7dd3-11e9-ab0b-0800274131a7
  resourceVersion: '919'
  creationTimestamp: '2019-05-24T03:25:02Z'
  labels:
    addonmanager.kubernetes.io/mode: EnsureExists
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: '{"apiVersion":"v1","data":{"Corefile":".:53
      {\n    errors\n    health\n    kubernetes cluster.local in-addr.arpa ip6.arpa
      {\n      pods insecure\n      upstream /etc/resolv.conf\n      fallthrough in-addr.arpa
      ip6.arpa\n    }\n    prometheus :9153\n    forward . /etc/resolv.conf\n    cache
      30\n    loop\n    reload\n    loadbalance\n}\n"},"kind":"ConfigMap","metadata":{"annotations":{},"labels":{"addonmanager.kubernetes.io/mode":"EnsureExists"},"name":"coredns","namespace":"kube-system"}}

'
data:
  Corefile: |
    .:53 {
        errors
        health
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          upstream 114.114.114.114
          fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        forward . 114.114.114.114
        cache 30
        loop
        reload
        loadbalance
    }
    consul:53 {
        errors
        cache 30
        forward . 10.233.5.74
}
</code>```

So which configuration I have missed?

答:
You can find the information here. More precisely:

To explicitly force all non-cluster DNS lookups to go through a
  specific nameserver at 172.16.0.1, point the proxy and upstream to the
  nameserver

```<code>proxy .  172.16.0.1
upstream 172.16.0.1
</code>```

Body:
For some reason, nameserver such as 4.2.2.1,208.67.220.220 is not the best option in China. When the pod tries to resolve the domain outside the cluster, daemon set nodelocaldns complains i/o timeout to resolve the domain name

[ERROR] plugin/errors: 2 checkpoint-api.hashicorp.com. A: read udp 192.168.1.15:35630->4.2.2.1:53: i/o timeout
[ERROR] plugin/errors: 2 checkpoint-api.hashicorp.com. AAAA: read udp 192.168.1.15:37137->4.2.2.2:53: i/o timeout

I modified the corefile of coredns in the configmap to use another nameserver 114.114.114.114, but without effect.

---
kind: ConfigMap
apiVersion: v1
metadata:
  name: coredns
  namespace: kube-system
  selfLink: "/api/v1/namespaces/kube-system/configmaps/coredns"
  uid: 844355d4-7dd3-11e9-ab0b-0800274131a7
  resourceVersion: '919'
  creationTimestamp: '2019-05-24T03:25:02Z'
  labels:
    addonmanager.kubernetes.io/mode: EnsureExists
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: '{"apiVersion":"v1","data":{"Corefile":".:53
      {\n    errors\n    health\n    kubernetes cluster.local in-addr.arpa ip6.arpa
      {\n      pods insecure\n      upstream /etc/resolv.conf\n      fallthrough in-addr.arpa
      ip6.arpa\n    }\n    prometheus :9153\n    forward . /etc/resolv.conf\n    cache
      30\n    loop\n    reload\n    loadbalance\n}\n"},"kind":"ConfigMap","metadata":{"annotations":{},"labels":{"addonmanager.kubernetes.io/mode":"EnsureExists"},"name":"coredns","namespace":"kube-system"}}

'
data:
  Corefile: |
    .:53 {
        errors
        health
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          upstream 114.114.114.114
          fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        forward . 114.114.114.114
        cache 30
        loop
        reload
        loadbalance
    }
    consul:53 {
        errors
        cache 30
        forward . 10.233.5.74
}

So which configuration I have missed?

Body:
You can find the information here. More precisely:

To explicitly force all non-cluster DNS lookups to go through a
  specific nameserver at 172.16.0.1, point the proxy and upstream to the
  nameserver

proxy .  172.16.0.1
upstream 172.16.0.1


问:
(unicode error) 'unicodeescape' codec can't decode bytes in position 16-17: truncated \uXXXX escape
I want to import one module of pyusb library that is in the d:\pyusb-1.0.0a2\usb. So first of all I must add its path to sys.path. But I receive the below error.

Note : I successfully can import d:\pyusb-1.0.0a2 !!!

```<code>Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import sys
>>> sys.path.append('d:\pyusb-1.0.0a2\usb')
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 16-17: truncated \uXXXX escape
</code>```

答:
I got the syntaxError when add the file upload method in flask as follows,

```

    def upload():
         if request.method == 'POST':
             f = request.files['file']
             basepath = os.path.dirname(__file__)
             print(basepath)
             upload_path = os.path.join(basepath, 'static\files',secure_filename(f.filename))
             f.save(upload_path)
             return redirect(url_for('upload'))
         return render_template('upload.html')

```

The console shows error as follows:

```

upload_path = os.path.join(basepath,r'static\files',secure_filename(f.filename))

```

So,I think it caused by '\u' in Unicode Escape Sequence,we should use raw strings to fix it.

```

upload_path = os.path.join(basepath,r'static\files',secure_filename(f.filename))

```

Body:
I want to import one module of pyusb library that is in the d:\pyusb-1.0.0a2\usb. So first of all I must add its path to sys.path. But I receive the below error.

Note : I successfully can import d:\pyusb-1.0.0a2 !!!

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import sys
>>> sys.path.append('d:\pyusb-1.0.0a2\usb')
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 16-17: truncated \uXXXX escape

Body:
I got the syntaxError when add the file upload method in flask as follows,

    def upload():
         if request.method == 'POST':
             f = request.files['file']
             basepath = os.path.dirname(__file__)
             print(basepath)
             upload_path = os.path.join(basepath, 'static\files',secure_filename(f.filename))
             f.save(upload_path)
             return redirect(url_for('upload'))
         return render_template('upload.html')

The console shows error as follows:

upload_path = os.path.join(basepath,r'static\files',secure_filename(f.filename))

So,I think it caused by '\u' in Unicode Escape Sequence,we should use raw strings to fix it.

upload_path = os.path.join(basepath,r'static\files',secure_filename(f.filename))


问:
Code to compare the number of "false" to total number of cases
I am trying to create a chart in tableau which will show me the comparison in weeks, i.e. the comparison between the trend from week 1 to week 5.

In simple terms it should be like:

```<code>If Verdict = "Not Reversing" THEN count the total number of Verdicts
</code>```

Else do not count

```<code>If IF [Verdict] = "Not Reversing"
THEN
COUNT([Verdict])

END

IF [Verdict] = "Not Reversing"
THEN
COUNT([Verdict])

END
</code>```

Error message shows cannot mix aggregate and non aggregate functions

答:
Assuming your data source has exactly one data row per verdict ... (Always be clear about what one row in your data source represents.)

You could define a calculated field called Number of Non Reversing Verdicts defined as INT([Verdict] = "Non Reversing") That field will have the value 1 for Non Reversing verdicts and 0 otherwise. The INT() function converts its arguments into an integer, and treats TRUE as 1 and FALSE as 0.

You can then plot SUM([Number of Non Reversing Verdicts]) as desired, along with SUM([Number of Records]) to see the total number of verdicts -- or even compute the ratio of the two formatted as a percentage.

For extra credit, you could rename the predefined field [Number of Records] to [Number of Verdicts] for this data source if that helps make it more clear. (BTW, look at the definition of [Number of Records] and make sure you understand why that works)

Body:
I am trying to create a chart in tableau which will show me the comparison in weeks, i.e. the comparison between the trend from week 1 to week 5.

In simple terms it should be like:

If Verdict = "Not Reversing" THEN count the total number of Verdicts

Else do not count

If IF [Verdict] = "Not Reversing"
THEN
COUNT([Verdict])

END

IF [Verdict] = "Not Reversing"
THEN
COUNT([Verdict])

END

Error message shows cannot mix aggregate and non aggregate functions


问:
How to read from video url or from usb camera using videoflow?
In the Videoflow python library there are examples on how to read from a video file, but how can I read video from the usb device in the computer?</p>

答:
It was just added into it.  You can do something like this. Just be sure to set the device id of your camera properly in the code.</p>

```<code>import videoflow
import videoflow.core.flow as flow
from videoflow.core.constants import REALTIME
from videoflow.producers import VideoDeviceReader
from videoflow.consumers import VideofileWriter

class FrameIndexSplitter(videoflow.core.node.ProcessorNode):
    def __init__(self):
        super(FrameIndexSplitter, self).__init__()

    def process(self, data):
        index, frame = data
        return frame

def main():
    output_file = "output.avi"
    device_id = 0
    reader = VideoDeviceReader(device_id)
    frame = FrameIndexSplitter()(reader)
    writer = VideofileWriter(output_file, fps = 30)(frame)
    fl = flow.Flow([reader], [writer], flow_type = REALTIME)
    fl.run()
    fl.join()

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

Body:
It was just added into it.  You can do something like this. Just be sure to set the device id of your camera properly in the code.

import videoflow
import videoflow.core.flow as flow
from videoflow.core.constants import REALTIME
from videoflow.producers import VideoDeviceReader
from videoflow.consumers import VideofileWriter

class FrameIndexSplitter(videoflow.core.node.ProcessorNode):
    def __init__(self):
        super(FrameIndexSplitter, self).__init__()

    def process(self, data):
        index, frame = data
        return frame

def main():
    output_file = "output.avi"
    device_id = 0
    reader = VideoDeviceReader(device_id)
    frame = FrameIndexSplitter()(reader)
    writer = VideofileWriter(output_file, fps = 30)(frame)
    fl = flow.Flow([reader], [writer], flow_type = REALTIME)
    fl.run()
    fl.join()

if __name__ == "__main__":
    main()


问:
How can i gathering swipe card information using vb winforms app?
I developed the billing project. I going to implement the card swipe reader. I have no idea about the card swipe reader application with VB + winforms

Can some one help me !!

Give samples and tutorials etc...

答: There really doesn't seem to be a lot of information out there about this topic. Check out this thread on the MSDN forums, it and the link provided inside might be useful to you. One common theme I found while browsing through some posts, and something that's just generally true when using third-party hardware with your app, is to contact the manufacturer of the swipe reader and get documentation from them, as they'll most likely have all that information on file. Good luck!</p>


问:
Export 'default' using index.ts
I've got the following project structure:

```<code>build/
    build.ts
config/
    config.ts
    index.ts
...
</code>```

The config.ts contains a default exported type like this:

```<code>export default {
    myProp: {
        someProp: "someValue"
    }
}
</code>```

And the index.ts within config/ looks like this:

```<code>export * from './config';
</code>```

Now I'd like to import the config type within build.ts like this:

```<code>import config from '../config';
</code>```

But when using it (e.g. with config.myProp), it tells me that myProp doesn't exist on index.ts.

According to the official module documentation here, this should work perfectly fine. Am I missing something here?

答:
It seems like there is a trend towards not using default export, due to the number of potential issues. The recommendation is to use named exports. I am myself happily following the convention to only use named exports. The reasons as shown here matches my experience on the subject.

But, should you still choose to export as default, then I think you should be able to re-export it in config/index.ts like this:

```<code>export {default} from './config';
</code>```

Then in build/build.ts you should be able to do a

```<code>import config from '../config';
</code>```

Title: Export 'default' using index.ts

Body:
I've got the following project structure:

build/
    build.ts
config/
    config.ts
    index.ts
...

The config.ts contains a default exported type like this:

export default {
    myProp: {
        someProp: "someValue"
    }
}

And the index.ts within config/ looks like this:

export * from './config';

Now I'd like to import the config type within build.ts like this:

import config from '../config';

But when using it (e.g. with config.myProp), it tells me that myProp doesn't exist on index.ts.

According to the official module documentation here, this should work perfectly fine. Am I missing something here?

Body:
It seems like there is a trend towards not using default export, due to the number of potential issues. The recommendation is to use named exports. I am myself happily following the convention to only use named exports. The reasons as shown here matches my experience on the subject.

But, should you still choose to export as default, then I think you should be able to re-export it in config/index.ts like this:

export {default} from './config';

Then in build/build.ts you should be able to do a

import config from '../config';


问:
How to prevent new user's registration on JHipster
I want to create a closed community. So I wold have a lot of users but all of them will be invited by myself or somebody.
Moreover I want them to have only one option to login - social accounts.

I've implemented this functionality but for me it looks like set of hack:
1) forbid /api/register endpoint to prevent self registration by the registration form
2) Do not create new user if it is still has not been created (here  SocialService#createUserIfNotExist)
3) Modify some email templates

My questions now are:
1) Is it is right way or you can suggest better solution?
2) Do you think that it may be a good option for further JHipster generator?

答: Open the corresponding route file (I think it's account ) and delete the entry to register, then open the login HTML file and delete the part referring to the registration. That should do the trick


问:
on-the-fly output redirection, seeing the file redirection output while the program is still running
If I use a command like this one:

./program >> a.txt &

, and the program is a long running one then I can only see the output once the program ended. That means I have no way of knowing if the computation is going well until it actually stops computing. I want to be able to read the redirected output on file while the program is running.

This is similar to opening a file, appending to it, then closing it back after every writing. If the file is only closed at the end of the program then no data can be read on it until the program ends. The only redirection I know is similar to closing the file at the end of the program.

You can test it with this little python script. The language doesn't matter. Any program that writes to standard output has the same problem.

```<code>l = range(0,100000)
for i in l:
  if i%1000==0:
    print i
  for j in l:
    s = i + j
</code>```

One can run this with:

./python program.py >> a.txt &

Then cat a.txt .. you will only get results once the script is done computing.

答:
The unbuffer command from the expect package does exactly what you are looking for.

```<code>$ sudo apt-get install expect
$ unbuffer python program.py | cat -
<watch output immediately show up here>
</code>```

ContentLicense: CC BY-SA 2.5

Body:
If I use a command like this one:

./program >> a.txt &

, and the program is a long running one then I can only see the output once the program ended. That means I have no way of knowing if the computation is going well until it actually stops computing. I want to be able to read the redirected output on file while the program is running.

This is similar to opening a file, appending to it, then closing it back after every writing. If the file is only closed at the end of the program then no data can be read on it until the program ends. The only redirection I know is similar to closing the file at the end of the program.

You can test it with this little python script. The language doesn't matter. Any program that writes to standard output has the same problem.

l = range(0,100000)
for i in l:
  if i%1000==0:
    print i
  for j in l:
    s = i + j

One can run this with:

./python program.py >> a.txt &

Then cat a.txt .. you will only get results once the script is done computing.

Body:
The unbuffer command from the expect package does exactly what you are looking for.

$ sudo apt-get install expect
$ unbuffer python program.py | cat -
<watch output immediately show up here>


问:
Mercurial central repository LAN ghost folder?
I'm working on setting up version control on a company LAN using the setup described in this tutorial

The central repository is located on a Mac OS, with the developers running either Windows or Mac OS. Pushing and pulling from the central repository to a local repository on both Windows and Mac OS works.

What I can't understand is that the central repository folder appears duplicated in Windows Explorer ('CentralRepo' and 'CentralRepo-1'), yet when logged in as admin on the Mac OS hosting the central repository, this folder cannot be located. The duplicated folder can only be seen on one particular Windows computer.

Is it a temp folder? Is there anything that can be done to remove this duplicated folder?

答: I don't think this has anything to do with Mercurial. It's just some Windows or Samba screwiness. Because of the nature of a DVCS, you should never need to use Explorer to view the remote repo, so just ignore it.</p>


问:
Is there a way to have a macro remove all paragraphs of a certain type?
Im creating an invoice Word Template on basis of Words Mail Merge. I get the necessary information via .csv file from a web application and create a table based on these informations. The data is given this way:

```<code>Person1 - InvoicePos1 - InvoicePos2 - InvoicePos3 - InvoicePos4
Person2 - InvoicePos1 - InvoicePos2 - InvoicePos3 - InvoicePos4
Person3 - InvoicePos1 - InvoicePos2 - InvoicePos3 - InvoicePos4
                              .
                              .
                              .
                              .
</code>```

There are different amounts of invoice types/ invoice positions so i have to create a dynamic table which works great so far.

My problem:
Word seems to automatically inserts a paragraph before each table that gets insert via a {IF}-Statement. Why do i know that its Word that inserts these paragraphs? Well the whole document is in Calibri size 12 but these Paragraphs are Times New Roman 10.

IMGUR-Link with (hopefully helpful images)

My question: Is there a way to create a macro that runs over the created document that disables/ hides each paragraph that is Times New Roman?

Ive tried different settings already to try to prevent the creation of these paragraphs but to no avail. So now im trying to hide these paragraphs after the document is created.

```<code>Sub HidePara()
    If /FoundParagraphs/.Font.Name = "Times New Roman" Then
        /FoundParagraphs/.Hidden = true
    End If
End Sub
</code>```

I know how to change the Hidden Attribute (which isnt hard at all .. )
But how would i look for either all paragraph marks (i would have to use the If-statement ive given) or (which would be better imho) filter for all paragraphs of the .Font.Name "Times New Roman".
I cant find any way to find the paragraph marks at all. But than again im pretty new to VBA and actually have no idea what im doing here. As VBA is really great. facepalm

答:
Even faster is a simple Find/Replace:</p>

```<code>Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = ""
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .Font.Name = "Times New Roman"
    .Execute Replace:=wdReplaceAll
  End With
End With
Application.ScreenUpdating = True
End Sub
</code>```

Body:
Im creating an invoice Word Template on basis of Words Mail Merge. I get the necessary information via .csv file from a web application and create a table based on these informations. The data is given this way:

Person1 - InvoicePos1 - InvoicePos2 - InvoicePos3 - InvoicePos4
Person2 - InvoicePos1 - InvoicePos2 - InvoicePos3 - InvoicePos4
Person3 - InvoicePos1 - InvoicePos2 - InvoicePos3 - InvoicePos4
                              .
                              .
                              .
                              .

There are different amounts of invoice types/ invoice positions so i have to create a dynamic table which works great so far.

My problem:
Word seems to automatically inserts a paragraph before each table that gets insert via a {IF}-Statement. Why do i know that its Word that inserts these paragraphs? Well the whole document is in Calibri size 12 but these Paragraphs are Times New Roman 10.

IMGUR-Link with (hopefully helpful images)

My question: Is there a way to create a macro that runs over the created document that disables/ hides each paragraph that is Times New Roman?

Ive tried different settings already to try to prevent the creation of these paragraphs but to no avail. So now im trying to hide these paragraphs after the document is created.

Sub HidePara()
    If /FoundParagraphs/.Font.Name = "Times New Roman" Then
        /FoundParagraphs/.Hidden = true
    End If
End Sub

I know how to change the Hidden Attribute (which isnt hard at all .. )
But how would i look for either all paragraph marks (i would have to use the If-statement ive given) or (which would be better imho) filter for all paragraphs of the .Font.Name "Times New Roman".
I cant find any way to find the paragraph marks at all. But than again im pretty new to VBA and actually have no idea what im doing here. As VBA is really great. facepalm

Body:
Even faster is a simple Find/Replace:

Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = ""
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .Font.Name = "Times New Roman"
    .Execute Replace:=wdReplaceAll
  End With
End With
Application.ScreenUpdating = True
End Sub


问:
Keras Custom Layer ValueError: An operation has `None` for gradient.
I have created a custom Keras Conv2D layer as follows:

```<code>class CustConv2D(Conv2D):

    def __init__(self, filters, kernel_size, kernelB=None, activation=None, **kwargs):
        self.rank = 2
        self.num_filters = filters
        self.kernel_size = conv_utils.normalize_tuple(kernel_size, self.rank, 'kernel_size')
        self.kernelB = kernelB
        self.activation = activations.get(activation)

        super(CustConv2D, self).__init__(self.num_filters, self.kernel_size, **kwargs)

    def build(self, input_shape):
        if K.image_data_format() == 'channels_first':
            channel_axis = 1
        else:
            channel_axis = -1
        if input_shape[channel_axis] is None:
            raise ValueError('The channel dimension of the inputs '
                     'should be defined. Found `None`.')

        input_dim = input_shape[channel_axis]
        num_basis = K.int_shape(self.kernelB)[-1]

        kernel_shape = (num_basis, input_dim, self.num_filters)

        self.kernelA = self.add_weight(shape=kernel_shape,
                                      initializer=RandomUniform(minval=-1.0,
                                      maxval=1.0, seed=None),
                                      name='kernelA',
                                      regularizer=self.kernel_regularizer,
                                      constraint=self.kernel_constraint)

        self.kernel = K.sum(self.kernelA[None, None, :, :, :] * self.kernelB[:, :, :, None, None], axis=2)

        # Set input spec.
        self.input_spec = InputSpec(ndim=self.rank + 2, axes={channel_axis: input_dim})
        self.built = True
        super(CustConv2D, self).build(input_shape)
</code>```

I use the CustomConv2D as the first Conv layer of my model.

```<code>img = Input(shape=(width, height, 1))
l1 = CustConv2D(filters=64, kernel_size=(11, 11), kernelB=basis_L1, activation='relu')(img)
</code>```

The model compiles fine; but gives me the following error while training.

ValueError: An operation has None for gradient. Please make sure that all of your ops have a gradient defined (i.e. are differentiable). Common ops without gradient: K.argmax, K.round, K.eval.

Is there a way to figure out which operation is throwing the error? Also, is there any implementation error in the way I am writing the custom layer?

答:
It may be because there are some weights in your code that are defined by not used in the calculation of the output. Thus its gradient wrt the loss is None/undefined.

A coded out example can be found here: https://github.com/keras-team/keras/issues/12521#issuecomment-496743146

Body:
I have created a custom Keras Conv2D layer as follows:

class CustConv2D(Conv2D):

    def __init__(self, filters, kernel_size, kernelB=None, activation=None, **kwargs):
        self.rank = 2
        self.num_filters = filters
        self.kernel_size = conv_utils.normalize_tuple(kernel_size, self.rank, 'kernel_size')
        self.kernelB = kernelB
        self.activation = activations.get(activation)

        super(CustConv2D, self).__init__(self.num_filters, self.kernel_size, **kwargs)

    def build(self, input_shape):
        if K.image_data_format() == 'channels_first':
            channel_axis = 1
        else:
            channel_axis = -1
        if input_shape[channel_axis] is None:
            raise ValueError('The channel dimension of the inputs '
                     'should be defined. Found `None`.')

        input_dim = input_shape[channel_axis]
        num_basis = K.int_shape(self.kernelB)[-1]

        kernel_shape = (num_basis, input_dim, self.num_filters)

        self.kernelA = self.add_weight(shape=kernel_shape,
                                      initializer=RandomUniform(minval=-1.0,
                                      maxval=1.0, seed=None),
                                      name='kernelA',
                                      regularizer=self.kernel_regularizer,
                                      constraint=self.kernel_constraint)

        self.kernel = K.sum(self.kernelA[None, None, :, :, :] * self.kernelB[:, :, :, None, None], axis=2)

        # Set input spec.
        self.input_spec = InputSpec(ndim=self.rank + 2, axes={channel_axis: input_dim})
        self.built = True
        super(CustConv2D, self).build(input_shape)

I use the CustomConv2D as the first Conv layer of my model.

img = Input(shape=(width, height, 1))
l1 = CustConv2D(filters=64, kernel_size=(11, 11), kernelB=basis_L1, activation='relu')(img)

The model compiles fine; but gives me the following error while training.

ValueError: An operation has None for gradient. Please make sure that all of your ops have a gradient defined (i.e. are differentiable). Common ops without gradient: K.argmax, K.round, K.eval.

Is there a way to figure out which operation is throwing the error? Also, is there any implementation error in the way I am writing the custom layer?


问:
Python function return value vs print
I am exceedingly new to programming, so go easy on me. I use Visual Studio Code as my editor in which I am working on a few python files. When I run the code, say for instance a pandas.dataframe.head() function, it doesn't return anything in the terminal. But when I print the same return value, I am seeing the data from a csv file as expected.

Can anyone explain what is going on?

Is it the case that when a function is run, that the data is stored but not necessarily displayed?

If so, is print the only means of displaying the value of a function when debugging?

Tried googling answers, but don't have clarity yet.

import pandas as pd

df = pd.read_csv('sample.csv')
df.head()
# print(df.head())
```

Expect some data to be displayed in the terminal

答:
If you want to get a value from a function and use it elsewhere, you should return that value at the end of the function definition. That way when you call the function at some point in your code and you can assign it to a variable which would store the output of the function

For instance

```<code>#test.py
def square(i):
   return i*i

def main():
   eight_square = square(8)
   print(eight_square)
</code>```

Only if you print the output you can actually see it in the terminal when you run python3 test.py. There are other ways to check, what the value is in a variable, for instance using a debugger. Visual Studio can be configured with a debugger if it isn't set up.
 A breakpoint is to be set at the location where the value of the variable has to be found and the debugger has to be started.

Reference: Microsoft visual studio docs

Title: Python function return value vs print

Body:
I am exceedingly new to programming, so go easy on me. I use Visual Studio Code as my editor in which I am working on a few python files. When I run the code, say for instance a pandas.dataframe.head() function, it doesn't return anything in the terminal. But when I print the same return value, I am seeing the data from a csv file as expected.

Can anyone explain what is going on?

Is it the case that when a function is run, that the data is stored but not necessarily displayed?

If so, is print the only means of displaying the value of a function when debugging?

Tried googling answers, but don't have clarity yet.

import pandas as pd

df = pd.read_csv('sample.csv')
df.head()
# print(df.head())

Expect some data to be displayed in the terminal

Body:
If you want to get a value from a function and use it elsewhere, you should return that value at the end of the function definition. That way when you call the function at some point in your code and you can assign it to a variable which would store the output of the function

For instance

#test.py
def square(i):
   return i*i

def main():
   eight_square = square(8)
   print(eight_square)

Only if you print the output you can actually see it in the terminal when you run python3 test.py. There are other ways to check, what the value is in a variable, for instance using a debugger. Visual Studio can be configured with a debugger if it isn't set up.
 A breakpoint is to be set at the location where the value of the variable has to be found and the debugger has to be started.

Reference: Microsoft visual studio docs


问:
Display URL Image Using Pyspark
I have a dataframe that contains a column with URL links, I want each of the images displayed.

I tried the following solution for local files but it didn't work for URL links.
Spark using PySpark read images

If anyone knows how to accomplish this for a pyspark dataframe using an URL link, please do share.

Example of url jpg:
https://steemitimages.com/DQmWSoXZPHH2XEuVRUbPqiPLf6niA2xfvFXYZ2FYPYhMQ4X/1%20(3).jpg

答:
Loading image only work for local path or hdfs like path.
You can only download this image to local disk then load it .

import urllib.request

# path to your image source directory
sample_img_dir = /tmp/images

urllib.request.urlretrieve(' https://steemitimages.com/DQmWSoXZPHH2XEuVRUbPqiPLf6niA2xfvFXYZ2FYPYhMQ4X/1%20(3).jpg', sample_img_dir+'/image1.jpg')

# Read image data using new image scheme
image_df = spark.read.format("image")\
           .option("dropInvalid", true)\
           .load(sample_img_dir)

image_df.select("image.origin", "image.width", "image.height").show(truncate=False)
+-------------------------------------------+-----+------+
|origin                                     |width|height|
+-------------------------------------------+-----+------+
|file:///tmp/images/image1.jpg              |300  |311   |
|file:///tmp/images/image2.jpg              |199  |313   |
|file:///tmp/images/image3.jpg              |300  |200   |
|file:///tmp/images/image4.jpg              |300  |296   |
+-------------------------------------------+-----+------+

```

Reference:

Introducing Built-in Image Data Source in Apache Spark 2.4

Title: Display URL Image Using Pyspark

Body:
Loading image only work for local path or hdfs like path.
You can only download this image to local disk then load it .

import urllib.request

# path to your image source directory
sample_img_dir = /tmp/images

urllib.request.urlretrieve(' https://steemitimages.com/DQmWSoXZPHH2XEuVRUbPqiPLf6niA2xfvFXYZ2FYPYhMQ4X/1%20(3).jpg', sample_img_dir+'/image1.jpg')

# Read image data using new image scheme
image_df = spark.read.format("image")\
           .option("dropInvalid", true)\
           .load(sample_img_dir)

image_df.select("image.origin", "image.width", "image.height").show(truncate=False)
+-------------------------------------------+-----+------+
|origin                                     |width|height|
+-------------------------------------------+-----+------+
|file:///tmp/images/image1.jpg              |300  |311   |
|file:///tmp/images/image2.jpg              |199  |313   |
|file:///tmp/images/image3.jpg              |300  |200   |
|file:///tmp/images/image4.jpg              |300  |296   |
+-------------------------------------------+-----+------+

Reference:

Introducing Built-in Image Data Source in Apache Spark 2.4


答:
I believe you have learned using either Jupyter or a python console. VS Code is an IDE; it's basically a glorified text editor with features that help developers. You must be used to using python in the console where each line/command it automatically prints the results, whereas you are now likely creating a script and expect the same thing to happen. I don't believe `return has anything to do with what you're asking as it acts the same either way.

EDIT (as I found the actual documentation)

When in an interactive console python calls sys.displayhook after every execution. here's the actual documentation:

If value is not None, this function prints repr(value) to sys.stdout,
  and saves value in builtins._. If repr(value) is not encodable to
  sys.stdout.encoding with sys.stdout.errors error handler (which is
  probably 'strict'), encode it to sys.stdout.encoding with
  'backslashreplace' error handler.

sys.displayhook is called on the result of evaluating an expression
  entered in an interactive Python session. The display of these values
  can be customized by assigning another one-argument function to
  sys.displayhook.

Here's my very basic explanation I hope I explain it well enough

In the python console each line/command's results are printed after execution (ie: when you hit enter). (For context, every function/operation implicitly returns None if nothing else is returned, therefore not printed)

When running a python script, nothing will display in the console unless explicitly printed (other cases are uncaught error tracebacks, logging, or writing to stdout, etc...)

So basically the line

```<code>df.head()
</code>```

In a script performs the head function on df and returns the results but nothing happens to the results, unless you assign it to a variable or print it. It's the same as just writing:

```<code>"This will only print in a console"
</code>```

If that line is executed in an interactive console it will call sys.displayhook with the value and print the results:

```<code>'This will only print in a console'
</code>```

But if ran in a script it is essentially a needless line of code unless assigned to a variable.

Basically, the console assumes you want to see results as you code. (basically calling a special print at every line that doesn't print None and isn't called when print is explicitly run) Whereas when running a script it only prints to the console when explicitly asked or other special cases.

Title: Python function return value vs print

Body:
I believe you have learned using either Jupyter or a python console. VS Code is an IDE; it's basically a glorified text editor with features that help developers. You must be used to using python in the console where each line/command it automatically prints the results, whereas you are now likely creating a script and expect the same thing to happen. I don't believe `return has anything to do with what you're asking as it acts the same either way.

EDIT (as I found the actual documentation)

When in an interactive console python calls sys.displayhook after every execution. here's the actual documentation:

If value is not None, this function prints repr(value) to sys.stdout,
  and saves value in builtins._. If repr(value) is not encodable to
  sys.stdout.encoding with sys.stdout.errors error handler (which is
  probably 'strict'), encode it to sys.stdout.encoding with
  'backslashreplace' error handler.

sys.displayhook is called on the result of evaluating an expression
  entered in an interactive Python session. The display of these values
  can be customized by assigning another one-argument function to
  sys.displayhook.

Here's my very basic explanation I hope I explain it well enough

In the python console each line/command's results are printed after execution (ie: when you hit enter). (For context, every function/operation implicitly returns None if nothing else is returned, therefore not printed)

When running a python script, nothing will display in the console unless explicitly printed (other cases are uncaught error tracebacks, logging, or writing to stdout, etc...)

So basically the line

df.head()

In a script performs the head function on df and returns the results but nothing happens to the results, unless you assign it to a variable or print it. It's the same as just writing:

"This will only print in a console"

If that line is executed in an interactive console it will call sys.displayhook with the value and print the results:

'This will only print in a console'

But if ran in a script it is essentially a needless line of code unless assigned to a variable.

Basically, the console assumes you want to see results as you code. (basically calling a special print at every line that doesn't print None and isn't called when print is explicitly run) Whereas when running a script it only prints to the console when explicitly asked or other special cases.


问:
Silverlight Simple and Complex Properties
I was asked recently in an interview to give an example of a simple property and a complex property in Silverlight.  I think they were asking about dependency properties and attached properties but I'm not sure.  I've never heard the term Silverlight Simple Property or Silverlight Complex Property and googling hasn't helped.  Are these common terms that I've just missed up until now?  If so, what do they refer to?</p>

答:
It sounds like your interviewer wasn't using the most common terminology for whatever concept they were trying to describe.

Or...

They may have been testing you to see if you'd press back for more "requirements". You should have pressed them for more information so you could have worked out what they meant and answered their question.


问:
TIDTCPClient EAccessViolation
I have a RFID reader that comes with a RFTT service. I start the service and try to access it with TidTCPClient, but I get an access violation as soon I try to connect. Read of Address 00000000
As soon it click connect I get the message.

```<code>    unit UClient;

interface

uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, IdBaseComponent,
    IdComponent, IdTCPConnection, IdTCPClient, IdThreadComponent;

type
    TFClient = class(TForm)

    Label1        : TLabel;
    Label2        : TLabel;

    messageToSend : TMemo;
    messagesLog   : TMemo;

    btn_connect   : TButton;
    btn_disconnect: TButton;
    btn_send      : TButton;

    procedure FormShow(Sender: TObject);

    procedure btn_connectClick(Sender: TObject);
    procedure btn_disconnectClick(Sender: TObject);
    procedure btn_sendClick(Sender: TObject);

    procedure IdTCPClientConnected(Sender: TObject);
    procedure IdTCPClientDisconnected(Sender: TObject);

    procedure IdThreadComponentRun(Sender: TIdThreadComponent);

    procedure Display(p_sender: String; p_message: string);
    function  GetNow():String;
    procedure FormCreate(Sender: TObject);

    private
        { Private declarations }
    public
        { Public declarations }
    end;

    // ... listening port : GUEST CLIENT
    const GUEST_PORT = 5733;

    var
        FClient             : TFClient;

        // ... TIdTCPClient
        idTCPClient         : TIdTCPClient;

        // ... TIdThreadComponent
        idThreadComponent   : TIdThreadComponent;

implementation

{$R *.dfm}

procedure TFClient.FormCreate(Sender: TObject);
begin
    // ... create TIdTCPClient
    idTCPClient                 := TIdTCPClient.Create();

    // ... set properties
    idTCPClient.Host            := 'localhost';
    idTCPClient.Port            := GUEST_PORT;
    idTCPClient.ConnectTimeout  := 5000;
    // ... etc..

    // ... callback functions
    idTCPClient.OnConnected     := IdTCPClientConnected;
    idTCPClient.OnDisconnected  := IdTCPClientDisconnected;
    // ... etc..

    // ... create TIdThreadComponent
    idThreadComponent           := TIdThreadComponent.Create();

    // ... callback functions
    idThreadComponent.OnRun     := IdThreadComponentRun;
    // ... etc..

end;

procedure TFClient.FormShow(Sender: TObject);
begin

    // ... INITAILIZE

    // ... message to send
    messageToSend.Clear;
    messageToSend.Enabled     := False;

    // ... clear log
    messagesLog.Clear;

    // ... buttons
    btn_connect.Enabled       := True;
    btn_disconnect.Enabled    := False;
    btn_send.Enabled          := False;

end;

procedure TFClient.btn_connectClick(Sender: TObject);
begin

    // ... disable connect button
    btn_connect.Enabled := False;

    // ... try to connect to Server
    try
        IdTCPClient.Connect;
    except
        on E: Exception do begin
            Display('CLIENT', 'CONNECTION ERROR! ' + E.Message);
            btn_connect.Enabled := True;
        end;
    end;
end;

procedure TFClient.btn_disconnectClick(Sender: TObject);
begin
    // ... is connected?
    if IdTCPClient.Connected then begin
        // ... disconnect from Server
        IdTCPClient.Disconnect;

        // ... set buttons
        btn_connect.Enabled       := True;
        btn_disconnect.Enabled    := False;
        btn_send.Enabled          := False;
        messageToSend.Enabled     := False;
    end;
end;
procedure TFClient.IdTCPClientConnected(Sender: TObject);
begin

    // ... messages log
    Display('CLIENT', 'CONNECTED!');

    // ... after connection is ok, run the Thread ... waiting messages from server
    IdThreadComponent.Active  := True;

    // ... set buttons
    btn_connect.Enabled       := False;
    btn_disconnect.Enabled    := True;
    btn_send.Enabled          := True;

    // ... enable message to send
    messageToSend.Enabled     := True;

end;

procedure TFClient.IdTCPClientDisconnected(Sender: TObject);
begin
    // ... message log
    Display('CLIENT', 'DISCONNECTED!');
end;

procedure TFClient.IdThreadComponentRun(Sender: TIdThreadComponent);
var
    msgFromServer : string;
begin
    // ... read message from server
    msgFromServer := IdTCPClient.IOHandler.ReadLn();

    // ... messages log
    Display('SERVER', msgFromServer);
end;

procedure TFClient.Display(p_sender : String; p_message : string);
begin
  TThread.Queue(nil, procedure
                     begin
                         MessagesLog.Lines.Add('[' + p_sender + '] - '
                         + GetNow() + ': ' + p_message);
                     end
               );
end;

function TFClient.getNow() : String;
begin
    Result := FormatDateTime('yyyy-mm-dd hh:nn:ss', Now) + ': ';
end;

end.
</code>```

This is the whole program unfortunately I have to put all this text because it will not let me post with out more detailed text.

Thanks for any help,
KimHJ

答: As Remy suggested after dropping the component on the form and us those instead, everything worked fine.</p>

Title: TIDTCPClient EAccessViolation

Body:
I have a RFID reader that comes with a RFTT service. I start the service and try to access it with TidTCPClient, but I get an access violation as soon I try to connect. Read of Address 00000000
As soon it click connect I get the message.

    unit UClient;

interface

uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, IdBaseComponent,
    IdComponent, IdTCPConnection, IdTCPClient, IdThreadComponent;

type
    TFClient = class(TForm)

    Label1        : TLabel;
    Label2        : TLabel;

    messageToSend : TMemo;
    messagesLog   : TMemo;

    btn_connect   : TButton;
    btn_disconnect: TButton;
    btn_send      : TButton;

    procedure FormShow(Sender: TObject);

    procedure btn_connectClick(Sender: TObject);
    procedure btn_disconnectClick(Sender: TObject);
    procedure btn_sendClick(Sender: TObject);

    procedure IdTCPClientConnected(Sender: TObject);
    procedure IdTCPClientDisconnected(Sender: TObject);

    procedure IdThreadComponentRun(Sender: TIdThreadComponent);

    procedure Display(p_sender: String; p_message: string);
    function  GetNow():String;
    procedure FormCreate(Sender: TObject);

    private
        { Private declarations }
    public
        { Public declarations }
    end;

    // ... listening port : GUEST CLIENT
    const GUEST_PORT = 5733;

    var
        FClient             : TFClient;

        // ... TIdTCPClient
        idTCPClient         : TIdTCPClient;

        // ... TIdThreadComponent
        idThreadComponent   : TIdThreadComponent;

implementation

{$R *.dfm}

procedure TFClient.FormCreate(Sender: TObject);
begin
    // ... create TIdTCPClient
    idTCPClient                 := TIdTCPClient.Create();

    // ... set properties
    idTCPClient.Host            := 'localhost';
    idTCPClient.Port            := GUEST_PORT;
    idTCPClient.ConnectTimeout  := 5000;
    // ... etc..

    // ... callback functions
    idTCPClient.OnConnected     := IdTCPClientConnected;
    idTCPClient.OnDisconnected  := IdTCPClientDisconnected;
    // ... etc..

    // ... create TIdThreadComponent
    idThreadComponent           := TIdThreadComponent.Create();

    // ... callback functions
    idThreadComponent.OnRun     := IdThreadComponentRun;
    // ... etc..

end;

procedure TFClient.FormShow(Sender: TObject);
begin

    // ... INITAILIZE

    // ... message to send
    messageToSend.Clear;
    messageToSend.Enabled     := False;

    // ... clear log
    messagesLog.Clear;

    // ... buttons
    btn_connect.Enabled       := True;
    btn_disconnect.Enabled    := False;
    btn_send.Enabled          := False;

end;

procedure TFClient.btn_connectClick(Sender: TObject);
begin

    // ... disable connect button
    btn_connect.Enabled := False;

    // ... try to connect to Server
    try
        IdTCPClient.Connect;
    except
        on E: Exception do begin
            Display('CLIENT', 'CONNECTION ERROR! ' + E.Message);
            btn_connect.Enabled := True;
        end;
    end;
end;

procedure TFClient.btn_disconnectClick(Sender: TObject);
begin
    // ... is connected?
    if IdTCPClient.Connected then begin
        // ... disconnect from Server
        IdTCPClient.Disconnect;

        // ... set buttons
        btn_connect.Enabled       := True;
        btn_disconnect.Enabled    := False;
        btn_send.Enabled          := False;
        messageToSend.Enabled     := False;
    end;
end;
procedure TFClient.IdTCPClientConnected(Sender: TObject);
begin

    // ... messages log
    Display('CLIENT', 'CONNECTED!');

    // ... after connection is ok, run the Thread ... waiting messages from server
    IdThreadComponent.Active  := True;

    // ... set buttons
    btn_connect.Enabled       := False;
    btn_disconnect.Enabled    := True;
    btn_send.Enabled          := True;

    // ... enable message to send
    messageToSend.Enabled     := True;

end;

procedure TFClient.IdTCPClientDisconnected(Sender: TObject);
begin
    // ... message log
    Display('CLIENT', 'DISCONNECTED!');
end;

procedure TFClient.IdThreadComponentRun(Sender: TIdThreadComponent);
var
    msgFromServer : string;
begin
    // ... read message from server
    msgFromServer := IdTCPClient.IOHandler.ReadLn();

    // ... messages log
    Display('SERVER', msgFromServer);
end;

procedure TFClient.Display(p_sender : String; p_message : string);
begin
  TThread.Queue(nil, procedure
                     begin
                         MessagesLog.Lines.Add('[' + p_sender + '] - '
                         + GetNow() + ': ' + p_message);
                     end
               );
end;

function TFClient.getNow() : String;
begin
    Result := FormatDateTime('yyyy-mm-dd hh:nn:ss', Now) + ': ';
end;

end.

This is the whole program unfortunately I have to put all this text because it will not let me post with out more detailed text.

Thanks for any help,
KimHJ


问:
Postgres ORDER BY twice DESC then ASC
I have a recursive query

```<code>With RECURSIVE tree AS
 (
 SELECT * FROM comments WHERE id = 83
 UNION
 SELECT t.*
      From comments t
 JOIN tree rt ON rt.parent_id = t.id

 )
 SELECT * from tree ORDER BY id DESC LIMIT 5
</code>```

How would I order it one more time by ASC?

Edit1: tried this solution:
Get the last N rows in the database in order?

```<code>With RECURSIVE tree AS
 (
 SELECT * FROM comments WHERE id = 83
 UNION
 SELECT t.*
      From comments t
 JOIN tree rt ON rt.parent_id = t.id

 )
 select * from (SELECT * from tree ORDER BY id DESC LIMIT 5) order by id
</code>```

Gives me an error:

```<code>ERROR:  subquery in FROM must have an alias
</code>```

答:
```<code>select * from (SELECT * from tree ORDER BY comment_id DESC LIMIT 5) t order by comment_id
</code>```

Title: Postgres ORDER BY twice DESC then ASC

Body:
I have a recursive query

With RECURSIVE tree AS
 (
 SELECT * FROM comments WHERE id = 83
 UNION
 SELECT t.*
      From comments t
 JOIN tree rt ON rt.parent_id = t.id

 )
 SELECT * from tree ORDER BY id DESC LIMIT 5

How would I order it one more time by ASC?

Edit1: tried this solution:
Get the last N rows in the database in order?

With RECURSIVE tree AS
 (
 SELECT * FROM comments WHERE id = 83
 UNION
 SELECT t.*
      From comments t
 JOIN tree rt ON rt.parent_id = t.id

 )
 select * from (SELECT * from tree ORDER BY id DESC LIMIT 5) order by id

Gives me an error:

ERROR:  subquery in FROM must have an alias


问:
Doctrine2 workaround for mapping MySql 'bit' data type
I have a few columns in my database schema that have bit data types and am having problems with Doctrine2 mapping it. I keep getting:

Unknown database type bit requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.

Is there any work around? I was thinking of just changing the data type to boolean and just use true and false statements but that would mean changing the schema on a large scale which I dont have time for.

答:
Please follow the following steps to solve this problem:

1)open the File at the following Location like in linux scenario the path is:

var\www\html\admin\libraries\Composer\vendor\doctrine\dbal\lib\Doctrine\DBAL\Platforms\MySqlPlatform.php

2)Go to this Function initializeDoctrineTypeMappings()

3)No simply add the entry of your mapping like in my case i mapped bit with Boolean as given below:

'bit'           => 'boolean',

4)Reload your App and it will work.


问:
Materialize CSS - Select Doesn't Seem to Render
I am currently working with materialize CSS and it seems I've gotten snagged with the select fields.

I'm using the example provided from their site but unfortunately it it's rendering in the view whatsoever.  I was wondering if someone else might be able to help.

What I am trying to do is create a row with 2 end spacers that provide padding - then within the inner two row items there should be a search text input and a search select dropdown.

This is the example I'm working from: http://materializecss.com/forms.html

Thank you in advance.

Here is the snippet of code in question.

```<code><div class="row">
<form class="col s12">
    <div class="row">
        <div class="input-field col s2"></div>
        <div class="input-field col s5">
            <input id="icon_prefix" type="text" class="validate" />
            <label for="icon_prefix">Search</label>
        </div>
        <div class="input-field col s3">
            <label>Materialize Select</label>
            <select>
                <option value="" disabled="disabled" selected="selected">Choose your option</option>
                <option value="1">Option 1</option>
                <option value="2">Option 2</option>
                <option value="3">Option 3</option>
            </select>
        </div>
        <div class="input-field col s2"></div>
    </div>
</form>
</code>```

答:
This worked for me, no jquery or select wrapper with input class, just material.js and this vanilla js:

document.addEventListener('DOMContentLoaded', function() {
    var elems = document.querySelectorAll('select');
    var instances = M.FormSelect.init(elems);
});
```

As you can tell I got the materialize css actual style and not the browsers default.

Body:
I am currently working with materialize CSS and it seems I've gotten snagged with the select fields.

I'm using the example provided from their site but unfortunately it it's rendering in the view whatsoever.  I was wondering if someone else might be able to help.

What I am trying to do is create a row with 2 end spacers that provide padding - then within the inner two row items there should be a search text input and a search select dropdown.

This is the example I'm working from: http://materializecss.com/forms.html

Thank you in advance.

Here is the snippet of code in question.

<form class="col s12">

            <input id="icon_prefix" type="text" class="validate" />
            Search

            Materialize Select
            <select>
                <option value="" disabled="disabled" selected="selected">Choose your option</option>
                <option value="1">Option 1</option>
                <option value="2">Option 2</option>
                <option value="3">Option 3</option>
            </select>

</form>

Body:
This worked for me, no jquery or select wrapper with input class, just material.js and this vanilla js:

document.addEventListener('DOMContentLoaded', function() {
    var elems = document.querySelectorAll('select');
    var instances = M.FormSelect.init(elems);
});

As you can tell I got the materialize css actual style and not the browsers default.


问:
query result only returns one value
I want to see multiple values from my query but when I start this query, the result has only one value

```<code>function get_prove_associati($num) {
    $this->db->select("prove.*");
    $this->db->where("prove.numero",$num);
    return $this->db->get("prove")->row_array();
}
</code>```

In my db , there are four rows, not only one

答:
You got four types of returns:

row_array one value as an array

row one value as an object

result_array all values as an array

result all values as an object

Title: query result only returns one value

Body:
I want to see multiple values from my query but when I start this query, the result has only one value

function get_prove_associati($num) {
    $this->db->select("prove.*");
    $this->db->where("prove.numero",$num);
    return $this->db->get("prove")->row_array();
}

In my db , there are four rows, not only one