问:
MediaTransportControls with Custom Button and Flyout
In my app I have a MediaTransortControls Template which I copied from the default System templates and removed a couple of in-needed buttons and added one AppBarButton with a Flyout. The flyout only hosts a TextBlock control to show some data. It shows the data fine if the MediaPlayerElement is in non-full screen state but there is no data shown in the flyout as soon as the MediaPlayerElementgoes full screen.

I have no way to know that why is this causing an issue. The data gets updated in real time as normal when not in full screen but as long as you go full screen there is no data. When you come back you can see the data again.

Is this the normal behavior for the MediaPlayerElement?

Custom Template:

```<code>
                            <!-- New CommandBar Style -->

                            <!-- Style for Error Message text -->

                            <!-- Style for Position slider used in Media Transport Controls -->

                                                </Grid.Resources>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="*" />
                                                </Grid.RowDefinitions>

                        <Border x:Name="ControlPanel_ControlPanelVisibilityStates_Border">
                            <Grid x:Name="ControlPanelGrid"
                            Background="{ThemeResource SystemControlPageBackgroundAltMediumBrush}"
                            VerticalAlignment="Bottom"
                            RenderTransformOrigin="0.5,0.5">
                                <Grid.RenderTransform>
                                    <TranslateTransform x:Name="TranslateVertical"/>
                                </Grid.RenderTransform>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Border x:Name="ErrorBorder"
                                        Width="320"
                                        Height="96"
                                        Grid.ColumnSpan="3"
                                        HorizontalAlignment="Center"
                                        Background="{ThemeResource SystemControlPageBackgroundAltMediumBrush}"
                                        Visibility="Collapsed">
                                    <TextBlock x:Name="ErrorTextBlock"
                                               Style="{StaticResource MediaTextBlockStyle}"
                                               TextWrapping="WrapWholeWords"
                                               Margin="12" />
                                </Border>
                                <Border x:Name="MediaTransportControls_Timeline_Border" Grid.Column="1" Grid.Row="1">
                                    <Grid x:Name="MediaTransportControls_Timeline_Grid">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <Slider x:Name="ProgressSlider"
                                        Style="{StaticResource MediaSliderStyle}"
                                        Margin="12,0"
                                        MinWidth="80"
                                        Height="33"
                                        VerticalAlignment="Center"
                                        IsThumbToolTipEnabled="False" />
                                        <ProgressBar x:Name="BufferingProgressBar"
                                        Height="4"
                                        IsIndeterminate="True"
                                        IsHitTestVisible="False"
                                        VerticalAlignment="Top"
                                        Margin="0,2,0,0"
                                        Visibility="Collapsed" />
                                        <Grid x:Name="TimeTextGrid"
                                        Margin="12,0"
                                        Grid.Row="1"
                                        Height="15">
                                            <TextBlock x:Name="TimeElapsedElement"
                                            Style="{StaticResource MediaTextBlockStyle}"
                                            Margin="0"
                                            Text="00:00"
                                            HorizontalAlignment="Left"
                                            VerticalAlignment="Bottom"/>
                                            <TextBlock x:Name="TimeRemainingElement"
                                            Style="{StaticResource MediaTextBlockStyle}"
                                            Text="00:00"
                                            HorizontalAlignment="Right"
                                            VerticalAlignment="Bottom" />
                                        </Grid>
                                    </Grid>
                                </Border>
                                <Border x:Name="LeftSidePlayBorder"
                                Grid.Column="0"
                                Grid.Row="1"
                                Visibility="Collapsed">
                                    <AppBarButton x:Name="PlayPauseButtonOnLeft"
                                    Margin="0"
                                    VerticalAlignment="Center"
                                    Style="{StaticResource AppBarButtonStyle}">
                                        <AppBarButton.Icon>
                                            <SymbolIcon x:Name="PlayPauseSymbolLeft" Symbol="Play" />
                                        </AppBarButton.Icon>
                                    </AppBarButton>
                                </Border>
                                <Border x:Name="MediaTransportControls_Command_Border"
                                Grid.Column="1"
                                Grid.Row="2">
                                    <CommandBar x:Name="MediaControlsCommandBar"
                                                Margin="0,0"
                                                Style="{StaticResource CommandBarStyle}"
                                                IsDynamicOverflowEnabled="False">
                                        <CommandBar.PrimaryCommands>
                                            <AppBarButton x:Name='VolumeMuteButton'
                                            Style='{StaticResource AppBarButtonStyle}'
                                            MediaTransportControlsHelper.DropoutOrder='919'>
                                                <AppBarButton.Flyout>
                                                    <Flyout x:Name='VolumeFlyout' FlyoutPresenterStyle="{StaticResource FlyoutStyle}">
                                                        <StackPanel Orientation="Horizontal" >
                                                            <AppBarButton x:Name='AudioMuteButton'
                                                                Style='{StaticResource AppBarButtonStyle}'
                                                                VerticalAlignment='Center'
                                                                HorizontalAlignment='Center'
                                                                Margin='12'>
                                                                <AppBarButton.Icon>
                                                                    <SymbolIcon x:Name='AudioMuteSymbol' Symbol='Volume' />
                                                                </AppBarButton.Icon>
                                                            </AppBarButton>
                                                            <Slider x:Name='VolumeSlider'
                                                                  Value='50'
                                                                  IsThumbToolTipEnabled='False'
                                                                  Width='{ThemeResource MTCHorizontalVolumeSliderWidth}'
                                                                  VerticalAlignment='Center'
                                                                  HorizontalAlignment='Center'
                                                                  Margin='0'/>
                                                            <TextBlock x:Name='VolumeValue'
                                                                    Style='{StaticResource MediaTextBlockStyle}'
                                                                    Text="{Binding ElementName=VolumeSlider,Path=Value}"
                                                                    HorizontalAlignment='Center'
                                                                    VerticalAlignment='Center'
                                                                    Width='24'
                                                                    Margin='12'/>
                                                        </StackPanel>
                                                    </Flyout>
                                                </AppBarButton.Flyout>
                                                <AppBarButton.Icon>
                                                    <SymbolIcon x:Name='VolumeMuteSymbol' Symbol='Volume' />
                                                </AppBarButton.Icon>
                                            </AppBarButton>

                                            <AppBarButton x:Name='CCSelectionButton'
                                          Style='{StaticResource AppBarButtonStyle}'
                                          MediaTransportControlsHelper.DropoutOrder='15'
                                          Visibility='Collapsed'>
                                                <AppBarButton.Icon>
                                                    <FontIcon Glyph=""/>
                                                </AppBarButton.Icon>
                                            </AppBarButton>

                                            <AppBarButton x:Name="MediaInfoButton"
                                                          Style="{StaticResource AppBarButtonStyle}">
                                                <AppBarButton.Icon>
                                                    <FontIcon Glyph=""/>
                                                </AppBarButton.Icon>
                                                <AppBarButton.Flyout>
                                                    <Flyout FlyoutPresenterStyle="{StaticResource FlyoutStyle}">
                                                        <TextBlock Name="IBlock"
                                                                   Text="{Binding Path=VideoInfoText, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
                                                                   Style="{StaticResource BodyTextBlockStyle}"
                                                                   HorizontalAlignment="Center"
                                                                   VerticalAlignment="Center"/>
                                                    </Flyout>
                                                </AppBarButton.Flyout>
                                            </AppBarButton>
    <!-- This is the custom button "MediaInfoButton" which I added -->

                                            <AppBarSeparator/>

                                                                                <AppBarButton x:Name='PlayPauseButton'
                                            Style='{StaticResource AppBarButtonStyle}'
                                            MediaTransportControlsHelper.DropoutOrder='23'>
                                                <AppBarButton.Icon>
                                                    <SymbolIcon x:Name='PlayPauseSymbol' Symbol='Play' />
                                                </AppBarButton.Icon>
                                            </AppBarButton>

                                            <AppBarSeparator/>

                                            <AppBarButton x:Name='ZoomButton'
                                            Style='{StaticResource AppBarButtonStyle}'
                                            MediaTransportControlsHelper.DropoutOrder='9'>
                                                <AppBarButton.Icon>
                                                    <FontIcon Glyph=""/>
                                                </AppBarButton.Icon>
                                            </AppBarButton>
                                            <AppBarButton x:Name='CastButton'
                                            Style='{StaticResource AppBarButtonStyle}'
                                            MediaTransportControlsHelper.DropoutOrder='11'>
                                                <AppBarButton.Icon>
                                                    <FontIcon Glyph=""/>
                                                </AppBarButton.Icon>
                                            </AppBarButton>
                                            <AppBarButton x:Name='FullWindowButton'
                                            Style='{StaticResource AppBarButtonStyle}'
                                            MediaTransportControlsHelper.DropoutOrder='20'>
                                                <AppBarButton.Icon>
                                                    <SymbolIcon x:Name='FullWindowSymbol' Symbol='FullScreen' />
                                                </AppBarButton.Icon>
                                            </AppBarButton>

                                            <!--
                                            <AppBarButton x:Name='FastForwardButton'
                                          Style='{StaticResource AppBarButtonStyle}'
                                          MediaTransportControlsHelper.DropoutOrder='1'
                                          Visibility='Collapsed'>
                                                <AppBarButton.Icon>
                                                    <FontIcon Glyph=""/>
                                                </AppBarButton.Icon>
                                            </AppBarButton>
                                            <AppBarButton x:Name='NextTrackButton'
                                            Icon='Next'
                                            Style='{StaticResource AppBarButtonStyle}'
                                            MediaTransportControlsHelper.DropoutOrder='3'
                                            Visibility='Collapsed'/>
                                            <AppBarButton x:Name='SkipForwardButton'
                                            Style='{StaticResource AppBarButtonStyle}'
                                            MediaTransportControlsHelper.DropoutOrder='5'
                                            Visibility='Collapsed'>
                                                <AppBarButton.Icon>
                                                    <FontIcon Glyph=""/>
                                                </AppBarButton.Icon>
                                            </AppBarButton>
                                            <AppBarButton x:Name='PlaybackRateButton'
                                            Style='{StaticResource AppBarButtonStyle}'
                                            MediaTransportControlsHelper.DropoutOrder='10'
                                            Visibility='Collapsed'>
                                                <AppBarButton.Icon>
                                                    <FontIcon Glyph=""/>
                                                </AppBarButton.Icon>
                                            </AppBarButton>
                                            -->
                                            <!--
                                            <AppBarSeparator x:Name='RightSeparator'
                                            Height='0'
                                            Width ='0'
                                            Margin='0,0' />
                                            -->

                                        </CommandBar.PrimaryCommands>

                                        <CommandBar.SecondaryCommands>

                                        </CommandBar.SecondaryCommands>
                                    </CommandBar>
                                </Border>
                            </Grid>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</code>```

