问:
How to set the ToolTip in only one control?
I have use the ToolTip with Behavior. So, when click on the control, ToolTip will be appear.

However, when change the disabled of control, this ToolTip is not appeared.
Because, mouse events were not activated. So, i was used the ContentContorl and it can be activate the mouse event when change the disabled.

But, when i have several control in one Grid, i dont know that how to activate the only one control.

```<code><Window.Resources>
    <Style TargetType="ContentControl" >
        <Setter Property="localToolTip:ToolTipTouchScreenBehavior.IsEnabled" Value="True"/>
    </Style>
    <Style TargetType="TextBlock" >
        <Setter Property="localToolTip:ToolTipTouchScreenBehavior.IsEnabled" Value="True"/>
    </Style>
</Window.Resources>

<ContentControl ToolTip="This is ToolTip5 Test.">
            <Grid IsEnabled="False">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="300"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <TextBlock  HorizontalAlignment="Left" Margin="5" TextWrapping="Wrap" Text="ToolTip Test5"  FontSize="25"
                            ToolTipService.ShowOnDisabled="True" />
                <TextBox Grid.Column="1" Width="200" />

            </Grid>
</ContentControl>

public class ToolTipTouchScreenBehavior : Behavior<FrameworkElement>
{

    public static DependencyProperty IsEnabledProperty =
        DependencyProperty.RegisterAttached("IsEnabled", typeof(bool),
            typeof(ToolTipTouchScreenBehavior), new FrameworkPropertyMetadata(false, OnIsEnabledChanged));

    public static bool GetIsEnabled(DependencyObject uie)
    {
        return (bool)uie.GetValue(IsEnabledProperty);
    }

    public static void SetIsEnabled(DependencyObject uie, bool value)
    {
        uie.SetValue(IsEnabledProperty, value);
    }

    public static void OnIsEnabledChanged(DependencyObject dpo, DependencyPropertyChangedEventArgs e)
    {

        UIElement uie = dpo as UIElement;

        if (uie != null)
        {

            var behColl = Interaction.GetBehaviors(uie);

            var existingBehavior = behColl.FirstOrDefault(b => b.GetType() ==
                  typeof(ToolTipTouchScreenBehavior)) as ToolTipTouchScreenBehavior;

            if ((bool)e.NewValue == false && existingBehavior != null)
                behColl.Remove(existingBehavior);
            else if ((bool)e.NewValue == true && existingBehavior == null)
                behColl.Add(new ToolTipTouchScreenBehavior());

        }

    }

    Timer timer { get; set; }
    ToolTip toolTip { get; set; }

    protected override void OnAttached()
    {
        base.OnAttached();

        toolTip = new ToolTip();

        timer = new Timer();
        timer.Interval = 5000;
        timer.Elapsed += OnTimerElapsed;

        AssociatedObject.MouseLeave += OnMouseLeave;
        AssociatedObject.MouseLeftButtonUp += OnMouseLeftButtonUp;

    }

    protected override void OnDetaching()
    {
        base.OnDetaching();

        AssociatedObject.MouseLeave -= OnMouseLeave;
        AssociatedObject.MouseLeftButtonUp -= OnMouseLeftButtonUp;
    }

    public void OnMouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
    {
        CloseToolTip();
    }

    public void OnMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
    {
        try
        {

            //var temp = AssociatedObject.ToolTip;
            //if (((dynamic)sender).ToolTip != null)
            if (AssociatedObject.ToolTip != null)
            {
                if (AssociatedObject.ToolTip is string)
                    toolTip.Content = AssociatedObject.ToolTip;
                else
                    toolTip = (ToolTip)AssociatedObject.ToolTip;

                //Debug.WriteLine("ToolTip Opened: {0}, ToolTip Value: {1}", toolTip.IsOpen, toolTip.ToolTip);

                toolTip.IsOpen = true;
                timer.Start();

            }
        }
        catch (Exception ex)
        {
            throw ex;
        }

    }

    private void CloseToolTip()
    {

        if (timer.Enabled)
        {
            timer.Stop();
        }

        if (toolTip != null)
        {
            toolTip.IsOpen = false;
        }
    }

    private void OnTimerElapsed(object sender, ElapsedEventArgs e)
    {
        Application.Current.Dispatcher.BeginInvoke((Action)CloseToolTip, DispatcherPriority.Send);
    }

}
</code>```

When i have above code, i just want to add the ToolTip for only TextBlock. not TextBox.

How to apply the ToolTip to only one special control?

答:
If you want to react to mouse interaction for an disabled element, you can add a visual to the adorner layer (which will stay enabled for a disabled underlying element) and capture input there. The following is just a rough sketch with an Adorner that executes an arbitrary action on MouseLeftButtonUp only for disabled controls and an attached property to connect the adorner to some framework element (you may want to utilize your behavior instead).

```<code>public class DisabledMouseUpAdorner : Adorner
{
    private Border _Child;
    private Action _OnDisabledMouseUp;

    public DisabledMouseUpAdorner(FrameworkElement element, Action onDisabledMouseUp)
        : base(element)
    {
        _OnDisabledMouseUp = onDisabledMouseUp;
        _Child = new Border();
        _Child.MouseLeftButtonUp += Adorner_Click;
        // actually you probably want an invisible adorner, but for demonstration lets add some color
        //_Child.Background = new SolidColorBrush(Colors.Transparent);
        _Child.Background = new SolidColorBrush(new Color() { A = 20, R = 255, G = 0, B = 0 });
        _Child.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
        _Child.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
        _Child.IsHitTestVisible = !element.IsEnabled;
        element.IsEnabledChanged += Adorned_IsEnabledChanged;
        AddVisualChild(_Child);
    }

    void Adorned_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
    {
        _Child.IsHitTestVisible = !AdornedElement.IsEnabled;
    }

    void Adorner_Click(object sender, RoutedEventArgs e)
    {
        if (_OnDisabledMouseUp != null)
        {
            _OnDisabledMouseUp();
        }
    }

    protected override int VisualChildrenCount
    { get { return 1; } }

    protected override Visual GetVisualChild(int index)
    {
        if (index != 0) throw new ArgumentOutOfRangeException();
        return _Child;
    }

    protected override Size MeasureOverride(Size constraint)
    {
        _Child.Measure(constraint);
        return base.MeasureOverride(constraint);
    }

    protected override Size ArrangeOverride(Size finalSize)
    {
        _Child.Arrange(new Rect(new Point(0, 0), finalSize));
        return finalSize;
    }
}

public static class Attached
{
    public static bool GetToolTipOnClickEnabled(DependencyObject obj)
    {
        return (bool)obj.GetValue(ToolTipOnClickEnabledProperty);
    }

    public static void SetToolTipOnClickEnabled(DependencyObject obj, bool value)
    {
        obj.SetValue(ToolTipOnClickEnabledProperty, value);
    }

    // Using a DependencyProperty as the backing store for ToolTipOnClickEnabled.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty ToolTipOnClickEnabledProperty =
        DependencyProperty.RegisterAttached("ToolTipOnClickEnabled", typeof(bool), typeof(Attached), new PropertyMetadata(false, new PropertyChangedCallback(OnToolTipOnClickChanged)));

    private static void OnToolTipOnClickChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        var element = d as FrameworkElement;

        if (element != null)
        {
            if (element.IsLoaded)
            {
                if ((bool)e.NewValue == true)
                {
                    AddOverlay(element);
                }
                else
                {
                    RemoveOverlay(element);
                }
            }
            else
            {
                element.Loaded -= Element_Loaded;
                element.Loaded += Element_Loaded;
            }
        }
    }

    private static void Element_Loaded(object sender, RoutedEventArgs e)
    {
        var elem = sender as FrameworkElement;
        elem.Loaded -= Element_Loaded;
        if (GetToolTipOnClickEnabled(elem))
        {
            AddOverlay(elem);
        }
        else
        {
            RemoveOverlay(elem);
        }
    }

    private static void RemoveOverlay(FrameworkElement element)
    {
        var adl = AdornerLayer.GetAdornerLayer(element);
        var ad = adl.GetAdorners(element);
        foreach (var item in ad)
        {
            if (item is DisabledMouseUpAdorner) adl.Remove(item);
        }
    }

    private static void AddOverlay(FrameworkElement element)
    {
        var a = AdornerLayer.GetAdornerLayer(element);
        if (a != null)
        {
            a.Add(new DisabledMouseUpAdorner(element, () => ClickHandler(element)));
        }
        else
        {
        }
    }

    // whatever you actually want to do when the adorner triggers
    private static void ClickHandler(FrameworkElement element)
    {
        if (element.ToolTip == null)
        {
            return;
        }
        var tt = element.ToolTip as ToolTip ?? new ToolTip() { Content = element.ToolTip, StaysOpen = false };
        tt.IsOpen = true;
    }
}
</code>```

Usage

```<code><TextBlock Text="ToolTip Test5"  FontSize="25"
    ToolTip="Shows on click when disabled"
    local:Attached.ToolTipOnClickEnabled="True" />
</code>```

Body:
I have use the ToolTip with Behavior. So, when click on the control, ToolTip will be appear.

However, when change the disabled of control, this ToolTip is not appeared.
Because, mouse events were not activated. So, i was used the ContentContorl and it can be activate the mouse event when change the disabled.

But, when i have several control in one Grid, i dont know that how to activate the only one control.

<Window.Resources>

</Window.Resources>

<ContentControl ToolTip="This is ToolTip5 Test.">
            <Grid IsEnabled="False">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="300"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <TextBlock  HorizontalAlignment="Left" Margin="5" TextWrapping="Wrap" Text="ToolTip Test5"  FontSize="25"
                            ToolTipService.ShowOnDisabled="True" />
                <TextBox Grid.Column="1" Width="200" />

            </Grid>
</ContentControl>

public class ToolTipTouchScreenBehavior : Behavior<FrameworkElement>
{

    public static DependencyProperty IsEnabledProperty =
        DependencyProperty.RegisterAttached("IsEnabled", typeof(bool),
            typeof(ToolTipTouchScreenBehavior), new FrameworkPropertyMetadata(false, OnIsEnabledChanged));

    public static bool GetIsEnabled(DependencyObject uie)
    {
        return (bool)uie.GetValue(IsEnabledProperty);
    }

    public static void SetIsEnabled(DependencyObject uie, bool value)
    {
        uie.SetValue(IsEnabledProperty, value);
    }

    public static void OnIsEnabledChanged(DependencyObject dpo, DependencyPropertyChangedEventArgs e)
    {

        UIElement uie = dpo as UIElement;

        if (uie != null)
        {

            var behColl = Interaction.GetBehaviors(uie);

            var existingBehavior = behColl.FirstOrDefault(b => b.GetType() ==
                  typeof(ToolTipTouchScreenBehavior)) as ToolTipTouchScreenBehavior;

            if ((bool)e.NewValue == false && existingBehavior != null)
                behColl.Remove(existingBehavior);
            else if ((bool)e.NewValue == true && existingBehavior == null)
                behColl.Add(new ToolTipTouchScreenBehavior());

        }

    }

    Timer timer { get; set; }
    ToolTip toolTip { get; set; }

    protected override void OnAttached()
    {
        base.OnAttached();

        toolTip = new ToolTip();

        timer = new Timer();
        timer.Interval = 5000;
        timer.Elapsed += OnTimerElapsed;

        AssociatedObject.MouseLeave += OnMouseLeave;
        AssociatedObject.MouseLeftButtonUp += OnMouseLeftButtonUp;

    }

    protected override void OnDetaching()
    {
        base.OnDetaching();

        AssociatedObject.MouseLeave -= OnMouseLeave;
        AssociatedObject.MouseLeftButtonUp -= OnMouseLeftButtonUp;
    }

    public void OnMouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
    {
        CloseToolTip();
    }

    public void OnMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
    {
        try
        {

            //var temp = AssociatedObject.ToolTip;
            //if (((dynamic)sender).ToolTip != null)
            if (AssociatedObject.ToolTip != null)
            {
                if (AssociatedObject.ToolTip is string)
                    toolTip.Content = AssociatedObject.ToolTip;
                else
                    toolTip = (ToolTip)AssociatedObject.ToolTip;

                //Debug.WriteLine("ToolTip Opened: {0}, ToolTip Value: {1}", toolTip.IsOpen, toolTip.ToolTip);

                toolTip.IsOpen = true;
                timer.Start();

            }
        }
        catch (Exception ex)
        {
            throw ex;
        }

    }

    private void CloseToolTip()
    {

        if (timer.Enabled)
        {
            timer.Stop();
        }

        if (toolTip != null)
        {
            toolTip.IsOpen = false;
        }
    }

    private void OnTimerElapsed(object sender, ElapsedEventArgs e)
    {
        Application.Current.Dispatcher.BeginInvoke((Action)CloseToolTip, DispatcherPriority.Send);
    }

}

When i have above code, i just want to add the ToolTip for only TextBlock. not TextBox.

How to apply the ToolTip to only one special control?

Body:
If you want to react to mouse interaction for an disabled element, you can add a visual to the adorner layer (which will stay enabled for a disabled underlying element) and capture input there. The following is just a rough sketch with an Adorner that executes an arbitrary action on MouseLeftButtonUp only for disabled controls and an attached property to connect the adorner to some framework element (you may want to utilize your behavior instead).

public class DisabledMouseUpAdorner : Adorner
{
    private Border _Child;
    private Action _OnDisabledMouseUp;

    public DisabledMouseUpAdorner(FrameworkElement element, Action onDisabledMouseUp)
        : base(element)
    {
        _OnDisabledMouseUp = onDisabledMouseUp;
        _Child = new Border();
        _Child.MouseLeftButtonUp += Adorner_Click;
        // actually you probably want an invisible adorner, but for demonstration lets add some color
        //_Child.Background = new SolidColorBrush(Colors.Transparent);
        _Child.Background = new SolidColorBrush(new Color() { A = 20, R = 255, G = 0, B = 0 });
        _Child.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
        _Child.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
        _Child.IsHitTestVisible = !element.IsEnabled;
        element.IsEnabledChanged += Adorned_IsEnabledChanged;
        AddVisualChild(_Child);
    }

    void Adorned_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
    {
        _Child.IsHitTestVisible = !AdornedElement.IsEnabled;
    }

    void Adorner_Click(object sender, RoutedEventArgs e)
    {
        if (_OnDisabledMouseUp != null)
        {
            _OnDisabledMouseUp();
        }
    }

    protected override int VisualChildrenCount
    { get { return 1; } }

    protected override Visual GetVisualChild(int index)
    {
        if (index != 0) throw new ArgumentOutOfRangeException();
        return _Child;
    }

    protected override Size MeasureOverride(Size constraint)
    {
        _Child.Measure(constraint);
        return base.MeasureOverride(constraint);
    }

    protected override Size ArrangeOverride(Size finalSize)
    {
        _Child.Arrange(new Rect(new Point(0, 0), finalSize));
        return finalSize;
    }
}

public static class Attached
{
    public static bool GetToolTipOnClickEnabled(DependencyObject obj)
    {
        return (bool)obj.GetValue(ToolTipOnClickEnabledProperty);
    }

    public static void SetToolTipOnClickEnabled(DependencyObject obj, bool value)
    {
        obj.SetValue(ToolTipOnClickEnabledProperty, value);
    }

    // Using a DependencyProperty as the backing store for ToolTipOnClickEnabled.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty ToolTipOnClickEnabledProperty =
        DependencyProperty.RegisterAttached("ToolTipOnClickEnabled", typeof(bool), typeof(Attached), new PropertyMetadata(false, new PropertyChangedCallback(OnToolTipOnClickChanged)));

    private static void OnToolTipOnClickChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        var element = d as FrameworkElement;

        if (element != null)
        {
            if (element.IsLoaded)
            {
                if ((bool)e.NewValue == true)
                {
                    AddOverlay(element);
                }
                else
                {
                    RemoveOverlay(element);
                }
            }
            else
            {
                element.Loaded -= Element_Loaded;
                element.Loaded += Element_Loaded;
            }
        }
    }

    private static void Element_Loaded(object sender, RoutedEventArgs e)
    {
        var elem = sender as FrameworkElement;
        elem.Loaded -= Element_Loaded;
        if (GetToolTipOnClickEnabled(elem))
        {
            AddOverlay(elem);
        }
        else
        {
            RemoveOverlay(elem);
        }
    }

    private static void RemoveOverlay(FrameworkElement element)
    {
        var adl = AdornerLayer.GetAdornerLayer(element);
        var ad = adl.GetAdorners(element);
        foreach (var item in ad)
        {
            if (item is DisabledMouseUpAdorner) adl.Remove(item);
        }
    }

    private static void AddOverlay(FrameworkElement element)
    {
        var a = AdornerLayer.GetAdornerLayer(element);
        if (a != null)
        {
            a.Add(new DisabledMouseUpAdorner(element, () => ClickHandler(element)));
        }
        else
        {
        }
    }

    // whatever you actually want to do when the adorner triggers
    private static void ClickHandler(FrameworkElement element)
    {
        if (element.ToolTip == null)
        {
            return;
        }
        var tt = element.ToolTip as ToolTip ?? new ToolTip() { Content = element.ToolTip, StaysOpen = false };
        tt.IsOpen = true;
    }
}

Usage

<TextBlock Text="ToolTip Test5"  FontSize="25"
    ToolTip="Shows on click when disabled"
    local:Attached.ToolTipOnClickEnabled="True" />


来源: stackexchange

问:
Execute command in rkt container, output results, then exit
I'm looking for a rkt command that is equivalent to the following docker command:

```<code>docker run nginx:1.11.5 find / -perm +6000 -type f -exec ls -ld {} \; 2> /dev/null
</code>```

The docker command creates a new container from nginx:1.11.5, executes find / -perm +6000 -type f -exec ls -ld {} \; 2> /dev/null within the container (which prints all binaries with setuid and setgid permissions to stdout), and then kills the container. The results look something like this:

```<code>root@localhost:~# docker run nginx:1.11.5 find / -perm +6000 -type f -exec ls -ld {} \; 2> /dev/null
-rwsr-xr-x 1 root root 40168 Nov 18  2015 /bin/su
-rwsr-xr-x 1 root root 40000 Mar 29  2015 /bin/mount
-rwsr-xr-x 1 root root 27416 Mar 29  2015 /bin/umount
-rwsr-xr-x 1 root root 61392 Oct 28  2014 /bin/ping6
-rwsr-xr-x 1 root root 70576 Oct 28  2014 /bin/ping
-rwsr-xr-x 1 root root 53616 Nov 18  2015 /usr/bin/chfn
-rwsr-xr-x 1 root root 39912 Nov 18  2015 /usr/bin/newgrp
-rwxr-sr-x 1 root tty 27232 Mar 29  2015 /usr/bin/wall
-rwsr-xr-x 1 root root 54192 Nov 18  2015 /usr/bin/passwd
-rwxr-sr-x 1 root shadow 22744 Nov 18  2015 /usr/bin/expiry
-rwsr-xr-x 1 root root 75376 Nov 18  2015 /usr/bin/gpasswd
-rwsr-xr-x 1 root root 44464 Nov 18  2015 /usr/bin/chsh
-rwxr-sr-x 1 root shadow 62272 Nov 18  2015 /usr/bin/chage
-rwxr-sr-x 1 root shadow 35408 Jan 28  2016 /sbin/unix_chkpwd
</code>```

This is what I've tried so far:

```<code>rkt run --insecure-options=image --net=host docker://nginx find / -perm +6000 -type f -exec ls -ld {} \; 2> /dev/null
</code>```

and

```<code>rkt run --insecure-options=image --net=host docker://nginx --exec find / -perm +6000 -type f -exec ls -ld {} \; 2> /dev/null
</code>```

both of which return no output.

I can acquire the information I want by overriding the initial command with --exec /bin/bash and adding the --interactive flag like so:

```<code>root@localhost:~# rkt run --interactive --insecure-options=image --net=host docker://nginx --exec /bin/bash
root@rkt-b5452809-0253-4da4-8026-d678c9bf7929:/# find / -perm +6000 -type f -exec ls -ld {} \; 2> /dev/null
-rwxr-sr-x 1 root shadow 35408 Jan 28  2016 /sbin/unix_chkpwd
-rwsr-xr-x 1 root root 40000 Mar 29  2015 /bin/mount
-rwsr-xr-x 1 root root 61392 Oct 28  2014 /bin/ping6
-rwsr-xr-x 1 root root 40168 Nov 18  2015 /bin/su
-rwsr-xr-x 1 root root 27416 Mar 29  2015 /bin/umount
-rwsr-xr-x 1 root root 70576 Oct 28  2014 /bin/ping
-rwxr-sr-x 1 root tty 27232 Mar 29  2015 /usr/bin/wall
-rwsr-xr-x 1 root root 75376 Nov 18  2015 /usr/bin/gpasswd
-rwsr-xr-x 1 root root 44464 Nov 18  2015 /usr/bin/chsh
-rwsr-xr-x 1 root root 53616 Nov 18  2015 /usr/bin/chfn
-rwsr-xr-x 1 root root 54192 Nov 18  2015 /usr/bin/passwd
-rwxr-sr-x 1 root shadow 62272 Nov 18  2015 /usr/bin/chage
-rwxr-sr-x 1 root shadow 22744 Nov 18  2015 /usr/bin/expiry
-rwsr-xr-x 1 root root 39912 Nov 18  2015 /usr/bin/newgrp
root@rkt-b5452809-0253-4da4-8026-d678c9bf7929:/# exit
exit
root@localhost:~#
</code>```