Note: I cant put the whole Template it's too big for the question body.

Images:

Can someone point out what I can do to make this work also in the full-screen?
Or maybe to hide the button altogether when the player is in full-screen?
Thanks

Update:

This is the Binding Property in code-behind:

```<code>    private string mediaInfo;
    public string VideoInfoText
    {
        get
        {
            if (mediaInfo == null || mediaInfo == "")
                return "Information will be shown when the video starts playing.";
            return mediaInfo;
        }
        set
        {
            if (value != mediaInfo)
            {
                mediaInfo = value;
                OnPropertyChanged();
            }
        }
    }
</code>```

This is the method that actually updates the data:

```<code>private async void MediaView_DownloadProgressChanged(MediaPlaybackSession sender, object args)
    {
        await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
        () =>
        {
            try
            {
                var i = MediaView.MediaPlayer.PlaybackSession.DownloadProgress;
                string p = sender.IsProtected ? "Protection enabled." : "Protection not available.";
                HtmlDocs.INotifyObject.VideoInfoText = $"DRM: {p}\nVideo Height: {sender.NaturalVideoHeight}\nVideo Width: {sender.NaturalVideoWidth}" +
                $"\n{string.Format("Video Stream Progress: {0:0.00}%", (i * 100))}";
            }
            catch (Exception)
            {

            }
        });

    }
</code>```

答: I got it working by setting the DataContext of the Custom class to the Binding object and it started showing the text in the full-screen. First the DataContext was only set in the main page that hosted the media player and it worked fine for non-full screen but in the full screen it only worked after setting the DataContext above.

Body:
In my app I have a MediaTransortControls Template which I copied from the default System templates and removed a couple of in-needed buttons and added one AppBarButton with a Flyout. The flyout only hosts a TextBlock control to show some data. It shows the data fine if the MediaPlayerElement is in non-full screen state but there is no data shown in the flyout as soon as the MediaPlayerElementgoes full screen.

I have no way to know that why is this causing an issue. The data gets updated in real time as normal when not in full screen but as long as you go full screen there is no data. When you come back you can see the data again.

Is this the normal behavior for the MediaPlayerElement?

Custom Template:

                                                </Grid.Resources>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="*" />
                                                </Grid.RowDefinitions>

                        <Border x:Name="ControlPanel_ControlPanelVisibilityStates_Border">
                            <Grid x:Name="ControlPanelGrid"
                            Background="{ThemeResource SystemControlPageBackgroundAltMediumBrush}"
                            VerticalAlignment="Bottom"
                            RenderTransformOrigin="0.5,0.5">
                                <Grid.RenderTransform>
                                    <TranslateTransform x:Name="TranslateVertical"/>
                                </Grid.RenderTransform>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Border x:Name="ErrorBorder"
                                        Width="320"
                                        Height="96"
                                        Grid.ColumnSpan="3"
                                        HorizontalAlignment="Center"
                                        Background="{ThemeResource SystemControlPageBackgroundAltMediumBrush}"
                                        Visibility="Collapsed">
                                    <TextBlock x:Name="ErrorTextBlock"
                                               Style="{StaticResource MediaTextBlockStyle}"
                                               TextWrapping="WrapWholeWords"
                                               Margin="12" />
                                </Border>
                                <Border x:Name="MediaTransportControls_Timeline_Border" Grid.Column="1" Grid.Row="1">
                                    <Grid x:Name="MediaTransportControls_Timeline_Grid">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <Slider x:Name="ProgressSlider"
                                        Style="{StaticResource MediaSliderStyle}"
                                        Margin="12,0"
                                        MinWidth="80"
                                        Height="33"
                                        VerticalAlignment="Center"
                                        IsThumbToolTipEnabled="False" />
                                        <ProgressBar x:Name="BufferingProgressBar"
                                        Height="4"
                                        IsIndeterminate="True"
                                        IsHitTestVisible="False"
                                        VerticalAlignment="Top"
                                        Margin="0,2,0,0"
                                        Visibility="Collapsed" />
                                        <Grid x:Name="TimeTextGrid"
                                        Margin="12,0"
                                        Grid.Row="1"
                                        Height="15">
                                            <TextBlock x:Name="TimeElapsedElement"
                                            Style="{StaticResource MediaTextBlockStyle}"
                                            Margin="0"
                                            Text="00:00"
                                            HorizontalAlignment="Left"
                                            VerticalAlignment="Bottom"/>
                                            <TextBlock x:Name="TimeRemainingElement"
                                            Style="{StaticResource MediaTextBlockStyle}"
                                            Text="00:00"
                                            HorizontalAlignment="Right"
                                            VerticalAlignment="Bottom" />
                                        </Grid>
                                    </Grid>
                                </Border>
                                <Border x:Name="LeftSidePlayBorder"
                                Grid.Column="0"
                                Grid.Row="1"
                                Visibility="Collapsed">
                                    <AppBarButton x:Name="PlayPauseButtonOnLeft"
                                    Margin="0"
                                    VerticalAlignment="Center"
                                    Style="{StaticResource AppBarButtonStyle}">
                                        <AppBarButton.Icon>
                                            <SymbolIcon x:Name="PlayPauseSymbolLeft" Symbol="Play" />
                                        </AppBarButton.Icon>
                                    </AppBarButton>
                                </Border>
                                <Border x:Name="MediaTransportControls_Command_Border"
                                Grid.Column="1"
                                Grid.Row="2">
                                    <CommandBar x:Name="MediaControlsCommandBar"
                                                Margin="0,0"
                                                Style="{StaticResource CommandBarStyle}"
                                                IsDynamicOverflowEnabled="False">
                                        <CommandBar.PrimaryCommands>
                                            <AppBarButton x:Name='VolumeMuteButton'
                                            Style='{StaticResource AppBarButtonStyle}'
                                            MediaTransportControlsHelper.DropoutOrder='919'>
                                                <AppBarButton.Flyout>
                                                    <Flyout x:Name='VolumeFlyout' FlyoutPresenterStyle="{StaticResource FlyoutStyle}">
                                                        <StackPanel Orientation="Horizontal" >
                                                            <AppBarButton x:Name='AudioMuteButton'
                                                                Style='{StaticResource AppBarButtonStyle}'
                                                                VerticalAlignment='Center'
                                                                HorizontalAlignment='Center'
                                                                Margin='12'>
                                                                <AppBarButton.Icon>
                                                                    <SymbolIcon x:Name='AudioMuteSymbol' Symbol='Volume' />
                                                                </AppBarButton.Icon>
                                                            </AppBarButton>
                                                            <Slider x:Name='VolumeSlider'
                                                                  Value='50'
                                                                  IsThumbToolTipEnabled='False'
                                                                  Width='{ThemeResource MTCHorizontalVolumeSliderWidth}'
                                                                  VerticalAlignment='Center'
                                                                  HorizontalAlignment='Center'
                                                                  Margin='0'/>
                                                            <TextBlock x:Name='VolumeValue'
                                                                    Style='{StaticResource MediaTextBlockStyle}'
                                                                    Text="{Binding ElementName=VolumeSlider,Path=Value}"
                                                                    HorizontalAlignment='Center'
                                                                    VerticalAlignment='Center'
                                                                    Width='24'
                                                                    Margin='12'/>
                                                        </StackPanel>
                                                    </Flyout>
                                                </AppBarButton.Flyout>
                                                <AppBarButton.Icon>
                                                    <SymbolIcon x:Name='VolumeMuteSymbol' Symbol='Volume' />
                                                </AppBarButton.Icon>
                                            </AppBarButton>

                                            <AppBarButton x:Name='CCSelectionButton'
                                          Style='{StaticResource AppBarButtonStyle}'
                                          MediaTransportControlsHelper.DropoutOrder='15'
                                          Visibility='Collapsed'>
                                                <AppBarButton.Icon>
                                                    <FontIcon Glyph=""/>
                                                </AppBarButton.Icon>
                                            </AppBarButton>

                                            <AppBarButton x:Name="MediaInfoButton"
                                                          Style="{StaticResource AppBarButtonStyle}">
                                                <AppBarButton.Icon>
                                                    <FontIcon Glyph=""/>
                                                </AppBarButton.Icon>
                                                <AppBarButton.Flyout>
                                                    <Flyout FlyoutPresenterStyle="{StaticResource FlyoutStyle}">
                                                        <TextBlock Name="IBlock"
                                                                   Text="{Binding Path=VideoInfoText, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
                                                                   Style="{StaticResource BodyTextBlockStyle}"
                                                                   HorizontalAlignment="Center"
                                                                   VerticalAlignment="Center"/>
                                                    </Flyout>
                                                </AppBarButton.Flyout>
                                            </AppBarButton>

                                            <AppBarSeparator/>

                                                                                <AppBarButton x:Name='PlayPauseButton'
                                            Style='{StaticResource AppBarButtonStyle}'
                                            MediaTransportControlsHelper.DropoutOrder='23'>
                                                <AppBarButton.Icon>
                                                    <SymbolIcon x:Name='PlayPauseSymbol' Symbol='Play' />
                                                </AppBarButton.Icon>
                                            </AppBarButton>

                                            <AppBarSeparator/>

                                            <AppBarButton x:Name='ZoomButton'
                                            Style='{StaticResource AppBarButtonStyle}'
                                            MediaTransportControlsHelper.DropoutOrder='9'>
                                                <AppBarButton.Icon>
                                                    <FontIcon Glyph=""/>
                                                </AppBarButton.Icon>
                                            </AppBarButton>
                                            <AppBarButton x:Name='CastButton'
                                            Style='{StaticResource AppBarButtonStyle}'
                                            MediaTransportControlsHelper.DropoutOrder='11'>
                                                <AppBarButton.Icon>
                                                    <FontIcon Glyph=""/>
                                                </AppBarButton.Icon>
                                            </AppBarButton>
                                            <AppBarButton x:Name='FullWindowButton'
                                            Style='{StaticResource AppBarButtonStyle}'
                                            MediaTransportControlsHelper.DropoutOrder='20'>
                                                <AppBarButton.Icon>
                                                    <SymbolIcon x:Name='FullWindowSymbol' Symbol='FullScreen' />
                                                </AppBarButton.Icon>
                                            </AppBarButton>

                                        </CommandBar.PrimaryCommands>

                                        <CommandBar.SecondaryCommands>

                                        </CommandBar.SecondaryCommands>
                                    </CommandBar>
                                </Border>
                            </Grid>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Note: I cant put the whole Template it's too big for the question body.

Images:

Can someone point out what I can do to make this work also in the full-screen?
Or maybe to hide the button altogether when the player is in full-screen?
Thanks

Update:

This is the Binding Property in code-behind:

    private string mediaInfo;
    public string VideoInfoText
    {
        get
        {
            if (mediaInfo == null || mediaInfo == "")
                return "Information will be shown when the video starts playing.";
            return mediaInfo;
        }
        set
        {
            if (value != mediaInfo)
            {
                mediaInfo = value;
                OnPropertyChanged();
            }
        }
    }

This is the method that actually updates the data:

private async void MediaView_DownloadProgressChanged(MediaPlaybackSession sender, object args)
    {
        await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
        () =>
        {
            try
            {
                var i = MediaView.MediaPlayer.PlaybackSession.DownloadProgress;
                string p = sender.IsProtected ? "Protection enabled." : "Protection not available.";
                HtmlDocs.INotifyObject.VideoInfoText = $"DRM: {p}\nVideo Height: {sender.NaturalVideoHeight}\nVideo Width: {sender.NaturalVideoWidth}" +
                $"\n{string.Format("Video Stream Progress: {0:0.00}%", (i * 100))}";
            }
            catch (Exception)
            {

            }
        });

    }


来源: stackexchange

问:
Given a set of positive integers <=k and its n subsets , find union of which pairs of subsets give the original set
I have a set A which consists of first p positive integers (1 to p), and I am given n subsets of this set. How can I find how many pair of subsets on union would give the original set A?

Of course this can be done naively by checking the size of the union of each pair and if it is equal to p , the union must make up the set A, but is there a more elegant way of doing this, which reduces the time complexity?

The set_union in c++ has a time complexity of 2*(size(set 1) + size(set 2)) - 1 which is not good for nC2 pairs.

答:
Just a possible improvement to your approach, instead of binary searching you can keep a boolean array to find out if some x appears in array i in O(1).

For example,
Let's say, when taking input you save all the appearances for an array i. Meaning, if x appears in array i, then isThere[i][x] should be true else false.

This can save some time.

ContentLicense: CC BY-SA 3.0


问:
How do I make Git treat a file as binary?
Having a problem with a medium sized project where visual studio project files keep having issues due to git treating them as text and merging. I'd like to just set the file as binary so that git won't auto merge these files ever.

Is there a way to do this?