How would I do this in one command?

答:
You need to use -- to pass arguments to an image.

```<code>root@localhost:~# rkt run --insecure-options=image --net=host docker://nginx --exec find -- / -perm +6000 -type f -exec ls -ld {} \; 2> /dev/null
[ 4356.161333] nginx[5]: -rwxr-sr-x 1 root shadow 62272 Feb 24 08:09 /usr/bin/chage
[ 4356.163359] nginx[5]: -rwsr-xr-x 1 root root 53616 Feb 24 08:09 /usr/bin/chfn
[ 4356.165202] nginx[5]: -rwsr-xr-x 1 root root 44464 Feb 24 08:09 /usr/bin/chsh
[ 4356.167506] nginx[5]: -rwxr-sr-x 1 root shadow 22744 Feb 24 08:09 /usr/bin/expiry
[ 4356.169553] nginx[5]: -rwsr-xr-x 1 root root 75376 Feb 24 08:09 /usr/bin/gpasswd
[ 4356.171651] nginx[5]: -rwsr-xr-x 1 root root 39912 Feb 24 08:09 /usr/bin/newgrp
[ 4356.173452] nginx[5]: -rwsr-xr-x 1 root root 54192 Feb 24 08:09 /usr/bin/passwd
[ 4356.175704] nginx[5]: -rwxr-sr-x 1 root tty 27232 Mar 29  2015 /usr/bin/wall
[ 4356.229841] nginx[5]: -rwsr-xr-x 1 root root 40000 Mar 29  2015 /bin/mount
[ 4356.231914] nginx[5]: -rwsr-xr-x 1 root root 70576 Oct 28  2014 /bin/ping
[ 4356.234003] nginx[5]: -rwsr-xr-x 1 root root 61392 Oct 28  2014 /bin/ping6
[ 4356.235932] nginx[5]: -rwsr-xr-x 1 root root 40168 Feb 24 08:09 /bin/su
[ 4356.237872] nginx[5]: -rwsr-xr-x 1 root root 27416 Mar 29  2015 /bin/umount
[ 4356.250513] nginx[5]: /usr/bin/find: `/proc/5/task/5/fd/5': No such file or directory
[ 4356.250812] nginx[5]: /usr/bin/find: `/proc/5/task/5/fdinfo/5': No such file or directory
[ 4356.251120] nginx[5]: /usr/bin/find: `/proc/5/fd/5': No such file or directory
[ 4356.251355] nginx[5]: /usr/bin/find: `/proc/5/fdinfo/5': No such file or directory
[ 4356.254186] nginx[5]: -rwxr-sr-x 1 root shadow 35408 Nov 12 07:43 /sbin/unix_chkpwd
</code>```

See https://coreos.com/rkt/docs/latest/subcommands/run.html#passing-arguments for more information.

ContentLicense: CC BY-SA 3.0

Body:
I'm looking for a rkt command that is equivalent to the following docker command:

docker run nginx:1.11.5 find / -perm +6000 -type f -exec ls -ld {} \; 2> /dev/null

The docker command creates a new container from nginx:1.11.5, executes find / -perm +6000 -type f -exec ls -ld {} \; 2> /dev/null within the container (which prints all binaries with setuid and setgid permissions to stdout), and then kills the container. The results look something like this:

root@localhost:~# docker run nginx:1.11.5 find / -perm +6000 -type f -exec ls -ld {} \; 2> /dev/null
-rwsr-xr-x 1 root root 40168 Nov 18  2015 /bin/su
-rwsr-xr-x 1 root root 40000 Mar 29  2015 /bin/mount
-rwsr-xr-x 1 root root 27416 Mar 29  2015 /bin/umount
-rwsr-xr-x 1 root root 61392 Oct 28  2014 /bin/ping6
-rwsr-xr-x 1 root root 70576 Oct 28  2014 /bin/ping
-rwsr-xr-x 1 root root 53616 Nov 18  2015 /usr/bin/chfn
-rwsr-xr-x 1 root root 39912 Nov 18  2015 /usr/bin/newgrp
-rwxr-sr-x 1 root tty 27232 Mar 29  2015 /usr/bin/wall
-rwsr-xr-x 1 root root 54192 Nov 18  2015 /usr/bin/passwd
-rwxr-sr-x 1 root shadow 22744 Nov 18  2015 /usr/bin/expiry
-rwsr-xr-x 1 root root 75376 Nov 18  2015 /usr/bin/gpasswd
-rwsr-xr-x 1 root root 44464 Nov 18  2015 /usr/bin/chsh
-rwxr-sr-x 1 root shadow 62272 Nov 18  2015 /usr/bin/chage
-rwxr-sr-x 1 root shadow 35408 Jan 28  2016 /sbin/unix_chkpwd

This is what I've tried so far:

rkt run --insecure-options=image --net=host docker://nginx find / -perm +6000 -type f -exec ls -ld {} \; 2> /dev/null

and

rkt run --insecure-options=image --net=host docker://nginx --exec find / -perm +6000 -type f -exec ls -ld {} \; 2> /dev/null

both of which return no output.

I can acquire the information I want by overriding the initial command with --exec /bin/bash and adding the --interactive flag like so:

root@localhost:~# rkt run --interactive --insecure-options=image --net=host docker://nginx --exec /bin/bash
root@rkt-b5452809-0253-4da4-8026-d678c9bf7929:/# find / -perm +6000 -type f -exec ls -ld {} \; 2> /dev/null
-rwxr-sr-x 1 root shadow 35408 Jan 28  2016 /sbin/unix_chkpwd
-rwsr-xr-x 1 root root 40000 Mar 29  2015 /bin/mount
-rwsr-xr-x 1 root root 61392 Oct 28  2014 /bin/ping6
-rwsr-xr-x 1 root root 40168 Nov 18  2015 /bin/su
-rwsr-xr-x 1 root root 27416 Mar 29  2015 /bin/umount
-rwsr-xr-x 1 root root 70576 Oct 28  2014 /bin/ping
-rwxr-sr-x 1 root tty 27232 Mar 29  2015 /usr/bin/wall
-rwsr-xr-x 1 root root 75376 Nov 18  2015 /usr/bin/gpasswd
-rwsr-xr-x 1 root root 44464 Nov 18  2015 /usr/bin/chsh
-rwsr-xr-x 1 root root 53616 Nov 18  2015 /usr/bin/chfn
-rwsr-xr-x 1 root root 54192 Nov 18  2015 /usr/bin/passwd
-rwxr-sr-x 1 root shadow 62272 Nov 18  2015 /usr/bin/chage
-rwxr-sr-x 1 root shadow 22744 Nov 18  2015 /usr/bin/expiry
-rwsr-xr-x 1 root root 39912 Nov 18  2015 /usr/bin/newgrp
root@rkt-b5452809-0253-4da4-8026-d678c9bf7929:/# exit
exit
root@localhost:~#

How would I do this in one command?

Body:
You need to use -- to pass arguments to an image.

root@localhost:~# rkt run --insecure-options=image --net=host docker://nginx --exec find -- / -perm +6000 -type f -exec ls -ld {} \; 2> /dev/null
[ 4356.161333] nginx[5]: -rwxr-sr-x 1 root shadow 62272 Feb 24 08:09 /usr/bin/chage
[ 4356.163359] nginx[5]: -rwsr-xr-x 1 root root 53616 Feb 24 08:09 /usr/bin/chfn
[ 4356.165202] nginx[5]: -rwsr-xr-x 1 root root 44464 Feb 24 08:09 /usr/bin/chsh
[ 4356.167506] nginx[5]: -rwxr-sr-x 1 root shadow 22744 Feb 24 08:09 /usr/bin/expiry
[ 4356.169553] nginx[5]: -rwsr-xr-x 1 root root 75376 Feb 24 08:09 /usr/bin/gpasswd
[ 4356.171651] nginx[5]: -rwsr-xr-x 1 root root 39912 Feb 24 08:09 /usr/bin/newgrp
[ 4356.173452] nginx[5]: -rwsr-xr-x 1 root root 54192 Feb 24 08:09 /usr/bin/passwd
[ 4356.175704] nginx[5]: -rwxr-sr-x 1 root tty 27232 Mar 29  2015 /usr/bin/wall
[ 4356.229841] nginx[5]: -rwsr-xr-x 1 root root 40000 Mar 29  2015 /bin/mount
[ 4356.231914] nginx[5]: -rwsr-xr-x 1 root root 70576 Oct 28  2014 /bin/ping
[ 4356.234003] nginx[5]: -rwsr-xr-x 1 root root 61392 Oct 28  2014 /bin/ping6
[ 4356.235932] nginx[5]: -rwsr-xr-x 1 root root 40168 Feb 24 08:09 /bin/su
[ 4356.237872] nginx[5]: -rwsr-xr-x 1 root root 27416 Mar 29  2015 /bin/umount
[ 4356.250513] nginx[5]: /usr/bin/find: `/proc/5/task/5/fd/5': No such file or directory
[ 4356.250812] nginx[5]: /usr/bin/find: `/proc/5/task/5/fdinfo/5': No such file or directory
[ 4356.251120] nginx[5]: /usr/bin/find: `/proc/5/fd/5': No such file or directory
[ 4356.251355] nginx[5]: /usr/bin/find: `/proc/5/fdinfo/5': No such file or directory
[ 4356.254186] nginx[5]: -rwxr-sr-x 1 root shadow 35408 Nov 12 07:43 /sbin/unix_chkpwd

See https://coreos.com/rkt/docs/latest/subcommands/run.html#passing-arguments for more information.


问:
Any good security encoding libraries for .NET out there?
Been reading up on various injection-type attacks, and it seems like the best way to get rid of these vulnurabilities is to encode all user input to remove / replace some characters with others (< > ; etc).

What's my best bet here? Are there any nice libraries out there to aid me with this? Or something that could help me spot potential vulnurabilities? - Or are regular expressions my best bet? :)

Thanks a lot

答:
Recently I've been looking at ESAPI.NET and the project seems incomplete and perhaps inactive -- especially compared to the java package.

Anti-XSS only covers a subset of ESAPI's scope and, indeed, ESAPI.NET uses AntiXSS (though not the latest) for encoding.

Any comments testifying to ESAPI.NET's usefulness would be helpful.

OwnerDisplayName: Meeh

ContentLicense: CC BY-SA 2.5


问:
Cannot run git pull command through php
I am not able to pull a file remotely from git server through php. I wrote the following BAT code and am trying to execute it via php.
 the batch file git1.bat is a follows:

```<code>cd C:\repos\rep2 && git pull origin master 2>&1
</code>```

the php code:

```<code><?php
echo shell_exec("C:\\xampp\htdocs\AS-otg\\git1.bat");
?>
</code>```

the output I get:

However, I get the required result when I do the same directly from cmd.

I tried some other git commands like log etc. which work just fine.
I need to do this via php only... please help.

答:
log is a local command that does not need to talk with a remote host. pull does a fetch first. It seems you are running the PHP script under another user than when you run the script manually. If you run it manually you authenticate to the remote server with your SSH key and when the PHP script runs the script, the effective user does not have that SSH key to authenticate with.

Btw. you should keep in mind that a pull is not suited for being done non-interactively. When doing a pull you can easily get conflicts if the incoming changes are not fast-forward.

Title: Cannot run git pull command through php

Body:
I am not able to pull a file remotely from git server through php. I wrote the following BAT code and am trying to execute it via php.
 the batch file git1.bat is a follows:

cd C:\repos\rep2 && git pull origin master 2>&1

the php code:

<?php
echo shell_exec("C:\\xampp\htdocs\AS-otg\\git1.bat");
?>

the output I get:

However, I get the required result when I do the same directly from cmd.

I tried some other git commands like log etc. which work just fine.
I need to do this via php only... please help.


问:
Cannot run mssql select query with where clause within python using pypyodbc
I am using the library pypyodbc and am trying to run a select query in mssql using a where clause.

However the error I am getting indicates the syntax is wrong.

```<code>Error here ('42000', "[42000] [FreeTDS][SQL Server]Incorrect syntax near the keyword 'User'.")
</code>```

my query within my function is as follows;

```<code>try:

    selectUserDetails = "SELECT Username,Password FROM User WHERE Username = ?"
   cursor.execute(selectUserDetails,(username,))

    for row in cursor:
        print(row);

except Exception as e:

    print('Error here ' + str(e))
</code>```

My function to get the cursor is as follows;

```<code>def msDbCred():

try:
    from msDb import connection_string

    conn = pypyodbc.connect(connection_string)
    cursor = conn.cursor();
    return cursor;

except pymysql.err.OperationalError:
    sys.exit("Invalid Input: Wrong username/db or password found, please try again")

cursor = msDbCred()
</code>```

and my db credentials are stored in a different file named msDb.py

```<code>db_host = '127.0.0.1'
db_name = 'TD_1.0'
db_user = 'ReadOnly'
db_password = 'mypaswword'

connection_string = 'Driver=SQL Server;Server=' + db_host + ';Database=' + db_name + ';uid=' + db_user + ';PWD=' + db_password + ';'
</code>```

My question here is, is there something wrong with the query itself. As I am using this same format on another query elsewhere in my code and it works. Or is there something else wrong with my functions?

UPDATE:

@Gord Thompson said I should change my query.

I have changed, my query to;

```<code>selectUserDetails = "SELECT Username FROM [TD_1.0].[dbo].[User] WHERE Username = ?"
cursor.execute(selectUserDetails,(username,))
</code>```

However now I get the error;

```<code>('HY010', '[HY010] [unixODBC][Driver Manager]Function sequence error')
</code>```

答:
I managed to figure out where the error was and how to fix it.

In my msDbCred() function I was directly returning the cursor. I was testing in another file and figured this was the problem.

So instead I created an empty array and appended the cursor to the array and then returned the array.

Then used the first index of the array as the cursor elsewhere in my code

```<code>def msDbCred():

    cred = []
    try:
        from msDb import connection_string
        conn = pypyodbc.connect(connection_string)
        cursor = conn.cursor();
        cred.append(cursor)
        return cred
    except pymysql.err.OperationalError:
        sys.exit("Invalid Input: Wrong username/db or password found, please try again")

cursor = msDbCred()
</code>```

Then use the first index of cursor array

```<code>try:
    selectUserDetails = "SELECT Username,Password,UserId FROM [User] WHERE Username = '"+str(username)+"' AND IsEditor = '"+str(True)+"'"
           cursor[0].execute(selectUserDetails)

    for row in cursor[0]:
        return  row[0] == username and row[1] == password
except Exception as e:
     print('Error is ' + str(e))
</code>```

this is now working.

Body:
I am using the library pypyodbc and am trying to run a select query in mssql using a where clause.

However the error I am getting indicates the syntax is wrong.

Error here ('42000', "[42000] [FreeTDS][SQL Server]Incorrect syntax near the keyword 'User'.")

my query within my function is as follows;

try:

    selectUserDetails = "SELECT Username,Password FROM User WHERE Username = ?"
   cursor.execute(selectUserDetails,(username,))

    for row in cursor:
        print(row);

except Exception as e:

    print('Error here ' + str(e))

My function to get the cursor is as follows;

def msDbCred():

try:
    from msDb import connection_string

    conn = pypyodbc.connect(connection_string)
    cursor = conn.cursor();
    return cursor;

except pymysql.err.OperationalError:
    sys.exit("Invalid Input: Wrong username/db or password found, please try again")

cursor = msDbCred()

and my db credentials are stored in a different file named msDb.py

db_host = '127.0.0.1'
db_name = 'TD_1.0'
db_user = 'ReadOnly'
db_password = 'mypaswword'

connection_string = 'Driver=SQL Server;Server=' + db_host + ';Database=' + db_name + ';uid=' + db_user + ';PWD=' + db_password + ';'

My question here is, is there something wrong with the query itself. As I am using this same format on another query elsewhere in my code and it works. Or is there something else wrong with my functions?

UPDATE:

@Gord Thompson said I should change my query.

I have changed, my query to;

selectUserDetails = "SELECT Username FROM [TD_1.0].[dbo].[User] WHERE Username = ?"
cursor.execute(selectUserDetails,(username,))

However now I get the error;

('HY010', '[HY010] [unixODBC][Driver Manager]Function sequence error')

Body:
I managed to figure out where the error was and how to fix it.

In my msDbCred() function I was directly returning the cursor. I was testing in another file and figured this was the problem.

So instead I created an empty array and appended the cursor to the array and then returned the array.

Then used the first index of the array as the cursor elsewhere in my code

def msDbCred():

    cred = []
    try:
        from msDb import connection_string
        conn = pypyodbc.connect(connection_string)
        cursor = conn.cursor();
        cred.append(cursor)
        return cred
    except pymysql.err.OperationalError:
        sys.exit("Invalid Input: Wrong username/db or password found, please try again")

cursor = msDbCred()

Then use the first index of cursor array

try:
    selectUserDetails = "SELECT Username,Password,UserId FROM [User] WHERE Username = '"+str(username)+"' AND IsEditor = '"+str(True)+"'"
           cursor[0].execute(selectUserDetails)

    for row in cursor[0]:
        return  row[0] == username and row[1] == password
except Exception as e:
     print('Error is ' + str(e))

this is now working.


问:
TableView and polymorphism [JavaFx]
There are 2 classes: PipeCable and Pipe which extends PipeCable.

I have a TableView: private TableView<PipeCable> workshopList;

And I'd like to add to this TableView an ObservableList of Pipes:

private ObservableList<Pipe> pipeList;

I try to add this list to TableView:

```<code>workshopList.setItems(data.getPipeList());
</code>```

But I get error:

The method setItems(ObservableList< PipeCable >) in the type TableView < PipeCable > is not applicable for the arguments (ObservableList< Pipe >)

What am I doing wrong?

答: You defined workshopList with the generic type PipeCable. So the signature is setItems(ObservableList<PipeCable>) and you cannot invoke this method with an ObservableList<Pipe>. Create your field as private TableView<Pipe> workshopList.

Title: TableView and polymorphism [JavaFx]

Body:
There are 2 classes: PipeCable and Pipe which extends PipeCable.

I have a TableView: private TableView<PipeCable> workshopList;

And I'd like to add to this TableView an ObservableList of Pipes:

private ObservableList<Pipe> pipeList;

I try to add this list to TableView:

workshopList.setItems(data.getPipeList());

But I get error:

The method setItems(ObservableList< PipeCable >) in the type TableView < PipeCable > is not applicable for the arguments (ObservableList< Pipe >)

What am I doing wrong?


问:
Python: Frequency Analysis of Sound Files
I am generating some sound files that play tones at various frequencies with a certain number of harmonics.

Ultimately, these sounds will be played on a device with a small speaker.

I have the frequency response curve of the speaker and want to do the following in Python:

Plot the frequency spectrum of sound file. I need a take the FFT of the file and plot it with gnuplot

Apply a nonlinear transfer function based on the frequency response curve in the data sheet.

Plot the result after the function is applied.

Does anyone know :

What the simplest way to do this would be?

or of an Application (GNU/Linux based) that could do this for me?

答:
you can use numpy and matPlotLib. Something like the code below:

```<code>spectrum = numpy.fft.fft(signal)
frequencies = numpy.fft.fftfreq(len(spectrum))
pylab.plot(frequencies,spectrum)
pylab.show()
</code>```

That will show a graph of the fft spectrum.

Body:
you can use numpy and matPlotLib. Something like the code below:

spectrum = numpy.fft.fft(signal)
frequencies = numpy.fft.fftfreq(len(spectrum))
pylab.plot(frequencies,spectrum)
pylab.show()

That will show a graph of the fft spectrum.


问:
Can't Edit Files in Android Studio
For some unknown reason, I can't edit files in Android Studio. This includes both Java and XML files.

When I launch Android Studio (v1.2.2), everything is fine. However, after some time, I lose the ability to edit files content. Here is what I noticed:

When I click on any line in the source code, the lines get highlighted but the caret indicator is not showing.

When I start typing, a search for: box starts appearing on the top of the left panel (Project window), and it starts filtering the project files according to what I type!

Files are not locked as Read-Only. I checked.

Restarting Android Studio did not resolve it permanently. Everything seems fine for some time, then the problem appears again.

I did check my keyboard to see if I have a stucked keystroke that might cause this problem. Didn't notice anything.

In the Project window, I noticed that MainActivity file name is in grey (See the screenshot below). I'm not sure if this is because of something I did, or if it is how Android Studio identifies the main Activity in the project.

答:
Permanent Fix for Can't Edit Files in Android Studio On Windows. Performing the following steps:

Close Android studio.

Go to your User Folder - on Windows 7/8 this would be:

[SYSDRIVE]:\Users[your username] (ex. C:\Users\Venky)

In this folder there should be a folder called .AndroidStudioBeta or .AndroidStudio (notice the period at the start - so on some OSes it would be hidden).

Delete this folder (or better yet, move it to a backup location - so you can return it if something goes wrong).

This should reset your Android Studio settings to default.

Now the isue got fixed, check it by opening Android studio.

This will not clear any projects history.

ContentLicense: CC BY-SA 4.0

Title: Can't Edit Files in Android Studio