答:
You should define binary file attributes in your .gitattributes file (create it if it doesn't exist) by  putting these lines in it, to prevent it to handle it as text diff file:

```<code># Define binary file attributes.
# - Do not treat them as text.
# - Include binary diff in patches instead of "binary files differ."
*.sln     -text diff
*.suo     -text diff
*.vcxproj -text diff
*.gif     -text diff
*.gz      -text diff
*.ico     -text diff
*.jpeg    -text diff
</code>```

Body:
You should define binary file attributes in your .gitattributes file (create it if it doesn't exist) by  putting these lines in it, to prevent it to handle it as text diff file:

# Define binary file attributes.
# - Do not treat them as text.
# - Include binary diff in patches instead of "binary files differ."
*.sln     -text diff
*.suo     -text diff
*.vcxproj -text diff
*.gif     -text diff
*.gz      -text diff
*.ico     -text diff
*.jpeg    -text diff


问:
First
 element in
 in same line
```<code><ul>
  <li>1</li>
  <ul>
    <li>a</li>
    <li>b</li>
    <li>c</li>
  </ul>
</ul>
</code>```

How would I display this list like so:

答:
You can add float: left to ul li and ul ul as follows:

1

a

b

c

```

Title: First <li> element in <ul> in same line

Body:
1

a

b

c

How would I display this list like so:

Body:
You can add float: left to ul li and ul ul as follows:

    <ul>
      <li style="float: left;">1</li>
      <ul style="float: left;">
        <li>a</li>
        <li>b</li>
        <li>c</li>
      </ul>
    </ul>


问:
How to create typed dataset which can have optional attributes in Spark 2.1
I have a need to use Datasets in Spark which can hold entities with some known attributes but also list of unknown at compile-time attributes as well. I need a simple way to pass those optional attributes through the computation pipeline and not to bother with them.

Made up code example:

```<code>> loaded.show
root
 |-- key: long (nullable = true)
 |-- value: string (nullable = true)
 |-- opt1: string (nullable = true)
 |-- opt2: long (nullable = true)
</code>```

Let's imagine only key and value I know and care about at compile-time.

```<code>case class BusinessEntity(key: Long, value: String) {
  def businessLogic = this
}
</code>```

If I convert dataframe to typed data set extra attributes are obviously lost.

```<code>loaded.as[BusinessEntity].map(_.businessLogic).toDF.printSchema
root
 |-- key: long (nullable = true)
 |-- value: string (nullable = true)
</code>```

What I need to be able to do is to have them stored somewhere in the entity so at the very end of the computation pipeline (which can contain joins etc) I was able to extract them to target storage.

I could imagine using some of the following approaches to store optional data

```<code>case class BusinessEntity(key: String, value: String, extra: Row)
dataset.select("key", "value", "row.*")

case class BusinessEntity(key: String, value: String, extra: Map[String, AnyVal])
dataset.select($"key", $"value",
/* Generate at runtime from attr list */
$"extra"("opt1").cast("long").as("opt2"),
$"extra"("opt2").cast("long").as("opt2"))

case class BusinessEntity(key: String, value: String, extra: List[AnyVal])
dataset.select($"key", $"value",
/* Generate at runtime from attr list */
$"extra"(0).cast("long").as("opt1"),
$"extra"(1).cast("long").as("opt2"))
</code>```

But neither of them wouldn't work because Spark can't generate encoders for Row/Map[?, AnyVal]/List[AnyVal]. So far I can only think of storing optional attributes as JSON-encoded string, but I can think of it as a last resort; or using Encoders.kryo to generate encoder for Map of AnyVal's. Am I missing something and there's easier way to target such problem?

答:
I would just define the optional values in my case class as Option and give them None as default value:

```<code>case class BusinessEntity(key: Long, value: String, opt1:Option[String]=None, opt2:Option[Long]=None)
</code>```

Body:
I have a need to use Datasets in Spark which can hold entities with some known attributes but also list of unknown at compile-time attributes as well. I need a simple way to pass those optional attributes through the computation pipeline and not to bother with them.

Made up code example:

> loaded.show
root
 |-- key: long (nullable = true)
 |-- value: string (nullable = true)
 |-- opt1: string (nullable = true)
 |-- opt2: long (nullable = true)

Let's imagine only key and value I know and care about at compile-time.

case class BusinessEntity(key: Long, value: String) {
  def businessLogic = this
}

If I convert dataframe to typed data set extra attributes are obviously lost.

loaded.as[BusinessEntity].map(_.businessLogic).toDF.printSchema
root
 |-- key: long (nullable = true)
 |-- value: string (nullable = true)

What I need to be able to do is to have them stored somewhere in the entity so at the very end of the computation pipeline (which can contain joins etc) I was able to extract them to target storage.

I could imagine using some of the following approaches to store optional data

case class BusinessEntity(key: String, value: String, extra: Row)
dataset.select("key", "value", "row.*")

case class BusinessEntity(key: String, value: String, extra: Map[String, AnyVal])
dataset.select($"key", $"value",
/* Generate at runtime from attr list */
$"extra"("opt1").cast("long").as("opt2"),
$"extra"("opt2").cast("long").as("opt2"))

case class BusinessEntity(key: String, value: String, extra: List[AnyVal])
dataset.select($"key", $"value",
/* Generate at runtime from attr list */
$"extra"(0).cast("long").as("opt1"),
$"extra"(1).cast("long").as("opt2"))

But neither of them wouldn't work because Spark can't generate encoders for Row/Map[?, AnyVal]/List[AnyVal]. So far I can only think of storing optional attributes as JSON-encoded string, but I can think of it as a last resort; or using Encoders.kryo to generate encoder for Map of AnyVal's. Am I missing something and there's easier way to target such problem?

Body:
I would just define the optional values in my case class as Option and give them None as default value:

case class BusinessEntity(key: Long, value: String, opt1:Option[String]=None, opt2:Option[Long]=None)


问:
Is it a Security Issue in Codeigniter which Allow to Run Controller Functions using URL?
I am not sure that this is a security  issue or I understand something wrongly? That's why I ask this question.

As I understood, Anyone can run any controller function using URL. Assume that I have a controller function called delete in controller called user.

So anyone can run that function using

```<code>http://example.com/index.php/user/delete
</code>```

Is it a securty issue?

I mean in pure PHP, you can't run any function via URL even you know the custom function name.

But seems like anyone can run any function in Codeigniter Controller if they know the controller name and function name. Is it a security issue or I understand something wrongly?

答:
it's no any security issue.
But you say you use delete function so set any delete parameter value.
if use any parameter for delete any row value then use as below url format
http://www.example.com/index.php/user/delete/id/1
may be it's work. or describe more in details then i help to you.</p>

Body:
I am not sure that this is a security  issue or I understand something wrongly? That's why I ask this question.

As I understood, Anyone can run any controller function using URL. Assume that I have a controller function called delete in controller called user.

So anyone can run that function using

http://example.com/index.php/user/delete

Is it a securty issue?

I mean in pure PHP, you can't run any function via URL even you know the custom function name.

But seems like anyone can run any function in Codeigniter Controller if they know the controller name and function name. Is it a security issue or I understand something wrongly?


答:
use display:inline-block in your nested ul tag, along with vertical-align:top

a

b

c

```

Title: First <li> element in <ul> in same line

Body:
use display:inline-block in your nested ul tag, along with vertical-align:top

<ul>
  <li>
  <ul style="display:inline-block;vertical-align:top;">
    <li>a</li>
    <li>b</li>
    <li>c</li>
  </ul>
  </li>
</ul>


问:
How to set up stylesheet in QT to choose random image for wiget background?
So I'm trying to choose random image from file system of my pc and make it background in wiget. So thats why I'm opening QFileDialog and using it. qDebug gives me right path to the image, but still it doesn't work.

```<code>void ChatWindow::on_actionImage_triggered()
{
    QString fileName = QFileDialog::getOpenFileName(
        this, tr("Open file"), "/home", tr("Images(*.jpg)")
    );
    QString filePath(fileName);
    qDebug () << filePath;
    setStyleSheet(
        "ChatWindow{border-image:url(:" +
            filePath +
        ") 0 0 0 0 stretch stretch;}"
    );

    QGraphicsOpacityEffect * effect1 =
        new QGraphicsOpacityEffect(ui->messageHistory);
    effect1->setOpacity(0.8);
    ui->messageHistory->setGraphicsEffect(effect1);
    ui->messageHistory->setStyleSheet("background-color: white;");

    QGraphicsOpacityEffect * effect2 =
        new QGraphicsOpacityEffect(ui->roomTree);
    effect2->setOpacity(0.8);
    ui->roomTree->setGraphicsEffect(effect2);
    ui->roomTree->setStyleSheet("background-color: white;");

    QGraphicsOpacityEffect * effect3 =
        new QGraphicsOpacityEffect(ui->messageInput);
    effect3->setOpacity(0.8);
    ui->messageInput->setGraphicsEffect(effect3);

    ui->sendButton->setStyleSheet("background-color: none;");
}
</code>```

I've seen this one Unable to set the background image in Qt Stylesheet related to my problem, but in my case it doesn't work.

答:
According to the documentation, there is no such property called border-image: what you're searching for is background-image.

Moreover, since you're also specifying other background's parameters, you should use background.

Moreover, since your file is on the disk and not in the resources, the url should not start with :: type url(" + filePath + ") instead of url(:" + filePath + ").

The corrected syntax:

```<code>setStyleSheet(
    "ChatWindow{background:url(" +
        filePath +
    ") 0 0 0 0 stretch stretch;}"
);
</code>```

Body:
So I'm trying to choose random image from file system of my pc and make it background in wiget. So thats why I'm opening QFileDialog and using it. qDebug gives me right path to the image, but still it doesn't work.

void ChatWindow::on_actionImage_triggered()
{
    QString fileName = QFileDialog::getOpenFileName(
        this, tr("Open file"), "/home", tr("Images(*.jpg)")
    );
    QString filePath(fileName);
    qDebug () << filePath;
    setStyleSheet(
        "ChatWindow{border-image:url(:" +
            filePath +
        ") 0 0 0 0 stretch stretch;}"
    );

    QGraphicsOpacityEffect * effect1 =
        new QGraphicsOpacityEffect(ui->messageHistory);
    effect1->setOpacity(0.8);
    ui->messageHistory->setGraphicsEffect(effect1);
    ui->messageHistory->setStyleSheet("background-color: white;");

    QGraphicsOpacityEffect * effect2 =
        new QGraphicsOpacityEffect(ui->roomTree);
    effect2->setOpacity(0.8);
    ui->roomTree->setGraphicsEffect(effect2);
    ui->roomTree->setStyleSheet("background-color: white;");

    QGraphicsOpacityEffect * effect3 =
        new QGraphicsOpacityEffect(ui->messageInput);
    effect3->setOpacity(0.8);
    ui->messageInput->setGraphicsEffect(effect3);

    ui->sendButton->setStyleSheet("background-color: none;");
}

I've seen this one Unable to set the background image in Qt Stylesheet related to my problem, but in my case it doesn't work.

Body:
According to the documentation, there is no such property called border-image: what you're searching for is background-image.

Moreover, since you're also specifying other background's parameters, you should use background.

Moreover, since your file is on the disk and not in the resources, the url should not start with :: type url(" + filePath + ") instead of url(:" + filePath + ").

The corrected syntax:

setStyleSheet(
    "ChatWindow{background:url(" +
        filePath +
    ") 0 0 0 0 stretch stretch;}"
);


问:
django get_available_name() got an unexpected keyword argument 'max_length'
I want to override files with the my django Model. So if I upload 'one' and later upload 'two', 'two' should override 'one' (on the file system). But I get an error.

This is my model:

```<code>class StudentAssignment(models.Model):
    file0 = models.FileField(upload_to=use_solution_path, storage=OverwriteStorage(), validators=[validate_file_extension])
</code>```

This is the storage.

```<code>import os
from django.conf import settings
from django.core.files.storage import FileSystemStorage

class OverwriteStorage(FileSystemStorage):
    def get_available_name(self, name):
        """
        Returns a filename that's free on the target storage system, and
        available for new content to be written to.
        """
        # If the filename already exists, remove it as if it was a true file system
        if self.exists(name):
            os.remove(os.path.join(settings.MEDIA_ROOT, name))
        return name
</code>```

The Error:

```<code>  [...]
  File "/home/mb/.local/lib/python3.5/site-packages/django/db/models/fields/files.py", line 95, in save
self.name = self.storage.save(name, content, max_length=self.field.max_length)
  File "/home/mb/.local/lib/python3.5/site-packages/django/core/files/storage.py", line 53, in save
name = self.get_available_name(name, max_length=max_length)
TypeError: get_available_name() got an unexpected keyword argument 'max_length'
</code>```

I am new to django and have no idea how to go on. Can someone help? Thanks :)

答:
Change

```<code>def get_available_name(self, name):
</code>```

to

```<code>def get_available_name(self, name, max_length=None):
</code>```

Body:
I want to override files with the my django Model. So if I upload 'one' and later upload 'two', 'two' should override 'one' (on the file system). But I get an error.

This is my model:

class StudentAssignment(models.Model):
    file0 = models.FileField(upload_to=use_solution_path, storage=OverwriteStorage(), validators=[validate_file_extension])

This is the storage.

import os
from django.conf import settings
from django.core.files.storage import FileSystemStorage

class OverwriteStorage(FileSystemStorage):
    def get_available_name(self, name):
        """
        Returns a filename that's free on the target storage system, and
        available for new content to be written to.
        """
        # If the filename already exists, remove it as if it was a true file system
        if self.exists(name):
            os.remove(os.path.join(settings.MEDIA_ROOT, name))
        return name

The Error:

  [...]
  File "/home/mb/.local/lib/python3.5/site-packages/django/db/models/fields/files.py", line 95, in save
self.name = self.storage.save(name, content, max_length=self.field.max_length)
  File "/home/mb/.local/lib/python3.5/site-packages/django/core/files/storage.py", line 53, in save
name = self.get_available_name(name, max_length=max_length)
TypeError: get_available_name() got an unexpected keyword argument 'max_length'

I am new to django and have no idea how to go on. Can someone help? Thanks :)