问:
How to get the marquee effect with list view in react native?
I am trying to get the marquee effect in react native list view.I am trying to implement in this way.</p>

```<code><ListView
    horizontal={true}
    ref={ref => this.infoListView = ref}
    showsHorizontalScrollIndicator={false}
    automaticallyAdjustContentInsets={false}
    onContentSizeChange={(contentWidth,contentHeight)=>{
      this.moveListToEnd()
    }}
    onEndReached={()=>this.moveListToTop()}
    enableEmptySections={true}
    style={styles.infolist}
    dataSource={this.state.dataSource}
    renderRow={(rowData,sectionID,rowID) => < Row data={rowData} rowID = {rowID}/>} />

moveListToEnd(){
    this.infoListView.scrollToEnd({animated: true});
}

moveListToTop(){
    this.infoListView.scrollTo({x: 0, y: 0, animated: true})
    this.moveListToEnd();
}
</code>```

答:
I have found out the way to do it.
Install NPM react-timer-mixin first. And use this code.</p>

```<code>var moveListTimer = require('react-timer-mixin');

const ds = '';
var timerInterval = 10;
var moveListTimerId;
var pos = 0;
var ListArr = [];

class MarqueeListClass extends Component{

constructor(props){
    super(props);
    ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
    this.state = {
        dataSource: ds.cloneWithRows(ListArr),
        listLength:ListArr.length,
        listmovingdirection:'right',
    };
}

componentDidMount() {
    moveListTimerId = moveListTimer.setInterval( () => {
        this.moveList();
    }, timerInterval);
}

componentWillUnmount() {
  moveListTimerId && clearInterval(moveListTimerId);
}

moveList(){
    if(this.state.listmovingdirection==='right'){
        this.moveListToRight();
    }
    else if(this.state.listmovingdirection ==='left'){
        this.moveListToLeft();
    }
}

moveListToEnd(){
    this.ListView.scrollToEnd({animated: true});
}

moveListToRight(){
    pos = pos + 0.5;
    this.ListView.scrollTo({x: pos, y: 0, animated: true})
}

moveListToLeft(){
    if(pos>0){
        pos = pos - 0.5;
        this.ListView.scrollTo({x: pos, y: 0, animated: true})
    }
    else{
        this.setState({listmovingdirection:'right'});
    }
}

onListReachEnd(){
    this.setState({listmovingdirection:'left'});
}

render(){

   return(
    <View style = {styles.main}>
                <ListView
                    horizontal={true}
                    ref={ref => this.ListView = ref}
                    showsHorizontalScrollIndicator={false}
                    automaticallyAdjustContentInsets={false}
                    onEndReached={()=>this.onListReachEnd()}
                    enableEmptySections={true}
                    style={styles.list}
                    dataSource={this.state.dataSource}
                    renderRow={(rowData,sectionID,rowID) => < Row info={rowData} rowID = {rowID}/>} />
    </View>
  );
}
}
</code>```

Body:
I am trying to get the marquee effect in react native list view.I am trying to implement in this way.

<ListView
    horizontal={true}
    ref={ref => this.infoListView = ref}
    showsHorizontalScrollIndicator={false}
    automaticallyAdjustContentInsets={false}
    onContentSizeChange={(contentWidth,contentHeight)=>{
      this.moveListToEnd()
    }}
    onEndReached={()=>this.moveListToTop()}
    enableEmptySections={true}
    style={styles.infolist}
    dataSource={this.state.dataSource}
    renderRow={(rowData,sectionID,rowID) => < Row data={rowData} rowID = {rowID}/>} />

moveListToEnd(){
    this.infoListView.scrollToEnd({animated: true});
}

moveListToTop(){
    this.infoListView.scrollTo({x: 0, y: 0, animated: true})
    this.moveListToEnd();
}

Body:
I have found out the way to do it.
Install NPM react-timer-mixin first. And use this code.

var moveListTimer = require('react-timer-mixin');

const ds = '';
var timerInterval = 10;
var moveListTimerId;
var pos = 0;
var ListArr = [];

class MarqueeListClass extends Component{

constructor(props){
    super(props);
    ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
    this.state = {
        dataSource: ds.cloneWithRows(ListArr),
        listLength:ListArr.length,
        listmovingdirection:'right',
    };
}

componentDidMount() {
    moveListTimerId = moveListTimer.setInterval( () => {
        this.moveList();
    }, timerInterval);
}

componentWillUnmount() {
  moveListTimerId && clearInterval(moveListTimerId);
}

moveList(){
    if(this.state.listmovingdirection==='right'){
        this.moveListToRight();
    }
    else if(this.state.listmovingdirection ==='left'){
        this.moveListToLeft();
    }
}

moveListToEnd(){
    this.ListView.scrollToEnd({animated: true});
}

moveListToRight(){
    pos = pos + 0.5;
    this.ListView.scrollTo({x: pos, y: 0, animated: true})
}

moveListToLeft(){
    if(pos>0){
        pos = pos - 0.5;
        this.ListView.scrollTo({x: pos, y: 0, animated: true})
    }
    else{
        this.setState({listmovingdirection:'right'});
    }
}

onListReachEnd(){
    this.setState({listmovingdirection:'left'});
}

render(){

   return(
    <View style = {styles.main}>
                <ListView
                    horizontal={true}
                    ref={ref => this.ListView = ref}
                    showsHorizontalScrollIndicator={false}
                    automaticallyAdjustContentInsets={false}
                    onEndReached={()=>this.onListReachEnd()}
                    enableEmptySections={true}
                    style={styles.list}
                    dataSource={this.state.dataSource}
                    renderRow={(rowData,sectionID,rowID) => < Row info={rowData} rowID = {rowID}/>} />
    </View>
  );
}
}


问:
How can I extract Data(fieldOutputs) which is bigger than my RAM from an Abaqus odb-file using the c++ API
I am using the c++ API to access *.odb files. Reading the file is no problem, unless the file is bigger than my RAM.

There are two routines in the documentation to read the data (in my case fieldOutputs) from the odb-file.

1. Bulk data

```<code>odb_FieldOutput& disp = lastFrame.fieldOutputs()["U"];
const odb_SequenceFieldBulkData& seqDispBulkData = disp.bulkDataBlocks();
int numDispBlocks = seqDispBulkData.size();
for (int iblock=0; iblock<numDispBlocks; iblock++) {
    const odb_FieldBulkData& bulkData = seqDispBulkData[iblock];
    int numNodes = bulkData.length();
    int numComp = bulkData.width();
    float* data = bulkData.data();
    int* nodeLabels = bulkData.nodeLabels();
    for (int node=0,pos=0; node<numNodes; node++) {
        int nodeLabel = nodeLabels[node];
        cout << "Node = " << nodeLabel;
        cout << " U = ";
        for (int comp=0;comp<numComp;comp++) {
            cout << data[pos++] << " ";
        }
        cout << endl;
    }
}
</code>```

2  Value

```<code>const odb_SequenceFieldValue& displacements =  lastFrame.fieldOutputs()["U"].values();
int numValues = displacements.size();
int numComp = 0;
for (int i=0; i<numValues; i++) {
    const odb_FieldValue val = displacements[i];
    cout << "Node = " << val.nodeLabel();
    const float* const U = val.data(numComp);
    cout << ", U = ";
    for (int comp=0;comp<numComp;comp++)
        cout << U[comp] << " ";
    }
    cout << endl;
}
</code>```

What I would like to do is to read the Data from the file and save them into a mat file.

Shape of the data:

Odb-file is a data base which can be represented as a tree structure.

It contains steps. Each step contains frames and each frame contains fieldOutputs.
Those fieldOutputs can be matrices or vectors. The dimension depends on the number of nodes and the number of parameters per fieldOutput.

My question:

Is one of the mentioned routines capable of loading files bigger than the RAM successively? If yes, I would be happy to get some hints.

Additional information:

Documentation:
http://abaqus.software.polimi.it/v6.12/books/ker/default.htm
and
http://xn--90ajn.xn--p1ai:2080/v6.12/pdf_books/SCRIPT_USER.pdf
I am using Abaqus  6.12
and visual studio 2010 compiler.

答:
Is one single field Output really bigger than your RAM? Do you have >1 Billion Elements?

I think you are running over a large amount of field Outputs and running out of memory when doing so.

There you can run out of memory, because the Abaqus Odb API doesn't release memory correctly (to my observation). There are some undocumented functions to release memory in the C++ API, which i can provide if I find them.

Even with this i could't get the API to release the memory. I got around this issue in (opening the Odb -> read a chunk of data -> close the Odb -> reopen the odb and read the next chunk of data)
My observation was, that it would be helpful to wait 1 or two seconds after each chunk that the memory is being released properly.

So reading the data chunk after chunk to Matlab (saving it in Matlab) would be a way to get it to work.

Of course the bulkData aproach would be favorable if you read whole field Outputs.

Body:
I am using the c++ API to access *.odb files. Reading the file is no problem, unless the file is bigger than my RAM.

There are two routines in the documentation to read the data (in my case fieldOutputs) from the odb-file.

1. Bulk data

odb_FieldOutput& disp = lastFrame.fieldOutputs()["U"];
const odb_SequenceFieldBulkData& seqDispBulkData = disp.bulkDataBlocks();
int numDispBlocks = seqDispBulkData.size();
for (int iblock=0; iblock<numDispBlocks; iblock++) {
    const odb_FieldBulkData& bulkData = seqDispBulkData[iblock];
    int numNodes = bulkData.length();
    int numComp = bulkData.width();
    float* data = bulkData.data();
    int* nodeLabels = bulkData.nodeLabels();
    for (int node=0,pos=0; node<numNodes; node++) {
        int nodeLabel = nodeLabels[node];
        cout << "Node = " << nodeLabel;
        cout << " U = ";
        for (int comp=0;comp<numComp;comp++) {
            cout << data[pos++] << " ";
        }
        cout << endl;
    }
}

2  Value

const odb_SequenceFieldValue& displacements =  lastFrame.fieldOutputs()["U"].values();
int numValues = displacements.size();
int numComp = 0;
for (int i=0; i<numValues; i++) {
    const odb_FieldValue val = displacements[i];
    cout << "Node = " << val.nodeLabel();
    const float* const U = val.data(numComp);
    cout << ", U = ";
    for (int comp=0;comp<numComp;comp++)
        cout << U[comp] << " ";
    }
    cout << endl;
}

What I would like to do is to read the Data from the file and save them into a mat file.

Shape of the data:

Odb-file is a data base which can be represented as a tree structure.

It contains steps. Each step contains frames and each frame contains fieldOutputs.
Those fieldOutputs can be matrices or vectors. The dimension depends on the number of nodes and the number of parameters per fieldOutput.

My question:

Is one of the mentioned routines capable of loading files bigger than the RAM successively? If yes, I would be happy to get some hints.

Additional information:

Documentation:
http://abaqus.software.polimi.it/v6.12/books/ker/default.htm
and
http://xn--90ajn.xn--p1ai:2080/v6.12/pdf_books/SCRIPT_USER.pdf
I am using Abaqus  6.12
and visual studio 2010 compiler.


问:
Can not get the special charcter from query string value using PHP
I need one help. I need to fetch all data from query string using PHP but some special charcters like (i.e-+,- etc) are not coming. I am explaining my code below.

```<code>http://localhost/test/getmethod.php?name=Goro + Gun
</code>```

Here I need to get the value assign to name using the below code.

```<code><?php
$name=$_GET['name'];
echo $name;
?>
</code>```

Here I am getting the output like Goro Gun but I need the original value i.e-Goro + Gun .Please help me to resolve this issue.

答:
```<code>$_SERVER['QUERY_STRING'] - this will return you full query string
</code>```

Body:
I need one help. I need to fetch all data from query string using PHP but some special charcters like (i.e-+,- etc) are not coming. I am explaining my code below.

http://localhost/test/getmethod.php?name=Goro + Gun

Here I need to get the value assign to name using the below code.

<?php
$name=$_GET['name'];
echo $name;
?>

Here I am getting the output like Goro Gun but I need the original value i.e-Goro + Gun .Please help me to resolve this issue.


问:
ImageView diplaying in one activity but not in aonther
I have an android app with 2 activities: activity_main and activity_login.

On top of my activities I have a logo. It is showing up fine in activity_main but not in the activity_login.

The strange this is they both use similar layout and similar code.

Here is my activity_main.xml:

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".app.MainActivity"
    android:background="@drawable/background_1">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@drawable/logo"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="36dp" />

    <Button
        android:id="@+id/button1"
        android:layout_width="195dp"
        android:layout_height="45dp"
        android:text="Sign a File"
        android:layout_marginTop="53dp"
        app:layout_constraintTop_toBottomOf="@+id/imageView"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintHorizontal_bias="0.502" />

    <Button
        android:id="@+id/button2"
        android:layout_width="195dp"
        android:layout_height="45dp"
        android:text="Button"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginTop="30dp"
        app:layout_constraintTop_toBottomOf="@+id/button4"
        app:layout_constraintHorizontal_bias="0.502" />

    <Button
        android:id="@+id/button3"
        android:layout_width="195dp"
        android:layout_height="45dp"
        android:text="Button"
        android:layout_marginTop="34dp"
        app:layout_constraintTop_toBottomOf="@+id/button1"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintHorizontal_bias="0.502" />

    <Button
        android:id="@+id/button4"
        android:layout_width="195dp"
        android:layout_height="45dp"
        android:text="Button"
        android:layout_marginTop="31dp"
        app:layout_constraintTop_toBottomOf="@+id/button3"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        app:layout_constraintVertical_bias="0.043"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent" />

</android.support.constraint.ConstraintLayout>
</code>```

And, here is my activity_login.xml:

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".login.LoginActivity"
    android:background="@drawable/background_1">

     <ImageView
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:srcCompat="@drawable/logo"
    app:layout_constraintLeft_toLeftOf="parent"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    android:layout_marginTop="36dp" />

     <EditText
        android:id="@+id/usernameTextField"
        android:layout_width="291dp"
        android:layout_height="63dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="53dp"
        android:background="@color/editTextBackground"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="Username"
        android:textColor="#000000"
        app:layout_constraintHorizontal_bias="0.506"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView" />

    <EditText
        android:id="@+id/passwordTextField"
        android:layout_width="291dp"
        android:layout_height="63dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="0dp"
        android:background="@color/editTextBackground"
        android:ems="10"
        android:inputType="textPassword"
        android:text="Password"
        android:textColor="#000000"
        app:layout_constraintHorizontal_bias="0.506"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/usernameTextField" />

    <Button
        android:id="@+id/button"
        android:onClick="loginButtonClick"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="66dp"
        android:background="@color/editTextBackground"
        android:text="Log In"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/passwordTextField"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp" />

</android.support.constraint.ConstraintLayout>
</code>```

In the design view of the activity_login it's displaying the image fine. But, when I run a test on emulator/phone it just doesn't show.

I tried removing all the other views from login_activity and still got the same problem. I also tried making a new activity xml with the same ConstarintLayout where I just add logo as imageView, and when I run the app the logo is not showing up.

And, that same logo using the same imageView in constraintLayout works fine in my activity_main

UPDATE: Why the downvote?

UPDATE2: As adviced by rafsanahmad007 this works:

instead of:

app:srcCompat="@drawable/logo" use:

android:src="@drawable/logo"

But, it still doesn't explain why it was working using app:srcCompat in one activity and not the other one.

答: Use android:src="@drawable/logo" instead of app:srcCompat="@drawable/logo".

Body:
I have an android app with 2 activities: activity_main and activity_login.

On top of my activities I have a logo. It is showing up fine in activity_main but not in the activity_login.

The strange this is they both use similar layout and similar code.

Here is my activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".app.MainActivity"
    android:background="@drawable/background_1">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@drawable/logo"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="36dp" />

    <Button
        android:id="@+id/button1"
        android:layout_width="195dp"
        android:layout_height="45dp"
        android:text="Sign a File"
        android:layout_marginTop="53dp"
        app:layout_constraintTop_toBottomOf="@+id/imageView"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintHorizontal_bias="0.502" />

    <Button
        android:id="@+id/button2"
        android:layout_width="195dp"
        android:layout_height="45dp"
        android:text="Button"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginTop="30dp"
        app:layout_constraintTop_toBottomOf="@+id/button4"
        app:layout_constraintHorizontal_bias="0.502" />

    <Button
        android:id="@+id/button3"
        android:layout_width="195dp"
        android:layout_height="45dp"
        android:text="Button"
        android:layout_marginTop="34dp"
        app:layout_constraintTop_toBottomOf="@+id/button1"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintHorizontal_bias="0.502" />

    <Button
        android:id="@+id/button4"
        android:layout_width="195dp"
        android:layout_height="45dp"
        android:text="Button"
        android:layout_marginTop="31dp"
        app:layout_constraintTop_toBottomOf="@+id/button3"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        app:layout_constraintVertical_bias="0.043"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent" />

</android.support.constraint.ConstraintLayout>

And, here is my activity_login.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".login.LoginActivity"
    android:background="@drawable/background_1">

     <ImageView
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:srcCompat="@drawable/logo"
    app:layout_constraintLeft_toLeftOf="parent"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    android:layout_marginTop="36dp" />

     <EditText
        android:id="@+id/usernameTextField"
        android:layout_width="291dp"
        android:layout_height="63dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="53dp"
        android:background="@color/editTextBackground"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="Username"
        android:textColor="#000000"
        app:layout_constraintHorizontal_bias="0.506"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView" />

    <EditText
        android:id="@+id/passwordTextField"
        android:layout_width="291dp"
        android:layout_height="63dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="0dp"
        android:background="@color/editTextBackground"
        android:ems="10"
        android:inputType="textPassword"
        android:text="Password"
        android:textColor="#000000"
        app:layout_constraintHorizontal_bias="0.506"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/usernameTextField" />

    <Button
        android:id="@+id/button"
        android:onClick="loginButtonClick"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="66dp"
        android:background="@color/editTextBackground"
        android:text="Log In"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/passwordTextField"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp" />

</android.support.constraint.ConstraintLayout>

In the design view of the activity_login it's displaying the image fine. But, when I run a test on emulator/phone it just doesn't show.

I tried removing all the other views from login_activity and still got the same problem. I also tried making a new activity xml with the same ConstarintLayout where I just add logo as imageView, and when I run the app the logo is not showing up.

And, that same logo using the same imageView in constraintLayout works fine in my activity_main

UPDATE: Why the downvote?

UPDATE2: As adviced by rafsanahmad007 this works:

instead of:

app:srcCompat="@drawable/logo" use:

android:src="@drawable/logo"

But, it still doesn't explain why it was working using app:srcCompat in one activity and not the other one.


问:
Align Paper Icon and Text left?
I have the following Google Polymer structure

```<code><paper-drawer-panel>
   <div drawer>

     <paper-header-panel>
       <paper-toolbar>Drawer Header</paper-toolbar>
       <div>
           <paper-icon-item>
              <iron-icon icon="favorite" item-icon></iron-icon>
              Add List
           </paper-icon-item>
       </div>
       </paper-header-panel>

   </div>
   <div main> Main panel... </div>
 </paper-drawer-panel>
</code>```

My result looks like this:

The icons and the text are centered aligned. How can I align them left like in the following image:

How can I align paper icon and text left?

答:
I'm a bit late, but I was having the same issue and I've found that reducing the icon area's width the content of the paper-icon-item aligns left correctly:

paper-icon-item {
    --paper-item-icon-width: 10px;
}

Hope it'll be useful for someone.

Title: Align Paper Icon and Text left?

Body:
I have the following Google Polymer structure

<paper-drawer-panel>

     <paper-header-panel>
       <paper-toolbar>Drawer Header</paper-toolbar>

           <paper-icon-item>
              <iron-icon icon="favorite" item-icon></iron-icon>
              Add List
           </paper-icon-item>

       </paper-header-panel>

 Main panel...

 </paper-drawer-panel>

My result looks like this:

The icons and the text are centered aligned. How can I align them left like in the following image:

How can I align paper icon and text left?


问:
java.lang.IllegalArgumentException in java spring using constructor injection
Hello i am using constructor injection in my spring demo app when i run this program i got :

java.lang.IllegalArgumentException exception

Anyone have solution where i am wong and whenever i run same program using setter injection it runs perfectly .

Here is my EmployeeBean.java

```<code>package cris;

public class Employee {
    private int id;
    private String name;
    public Employee() { }
    public Employee(int id,String name) {
        this.id=id;
        this.name=name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    void show() {
        System.out.println(id+" "+name);

    }
}
</code>```

Here is my Address Bean using setter injection

```<code>package cris;

public class Address {
private String city,state,country;

public String getCity() {
    return city;
}

public void setCity(String city) {
    this.city = city;
}

public String getState() {
    return state;
}

public void setState(String state) {
    this.state = state;
}

public String getCountry() {
    return country;
}

public void setCountry(String country) {
    this.country = country;
}

public String toString()
{
    return city+" "+state+" "+country;
}
}
</code>```

Here is my spring.xml ie spring config file

```<code>    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<bean id="a1" class="cris.Address">
<property name="city" value="Tikamgarh"></property>
<property name="state" value="Mp"></property>
<property name="country" value="India"></property>
</bean>
<bean id="e" class="cris.Employee">
<constructor-arg type="int" value="12"></constructor-arg>
<constructor-arg type="String" value="anil"></constructor-arg>
</bean>
</beans>
</code>```