Body:
Change

def get_available_name(self, name):

to

def get_available_name(self, name, max_length=None):


问:
How to convert String to Json
I have a servlet in Java and I would like to know how I can do the following.

I have a String variable with the value of a name and want to create a Json with the variable being something like {"name": "David"}.

How do I do this?

I have the following code but I get an error :

```<code>   Serious: Servlet.service () for servlet threw
   exception servlet.UsuarioServlet java.lang.NullPointerException
               at servlet.UsuarioServlet.doPost (UsuarioServlet.java: 166):
</code>```

at line

```<code>String myString = new JSONObject().put("name", "Hello, World!").toString();
</code>```

答:
I tried with GSON, GSON is directly convert your JSONString to java class object.

Example:

```<code>String jsonString = {"phoneNumber": "8888888888"}
</code>```

create a new class:

```<code>class Phone {

@SerializedName("phoneNumber")
private String phoneNumebr;

public void setPhoneNumber(String phoneNumebr) {
this.phoneNumebr = phoneNumebr;
}

public String getPhoneNumebr(){
return phoneNumber;
}

}
</code>```

// in java

```<code>Gson gson = new Gson();
Phone phone = gson.fromJson(jsonString, Phone.class);

System.out.println(" Phone number is "+phone.getPhoneNumebr());
</code>```

Title: How to convert String to Json

Body:
I have a servlet in Java and I would like to know how I can do the following.

I have a String variable with the value of a name and want to create a Json with the variable being something like {"name": "David"}.

How do I do this?

I have the following code but I get an error :

   Serious: Servlet.service () for servlet threw
   exception servlet.UsuarioServlet java.lang.NullPointerException
               at servlet.UsuarioServlet.doPost (UsuarioServlet.java: 166):

at line

String myString = new JSONObject().put("name", "Hello, World!").toString();

Body:
I tried with GSON, GSON is directly convert your JSONString to java class object.

Example:

String jsonString = {"phoneNumber": "8888888888"}

create a new class:

class Phone {

@SerializedName("phoneNumber")
private String phoneNumebr;

public void setPhoneNumber(String phoneNumebr) {
this.phoneNumebr = phoneNumebr;
}

public String getPhoneNumebr(){
return phoneNumber;
}

}

// in java

Gson gson = new Gson();
Phone phone = gson.fromJson(jsonString, Phone.class);

System.out.println(" Phone number is "+phone.getPhoneNumebr());


问:
SSIS - Splitting String into multiple rows
Looking for some advice really. I've got a dataset for school attendance data that comes into me as: student_id, school_id, term_start_date, attendance_marks.

An example line of this data would be:

```<code>1234, 1002, 2016-09-01, '/\##/L/\##BB/\/\/\/\/\'
</code>```

The attendance marks string is basically two sessions per day, each mark corresponds to various different codes. Basically, I get a start date and then have to work out each day's attendance mark going forward from that... horrible I know, but that's how I get the data I'm afraid.

I've written a script object to loop through this string and output a row for each day to get loaded into a data warehouse.

I should say before posting the code that this script works, it does what I need it to do... but it is painfully slow. I'm hoping I can draw upon the collective experience here to see if there is a more efficient way of achieving this?

```<code>public override void Input0_ProcessInputRow(Input0Buffer Row)
{
    int studentID = Row.STUDDENTID;
    int baseID = Row.SCHOOLID;
    DateTime dateKey = Row.STARTDATE;
    string marks = Row.MARKS.ToString();

    // TODO
    // This is a bodge at the moment to make sure the mark string is always divisible by 2
    // in the production release I'll have to handle this as an exception
    if (marks.Length % 2 != 0)
    {
        marks = marks + '@';
    }

    char[] c = marks.ToCharArray();

    for (int i = 0; i < c.Length; i += 2)
    {
        Output0Buffer.AddRow();
        Output0Buffer.baseID = baseID;
        Output0Buffer.studentID = studentID;
        Output0Buffer.dateKey = dateKey.AddDays(i / 2).Year * 10000 + dateKey.AddDays(i / 2).Month * 100 + dateKey.AddDays(i / 2).Day;
        Output0Buffer.markAM = c[i].ToString();
        Output0Buffer.markPM = c[i + 1].ToString();

        if (i == c.Length - 1)
        {
            base.FinishOutputs();
        }
    }
}
</code>```

Is there a better way of doing this? Have I massively overthought it or do I just have to live with it taking ages to run? Thanks in advance.

答:
This could probably be written in Oracle Pl-SQL, though I neither work with Oracle nor recommend you doing transformations within your live system as part of the extract

If you load your data as is into a SQL Server staging environment, you can then return it in your OLEDB Source component using the script that utilises a derived tally table to split out the Attendance string into one character per row.  This will work with multiple students, schools and days (ie: it is a proper set based solution), so can be used as a one pass fetch that will return your entire dataset:

```<code>-- Create test data
declare @d table(StudentID int,SchoolID int, AttDate date, Attendance nvarchar(500));
insert into @d values
 (1234, 1002, '20160901', '/\##/L/\##BB/\/\/\/\')
,(1235, 1002, '20160901', '/\##/L/\##/\BB/\/\/\')
,(1234, 1002, '20160902', '/\##/L/\##BB/\/\/\/\/\')
,(1235, 1002, '20160902', '/\##/L/\/\BB/\/\##/\/\');

              -- Create a list of 10 rows
with n(n) as (select n from (values(1),(1),(1),(1),(1),(1),(1),(1),(1),(1)) n(n))
              -- Cross join 6 times to reach 1,000,000 numbers if required.  Filtered to longest Attendance string in the SELECT TOP()
    ,t(t) as (select top (select max(len(Attendance)) from @d) row_number() over (order by (select null)) from n n1,n n2,n n3,n n4,n n5,n n6)
select d.StudentID
        ,d.SchoolID
        ,d.AttDate
        ,d.Attendance
        ,t.t as AttCharNum
        ,substring(d.Attendance,t.t,1) as AttChar  -- Use SUBSTRING to retreive just the one character
from @d d
    join t  -- Join to numbers only where they are actually required
        on t.t <= len(d.Attendance)
order by d.StudentID
        ,d.AttDate
        ,t.t;
</code>```