And here is my Application Main Method

```<code>package cris;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test {
public static void main(String[] args) {
    ApplicationContext context=new ClassPathXmlApplicationContext("cris/spring.xml");
    Employee emp = (Employee)context.getBean("e");
    emp.show();
}
}
</code>```

kindly provide me suggestion where i am wrong so i will catch the exception thanks

The Exception:

```<code>Apr 03, 2017 4:16:16 PM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@27f8302d: startup date [Mon Apr 03 16:16:16 IST 2017]; root of context hierarchy
Apr 03, 2017 4:16:16 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [cris/spring.xml]
Apr 03, 2017 4:16:16 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@17550481: defining beans [a1,e]; root of factory hierarchy
Exception in thread "main" java.lang.IllegalArgumentException
    at org.springframework.asm.ClassReader.<init>(Unknown Source)
    at org.springframework.asm.ClassReader.<init>(Unknown Source)
    at org.springframework.asm.ClassReader.<init>(Unknown Source)
    at org.springframework.core.LocalVariableTableParameterNameDiscoverer.inspectClass(LocalVariableTableParameterNameDiscoverer.java:112)
    at org.springframework.core.LocalVariableTableParameterNameDiscoverer.getParameterNames(LocalVariableTableParameterNameDiscoverer.java:86)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:193)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1049)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:953)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at cris.Test.main(Test.java:8)
</code>```

答:
Add type to your constructor-arg

<constructor-arg type="int" value="12" />

and

<constructor-arg type="java.lang.String" value="anil" />

EDIT

or you can use indexes

<constructor-arg index="0" value="12" />

and

<constructor-arg index="1" value="anil" />

Body:
Hello i am using constructor injection in my spring demo app when i run this program i got :

java.lang.IllegalArgumentException exception

Anyone have solution where i am wong and whenever i run same program using setter injection it runs perfectly .

Here is my EmployeeBean.java

package cris;

public class Employee {
    private int id;
    private String name;
    public Employee() { }
    public Employee(int id,String name) {
        this.id=id;
        this.name=name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    void show() {
        System.out.println(id+" "+name);

    }
}

Here is my Address Bean using setter injection

package cris;

public class Address {
private String city,state,country;

public String getCity() {
    return city;
}

public void setCity(String city) {
    this.city = city;
}

public String getState() {
    return state;
}

public void setState(String state) {
    this.state = state;
}

public String getCountry() {
    return country;
}

public void setCountry(String country) {
    this.country = country;
}

public String toString()
{
    return city+" "+state+" "+country;
}
}

Here is my spring.xml ie spring config file

    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<bean id="a1" class="cris.Address">
<property name="city" value="Tikamgarh"></property>
<property name="state" value="Mp"></property>
<property name="country" value="India"></property>
</bean>
<bean id="e" class="cris.Employee">
<constructor-arg type="int" value="12"></constructor-arg>
<constructor-arg type="String" value="anil"></constructor-arg>
</bean>
</beans>

And here is my Application Main Method

package cris;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test {
public static void main(String[] args) {
    ApplicationContext context=new ClassPathXmlApplicationContext("cris/spring.xml");
    Employee emp = (Employee)context.getBean("e");
    emp.show();
}
}

kindly provide me suggestion where i am wrong so i will catch the exception thanks

The Exception:

Apr 03, 2017 4:16:16 PM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@27f8302d: startup date [Mon Apr 03 16:16:16 IST 2017]; root of context hierarchy
Apr 03, 2017 4:16:16 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [cris/spring.xml]
Apr 03, 2017 4:16:16 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@17550481: defining beans [a1,e]; root of factory hierarchy
Exception in thread "main" java.lang.IllegalArgumentException
    at org.springframework.asm.ClassReader.<init>(Unknown Source)
    at org.springframework.asm.ClassReader.<init>(Unknown Source)
    at org.springframework.asm.ClassReader.<init>(Unknown Source)
    at org.springframework.core.LocalVariableTableParameterNameDiscoverer.inspectClass(LocalVariableTableParameterNameDiscoverer.java:112)
    at org.springframework.core.LocalVariableTableParameterNameDiscoverer.getParameterNames(LocalVariableTableParameterNameDiscoverer.java:86)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:193)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1049)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:953)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at cris.Test.main(Test.java:8)


问:
Multi-dimensional array return keys with duplicate values
Please Help! I want to validate array with duplicate sub-array values. I have an multi-dimensional array. I want to return keys of sub-array with duplicate product_id value. Example: In my array, I have sub-array with duplicate product_id = 124. I want to return their key.

```<code>[purchase_order_products] => Array
    (
        [0] => Array
            (
                [product_id] => 124
                [barcode] => 480001407081
                [item_code] =>
                [name] => Brew Kettle Can 330mL
                [qty] =>
                [unit] => 2
                [pcs_have] => 1
                [total_pcs] => 1
                [cost] => 34.83
                [total_item_price] => 34.83
                [stocks] =>
                [po_qty] =>
            )

        [1] => Array
            (
                [product_id] => 125
                [barcode] => 480001416108
                [item_code] =>
                [name] => Colt 45 Can 330mL
                [qty] =>
                [unit] => 2
                [pcs_have] => 1
                [total_pcs] => 1
                [cost] => 29.58
                [total_item_price] => 29.58
                [stocks] =>
                [po_qty] =>
            )

        [2] => Array
            (
                [product_id] => 124
                [barcode] => 480001407081
                [item_code] =>
                [name] => Brew Kettle Can 330mL
                [qty] =>
                [unit] => 2
                [pcs_have] => 1
                [total_pcs] => 1
                [cost] => 34.83
                [total_item_price] => 34.83
                [stocks] =>
                [po_qty] =>
            )
)
</code>```

The output I want is:

```<code>Array(0,2)
</code>```

答:
Use this code to get key for duplicate product id:</p>

```<code>$products = $array['purchase_order_products'];

$duplicate_products_keys = array();
$products_ids = array();

foreach($products as $key => $product) {
   if(in_array($product['product_id'], $products_ids)) {
      $duplicate_products_keys[] = $key;
   }
   $products_ids[$product['product_id']] = $product['product_id'];
}

prinr_r($duplicate_products_keys);
</code>```

Body:
Please Help! I want to validate array with duplicate sub-array values. I have an multi-dimensional array. I want to return keys of sub-array with duplicate product_id value. Example: In my array, I have sub-array with duplicate product_id = 124. I want to return their key.

[purchase_order_products] => Array
    (
        [0] => Array
            (
                [product_id] => 124
                [barcode] => 480001407081
                [item_code] =>
                [name] => Brew Kettle Can 330mL
                [qty] =>
                [unit] => 2
                [pcs_have] => 1
                [total_pcs] => 1
                [cost] => 34.83
                [total_item_price] => 34.83
                [stocks] =>
                [po_qty] =>
            )

        [1] => Array
            (
                [product_id] => 125
                [barcode] => 480001416108
                [item_code] =>
                [name] => Colt 45 Can 330mL
                [qty] =>
                [unit] => 2
                [pcs_have] => 1
                [total_pcs] => 1
                [cost] => 29.58
                [total_item_price] => 29.58
                [stocks] =>
                [po_qty] =>
            )

        [2] => Array
            (
                [product_id] => 124
                [barcode] => 480001407081
                [item_code] =>
                [name] => Brew Kettle Can 330mL
                [qty] =>
                [unit] => 2
                [pcs_have] => 1
                [total_pcs] => 1
                [cost] => 34.83
                [total_item_price] => 34.83
                [stocks] =>
                [po_qty] =>
            )
)

The output I want is:

Array(0,2)

Body:
Use this code to get key for duplicate product id:

$products = $array['purchase_order_products'];

$duplicate_products_keys = array();
$products_ids = array();

foreach($products as $key => $product) {
   if(in_array($product['product_id'], $products_ids)) {
      $duplicate_products_keys[] = $key;
   }
   $products_ids[$product['product_id']] = $product['product_id'];
}

prinr_r($duplicate_products_keys);


问:
Split and remove particular value in href attribute and add new value using jquery
I have splitted the value in href attribute of a tag.

i splitted the value but i cannot remove the values and append new into it.

My HTML code is

```<code><a class="chapter_video" href="http://localhost/SVE128-portal2/public/video/9/25"></a>
</code>```

And my jquery is

```<code> var new = 4;
 var video_url = $('.chapter_video');
 var href = video_url.attr("href");
 //splitting value of href
 var split = href.split("/");
 if(split[7] !== undefined){
     href.remove(split[7]);
 }

 video_url.attr('href', video_url.attr('href') + '/'+ new);
</code>```

I have tried

```<code> var remove = href.replace('split[7]', '')
</code>```

instead of href.remove(split[7]);

答:
This is simple:</p>

```<code> var newUrl = 4;
 var video_url = $('.chapter_video');
 var href = video_url.attr("href");
 //splitting value of href
 var split = href.split("/");
 if(split[7] !== undefined){

     href = href.replace(split[7], '');
 }

 video_url.attr('href', href + newUrl);
</code>```

Body:
I have splitted the value in href attribute of a tag.

i splitted the value but i cannot remove the values and append new into it.

My HTML code is

And my jquery is

 var new = 4;
 var video_url = $('.chapter_video');
 var href = video_url.attr("href");
 //splitting value of href
 var split = href.split("/");
 if(split[7] !== undefined){
     href.remove(split[7]);
 }

 video_url.attr('href', video_url.attr('href') + '/'+ new);

I have tried

 var remove = href.replace('split[7]', '')

instead of href.remove(split[7]);

Body:
This is simple:

 var newUrl = 4;
 var video_url = $('.chapter_video');
 var href = video_url.attr("href");
 //splitting value of href
 var split = href.split("/");
 if(split[7] !== undefined){

     href = href.replace(split[7], '');
 }

 video_url.attr('href', href + newUrl);


问:
Resizing Highchart based on window size
Hi i have left navigation menu, and content on right side which is a highchart.
Following is my Highchart config,

```<code>this.InputData = {

            chart: { type: 'column' },
            title : { text : 'Overview' },

            xAxis: {
                categories: this._weekValues
            },
            yAxis: {
                allowDecimals: false,
                title: { text: 'some title'},
                min: 0,
                max: 100,
                labels: {
                    formatter:function() {
                        var pcnt = (this.value / 100) * 100;
                        return Highcharts.numberFormat(pcnt, 0) + '%';
                    }
                }
            }
        }
</code>```

And I have a function which will be triggered on change the size of my left menu,

```<code>this.menuEvent.onChangeLeftMenu().subscribe(()=>{
            Observable.timer().subscribe(()=>{
                console.log('highchart redraw?');
            });
        });
</code>```

How can I redraw or resize my chart on changing my leftmenu size? Currently the chart is overflowing from my div wrapper. Thanks in advance guys.