Output:

```<code>+-----------+----------+------------+------------------------+------------+---------+
| StudentID | SchoolID |  AttDate   |       Attendance       | AttCharNum | AttChar |
+-----------+----------+------------+------------------------+------------+---------+
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          1 | /       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          2 | \       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          3 | #       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          4 | #       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          5 | /       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          6 | L       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          7 | /       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          8 | \       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          9 | #       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         10 | #       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         11 | B       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         12 | B       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         13 | /       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         14 | \       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         15 | /       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         16 | \       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         17 | /       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         18 | \       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         19 | /       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         20 | \       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          1 | /       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          2 | \       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          3 | #       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          4 | #       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          5 | /       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          6 | L       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          7 | /       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          8 | \       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          9 | #       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         10 | #       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         11 | B       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         12 | B       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         13 | /       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         14 | \       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         15 | /       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         16 | \       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         17 | /       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         18 | \       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         19 | /       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         20 | \       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         21 | /       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         22 | \       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          1 | /       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          2 | \       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          3 | #       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          4 | #       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          5 | /       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          6 | L       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          7 | /       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          8 | \       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          9 | #       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         10 | #       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         11 | /       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         12 | \       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         13 | B       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         14 | B       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         15 | /       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         16 | \       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         17 | /       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         18 | \       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         19 | /       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         20 | \       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          1 | /       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          2 | \       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          3 | #       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          4 | #       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          5 | /       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          6 | L       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          7 | /       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          8 | \       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          9 | /       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         10 | \       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         11 | B       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         12 | B       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         13 | /       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         14 | \       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         15 | /       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         16 | \       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         17 | #       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         18 | #       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         19 | /       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         20 | \       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         21 | /       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         22 | \       |
+-----------+----------+------------+------------------------+------------+---------+
</code>```

Body:
Looking for some advice really. I've got a dataset for school attendance data that comes into me as: student_id, school_id, term_start_date, attendance_marks.

An example line of this data would be:

1234, 1002, 2016-09-01, '/\##/L/\##BB/\/\/\/\/\'

The attendance marks string is basically two sessions per day, each mark corresponds to various different codes. Basically, I get a start date and then have to work out each day's attendance mark going forward from that... horrible I know, but that's how I get the data I'm afraid.

I've written a script object to loop through this string and output a row for each day to get loaded into a data warehouse.

I should say before posting the code that this script works, it does what I need it to do... but it is painfully slow. I'm hoping I can draw upon the collective experience here to see if there is a more efficient way of achieving this?

public override void Input0_ProcessInputRow(Input0Buffer Row)
{
    int studentID = Row.STUDDENTID;
    int baseID = Row.SCHOOLID;
    DateTime dateKey = Row.STARTDATE;
    string marks = Row.MARKS.ToString();

    // TODO
    // This is a bodge at the moment to make sure the mark string is always divisible by 2
    // in the production release I'll have to handle this as an exception
    if (marks.Length % 2 != 0)
    {
        marks = marks + '@';
    }

    char[] c = marks.ToCharArray();

    for (int i = 0; i < c.Length; i += 2)
    {
        Output0Buffer.AddRow();
        Output0Buffer.baseID = baseID;
        Output0Buffer.studentID = studentID;
        Output0Buffer.dateKey = dateKey.AddDays(i / 2).Year * 10000 + dateKey.AddDays(i / 2).Month * 100 + dateKey.AddDays(i / 2).Day;
        Output0Buffer.markAM = c[i].ToString();
        Output0Buffer.markPM = c[i + 1].ToString();

        if (i == c.Length - 1)
        {
            base.FinishOutputs();
        }
    }
}

Is there a better way of doing this? Have I massively overthought it or do I just have to live with it taking ages to run? Thanks in advance.

Body:
This could probably be written in Oracle Pl-SQL, though I neither work with Oracle nor recommend you doing transformations within your live system as part of the extract

If you load your data as is into a SQL Server staging environment, you can then return it in your OLEDB Source component using the script that utilises a derived tally table to split out the Attendance string into one character per row.  This will work with multiple students, schools and days (ie: it is a proper set based solution), so can be used as a one pass fetch that will return your entire dataset:

-- Create test data
declare @d table(StudentID int,SchoolID int, AttDate date, Attendance nvarchar(500));
insert into @d values
 (1234, 1002, '20160901', '/\##/L/\##BB/\/\/\/\')
,(1235, 1002, '20160901', '/\##/L/\##/\BB/\/\/\')
,(1234, 1002, '20160902', '/\##/L/\##BB/\/\/\/\/\')
,(1235, 1002, '20160902', '/\##/L/\/\BB/\/\##/\/\');

              -- Create a list of 10 rows
with n(n) as (select n from (values(1),(1),(1),(1),(1),(1),(1),(1),(1),(1)) n(n))
              -- Cross join 6 times to reach 1,000,000 numbers if required.  Filtered to longest Attendance string in the SELECT TOP()
    ,t(t) as (select top (select max(len(Attendance)) from @d) row_number() over (order by (select null)) from n n1,n n2,n n3,n n4,n n5,n n6)
select d.StudentID
        ,d.SchoolID
        ,d.AttDate
        ,d.Attendance
        ,t.t as AttCharNum
        ,substring(d.Attendance,t.t,1) as AttChar  -- Use SUBSTRING to retreive just the one character
from @d d
    join t  -- Join to numbers only where they are actually required
        on t.t <= len(d.Attendance)
order by d.StudentID
        ,d.AttDate
        ,t.t;

Output:

+-----------+----------+------------+------------------------+------------+---------+
| StudentID | SchoolID |  AttDate   |       Attendance       | AttCharNum | AttChar |
+-----------+----------+------------+------------------------+------------+---------+
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          1 | /       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          2 | \       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          3 | #       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          4 | #       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          5 | /       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          6 | L       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          7 | /       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          8 | \       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |          9 | #       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         10 | #       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         11 | B       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         12 | B       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         13 | /       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         14 | \       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         15 | /       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         16 | \       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         17 | /       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         18 | \       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         19 | /       |
|      1234 |     1002 | 2016-09-01 | /\##/L/\##BB/\/\/\/\   |         20 | \       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          1 | /       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          2 | \       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          3 | #       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          4 | #       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          5 | /       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          6 | L       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          7 | /       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          8 | \       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |          9 | #       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         10 | #       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         11 | B       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         12 | B       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         13 | /       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         14 | \       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         15 | /       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         16 | \       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         17 | /       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         18 | \       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         19 | /       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         20 | \       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         21 | /       |
|      1234 |     1002 | 2016-09-02 | /\##/L/\##BB/\/\/\/\/\ |         22 | \       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          1 | /       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          2 | \       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          3 | #       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          4 | #       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          5 | /       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          6 | L       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          7 | /       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          8 | \       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |          9 | #       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         10 | #       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         11 | /       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         12 | \       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         13 | B       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         14 | B       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         15 | /       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         16 | \       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         17 | /       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         18 | \       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         19 | /       |
|      1235 |     1002 | 2016-09-01 | /\##/L/\##/\BB/\/\/\   |         20 | \       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          1 | /       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          2 | \       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          3 | #       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          4 | #       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          5 | /       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          6 | L       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          7 | /       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          8 | \       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |          9 | /       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         10 | \       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         11 | B       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         12 | B       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         13 | /       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         14 | \       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         15 | /       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         16 | \       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         17 | #       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         18 | #       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         19 | /       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         20 | \       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         21 | /       |
|      1235 |     1002 | 2016-09-02 | /\##/L/\/\BB/\/\##/\/\ |         22 | \       |
+-----------+----------+------------+------------------------+------------+---------+


问:
jQuery - Hide DIV which has a span element with certain text inside
I have several divs with the same class names and varying IDs. The ID is not set for the text I need to target

I need to target the Telephone Call text. If the div contains that text, how do I hide the containing div

```<code><div id="rn_FieldDisplay_155" class="rn_FieldDisplay rn_Output">
   <span class="rn_DataLabel">Telephone Call </span>
   <div class="rn_DataValue">No</div>
</div>
</code>```

I have tried the following to no avail

```<code><script>
$(document).ready(function() {
  $(".rn_FieldDisplay > span:contains('Telephone Call')").hide ();
});
</script>
</code>```

答:
Try with find() function

$(document).ready(function() {
    $(".rn_FieldDisplay").find(":contains('Telephone Call')").hide ();
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="rn_FieldDisplay_155" class="rn_FieldDisplay rn_Output">
    <span class="rn_DataLabel">Telephone Call </span>
    <div class="rn_DataValue">No</div>
        <p class="rn_DataLabel">Telephone Call </p>
</div></code>```

Body:
I have several divs with the same class names and varying IDs. The ID is not set for the text I need to target

I need to target the Telephone Call text. If the div contains that text, how do I hide the containing div

   Telephone Call

No

I have tried the following to no avail

Body:
Try with find() function

$(document).ready(function() {
    $(".rn_FieldDisplay").find(":contains('Telephone Call')").hide ();
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="rn_FieldDisplay_155" class="rn_FieldDisplay rn_Output">
    <span class="rn_DataLabel">Telephone Call </span>
    <div class="rn_DataValue">No</div>
        <p class="rn_DataLabel">Telephone Call </p>
</div>


问:
Using the bootstrap modal in the angular2, closing modal will shake
When I open the window, the page wider, I think it is the problem of the scroll bar, could you tell me how to solve in angular2?

it is a list:

```<code><tbody>
    <tr *ngFor="let interview of interviews;" role="row" class="gradeA">
      <td class="col-sm-2" style="text-align: left;">{{ interview.company.name }}</td>
      <td class="col-sm-1" style="text-align: left;">{{ interview.inviter.real_name }}</td>
      <td class="col-sm-1" style="text-align: left;" *ngIf="interview.interviewee.user_id==0">未知</td>
      <td class="col-sm-1" style="text-align: left;" *ngIf="interview.interviewee.user_id!=0">{{ interview.interviewee.real_name }}</td>
      <td class="col-sm-1" style="text-align: left;" *ngIf="interview.notice_type==0">
        <a data-toggle="modal" data-target="#modal" (click)="showModal(interview)">短信</a>
      </td>
      <td class="col-sm-1" style="text-align: left;" *ngIf="interview.notice_type==1">
        <a data-toggle="modal" data-target="#modal" (click)="showModal(interview)">邮件</a>
      </td>
      <td class="col-sm-1" style="text-align: left;">{{ interview.interview_time }}</td>
      <td class="col-sm-1" style="text-align: left;" *ngIf="interview.status==0">发起面试</td>
      <td class="col-sm-1" style="text-align: left;" *ngIf="interview.status==1">确认面试时间</td>
      <td class="col-sm-1" style="text-align: left;" *ngIf="interview.status==2">面试完成</td>
      <td class="col-sm-1" style="text-align: left;" *ngIf="interview.status==3">面试者没有参加面试</td>
    </tr>
</tbody>
</code>```

the modal:

```<code><div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
        <h4 class="modal-title" id="myModalLabel">通知内容</h4>
      </div>
      <div class="modal-body" *ngIf="selectedInterview !== undefined">
        <span style="font-weight:bold;">公司名称：</span><p>{{ selectedInterview.company.name }}</p>
        <span style="font-weight:bold;">面试官：</span><p>{{ selectedInterview.inviter.real_name }}</p>
        <span style="font-weight:bold;">应聘者：</span><p>{{ selectedInterview.interviewee.real_name }}</p>
        <span style="font-weight:bold;">通知内容：</span><p>{{ selectedInterview.notice_content }}</p>
      </div>
    </div>
  </div>
</div>
</code>```

showmodal method:

```<code>selectedInterview: any;
showModal(interviewObj) {
this.selectedInterview = interviewObj;
}
</code>```

答: This is not Angular issue, its CSS problem. Try to give the parent div some width. If you could share your code then it will be easier to solve the problem.

Body:
When I open the window, the page wider, I think it is the problem of the scroll bar, could you tell me how to solve in angular2?

it is a list:

      {{ interview.company.name }}
      {{ interview.inviter.real_name }}
      未知
      {{ interview.interviewee.real_name }}

        短信

        邮件

      {{ interview.interview_time }}
      发起面试
      确认面试时间
      面试完成
      面试者没有参加面试

the modal:

        <button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>

通知内容

        公司名称：
{{ selectedInterview.company.name }}

        面试官：
{{ selectedInterview.inviter.real_name }}

        应聘者：
{{ selectedInterview.interviewee.real_name }}

        通知内容：
{{ selectedInterview.notice_content }}

showmodal method:

selectedInterview: any;
showModal(interviewObj) {
this.selectedInterview = interviewObj;
}


答:
The documentation for file storage classes clearly shows that get_available_name takes a max_length keyword argument. So you need to at least accept that argument, even if you don't use it.

```<code>def get_available_name(self, name, max_length=None):
</code>```

Title: django get_available_name() got an unexpected keyword argument 'max_length'

Body:
The documentation for file storage classes clearly shows that get_available_name takes a max_length keyword argument. So you need to at least accept that argument, even if you don't use it.

def get_available_name(self, name, max_length=None):


问:
is it possible to covert json string in php?
Is it possible to decode this by json_decode method?

```<code>[{"sample1":{"t":"{a={b=1},c={d=2}}"}, "sample2" : "something"}]
</code>```

I'm getting NULL while decoding {a={b=1},c={d=2}}.

Anyone help me?

答: There is json_decode and json_encode, but your string is not valid JSON. It should be [{"sample1":{"t":"{"a":{"b":1},"c":{"d":2}}"}, "sample2" : "something"}]

Body:
Is it possible to decode this by json_decode method?

[{"sample1":{"t":"{a={b=1},c={d=2}}"}, "sample2" : "something"}]

I'm getting NULL while decoding {a={b=1},c={d=2}}.

Anyone help me?


问:
mkdir throws 'unknown option' error
I have a problem with mkdir command.
When I run mkdir -p "-AFolder", I am getting the following error:

```<code>mkdir: unknown option -- A
</code>```

What's is causing the error?

答:
In addition to the -- convention that mkdir supports, you can also prepend the directory name with ./.

```<code>mkdir ./-AFolder
</code>```

Title: mkdir throws 'unknown option' error

Body:
I have a problem with mkdir command.
When I run mkdir -p "-AFolder", I am getting the following error:

mkdir: unknown option -- A

What's is causing the error?

Body:
In addition to the -- convention that mkdir supports, you can also prepend the directory name with ./.

mkdir ./-AFolder


问:
Correct naming of properties in Angular2+
I want to write this:

```<code>private _name:string;
public get name():string{
    return this._name;
}
</code>```

But the Angular Style Guide advise against it: https://angular.io/styleguide#!#03-04

Am I thinking wrong?
What should I use instead?

答:
What you're using is TypeScript standard. Since you can't name your variable name, because get name() will be compiled to whatever.name, you have to use the underscore.

Angular isn't any different there because it uses TypeScript itself. They just say you should use name if you don't have a specific getter or setter method for that property.

I don't know if your code is just an example but it wouldn't make sense since the property name simply would be public in the end anyway.

Body:
I want to write this:

private _name:string;
public get name():string{
    return this._name;
}

But the Angular Style Guide advise against it: https://angular.io/styleguide#!#03-04

Am I thinking wrong?
What should I use instead?


问:
Lambda variable names - to short name, or not to short name?
Typically, when I use lambdas, I just use "a, b, c, d..." as variable names as the types are easily inferred, and I find short names to be easier to read.  Here is an example:

```<code>var someEnumerable = GetSomeEnumerable();
var somethingElseList = someEnumerable.Select(a => a.SomeProperty)
                                      .OrderBy(a => a.SomePropertyField);
var someDictionary = somethingElseList.ToDictionary(a => new SomeClass(a.Prop1),
                                                    a => a);
</code>```

Some question this naming, and would prefer to see long typed out names, like this:

```<code>var someEnumerable = GetSomeEnumerable();
var somethingElseList = someEnumerable.Select(importantObj => importantObj.SomeProperty)
                                      .OrderBy(objsInfo => objsInfo.SomePropertyField);
var someDictionary = somethingElseList.ToDictionary(theInfoId => new SomeClass(theInfoId.Prop1),
                                                    theInfoId2 => theInfoId2);
</code>```

Since the scope is so narrow (between the parens), unless you're getting stupid and nesting them, I find it easier to read short names.

Without getting caught up in the silly naming examples I used above, what is the general consensus on Lambda variable names?  To short name, or not to short name?

答:
I go with one, two or three letters, which form an abbreviated representation of the object in question.</p>

```<code>Persons.Where(p => ...)
AnalysisCode.Where(ac => ...)
</code>```

OwnerDisplayName: TheSoftwareJedi

ContentLicense: CC BY-SA 2.5

Body:
Typically, when I use lambdas, I just use "a, b, c, d..." as variable names as the types are easily inferred, and I find short names to be easier to read.  Here is an example:

var someEnumerable = GetSomeEnumerable();
var somethingElseList = someEnumerable.Select(a => a.SomeProperty)
                                      .OrderBy(a => a.SomePropertyField);
var someDictionary = somethingElseList.ToDictionary(a => new SomeClass(a.Prop1),
                                                    a => a);

Some question this naming, and would prefer to see long typed out names, like this:

var someEnumerable = GetSomeEnumerable();
var somethingElseList = someEnumerable.Select(importantObj => importantObj.SomeProperty)
                                      .OrderBy(objsInfo => objsInfo.SomePropertyField);
var someDictionary = somethingElseList.ToDictionary(theInfoId => new SomeClass(theInfoId.Prop1),
                                                    theInfoId2 => theInfoId2);

Since the scope is so narrow (between the parens), unless you're getting stupid and nesting them, I find it easier to read short names.

Without getting caught up in the silly naming examples I used above, what is the general consensus on Lambda variable names?  To short name, or not to short name?

LastEditorDisplayName: TheSoftwareJedi

Body:
I go with one, two or three letters, which form an abbreviated representation of the object in question.

Persons.Where(p => ...)
AnalysisCode.Where(ac => ...)

OwnerDisplayName: Yaakov Ellis


问:
Finding orders made within any ISO week of a specific year using T-SQL
As part of a reporting setup, I have a SQL query fetching the number of orders placed each week:

```<code>select datepart(isowk, order_date), count(*)
from orders where year(order_date) = @Year
group by datepart(isowk, order_date), year(order_date)
order by 1
</code>```

Note that I am using the new isowk format in the datepart function call, as business in Denmark typically use ISO week numbers.

Running this query with @Year = 2010 yields a result set simialar to this:

```<code>1           5
2           7
3           10
...
53          3
</code>```

You and I both know that 2010 isn't over yet, and certainly there has been no week 53 yet. Actually, there has - the first three days of the year belonged to ISO week 53 of 2009. While it might be possible to explain this to other programmers, the people who are going to read my reports are never going to understand this. Hence, I want to get rid of this week 53, by "moving" the data over to 2009.

How can I rewrite my WHERE clause to filter the data set to orders made between monday of week 1 and friday of the last week (52 or 53) in the year defined as @Year?

答:
You could try this:

```<code>set datefirst 1;

declare @Year smallint = 2010;

declare @DayInFirstWeek datetime = cast(@Year as varchar)+'0104';
declare @FirstDayInFirstWeek datetime =
             @DayInFirstWeek - datepart(dw,@DayInFirstWeek)+1
declare @DayInFirstWeekNextYear datetime = cast(@Year+1 as varchar)+'0104';
declare @LastDayInLastWeek datetime =
             @DayInFirstWeekNextYear - datepart(dw,@DayInFirstWeekNextYear);

select datepart(isowk, order_date), count(*)
from orders
where order_date between @FirstDayInFirstWeek and @LastDayInLastWeek
group by datepart(isowk, order_date)
order by 1;
</code>```

If your first day of week isn't Monday it perhaps won't work!

Body:
As part of a reporting setup, I have a SQL query fetching the number of orders placed each week:

select datepart(isowk, order_date), count(*)
from orders where year(order_date) = @Year
group by datepart(isowk, order_date), year(order_date)
order by 1

Note that I am using the new isowk format in the datepart function call, as business in Denmark typically use ISO week numbers.

Running this query with @Year = 2010 yields a result set simialar to this:

1           5
2           7
3           10
...
53          3

You and I both know that 2010 isn't over yet, and certainly there has been no week 53 yet. Actually, there has - the first three days of the year belonged to ISO week 53 of 2009. While it might be possible to explain this to other programmers, the people who are going to read my reports are never going to understand this. Hence, I want to get rid of this week 53, by "moving" the data over to 2009.

How can I rewrite my WHERE clause to filter the data set to orders made between monday of week 1 and friday of the last week (52 or 53) in the year defined as @Year?

Body:
You could try this:

set datefirst 1;

declare @Year smallint = 2010;

declare @DayInFirstWeek datetime = cast(@Year as varchar)+'0104';
declare @FirstDayInFirstWeek datetime =
             @DayInFirstWeek - datepart(dw,@DayInFirstWeek)+1
declare @DayInFirstWeekNextYear datetime = cast(@Year+1 as varchar)+'0104';
declare @LastDayInLastWeek datetime =
             @DayInFirstWeekNextYear - datepart(dw,@DayInFirstWeekNextYear);

select datepart(isowk, order_date), count(*)
from orders
where order_date between @FirstDayInFirstWeek and @LastDayInLastWeek
group by datepart(isowk, order_date)
order by 1;

If your first day of week isn't Monday it perhaps won't work!


问:
About the screen on in android application
I have an Android application and I want to keep the screen on. But sometimes I don't want to keep the screen on. What can I do to that?

EDIT: I have already used this code to set my screen on:

```<code>getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
</code>```

答:
See the docs - either

```<code>android:keepScreenOn="true"
</code>```

in layout or programatically

```<code>getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
</code>```

https://developer.android.com/training/scheduling/wakelock.html

Body:
I have an Android application and I want to keep the screen on. But sometimes I don't want to keep the screen on. What can I do to that?

EDIT: I have already used this code to set my screen on:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

Body:
See the docs - either

android:keepScreenOn="true"

in layout or programatically

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

https://developer.android.com/training/scheduling/wakelock.html


问:
Submitting two applications on same apache spark cluster spawns driver processes on same JVM or on different
I have a question. In case I submit two applications on same spark cluster in yarn-client mode will it spawn two driver processes for each application on same JVM or different JVM will be spawned for each driver process on client host?

Also If I submit two applications on same spark cluster in yarn-cluster mode will it create two different application master process for each application and then these master processes will take care of each application in different JVM or only one Application master process is created for all applications submitted to spark cluster and each driver process run under this one master process in a single JVM?

答: In the client mode each application will use separate driver process running in its own local JVM. Also each application will have its own, remote master, responsible for requesting resources.</p>


问:
Column count of mysql.user is wrong. Expected 42, found 44. The table is probably corrupted
Currently I'm using the newest version of ISPConfig 3. Today I wanted to add a db and user. It didn't work. Then I tried it on PHPmyadmin and it didn't work.

When I tried to add a user in PHPMyadmin Users Panel I received the following error message:

You have an error in your SQL syntax; check the manual that
  corresponds to your MySQL server version for the right syntax to use
  near '* TO 'test'@'localhost'' at line 1

The output from /var/log/mysql/error.log:

[ERROR] Column count of mysql.user is wrong. Expected 42, found 44.
  The table is probably corrupted

Mysql Version: 5.5.55-0+deb8u1
PHPMyadmin Version: 4:4.2.12-2+deb8u2

Debian Linux 8

答:
I've ran into the same issue today..
The solution for me was to manually add the missing columns to the user table.

Beware - Use at your own risk

The newly added columns with mysql.5.5.55 are:

```<code>plugin, authentication_string, Create_tablespace_priv
</code>```

They need to be added in a specific oder:

```<code>use mysql;
alter Table user ADD Create_tablespace_priv enum('N','Y')  DEFAULT 'N' NOT NULL AFTER Trigger_priv;
alter Table user ADD plugin char(64) DEFAULT '';
alter Table user ADD authentication_string text DEFAULT NULL;
</code>```

After this, I was able to again, modify the user table.

Body:
I've ran into the same issue today..
The solution for me was to manually add the missing columns to the user table.

Beware - Use at your own risk

The newly added columns with mysql.5.5.55 are:

plugin, authentication_string, Create_tablespace_priv

They need to be added in a specific oder:

use mysql;
alter Table user ADD Create_tablespace_priv enum('N','Y')  DEFAULT 'N' NOT NULL AFTER Trigger_priv;
alter Table user ADD plugin char(64) DEFAULT '';
alter Table user ADD authentication_string text DEFAULT NULL;

After this, I was able to again, modify the user table.


答:
Your question is not clear, but I guess you are looking for this. You can do this grammatically.

Keep Screen Awake

or Add this to your layout

```<code><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true">
...
</RelativeLayout>
</code>```

Title: About the screen on in android application

Body:
Your question is not clear, but I guess you are looking for this. You can do this grammatically.

Keep Screen Awake

or Add this to your layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true">
...
</RelativeLayout>