答:
JS Fiddle</p>

```<code> $('#add').click(function () {
chart.addAxis({ // Secondary yAxis
    id: 'rainfall-axis',
    title: {
        text: 'Rainfall'
    },
    lineWidth: 2,
    lineColor: '#08F',
    opposite: true
});
chart.addSeries({
    name: 'Rainfall',
    type: 'column',
    color: '#08F',
    yAxis: 'rainfall-axis',
    data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
  $(this).attr('disabled', true);
  $('#remove').attr('disabled', false);
});
 $('#remove').click(function () {
  chart.get('temperature-axis').remove();

  $(this).attr('disabled', true);
$('#add').attr('disabled', false);
 });
</code>```

Title: Resizing Highchart based on window size

Body:
Hi i have left navigation menu, and content on right side which is a highchart.
Following is my Highchart config,

this.InputData = {

            chart: { type: 'column' },
            title : { text : 'Overview' },

            xAxis: {
                categories: this._weekValues
            },
            yAxis: {
                allowDecimals: false,
                title: { text: 'some title'},
                min: 0,
                max: 100,
                labels: {
                    formatter:function() {
                        var pcnt = (this.value / 100) * 100;
                        return Highcharts.numberFormat(pcnt, 0) + '%';
                    }
                }
            }
        }

And I have a function which will be triggered on change the size of my left menu,

this.menuEvent.onChangeLeftMenu().subscribe(()=>{
            Observable.timer().subscribe(()=>{
                console.log('highchart redraw?');
            });
        });

How can I redraw or resize my chart on changing my leftmenu size? Currently the chart is overflowing from my div wrapper. Thanks in advance guys.

Body:
JS Fiddle

 $('#add').click(function () {
chart.addAxis({ // Secondary yAxis
    id: 'rainfall-axis',
    title: {
        text: 'Rainfall'
    },
    lineWidth: 2,
    lineColor: '#08F',
    opposite: true
});
chart.addSeries({
    name: 'Rainfall',
    type: 'column',
    color: '#08F',
    yAxis: 'rainfall-axis',
    data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
  $(this).attr('disabled', true);
  $('#remove').attr('disabled', false);
});
 $('#remove').click(function () {
  chart.get('temperature-axis').remove();

  $(this).attr('disabled', true);
$('#add').attr('disabled', false);
 });


Title: Pandas: How to extract Datetime ranges from DatetimeIndex

Body:
I have a collection of DatetimeIndex objects such as

DatetimeIndex(['2007-11-01 00:00:00', '2008-01-01 00:00:00',
               '2008-02-01 00:00:00', '2008-03-01 00:00:00',
               '2008-04-01 00:00:00', '2012-09-01 00:10:00',
               '2012-09-01 00:20:00', '2012-09-01 00:30:00',
               '2012-09-01 00:40:00', '2012-09-01 00:50:00',
               ...
               '2012-09-30 22:40:00', '2012-09-30 22:50:00',
               '2012-09-30 23:00:00', '2012-09-30 23:10:00',
               '2012-09-30 23:20:00', '2012-09-30 23:30:00',
               '2012-09-30 23:40:00', '2012-09-30 23:50:00',
               '2012-10-01 00:00:00', '2015-07-01 00:00:00'],
              dtype='datetime64[ns]', length=4326, freq=None, tz=None)

Both its freq and inferred_freq are None, I think because even though the data in fact have a 10 minute period, this cannot be detected due to missing parts. It is just these missing parts, or, equivalently, available parts, which I want to extract as efficiently as possible. Namely, i'd like to get something such as the following list of ranges:

[('2007-11-01 00:00:00', '2007-11-01 00:00:00'),
 ('2008-01-01 00:00:00', '2008-01-01 00:00:00'),
 ('2008-02-01 00:00:00', '2008-02-01 00:00:00'),
 ('2008-03-01 00:00:00', '2008-03-01 00:00:00'),
 ('2008-04-01 00:00:00', '2008-04-01 00:00:00'),
 ('2012-09-01 00:10:00', '2012-10-01 00:00:00'),
 ('2015-07-01 00:00:00', '2015-07-01 00:00:00')]

How should I go about doing this? I have looked at PeriodIndex, but that seems to be for a different type of application, or perhaps just doesn't deal with arbitrary time intervals yet.

Body:
I think you can use groupby by Series grouper and aggregate min and max:

grouper is created by comparing difference with 10 minute and cumsum.

rng = pd.DatetimeIndex(['2007-11-01 00:00:00', '2008-01-01 00:00:00',
               '2008-02-01 00:00:00', '2008-03-01 00:00:00',
               '2008-04-01 00:00:00', '2012-09-01 00:10:00',
               '2012-09-01 00:20:00', '2012-09-01 00:30:00',
               '2012-09-01 00:40:00', '2012-09-01 00:50:00',
               '2012-09-30 22:40:00', '2012-09-30 22:50:00',
               '2012-09-30 23:00:00', '2012-09-30 23:10:00',
               '2012-09-30 23:20:00', '2012-09-30 23:30:00',
               '2012-09-30 23:40:00', '2012-09-30 23:50:00',
               '2012-10-01 00:00:00', '2015-07-01 00:00:00'])

s = pd.Series(rng)
grouper = s.diff().ne(pd.to_timedelta('10min')).cumsum()
print (grouper)
0     1
1     2
2     3
3     4
4     5
5     6
6     6
7     6
8     6
9     6
10    7
11    7
12    8
13    8
14    8
15    8
16    8
17    8
18    8
19    9
dtype: int32

print (s.groupby(grouper).agg(['min', 'max']).astype(str).apply(tuple, axis=1).tolist())
[('2007-11-01 00:00:00', '2007-11-01 00:00:00'),
 ('2008-01-01 00:00:00', '2008-01-01 00:00:00'),
 ('2008-02-01 00:00:00', '2008-02-01 00:00:00'),
 ('2008-03-01 00:00:00', '2008-03-01 00:00:00'),
 ('2008-04-01 00:00:00', '2008-04-01 00:00:00'),
 ('2012-09-01 00:10:00', '2012-09-01 00:50:00'),
 ('2015-09-30 22:40:00', '2015-09-30 22:50:00'),
 ('2012-09-30 23:00:00', '2012-10-01 00:00:00'),
 ('2015-07-01 00:00:00', '2015-07-01 00:00:00')]


问:
Allow for loop initialization in GCC and Clang when std={c,gnu}89?
How can I enable for loop initialization when compiling in c89 or gnu89 mode using GCC and Clang?</p>

答:
You can't since loop initialization is a c99 feature.
Just use gnu99 or c99</p>


问:
Text alignment without using table in html and css
I'm trying to learn HTML and CSS and using the old-school approach by creating a login page with three input controls (two text and one button). However, I'm using

 for the alignment issues of textboxes. But I've read somewhere that using tables is not considered a good approach. This is what I'm doing:

Home.html

```<code><div>
    <table>
        <thead>
            <tr><th><span>Login Page</span></th></tr>
        </thead>
        <tbody>
            <tr>
            <th><label>Username:</label></th>
            <td><input type="text" value="" /></td>
            </tr>
            <tr>
                <th><label>Password:</label></th>
                <td><input type="text" value="" /></td>
            </tr>
            <tr>
                <td><input type="button" value="Submit" /></td>
            </tr>
        </tbody>
    </table>
</div>
</code>```

However, I'm using some beginner stuff of CSS to align input controls without using tables and this is what I'm trying:

Home.html

```<code><div class="box">
    <span>Login Page</span>
    <br />
    <span>
        <label>Username:</label>
        <input type="text" value="" />
        <br />
        <label>Password:</label>
        <input type="text" value="" />
        <br />
        <input type="button" value="Submit" />
    </span>
</div>
</code>```

style.css

```<code>.box {
   margin: 10px 10px 10px 10px;
   border: dotted 2px #fff;
   width: 500px;
}

.box span:first-child {
    border: dotted 1px;
    margin-left: 30%;
    font-family: Arial, sans-serif;
    width: 50%;
}

.box span label:nth-of-type(odd)
{
    color:blue;
    font-family: Arial, sans-serif;
}

.box span label:nth-of-type(even)
{
    color: red;
    font-family: Arial, sans-serif;
    display: inline-block;
}
</code>```

My concern is using css, I'm able to align the input controls but I have to use multiple break tags (
) and also extra code for alignment which is easier by simply using the
 tag. Can someone suggest me the standard approach and either I'm on the right path or not?

答:
Using table is not always good. One way to do is

```<code>   <div class="form-wrap">
     <h2>Login Form</h2>
     <div class="form-field">
       <label>User Name</label>
       <input type="text" value="" />
     </div>
     <div class="form-field">
       <label>Password</label>
       <input type="text" value="" />
     </div>
     <input type="button" value="Submit" />
    </div>
</code>```

CSS:

```<code>.form-field label {
  width: 80px;
  display: inline-block;
}
.form-field {
  margin-bottom: 10px;
}
</code>```

link to codepen

Body:
I'm trying to learn HTML and CSS and using the old-school approach by creating a login page with three input controls (two text and one button). However, I'm using

 for the alignment issues of textboxes. But I've read somewhere that using tables is not considered a good approach. This is what I'm doing:

Home.html

Login Page

            Username:
            <input type="text" value="" />

                Password:
                <input type="text" value="" />

                <input type="button" value="Submit" />

However, I'm using some beginner stuff of CSS to align input controls without using tables and this is what I'm trying:

Home.html

    Login Page

        Username:
        <input type="text" value="" />

        Password:
        <input type="text" value="" />

        <input type="button" value="Submit" />

style.css

.box {
   margin: 10px 10px 10px 10px;
   border: dotted 2px #fff;
   width: 500px;
}

.box span:first-child {
    border: dotted 1px;
    margin-left: 30%;
    font-family: Arial, sans-serif;
    width: 50%;
}

.box span label:nth-of-type(odd)
{
    color:blue;
    font-family: Arial, sans-serif;
}

.box span label:nth-of-type(even)
{
    color: red;
    font-family: Arial, sans-serif;
    display: inline-block;
}

My concern is using css, I'm able to align the input controls but I have to use multiple break tags (
) and also extra code for alignment which is easier by simply using the
 tag. Can someone suggest me the standard approach and either I'm on the right path or not?

Body:
Using table is not always good. One way to do is

   <div class="form-wrap">
     <h2>Login Form</h2>
     <div class="form-field">
       <label>User Name</label>
       <input type="text" value="" />
     </div>
     <div class="form-field">
       <label>Password</label>
       <input type="text" value="" />
     </div>
     <input type="button" value="Submit" />
    </div>

CSS:

.form-field label {
  width: 80px;
  display: inline-block;
}
.form-field {
  margin-bottom: 10px;
}

link to codepen