问:
jQuery UI Focus Stealing
Whenever I type something in the following Insert Hyperlink text input, all the words are going to textarea behind it. OK and Cancel buttons are working fine but I cannot focus to text input.

We'are using jQuery UI 1.10.1. It was working nicely with previous version of jQuery which was 1.8.x.

I've checked code behind of jQuery and it has the following methods called when opening a Modal Dialog:

```<code>_focusTabbable: function () {
    // Set focus to the first match:
    // 1. First element inside the dialog matching [autofocus]
    // 2. Tabbable element inside the content element
    // 3. Tabbable element inside the buttonpane
    // 4. The close button
    // 5. The dialog itself
    var hasFocus = this.element.find("[autofocus]");
    if (!hasFocus.length) {
        hasFocus = this.element.find(":tabbable");
    }
    if (!hasFocus.length) {
        hasFocus = this.uiDialogButtonPane.find(":tabbable");
    }
    if (!hasFocus.length) {
        hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
    }
    if (!hasFocus.length) {
        hasFocus = this.uiDialog;
    }
    hasFocus.eq(0).focus();
},

_keepFocus: function (event) {
    function checkFocus() {
        var activeElement = this.document[0].activeElement,
            isActive = this.uiDialog[0] === activeElement ||
                $.contains(this.uiDialog[0], activeElement);
        if (!isActive) {
            this._focusTabbable();
        }
    }
    event.preventDefault();
    checkFocus.call(this);
    // support: IE
    // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
    // so we check again later
    this._delay(checkFocus);
},
</code>```

that is taken from here: http://code.jquery.com/ui/1.10.1/jquery-ui.js

答:
I had a similar issue where I needed the focus to be within the content of my dialog box (for WCAG). Using focus() alone failed, so what my end solution was in the dialog instantiation I added:

```<code>focus: function(event, ui) {
                    setTimeout(function(){
                        $('#element').blur().focus().css({'color': '#000', 'text-decoration' : 'none', 'cursor' : 'default'});
                    }, 500);
                }
</code>```

I used the timeout to ensure compatibility. *Note, I made the '#element' an anchor tag (interactive element) so the focus would take. That is the reason for the styling.

This code should be able to be added into the "open" function of the jQuery Dialog as well.

Title: jQuery UI Focus Stealing

Body:
Whenever I type something in the following Insert Hyperlink text input, all the words are going to textarea behind it. OK and Cancel buttons are working fine but I cannot focus to text input.

We'are using jQuery UI 1.10.1. It was working nicely with previous version of jQuery which was 1.8.x.

I've checked code behind of jQuery and it has the following methods called when opening a Modal Dialog:

_focusTabbable: function () {
    // Set focus to the first match:
    // 1. First element inside the dialog matching [autofocus]
    // 2. Tabbable element inside the content element
    // 3. Tabbable element inside the buttonpane
    // 4. The close button
    // 5. The dialog itself
    var hasFocus = this.element.find("[autofocus]");
    if (!hasFocus.length) {
        hasFocus = this.element.find(":tabbable");
    }
    if (!hasFocus.length) {
        hasFocus = this.uiDialogButtonPane.find(":tabbable");
    }
    if (!hasFocus.length) {
        hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
    }
    if (!hasFocus.length) {
        hasFocus = this.uiDialog;
    }
    hasFocus.eq(0).focus();
},

_keepFocus: function (event) {
    function checkFocus() {
        var activeElement = this.document[0].activeElement,
            isActive = this.uiDialog[0] === activeElement ||
                $.contains(this.uiDialog[0], activeElement);
        if (!isActive) {
            this._focusTabbable();
        }
    }
    event.preventDefault();
    checkFocus.call(this);
    // support: IE
    // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
    // so we check again later
    this._delay(checkFocus);
},

that is taken from here: http://code.jquery.com/ui/1.10.1/jquery-ui.js

Body:
I had a similar issue where I needed the focus to be within the content of my dialog box (for WCAG). Using focus() alone failed, so what my end solution was in the dialog instantiation I added:

focus: function(event, ui) {
                    setTimeout(function(){
                        $('#element').blur().focus().css({'color': '#000', 'text-decoration' : 'none', 'cursor' : 'default'});
                    }, 500);
                }

I used the timeout to ensure compatibility. *Note, I made the '#element' an anchor tag (interactive element) so the focus would take. That is the reason for the styling.

This code should be able to be added into the "open" function of the jQuery Dialog as well.


来源: stackexchange

问:
How to solve this transformClassesAndResourcesWithProguardForRelease issue?
I'm trying to generate a signed apk of an app that is already in version code number 22, in this release I added push notifications from Firebase, so I've to add Google Services. In debug my app runs correctly, but when I try to generate the signed apk I receive the warning message above:

```<code>Warning:Exception while processing task java.io.IOException:
Can't write [C:\Users\Alejandro\HCT\Project\Project-Android\app\build\intermediates\transforms\proguard\release\jars\3\1f\main.jar]
(Can't read [C:\Users\Alejandro\.android\build-cache\04825c1d096bb9aba606e23c0e99208109f6122a\output\jars\classes.jar(;;;;;;**.class)]
(Duplicate zip entry [com/google/android/gms/internal/d.class ==
classes.jar:com/google/android/gms/internal/zzab.class]))
</code>```

And this error:

```<code>Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details
</code>```

This is my app.gradle:

```<code>buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'
    defaultConfig {
        applicationId "com.hct.btracker"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 22
        versionName "1.3.0"
    }
    buildTypes {
        release {
            //shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            debuggable true
            signingConfig signingConfigs.config
        }
    }
    dexOptions {
        jumboMode true
    }
}

repositories {
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile('com.mikepenz:materialdrawer:5.8.0@aar') { transitive = true }
    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { transitive = true; }
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.parse:parse-android:1.15.8'
    compile 'com.parse:parseui-login-android:0.0.2'
    compile 'com.parse:parseui-widget-android:0.0.2'
    compile 'com.github.PhilJay:MPAndroidChart:v2.2.4'
    compile 'com.github.hotchemi:android-rate:1.0.1'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.facebook.android:audience-network-sdk:4.16.0'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'joda-time:joda-time:2.9.3'
    compile 'uk.co.chrisjenx:calligraphy:2.3.0'
    compile 'com.google.firebase:firebase-messaging:10.2.6'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
</code>```

And this my project gradle:

```<code>// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
</code>```

I have this rules also:

```<code>-keep public class com.parse.**
-dontwarn com.parse.**
-dontwarn okio.**
-dontwarn org.joda.**
-dontwarn com.github.mikephil.**
-dontwarn com.google.android.gms.**
-dontwarn com.google.ads.**
-dontwarn okhttp3.**
-printmapping build/outputs/mapping/release/mapping.txt
</code>```

Can you please help me to solve this issue? I just don't know what is happening.

Thanks in advance!

答:
try this :</p>

```<code>compile 'com.google.firebase:firebase-messaging:10.2.6'
    exclude group: "com.google.android.gms"
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I'm trying to generate a signed apk of an app that is already in version code number 22, in this release I added push notifications from Firebase, so I've to add Google Services. In debug my app runs correctly, but when I try to generate the signed apk I receive the warning message above:

Warning:Exception while processing task java.io.IOException:
Can't write [C:\Users\Alejandro\HCT\Project\Project-Android\app\build\intermediates\transforms\proguard\release\jars\3\1f\main.jar]
(Can't read [C:\Users\Alejandro\.android\build-cache\04825c1d096bb9aba606e23c0e99208109f6122a\output\jars\classes.jar(;;;;;;**.class)]
(Duplicate zip entry [com/google/android/gms/internal/d.class ==
classes.jar:com/google/android/gms/internal/zzab.class]))

And this error:

Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details

This is my app.gradle:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'
    defaultConfig {
        applicationId "com.hct.btracker"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 22
        versionName "1.3.0"
    }
    buildTypes {
        release {
            //shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            debuggable true
            signingConfig signingConfigs.config
        }
    }
    dexOptions {
        jumboMode true
    }
}

repositories {
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile('com.mikepenz:materialdrawer:5.8.0@aar') { transitive = true }
    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { transitive = true; }
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.parse:parse-android:1.15.8'
    compile 'com.parse:parseui-login-android:0.0.2'
    compile 'com.parse:parseui-widget-android:0.0.2'
    compile 'com.github.PhilJay:MPAndroidChart:v2.2.4'
    compile 'com.github.hotchemi:android-rate:1.0.1'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.facebook.android:audience-network-sdk:4.16.0'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'joda-time:joda-time:2.9.3'
    compile 'uk.co.chrisjenx:calligraphy:2.3.0'
    compile 'com.google.firebase:firebase-messaging:10.2.6'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

And this my project gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

I have this rules also:

-keep public class com.parse.**
-dontwarn com.parse.**
-dontwarn okio.**
-dontwarn org.joda.**
-dontwarn com.github.mikephil.**
-dontwarn com.google.android.gms.**
-dontwarn com.google.ads.**
-dontwarn okhttp3.**
-printmapping build/outputs/mapping/release/mapping.txt

Can you please help me to solve this issue? I just don't know what is happening.

Thanks in advance!

Body:
try this :

compile 'com.google.firebase:firebase-messaging:10.2.6'
    exclude group: "com.google.android.gms"
}


问:
how do i invoke 32 bit gdb installed on Centos 64
I have Centos7 and I see both 32 and 64 bit version of gdb are installed however /usr/bin/gdb is the 64bit version. How can I invoke 32bit gdb version since i need to debug application compiled with -m32 compiler option</p>

答: The 64-bit GDB is perfectly capable of debugging both 64 and 32-bit programs. You don't need to invoke 32-bit GDB.


问:
Bind Combobox in WPF to Entity class
I have a data input form where i have textboxes,comboboxes and datepickers. I want to Bind comboboxes to the DB column so that users select the correct value for insertion. I have attached the viewmodel class and XAML code. In the viewmodel code "private void GetSW()" - this gets all the list of the entity class and "private void addSW()" this adds the record to the DB, Except the combobox binding everything works fine. in XAML i have binded combobox like this but this give blank combobox, please help what i am missing. I researched many topics on this forum but didn't find any solution

```<code><ComboBox x:Name="PSW" Grid.Column="3" Grid.Row="2" ItemsSource="{Binding newSW.PreviousSW}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Height="20"/>
</code>```

Its a ViewModel Code

```<code>using BusinessEntities;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using MUDB.Services;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace MUDB.Ui.Logic
{
    public class SoftwareVersionListViewModel:ViewModelBase
    {
        private bool enableRowDetails=false;
        public bool EnagleRowDetails
        {
            get { return enableRowDetails; }
            set {
                enableRowDetails = value;
                RaisePropertyChanged();
            }
        }

        public SoftwareVersionListViewModel()
        {
            SaveSW = new RelayCommand(addSW);
            //savecommand = new RelayCommand(addprod);
            GetSW();
            newSW = new SoftwareDefEntity();
            EditSW = new RelayCommand(() => {
                EnagleRowDetails = true;

                MessageBox.Show("Edit button clicked!!");});

            //SWList = new SoftwareDefEntity(); //Initializing the object of the Entity class
            }

        public List<SoftwareDefEntity> SWentities
        {
            get;
            set;
        }

        private SoftwareDefEntity _selectedsw;
        public SoftwareDefEntity Selectedsw
        {
            get { return _selectedsw; }
            set
            {
                _selectedsw = value; //This will get all the values of that particular Selected row that are defined in the entity class
                EnagleRowDetails = false; //Reset boolean value EnagleRowDetails, so that the selected rowdetails are disabled until Edit button is not clicked.
                //ShowView();
            }
        }

        public RelayCommand SaveSW { get; private set; }
        public RelayCommand EditSW { get; private set; }
        public SoftwareDefEntity newSW { get; private set; }

        private void ShowView()
        {
            //cUSTOM METHODS
        }

        private void GetSW() // Method that reads the data from the service layer
        {
            SWDefService obj = new SWDefService();
            SWentities = obj.getSW() ; //getSW is the method refered in Service layer

        }

        private void addSW()
        {
            SWDefService obj = new SWDefService();
            obj.addSW(newSW); //newproduct object will hold the value of the binded control, in XAML its binded like this "{Binding newproduct.ProductName(ProductName is the field name in the entityclass/DB table)}"
            newSW = new SoftwareDefEntity();

        }
    }

}
</code>```

This is the XAML Code

```<code><UserControl x:Class="MUDB.Ui.CreateSW"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:MUDB.Ui"
             xmlns:converter="clr-namespace:MUDB.Ui.Logic.Converters;assembly=MUDB.Ui.Logic"
             xmlns:enums="clr-namespace:MUDB.Ui.Logic.Enums;assembly=MUDB.Ui.Logic"
             mc:Ignorable="d" Height="Auto" Width="Auto"
            DataContext="{Binding SoftwareVersionList,Source={StaticResource Locator}}" >
    <UserControl.Resources>
        <converter:RadioButtonToBooleanConverter x:Key="RadioButtonToBooleanConverter" />
    </UserControl.Resources>
    <Grid>
        <Border Background="#90000000" Visibility="{Binding Visibility}">
            <Border BorderBrush="Black" BorderThickness="1" Background="White"
                    CornerRadius="10,0,10,0" VerticalAlignment="Center"
                    HorizontalAlignment="Center">
                <Border.BitmapEffect>
                    <DropShadowBitmapEffect Color="Black" Opacity="0.5" Direction="270" ShadowDepth="0.7" />
                </Border.BitmapEffect>
                <Grid Margin="10">

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition Width="Auto"/>

        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="40"/>
            <RowDefinition Height="25"/>
            <RowDefinition Height="30"/>
            <RowDefinition Height="25"/>
            <RowDefinition Height="30"/>
            <RowDefinition Height="25"/>
            <RowDefinition Height="30"/>
            <RowDefinition Height="100"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>

        <Label Content="Create New Software Version" Grid.Column="0" Grid.Row="0" Foreground="White" Background="black"
               HorizontalAlignment="Stretch" VerticalAlignment="Center" Grid.ColumnSpan="3" />
        <Label Content="ECU" Grid.Column="0" Grid.Row="1" Foreground="Black" HorizontalAlignment="Left"
               VerticalAlignment="Bottom" />
        <Label Content="Software Name" Grid.Column="1" Grid.Row="1" Foreground="Black" HorizontalAlignment="Left"
               VerticalAlignment="Bottom" />
        <Label Content="Previous Software" Grid.Column="2" Grid.Row="1" Foreground="Black" HorizontalAlignment="Left"
               VerticalAlignment="Bottom" />
        <Label Content="Request Freeze Date" Grid.Column="0" Grid.Row="3" Foreground="Black" HorizontalAlignment="Left"
               VerticalAlignment="Bottom" />
        <Label Content="Request Freeze Status" Grid.Column="1" Grid.Row="3" Foreground="Black" HorizontalAlignment="Left"
               VerticalAlignment="Bottom" />
        <Label Content="Software Freeze Date" Grid.Column="0" Grid.Row="5" Foreground="Black" HorizontalAlignment="Left"
               VerticalAlignment="Center" />
        <Label Content="Software Freeze Status" Grid.Column="1" Grid.Row="5" Foreground="Black" HorizontalAlignment="Left"
               VerticalAlignment="Center" />
        <Label Content="Comments" Grid.Column="0" Grid.Row="7" Foreground="Black" HorizontalAlignment="Left"
               VerticalAlignment="Center" />
                    <ComboBox x:Name="ECU" Grid.Column="0" Grid.Row="2" Text="{Binding newSW.ECU}" Margin="10 0 0 0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="80" Height="Auto">
                        <ComboBoxItem Name="cbi1">ACM</ComboBoxItem>
                        <ComboBoxItem Name="cbi2">MCM</ComboBoxItem>
                    </ComboBox>
                    <TextBox x:Name="SW" Grid.Column="1" Grid.Row="2" Text="{Binding newSW.SoftwareName}" HorizontalAlignment="Left" VerticalAlignment="Top"  Height="Auto" Width="150"  />
                    <ComboBox x:Name="PSW" Grid.Column="3" Grid.Row="2" ItemsSource="{Binding PreviousSW}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Height="20"/>
                    <DatePicker Grid.Column="0" Grid.Row="4" Margin="10 0 0 0" HorizontalAlignment="Left" VerticalAlignment="top" SelectedDate="{Binding newSW.Req_Freeze_Date}" Height="Auto" Width="Auto"/>
                    <DatePicker Grid.Column="0" Grid.Row="6" Margin="10 0 0 0" HorizontalAlignment="Left" VerticalAlignment="top" SelectedDate="{Binding newSW.SW_Freeze_Date}" Height="Auto" Width="Auto"/>
                    <RadioButton Content="Yes" GroupName="ReQstat" IsChecked="{Binding newSW.Req_Freeze_Status, Mode=OneWayToSource, Converter={StaticResource RadioButtonToBooleanConverter}, ConverterParameter={x:Static enums:RadioSelectionEnum.Yes}}" Style="{StaticResource AccentRadioButton}" Grid.Column="1" Grid.Row="4"  HorizontalAlignment="Left"  VerticalAlignment="Top" Height="14" Width="Auto"/>
                    <RadioButton Content="No" GroupName="ReQstat"  IsChecked="{Binding newSW.Req_Freeze_Status, Mode=OneWayToSource, Converter={StaticResource RadioButtonToBooleanConverter}, ConverterParameter={x:Static enums:RadioSelectionEnum.No}}" Style="{StaticResource AccentRadioButton}" Grid.Column="1" Grid.Row="4" Margin="60 0 0 0" HorizontalAlignment="Left"  VerticalAlignment="Top" Height="Auto" Width="Auto"/>
                    <RadioButton Content="Yes" GroupName="SWstat" IsChecked="{Binding newSW.SW_Freeze_Status, Mode=OneWayToSource, Converter={StaticResource RadioButtonToBooleanConverter}, ConverterParameter={x:Static enums:RadioSelectionEnum.Yes}}"   Style="{StaticResource AccentRadioButton}" Grid.Column="1" Grid.Row="6"  HorizontalAlignment="Left"  VerticalAlignment="Top" Height="Auto" Width="Auto"/>
                    <RadioButton Content="No" GroupName="SWstat" IsChecked="{Binding newSW.SW_Freeze_Status, Mode=OneWayToSource, Converter={StaticResource RadioButtonToBooleanConverter}, ConverterParameter={x:Static enums:RadioSelectionEnum.No}}"  Style="{StaticResource AccentRadioButton}" Grid.Column="1" Grid.Row="6" Margin="60 0 0 0" HorizontalAlignment="Left"  VerticalAlignment="Top" Height="Auto" Width="Auto"/>
                    <TextBox x:Name="CommenttextBox" Grid.Column="1" Grid.Row="7"  HorizontalAlignment="Left" Height="69" TextWrapping="WrapWithOverflow" VerticalAlignment="Center" Text="{Binding Comment}" Width="170" Margin="4.4,2.2,0,0" />
                    <UniformGrid Grid.Row="9" Margin="2" Columns="2" HorizontalAlignment="Stretch"
                                 VerticalAlignment="Center" Height="Auto">
                        <Button x:Name="SaveButton" Command="{Binding SaveSW}" Content="Save"  Height="27"   />
                        <Button x:Name="CloseButton" Click="CloseButton_Click" Content="Close" Height="26"  />
                    </UniformGrid>
                </Grid>
            </Border>
        </Border>
    </Grid>
</UserControl>
</code>```

答:
I guess you want to display the list of SoftwareDefEntity objects in your ComboBox.

Bind to the SWentities property then:

```<code><ComboBox x:Name="PSW" Grid.Column="3" Grid.Row="2" ItemsSource="{Binding SWentities}" DisplayMemberPath="Name" ... />
</code>```

And raise the PropertyChanged event in its setter of this property:

```<code>private List<SoftwareDefEntity> _swEntities;
public List<SoftwareDefEntity> SWentities
{
    get { return _swEntities; }
    set { _swEntities = value; RaisePropertyChanged(); }
}
</code>```

Title: Bind Combobox in WPF to Entity class

Body:
I have a data input form where i have textboxes,comboboxes and datepickers. I want to Bind comboboxes to the DB column so that users select the correct value for insertion. I have attached the viewmodel class and XAML code. In the viewmodel code "private void GetSW()" - this gets all the list of the entity class and "private void addSW()" this adds the record to the DB, Except the combobox binding everything works fine. in XAML i have binded combobox like this but this give blank combobox, please help what i am missing. I researched many topics on this forum but didn't find any solution

<ComboBox x:Name="PSW" Grid.Column="3" Grid.Row="2" ItemsSource="{Binding newSW.PreviousSW}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Height="20"/>

Its a ViewModel Code

using BusinessEntities;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using MUDB.Services;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace MUDB.Ui.Logic
{
    public class SoftwareVersionListViewModel:ViewModelBase
    {
        private bool enableRowDetails=false;
        public bool EnagleRowDetails
        {
            get { return enableRowDetails; }
            set {
                enableRowDetails = value;
                RaisePropertyChanged();
            }
        }

        public SoftwareVersionListViewModel()
        {
            SaveSW = new RelayCommand(addSW);
            //savecommand = new RelayCommand(addprod);
            GetSW();
            newSW = new SoftwareDefEntity();
            EditSW = new RelayCommand(() => {
                EnagleRowDetails = true;

                MessageBox.Show("Edit button clicked!!");});

            //SWList = new SoftwareDefEntity(); //Initializing the object of the Entity class
            }

        public List<SoftwareDefEntity> SWentities
        {
            get;
            set;
        }

        private SoftwareDefEntity _selectedsw;
        public SoftwareDefEntity Selectedsw
        {
            get { return _selectedsw; }
            set
            {
                _selectedsw = value; //This will get all the values of that particular Selected row that are defined in the entity class
                EnagleRowDetails = false; //Reset boolean value EnagleRowDetails, so that the selected rowdetails are disabled until Edit button is not clicked.
                //ShowView();
            }
        }

        public RelayCommand SaveSW { get; private set; }
        public RelayCommand EditSW { get; private set; }
        public SoftwareDefEntity newSW { get; private set; }

        private void ShowView()
        {
            //cUSTOM METHODS
        }

        private void GetSW() // Method that reads the data from the service layer
        {
            SWDefService obj = new SWDefService();
            SWentities = obj.getSW() ; //getSW is the method refered in Service layer

        }

        private void addSW()
        {
            SWDefService obj = new SWDefService();
            obj.addSW(newSW); //newproduct object will hold the value of the binded control, in XAML its binded like this "{Binding newproduct.ProductName(ProductName is the field name in the entityclass/DB table)}"
            newSW = new SoftwareDefEntity();

        }
    }

}

This is the XAML Code

<UserControl x:Class="MUDB.Ui.CreateSW"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:MUDB.Ui"
             xmlns:converter="clr-namespace:MUDB.Ui.Logic.Converters;assembly=MUDB.Ui.Logic"
             xmlns:enums="clr-namespace:MUDB.Ui.Logic.Enums;assembly=MUDB.Ui.Logic"
             mc:Ignorable="d" Height="Auto" Width="Auto"
            DataContext="{Binding SoftwareVersionList,Source={StaticResource Locator}}" >
    <UserControl.Resources>
        <converter:RadioButtonToBooleanConverter x:Key="RadioButtonToBooleanConverter" />
    </UserControl.Resources>
    <Grid>
        <Border Background="#90000000" Visibility="{Binding Visibility}">
            <Border BorderBrush="Black" BorderThickness="1" Background="White"
                    CornerRadius="10,0,10,0" VerticalAlignment="Center"
                    HorizontalAlignment="Center">
                <Border.BitmapEffect>
                    <DropShadowBitmapEffect Color="Black" Opacity="0.5" Direction="270" ShadowDepth="0.7" />
                </Border.BitmapEffect>
                <Grid Margin="10">

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition Width="Auto"/>

        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="40"/>
            <RowDefinition Height="25"/>
            <RowDefinition Height="30"/>
            <RowDefinition Height="25"/>
            <RowDefinition Height="30"/>
            <RowDefinition Height="25"/>
            <RowDefinition Height="30"/>
            <RowDefinition Height="100"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>

                    <ComboBox x:Name="ECU" Grid.Column="0" Grid.Row="2" Text="{Binding newSW.ECU}" Margin="10 0 0 0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="80" Height="Auto">
                        <ComboBoxItem Name="cbi1">ACM</ComboBoxItem>
                        <ComboBoxItem Name="cbi2">MCM</ComboBoxItem>
                    </ComboBox>
                    <TextBox x:Name="SW" Grid.Column="1" Grid.Row="2" Text="{Binding newSW.SoftwareName}" HorizontalAlignment="Left" VerticalAlignment="Top"  Height="Auto" Width="150"  />
                    <ComboBox x:Name="PSW" Grid.Column="3" Grid.Row="2" ItemsSource="{Binding PreviousSW}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Height="20"/>
                    <DatePicker Grid.Column="0" Grid.Row="4" Margin="10 0 0 0" HorizontalAlignment="Left" VerticalAlignment="top" SelectedDate="{Binding newSW.Req_Freeze_Date}" Height="Auto" Width="Auto"/>
                    <DatePicker Grid.Column="0" Grid.Row="6" Margin="10 0 0 0" HorizontalAlignment="Left" VerticalAlignment="top" SelectedDate="{Binding newSW.SW_Freeze_Date}" Height="Auto" Width="Auto"/>
                    <RadioButton Content="Yes" GroupName="ReQstat" IsChecked="{Binding newSW.Req_Freeze_Status, Mode=OneWayToSource, Converter={StaticResource RadioButtonToBooleanConverter}, ConverterParameter={x:Static enums:RadioSelectionEnum.Yes}}" Style="{StaticResource AccentRadioButton}" Grid.Column="1" Grid.Row="4"  HorizontalAlignment="Left"  VerticalAlignment="Top" Height="14" Width="Auto"/>
                    <RadioButton Content="No" GroupName="ReQstat"  IsChecked="{Binding newSW.Req_Freeze_Status, Mode=OneWayToSource, Converter={StaticResource RadioButtonToBooleanConverter}, ConverterParameter={x:Static enums:RadioSelectionEnum.No}}" Style="{StaticResource AccentRadioButton}" Grid.Column="1" Grid.Row="4" Margin="60 0 0 0" HorizontalAlignment="Left"  VerticalAlignment="Top" Height="Auto" Width="Auto"/>
                    <RadioButton Content="Yes" GroupName="SWstat" IsChecked="{Binding newSW.SW_Freeze_Status, Mode=OneWayToSource, Converter={StaticResource RadioButtonToBooleanConverter}, ConverterParameter={x:Static enums:RadioSelectionEnum.Yes}}"   Style="{StaticResource AccentRadioButton}" Grid.Column="1" Grid.Row="6"  HorizontalAlignment="Left"  VerticalAlignment="Top" Height="Auto" Width="Auto"/>
                    <RadioButton Content="No" GroupName="SWstat" IsChecked="{Binding newSW.SW_Freeze_Status, Mode=OneWayToSource, Converter={StaticResource RadioButtonToBooleanConverter}, ConverterParameter={x:Static enums:RadioSelectionEnum.No}}"  Style="{StaticResource AccentRadioButton}" Grid.Column="1" Grid.Row="6" Margin="60 0 0 0" HorizontalAlignment="Left"  VerticalAlignment="Top" Height="Auto" Width="Auto"/>
                    <TextBox x:Name="CommenttextBox" Grid.Column="1" Grid.Row="7"  HorizontalAlignment="Left" Height="69" TextWrapping="WrapWithOverflow" VerticalAlignment="Center" Text="{Binding Comment}" Width="170" Margin="4.4,2.2,0,0" />
                    <UniformGrid Grid.Row="9" Margin="2" Columns="2" HorizontalAlignment="Stretch"
                                 VerticalAlignment="Center" Height="Auto">
                        <Button x:Name="SaveButton" Command="{Binding SaveSW}" Content="Save"  Height="27"   />
                        <Button x:Name="CloseButton" Click="CloseButton_Click" Content="Close" Height="26"  />
                    </UniformGrid>
                </Grid>
            </Border>
        </Border>
    </Grid>
</UserControl>

Body:
I guess you want to display the list of SoftwareDefEntity objects in your ComboBox.

Bind to the SWentities property then:

<ComboBox x:Name="PSW" Grid.Column="3" Grid.Row="2" ItemsSource="{Binding SWentities}" DisplayMemberPath="Name" ... />

And raise the PropertyChanged event in its setter of this property:

private List<SoftwareDefEntity> _swEntities;
public List<SoftwareDefEntity> SWentities
{
    get { return _swEntities; }
    set { _swEntities = value; RaisePropertyChanged(); }
}


问:
Use of sizeof operator in C
I wrote a code to print size of different data types in C .

```<code>#include<stdio.h>
int main()
{
     printf("%d", sizeof(int));//size of integer
     printf("%d", sizeof(float));
     printf("%d", sizeof(double));
     printf("%d", sizeof(char));
}
</code>```

This does not work , but if I replace %d with %ld, it works. I did not understand why I have to take long int to print a small range number.

答:
You say it does not work, but you do not say what it does. The most probable reason for this unexpected behavior is:

the conversion specifier %d expects an int value. sizeof(int) has type size_t which is unsigned and, on many platforms, larger than int, causing undefined behavior.

The conversion specifier and the type of the passed argument must be consistent because different types are passed in different ways to a vararg function like printf().  If you pass a size_t and printf expects an int, it will retrieve the value from the wrong place and produce inconsistent output if at all.

You say it works if I put %ld.  This conversion may work because size_t happens to have the same size as long for your platform, but it is only a coincidence, on 64-bit Windows, size_t is larger than long.

To correct the problem, you can either:

use the standard conversion specifier %zu or

cast the value as int.

The first is the correct fix but some C libraries do not support %zu, most notably Microsoft C runtime libraries prior to VS2013.  Hence I recommend the second as more portable and sufficient for types and objects that obviously have a small size:

```<code>#include <stdio.h>

int main(void) {
    printf("%d\n", (int)sizeof(int));
    printf("%d\n", (int)sizeof(float));
    printf("%d\n", (int)sizeof(double));
    printf("%d\n", (int)sizeof(char));
    return 0;
}
</code>```

Also note that you do not output a newline:  Depending on the environment, the output will not be visible to the user until a newline is output or fflush(stdout) is called. It is even possible that the output not be flushed to the console upon program exit, causing your observed behavior, but such environments are uncommon. It is recommended to output newlines at the end of meaningful pieces of output. In your case, not doing so would cause all sizes to be clumped together as a sequence of digits like 4481, which may or may not be what you expect.

Title: Use of sizeof operator in C

Body:
I wrote a code to print size of different data types in C .

#include<stdio.h>
int main()
{
     printf("%d", sizeof(int));//size of integer
     printf("%d", sizeof(float));
     printf("%d", sizeof(double));
     printf("%d", sizeof(char));
}

This does not work , but if I replace %d with %ld, it works. I did not understand why I have to take long int to print a small range number.

Body:
You say it does not work, but you do not say what it does. The most probable reason for this unexpected behavior is:

the conversion specifier %d expects an int value. sizeof(int) has type size_t which is unsigned and, on many platforms, larger than int, causing undefined behavior.

The conversion specifier and the type of the passed argument must be consistent because different types are passed in different ways to a vararg function like printf().  If you pass a size_t and printf expects an int, it will retrieve the value from the wrong place and produce inconsistent output if at all.

You say it works if I put %ld.  This conversion may work because size_t happens to have the same size as long for your platform, but it is only a coincidence, on 64-bit Windows, size_t is larger than long.

To correct the problem, you can either:

use the standard conversion specifier %zu or

cast the value as int.

The first is the correct fix but some C libraries do not support %zu, most notably Microsoft C runtime libraries prior to VS2013.  Hence I recommend the second as more portable and sufficient for types and objects that obviously have a small size:

#include <stdio.h>

int main(void) {
    printf("%d\n", (int)sizeof(int));
    printf("%d\n", (int)sizeof(float));
    printf("%d\n", (int)sizeof(double));
    printf("%d\n", (int)sizeof(char));
    return 0;
}

Also note that you do not output a newline:  Depending on the environment, the output will not be visible to the user until a newline is output or fflush(stdout) is called. It is even possible that the output not be flushed to the console upon program exit, causing your observed behavior, but such environments are uncommon. It is recommended to output newlines at the end of meaningful pieces of output. In your case, not doing so would cause all sizes to be clumped together as a sequence of digits like 4481, which may or may not be what you expect.


问:
Can anyone tell me why I'm getting the attributeError? 'str' object has no attribute 'real'
```<code>def getFFtMag(data):
    maglist = []
    for x in range(0, len(data)):
        dataVal = data[x]
        firstVal = dataVal.real
        secondVal = dataVal.imag
        mag = math.sqrt(firstVal*firstVal + secondVal*secondVal)
        maglist.append(mag)
    return maglist

>>> getFFtMag("25 - Copy.xlsx")
Traceback (most recent call last):
  File "<pyshell#11>", line 1, in <module>
    getFFtMag("25 - Copy.xlsx")
  File "<pyshell#10>", line 5, in getFFtMag
    firstVal = dataVal.real
AttributeError: 'str' object has no attribute 'real'
>>>
</code>```

So can anyone tell me why my code is wrong?  The attached error seems to be popping up.  I'm new to python and learning what is going on.  Is the problem with my data that I inputted?  Thanks.

答:
You're attempting to read data out of a file and not first parsing it into the complex number format. Data read out of a file will either be a string or a byte-like object depending on how you opened the file. But here, you haven't even opened the file yet.

In order to tell you how to specifically resolve this problem we will need to see the format of the file you are trying to operate on.

Body:
def getFFtMag(data):
    maglist = []
    for x in range(0, len(data)):
        dataVal = data[x]
        firstVal = dataVal.real
        secondVal = dataVal.imag
        mag = math.sqrt(firstVal*firstVal + secondVal*secondVal)
        maglist.append(mag)
    return maglist

>>> getFFtMag("25 - Copy.xlsx")
Traceback (most recent call last):
  File "<pyshell#11>", line 1, in <module>
    getFFtMag("25 - Copy.xlsx")
  File "<pyshell#10>", line 5, in getFFtMag
    firstVal = dataVal.real
AttributeError: 'str' object has no attribute 'real'
>>>

So can anyone tell me why my code is wrong?  The attached error seems to be popping up.  I'm new to python and learning what is going on.  Is the problem with my data that I inputted?  Thanks.


问:
Can you add pie charts to a dashboard in Youtrack 2017.2?
I can create pie charts in Youtrack and I was under the impression that it is possible to add such as widgets to your dashboard, but I can't figure out how to do this. Is this really not possible?</p>

答: You need a report for creating a chart widget. In the report options you can change the presentation to pie diagram.</p>


问:
Syntax Error(missing operator) in query expression - MS-Access
This doesn't produce syntax errors but it gives wrong arguments error:

```<code>SELECT left(
  [aname],
 IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
   Len(FinalForgotten.aname),
  IIF(instr([aname], ",") = 0,
    InStr(1,[aname]," ")-1,
    InStr(1,[aname],",")-1)))
&  ","  &

right(
   [aname],
 IIF(instr([aname], " " = 0 AND instr([aname], ",") = 0,
   Len(FinalForgotten.aname),
    IIF(instr([aname], ",") = 0,
      Len(aname)-InStr(1,[aname]," "),
      Len(aname)-InStr(1,[aname],",")))))
 &  " " &

defense_final.middle_initial AS fullname INTO FinalForgottenWithMiddle
FROM FinalForgotten INNER JOIN defense_final ON (right(FinalForgotten.aname,
 IIF(instr([aname], ",") = 0,
 Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname]," "),
 Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname],",")
  )
 )=defense_final.first_name) AND (left(FinalForgotten.aname,
IIF(instr([aname], ",") = 0,
  InStr(1,FinalForgotten.[aname]," ")-1,
  InStr(1,FinalForgotten.[aname],",")-1
    )
)=defense_final.last_name);
</code>```

So adding the extra arguments I now get syntax error "Missing ), ], or Item in query expression" :

```<code>   SELECT left(
  [aname],
 IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
   Len(FinalForgotten.aname),
  IIF(instr([aname], ",") = 0,
    InStr(1,[aname]," ")-1,
    InStr(1,[aname],",")-1)))
&  ","  &

right(
   [aname],
 IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
   Len(FinalForgotten.aname),
    IIF(instr([aname], ",") = 0,
      Len(aname)-InStr(1,[aname]," "),
      Len(aname)-InStr(1,[aname],","))))
 &  " " &

defense_final.middle_initial AS fullname INTO FinalForgottenWithMiddle
FROM FinalForgotten INNER JOIN defense_final ON

left(FinalForgotten.aname,
   IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
      Len(FinalForgotten.aname),
      IIF(instr([aname], ",") = 0,
        InStr(1,FinalForgotten.[aname]," ")-1,
        InStr(1,FinalForgotten.[aname],",")-1)))

 =defense_final.last_name AND

 right(FinalForgotten.aname,
      IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
      Len(FinalForgotten.aname),
       IIF(instr([aname], ",") = 0,
        Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname]," "),
        Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname],","))))

=defense_final.first_name;
</code>```

Any workaround?

Thanks for response.

答:
It would be easier to put that logic into VBA functions so your query looks like this

```<code>SELECT GetFullNameWithMiddle([aname]) AS fullname
INTO FinalForgottenWithMiddle
FROM FinalForgotten INNER JOIN defense_final
    ON GetLastName([aname])=defense_final.last_name
    AND GetFirstName([aname])=defense_final.first_name
</code>```

Since you say you don't want to use VBA, try this instead.  I enclosed every

```<code>InStr(x, y) = 0
</code>```

in parentheses, so

```<code>IIf(InStr(x, y) = 0 AND InStr(p, q) = 0, g, h)
</code>```

becomes

```<code>IIf((InStr(x, y) = 0) AND (InStr(p, q) = 0), g, h)
</code>```

Making that change allowed me to switch into the query design grid, which means that the SQL parser liked it:

```<code>SELECT left(
    [aname],
    IIF((instr([aname], " ") = 0) AND (instr([aname], ",") = 0),
    Len(FinalForgotten.aname),
    IIF((instr([aname], ",") = 0),
    InStr(1,[aname]," ")-1,
    InStr(1,[aname],",")-1)))

    &  ","  &

right(
    [aname],
    IIF((instr([aname], " ") = 0) AND (instr([aname], ",") = 0),
    Len(FinalForgotten.aname),
    IIF((instr([aname], ",") = 0),
      Len(aname)-InStr(1,[aname]," "),
      Len(aname)-InStr(1,[aname],","))))

    &  " " &

defense_final.middle_initial AS fullname INTO FinalForgottenWithMiddle
FROM FinalForgotten INNER JOIN defense_final ON

left(FinalForgotten.aname,
    IIF((instr([aname], " ") = 0) AND (instr([aname], ",") = 0),
    Len(FinalForgotten.aname),
    IIF((instr([aname], ",") = 0),
    InStr(1,FinalForgotten.[aname]," ")-1,
    InStr(1,FinalForgotten.[aname],",")-1)))

=defense_final.last_name AND

right(FinalForgotten.aname,
    IIF((instr([aname], " ") = 0) AND (instr([aname], ",") = 0),
    Len(FinalForgotten.aname),
    IIF((instr([aname], ",") = 0),
    Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname]," "),
    Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname],","))))

=defense_final.first_name;
</code>```

ContentLicense: CC BY-SA 2.5

Body:
This doesn't produce syntax errors but it gives wrong arguments error:

SELECT left(
  [aname],
 IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
   Len(FinalForgotten.aname),
  IIF(instr([aname], ",") = 0,
    InStr(1,[aname]," ")-1,
    InStr(1,[aname],",")-1)))
&  ","  &

right(
   [aname],
 IIF(instr([aname], " " = 0 AND instr([aname], ",") = 0,
   Len(FinalForgotten.aname),
    IIF(instr([aname], ",") = 0,
      Len(aname)-InStr(1,[aname]," "),
      Len(aname)-InStr(1,[aname],",")))))
 &  " " &

defense_final.middle_initial AS fullname INTO FinalForgottenWithMiddle
FROM FinalForgotten INNER JOIN defense_final ON (right(FinalForgotten.aname,
 IIF(instr([aname], ",") = 0,
 Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname]," "),
 Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname],",")
  )
 )=defense_final.first_name) AND (left(FinalForgotten.aname,
IIF(instr([aname], ",") = 0,
  InStr(1,FinalForgotten.[aname]," ")-1,
  InStr(1,FinalForgotten.[aname],",")-1
    )
)=defense_final.last_name);

So adding the extra arguments I now get syntax error "Missing ), ], or Item in query expression" :

   SELECT left(
  [aname],
 IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
   Len(FinalForgotten.aname),
  IIF(instr([aname], ",") = 0,
    InStr(1,[aname]," ")-1,
    InStr(1,[aname],",")-1)))
&  ","  &

right(
   [aname],
 IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
   Len(FinalForgotten.aname),
    IIF(instr([aname], ",") = 0,
      Len(aname)-InStr(1,[aname]," "),
      Len(aname)-InStr(1,[aname],","))))
 &  " " &

defense_final.middle_initial AS fullname INTO FinalForgottenWithMiddle
FROM FinalForgotten INNER JOIN defense_final ON

left(FinalForgotten.aname,
   IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
      Len(FinalForgotten.aname),
      IIF(instr([aname], ",") = 0,
        InStr(1,FinalForgotten.[aname]," ")-1,
        InStr(1,FinalForgotten.[aname],",")-1)))

 =defense_final.last_name AND

 right(FinalForgotten.aname,
      IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
      Len(FinalForgotten.aname),
       IIF(instr([aname], ",") = 0,
        Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname]," "),
        Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname],","))))

=defense_final.first_name;

Any workaround?

Thanks for response.

Body:
It would be easier to put that logic into VBA functions so your query looks like this

SELECT GetFullNameWithMiddle([aname]) AS fullname
INTO FinalForgottenWithMiddle
FROM FinalForgotten INNER JOIN defense_final
    ON GetLastName([aname])=defense_final.last_name
    AND GetFirstName([aname])=defense_final.first_name

Since you say you don't want to use VBA, try this instead.  I enclosed every

InStr(x, y) = 0

in parentheses, so

IIf(InStr(x, y) = 0 AND InStr(p, q) = 0, g, h)

becomes

IIf((InStr(x, y) = 0) AND (InStr(p, q) = 0), g, h)

Making that change allowed me to switch into the query design grid, which means that the SQL parser liked it:

SELECT left(
    [aname],
    IIF((instr([aname], " ") = 0) AND (instr([aname], ",") = 0),
    Len(FinalForgotten.aname),
    IIF((instr([aname], ",") = 0),
    InStr(1,[aname]," ")-1,
    InStr(1,[aname],",")-1)))

    &  ","  &

right(
    [aname],
    IIF((instr([aname], " ") = 0) AND (instr([aname], ",") = 0),
    Len(FinalForgotten.aname),
    IIF((instr([aname], ",") = 0),
      Len(aname)-InStr(1,[aname]," "),
      Len(aname)-InStr(1,[aname],","))))

    &  " " &

defense_final.middle_initial AS fullname INTO FinalForgottenWithMiddle
FROM FinalForgotten INNER JOIN defense_final ON

left(FinalForgotten.aname,
    IIF((instr([aname], " ") = 0) AND (instr([aname], ",") = 0),
    Len(FinalForgotten.aname),
    IIF((instr([aname], ",") = 0),
    InStr(1,FinalForgotten.[aname]," ")-1,
    InStr(1,FinalForgotten.[aname],",")-1)))

=defense_final.last_name AND

right(FinalForgotten.aname,
    IIF((instr([aname], " ") = 0) AND (instr([aname], ",") = 0),
    Len(FinalForgotten.aname),
    IIF((instr([aname], ",") = 0),
    Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname]," "),
    Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname],","))))

=defense_final.first_name;


问:
Most efficient way to check if any element in a JSON array contains a specific id?
I am using Node v8.1.3

I have a JSON array as following:

```<code>[
  {
    "id":99,
    "name": "ABC"
  },
  {
    "id": 187,
    "name": "AXZ"
  }
]
</code>```

This array has around 213000 e=objects in it.

Also, the ids in the objects are not in any order or pattern.

Now, I want to find if a particular id matches any ID in the array? what  is the fastest wait to do it?

I tried

```<code>isIdValid(id) {
    console.log(id)
    return this.list.filter((elem) => {
        return elem.id == id
    }).length > 0;
}
</code>```

But this is taking over 4 seconds.

答:
These are not the "Most efficient way to check". I'm posting here just as a reference about some ways to prepare the data to have a more performant search by a specific key.

Also is worth considering that in this script, Map can have a better performance, just because it is the last of all the executions. When its turn comes, V8 would have already been done some optimizations internally. So try to run each of them separately to have better findings.

'use strict';

////////////////////////
// GENERATE TEST DATA //
////////////////////////
const dataSet = [];
let count = 213000;
while(count--) dataSet.push({id: count});
let idToBeFound = 212999;

// //////////////////////////
// // Using Literal Object //
// //////////////////////////
console.time('creatingIndexAsLiteralObject');
const literalObjectKeyedByID = dataSet.map(item => ({[item.id]: true}));
console.timeEnd('creatingIndexAsLiteralObject');

console.time('isIdValidSeekingOnLiteralObject');
console.log('isIdValidSeekingOnLiteralObject :: Found?', isIdValidSeekingOnLiteralObject(idToBeFound, literalObjectKeyedByID));
console.timeEnd('isIdValidSeekingOnLiteralObject');
function isIdValidSeekingOnLiteralObject(id, list) {
    return !!list[id];
}

// //////////////////////
// // Using Set Object //
// //////////////////////
console.time('creatingIndexAsSetObject');
const setObject = new Set(dataSet.map(item => item.id));
console.timeEnd('creatingIndexAsSetObject');

console.time('isIdValidSeekingOnSet');
console.log('isIdValidSeekingOnSet :: Found?', isIdValidSeekingOnSet(idToBeFound, setObject));
console.timeEnd('isIdValidSeekingOnSet');
function isIdValidSeekingOnSet(id, list) {
    return list.has(id);
}

//////////////////////
// Using Map Object //
//////////////////////
console.time('creatingIndexAsMapObject');
const mapObjectKeyedByID = new Map();
dataSet.forEach(item => mapObjectKeyedByID.set(item.id));
console.timeEnd('creatingIndexAsMapObject');

console.time('isIdValidSeekingOnMap');
console.log('isIdValidSeekingOnMap :: Found?', isIdValidSeekingOnMap(idToBeFound, mapObjectKeyedByID));
console.timeEnd('isIdValidSeekingOnMap');
function isIdValidSeekingOnMap(id, list) {
    return list.has(id);
}```

Body:
I am using Node v8.1.3

I have a JSON array as following:

[
  {
    "id":99,
    "name": "ABC"
  },
  {
    "id": 187,
    "name": "AXZ"
  }
]

This array has around 213000 e=objects in it.

Also, the ids in the objects are not in any order or pattern.

Now, I want to find if a particular id matches any ID in the array? what  is the fastest wait to do it?

I tried

isIdValid(id) {
    console.log(id)
    return this.list.filter((elem) => {
        return elem.id == id
    }).length > 0;
}

But this is taking over 4 seconds.


问:
How to skip first few elements from array?
I have an array with total 5000 elements and at one functionality, I only need last 3000 elements only to proceed further.

for that I have tried following solution.

```<code>//skipping first 2000 elements
list = list.Skip(5000 - 3000).ToArray();
</code>```

This solution is actually giving me desired solution, but when I ran profiler on my code, It is showing huge amount memory allocation on this line.

I have to use Array only due to carried on legacy. and very frequent ToArray() doesn't seem to be good for performance.

there is also possible solution,

```<code>//reversing whole list
Array.Reverse(list);
//restricting size of an array to 3000,
//so first (as reversed the list, they are last 3000 elements)
Array.Resize(ref list, 3000);
//again reversing list to make it proper order
Array.Reverse(list);
</code>```

but this is even worse in time complexity.

Is there any better solution for this, which doesn't need casting from List to Array ?

答:
If you absolutely have to use an array, then Array.Copy is probably your friend:

```<code>int[] smallerArray = new int[array.Length - 2000];
Array.Copy(array, 2000, smallerArray, 0, smallerArray.Length);
</code>```

I'd expect that to be a bit more efficient than using Take followed by ToArray.

Body:
I have an array with total 5000 elements and at one functionality, I only need last 3000 elements only to proceed further.

for that I have tried following solution.

//skipping first 2000 elements
list = list.Skip(5000 - 3000).ToArray();

This solution is actually giving me desired solution, but when I ran profiler on my code, It is showing huge amount memory allocation on this line.

I have to use Array only due to carried on legacy. and very frequent ToArray() doesn't seem to be good for performance.

there is also possible solution,

//reversing whole list
Array.Reverse(list);
//restricting size of an array to 3000,
//so first (as reversed the list, they are last 3000 elements)
Array.Resize(ref list, 3000);
//again reversing list to make it proper order
Array.Reverse(list);

but this is even worse in time complexity.

Is there any better solution for this, which doesn't need casting from List to Array ?

Body:
If you absolutely have to use an array, then Array.Copy is probably your friend:

int[] smallerArray = new int[array.Length - 2000];
Array.Copy(array, 2000, smallerArray, 0, smallerArray.Length);

I'd expect that to be a bit more efficient than using Take followed by ToArray.


问:
Find every two (non-overlapping) vowels inbetween consonants

Task
   You are given a string . It consists of alphanumeric characters, spaces and symbols(+,-).
   Your task is to find all the substrings of the origina string that contain two or more vowels.
   Also, these substrings must lie in between consonants and should contain vowels only.

Input Format: a single line of input containing string .

Output Format: print the matched substrings in their order of occurrence on separate
  lines.   If no match is found, print -1.

Sample Input:
  rabcdeefgyYhFjkIoomnpOeorteeeeet

Sample Output:

ee

  Ioo

  Oeo

  eeeee

The challenge above was taken from https://www.hackerrank.com/challenges/re-findall-re-finditer

The following code passes all the test cases:

```<code>import re

sol = re.findall(r"[^aiueo]([aiueoAIUEO]{2,})(?=[^aiueo])", input())

if sol:
    for s in sol:
        print(s)
else:
    print(-1)
</code>```

The following doesn't.

```<code>import re

sol = re.findall(r"[^aiueo]([aiueoAIUEO]{2,})[^aiueo]", input())

if sol:
    for s in sol:
        print(s)
else:
    print(-1)
</code>```

The only difference beteen them is the final bit of the regex. I can't understand why the second code fails. I would argue that ?= is useless because by grouping [aiueoAIUEO]{2,} I'm already excluding it from capture, but obviously I'm wrong and I can't tell why.

Any help?

答:
The lookahead approach allows the consonant that ends one sequence of vowels to start the next sequence, whereas the non-lookahead approach requires at least two consonants between those sequences (one to end a sequence, another to start the next, as both are matched).

See

```<code>import re
print(re.findall(r'[^aiueo]([aiueoAIUEO]{2,})(?=[^aiueo])', 'moomoom'))
print(re.findall(r'[^aiueo]([aiueoAIUEO]{2,})[^aiueo]', 'moomoom'))
</code>```

Which will output

```<code>['oo', 'oo']
['oo']
</code>```

https://ideone.com/2Wn1TS

To be a bit picky, both attempts aren't correct regarding your problem description. They allow for uppercase vowels, spaces and symbols to be separators. You might want to use [b-df-hj-np-tv-z] instead of [^aeiou] and use flags=re.I

Body:
Task
   You are given a string . It consists of alphanumeric characters, spaces and symbols(+,-).
   Your task is to find all the substrings of the origina string that contain two or more vowels.
   Also, these substrings must lie in between consonants and should contain vowels only.

Input Format: a single line of input containing string .

Output Format: print the matched substrings in their order of occurrence on separate
  lines.   If no match is found, print -1.

Sample Input:
  rabcdeefgyYhFjkIoomnpOeorteeeeet

Sample Output:

ee

  Ioo

  Oeo

  eeeee

The challenge above was taken from https://www.hackerrank.com/challenges/re-findall-re-finditer

The following code passes all the test cases:

import re

sol = re.findall(r"[^aiueo]([aiueoAIUEO]{2,})(?=[^aiueo])", input())

if sol:
    for s in sol:
        print(s)
else:
    print(-1)

The following doesn't.

import re

sol = re.findall(r"[^aiueo]([aiueoAIUEO]{2,})[^aiueo]", input())

if sol:
    for s in sol:
        print(s)
else:
    print(-1)

The only difference beteen them is the final bit of the regex. I can't understand why the second code fails. I would argue that ?= is useless because by grouping [aiueoAIUEO]{2,} I'm already excluding it from capture, but obviously I'm wrong and I can't tell why.

Any help?

Body:
The lookahead approach allows the consonant that ends one sequence of vowels to start the next sequence, whereas the non-lookahead approach requires at least two consonants between those sequences (one to end a sequence, another to start the next, as both are matched).

See

import re
print(re.findall(r'[^aiueo]([aiueoAIUEO]{2,})(?=[^aiueo])', 'moomoom'))
print(re.findall(r'[^aiueo]([aiueoAIUEO]{2,})[^aiueo]', 'moomoom'))

Which will output

['oo', 'oo']
['oo']

https://ideone.com/2Wn1TS

To be a bit picky, both attempts aren't correct regarding your problem description. They allow for uppercase vowels, spaces and symbols to be separators. You might want to use [b-df-hj-np-tv-z] instead of [^aeiou] and use flags=re.I


问:
C#: Properties that may require a network call?
I know that in C#, properties are supposed to be quick operations (not reading data from a network or file system, etc.) However, I am building a Silverlight app and I need to bind a XAML element to some network data on a ViewModel. As far as I am aware, binding can only be done to properties, not methods. Should I break the guideline here, or is there another way around this that's not occurring to me?</p>

```<code><ListBox ItemsSource="{Binding Users}" />

public IEnumerable<User> Users
{
    get
    {
        // may be cached
        return expensiveNetworkCall();
    }
}
</code>```

答:
I think the concern here is - should you make your users wait for the complete binding to take place? You could spawn that activity off to another method and return what you got (nothing in the beginning, something next time they call).

You could also let the users know that the values are not yet all available and give them the chance to refresh and then start showing the results of the long running network related process.

Body:
I know that in C#, properties are supposed to be quick operations (not reading data from a network or file system, etc.) However, I am building a Silverlight app and I need to bind a XAML element to some network data on a ViewModel. As far as I am aware, binding can only be done to properties, not methods. Should I break the guideline here, or is there another way around this that's not occurring to me?

<ListBox ItemsSource="{Binding Users}" />

public IEnumerable<User> Users
{
    get
    {
        // may be cached
        return expensiveNetworkCall();
    }
}


问:
Set default value of Javascript object attributes
Is there a way to set the default attribute of a Javascript object such that:</p>
```<code>let emptyObj = {};
// do some magic
emptyObj.nonExistingAttribute // => defaultValue
</code>```

答:
I think the simplest approach is using Object.assign.

If you have this Class:

```<code>class MyHelper {
    constructor(options) {
        this.options = Object.assign({
            name: "John",
            surname: "Doe",
            birthDate: "1980-08-08"
        }, options);
    }
}
</code>```

You can use it like this:

```<code>let helper = new MyHelper({ name: "Mark" });
console.log(helper.options.surname); // this will output "Doe"
</code>```

Documentation (with polyfill):
https://developer.mozilla.org/it/docs/Web/JavaScript/Reference/Global_Objects/Object/assign

ContentLicense: CC BY-SA 4.0

Body:
Is there a way to set the default attribute of a Javascript object such that:

let emptyObj = {};
// do some magic
emptyObj.nonExistingAttribute // => defaultValue

Body:
I think the simplest approach is using Object.assign.

If you have this Class:

class MyHelper {
    constructor(options) {
        this.options = Object.assign({
            name: "John",
            surname: "Doe",
            birthDate: "1980-08-08"
        }, options);
    }
}

You can use it like this:

let helper = new MyHelper({ name: "Mark" });
console.log(helper.options.surname); // this will output "Doe"

Documentation (with polyfill):
https://developer.mozilla.org/it/docs/Web/JavaScript/Reference/Global_Objects/Object/assign


问:
Which module to use to edit files - Ansible
I want to edit the configuration file of telegraf(system metrics collecting agent).

Telegraf comes in with a default config file which can be edited. There are many input and output plugins defined in there, which are commented out and can be added by removing the comments and also be customized.

I want to edit only some of the plugins defined there, not all of them. For example, consider this is the file,

```<code>[global]
  interval='10s'

[outputs.influxdb]
  host=['http://localhost:8086']

#[outputs.elasticsearch]
#  host=['http://localhost:9200']

[inputs.netstat]
  interface='eth0'
</code>```

Now, I want to edit the 3 blocks, global, outputs.influxdb and inputs.netstat. I don't want to edit outputs.elasticsearch but also want that the block outputs.elasticsearch should remain in the file.

When Using Ansible, I firstly used Template module, but if I use that, then the commented data would be lost.

Then I used the ini_file module, instead of editing the already present block, it adds a new block even if it is already present, and results in something like this,

```<code>[outputs.influxdb]
 host=[http://localhost:8086]
[outputs.influxdb]
 host=[http://xx.xx.xx.xx:8086]
</code>```

Which module is ideal for my scenario ?

答:
Ok, if you really really want to avoid using templates, you could try to use replace and a regex like this:

```<code>- hosts: local
  tasks:
    - replace:
        path: testfile
        regexp: '^\[{{ item.category }}\]\s(.*)host(.*)$'
        replace: '[{{ item.category }}]\n  host=[{{ item.host }}]'
      with_items:
        - { category: 'outputs.influxdb', host: 'http://cake.com:8080' }
</code>```

This, in its current form, would not necessarily handle more than one option under each category, but the regex can be modified to handle multiple lines.

As required, it will not touch the # commented lines. However, if you decide to enable some of the previously inactive sections, you might end up with a slightly messier configuration file that would include the instructions both commented and uncommented (shouldn't impact functionality, only 'looks'). You will also need to account for options that look like the example below (interleaved commented/uncommented values) and create regexes specially for those use-cases:

```<code>[section]
  option1=['value']
  # option2=['value']
  option3=['value']
</code>```

It highly depends on your use-case, but my recommendation remains that templates are to be used instead, as they are a more robust approach, with less chances of things going wrong.

Body:
I want to edit the configuration file of telegraf(system metrics collecting agent).

Telegraf comes in with a default config file which can be edited. There are many input and output plugins defined in there, which are commented out and can be added by removing the comments and also be customized.

I want to edit only some of the plugins defined there, not all of them. For example, consider this is the file,

[global]
  interval='10s'

[outputs.influxdb]
  host=['http://localhost:8086']

#[outputs.elasticsearch]
#  host=['http://localhost:9200']

[inputs.netstat]
  interface='eth0'

Now, I want to edit the 3 blocks, global, outputs.influxdb and inputs.netstat. I don't want to edit outputs.elasticsearch but also want that the block outputs.elasticsearch should remain in the file.

When Using Ansible, I firstly used Template module, but if I use that, then the commented data would be lost.

Then I used the ini_file module, instead of editing the already present block, it adds a new block even if it is already present, and results in something like this,

[outputs.influxdb]
 host=[http://localhost:8086]
[outputs.influxdb]
 host=[http://xx.xx.xx.xx:8086]

Which module is ideal for my scenario ?

Body:
Ok, if you really really want to avoid using templates, you could try to use replace and a regex like this:

- hosts: local
  tasks:
    - replace:
        path: testfile
        regexp: '^\[{{ item.category }}\]\s(.*)host(.*)$'
        replace: '[{{ item.category }}]\n  host=[{{ item.host }}]'
      with_items:
        - { category: 'outputs.influxdb', host: 'http://cake.com:8080' }

This, in its current form, would not necessarily handle more than one option under each category, but the regex can be modified to handle multiple lines.

As required, it will not touch the # commented lines. However, if you decide to enable some of the previously inactive sections, you might end up with a slightly messier configuration file that would include the instructions both commented and uncommented (shouldn't impact functionality, only 'looks'). You will also need to account for options that look like the example below (interleaved commented/uncommented values) and create regexes specially for those use-cases:

[section]
  option1=['value']
  # option2=['value']
  option3=['value']

It highly depends on your use-case, but my recommendation remains that templates are to be used instead, as they are a more robust approach, with less chances of things going wrong.


问:
How to JAR files using relative path of root directory?
How to use JarOutputStream to create a JAR file?

Using that solution causes creating entry with absolute path in *.jar file, for example c:/Users/foo/Temp/blah/com/example/Main.class. I want to build jar with path relative to root, in this example it will be c:/Users/foo/Temp/blah and entries should be com/example/... How to achieve that? Changing working directory is strongly platform-dependent, so it's not good solution.

PS. I've replaced Windows's backslash with slash.

答: The 'path' is actually whatever name you set into each JarEntry when creating it. Just calculate the relative path yourself and use that for the name parameter when calling the JarEntry constructor.


问:
Can view in tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) ever not be UITableViewHeaderFooterView?
For some reason, the view in the arguments is UIView and most examples I see this being force unwrapped to UITableViewHeaderFooterView. I generally dislike force unwrapping unless I'm 100% sure this is impossible to be the class I'm force unwrapping. It seems that you can not set a section to anything other than UITableViewHeaderFooterView</p>

答:
I believe UITableViewHeaderFooterView is a conveniently wrapped UIView that allows you to use reuseIdentifiers on the view to reuse the same instance (similar to how you would use a UITableViewCell). You can check out the documentation about it here. You'll notice that it's really just a UIView with some very simple subview structure and reuse conveniences.

You should be able to use a normal UIView (I've certainly done it before) for your header or footer, you just lose that extra convenience.


问:
Number comparision in java
This might be a very dumb question. I tried to reverse the input number and compare it.If they are same then, the output should be "the number entered is a palindrome" But, I'm getting out for every number like it is a palindrome. </p>

```<code>package com.practise.examples;

import java.util.Scanner;

public class Practise
{
    public static void main(String[] args) {

        Scanner s=new Scanner(System.in);
        System.out.println("enter the number to reverse it:\n");
        int num=s.nextInt();
        int revNum=0;

        while(num!=0)
        {
            revNum=revNum *10;
            revNum= revNum+ num%10;
            num=num/10;
        }
        System.out.println("the reverse of the number is: " +revNum);

            if(revNum==num)
            {
                System.out.println("the number is a palindrome" );

            }
            else
            {
                System.out.println("the number entered is not a palindrome");

            }

        }
    }
</code>```

答:
your idea seems to only work in VERY specific instances, and the code itself... well, ill just give you a different idea.

create a stack and a queue.

take the original input, and add each consecutive item to each the stack and the queue.

once the queue and stack are full...

```<code>iterate until length=0
if stack.pop != queue.dequeue
    palindrome=false
</code>```

Title: Number comparision in java

Body:
This might be a very dumb question. I tried to reverse the input number and compare it.If they are same then, the output should be "the number entered is a palindrome" But, I'm getting out for every number like it is a palindrome.

package com.practise.examples;

import java.util.Scanner;

public class Practise
{
    public static void main(String[] args) {

        Scanner s=new Scanner(System.in);
        System.out.println("enter the number to reverse it:\n");
        int num=s.nextInt();
        int revNum=0;

        while(num!=0)
        {
            revNum=revNum *10;
            revNum= revNum+ num%10;
            num=num/10;
        }
        System.out.println("the reverse of the number is: " +revNum);

            if(revNum==num)
            {
                System.out.println("the number is a palindrome" );

            }
            else
            {
                System.out.println("the number entered is not a palindrome");

            }

        }
    }

Body:
your idea seems to only work in VERY specific instances, and the code itself... well, ill just give you a different idea.

create a stack and a queue.

take the original input, and add each consecutive item to each the stack and the queue.

once the queue and stack are full...

iterate until length=0
if stack.pop != queue.dequeue
    palindrome=false


问:
Hosting-specific code in projects: push to Github too?
Imagine this common scenario: i hacked together a cool project i want to share with the world. So: i put it on Github, and fetch it from Github on my own website so people can see a demo. This also makes updating easy: just push from my local box to Github, fetch on my server.

I'd like to track visitors so i add Google Analytics and maybe some other site-specific stuff (like a global header for all pages on my site) to the project. However, everybody who checks out my project from Github gets all that stuff too.

There are a few solutions to prevent that. I could make a specific 'deployment branch' for my website, but that's cumbersome. I could make some kind of switch in my code (if ip === myip showStats()), but that's ugly.

Another option might be to use githooks, but i haven't got any experience with that.

Any other suggestions? Are people even bothered when getting deployment-specific code like that in their checkouts?

答:
Similar to Breun's suggestion, (so your question will be double answered) I deploy my Python projects with a settings.py file which defines the settings that are needed on the production machine. (debug=False, proper database settings and file paths...)

At the end of the file, I try to import developmentsettings.py like this:

```<code>try:
    from projectnaam import developmentsettings
except:
    pass
</code>```

The file does not exist in version control, so this will fail and silently pass on the server. On my dev machine, I manually create the file and override specific settings to match my dev needs. (things like sqlite instead of postgres)

This can be extended into a more sophisticated deployment strategy, involving stuff like Fabric, Buildout, Capistrano and Chef. This all gets more important when working in (distributed) teams.

My current development flow now goes like: edit code, $ git commit -m "comment", $ git push, $ fab deploy master production (<- this pulls 'master' from origin onto the server)

Body:
Similar to Breun's suggestion, (so your question will be double answered) I deploy my Python projects with a settings.py file which defines the settings that are needed on the production machine. (debug=False, proper database settings and file paths...)

At the end of the file, I try to import developmentsettings.py like this:

try:
    from projectnaam import developmentsettings
except:
    pass

The file does not exist in version control, so this will fail and silently pass on the server. On my dev machine, I manually create the file and override specific settings to match my dev needs. (things like sqlite instead of postgres)

This can be extended into a more sophisticated deployment strategy, involving stuff like Fabric, Buildout, Capistrano and Chef. This all gets more important when working in (distributed) teams.

My current development flow now goes like: edit code, $ git commit -m "comment", $ git push, $ fab deploy master production (<- this pulls 'master' from origin onto the server)


答: You're calling getFFtMag function with a string (apparently a filename) as argument. This function however requires a list (or, in general, iterable) with elements having .real and .imag attributes. Elements of a string are one-character strings, and strings don't have those attributes - complex numbers have. You need to read in contents of your file and somehow convert them to complex.

Title: Can anyone tell me why I'm getting the attributeError? 'str' object has no attribute 'real'


问:
QT Application segmentation fault on exit when using std::unique_ptr for the QMainWindow
I should clarify first, my question is, why does the segfault happen in the case where I use a std::unique_ptr but it doesn't when I change the code to use new and delete? I don't really have an issue here, since the segfault is fixed and I know I'm properly cleaning things up with new and delete. I just want to know why I couldn't use a std::unique_ptr.

If I create my QMainWindow instance in a std::unique_ptr and my MainWindow creates a child window (e.g. opening a QComboBox or ToolTip), my application will segfault on exit. In this case, if my MainWindow does not create any child windows, there is no segfault.

If I manage my QMainWindow instance myself with new and delete, there is no segfault regardless of whether or not I create a child window.

This is my main, it simply calls run on my Bridge class that handles creating the instance of my MainWindow class and starting it.

```<code>int main(int argc, char *argv[])
{
    Bridge bridge(argc, argv);
    bridge.run(); // Handles starting the main window
}
</code>```

This is a shortened version of my Bridge class that results in a segfault (using std::unique_ptr I get a segfault on exit):

```<code>class Bridge::IMPL {
public:
    IMPL(int& argc, char ** argv) :
        mainwindow(), isRunning(true), app(argc, argv) {}
    ~IMPL() = default;
public:
    std::unique_ptr<MainWindow> mainwindow;
    bool isRunning;
    QApplication app;
};

Bridge::Bridge(int& argc, char ** argv) :
    pImpl(make_unique<IMPL>(argc, argv)) {

    pImpl->mainwindow.reset(new MainWindow(this));
}
</code>```

This is the Bridge class with no segfault (slightly modified to remove the std::unique_ptr and instead use new and delete. This version of the Bridge class DOES NOT CRASH):

```<code>class Bridge::IMPL {
public:
    IMPL(int& argc, char ** argv) :
        mainwindow(nullptr), isRunning(true), app(argc, argv) {}
    ~IMPL() {
        if (mainwindow) {
            delete mainwindow;
        }
    }
public:
    MainWindow* mainwindow;
    bool isRunning;
    QApplication app;
};

Bridge::Bridge(int& argc, char ** argv) :
    pImpl(make_unique<IMPL>(argc, argv)) {

    pImpl->mainwindow= new MainWindow(this);
}
</code>```

This is the back-trace when a segfault would happen:

Also there is a weird print-out about QBasicTimer that doesn't get printed after I changed the code to use new and delete instead of std::unique_ptr

```<code>QBasicTimer::start: QBasicTimer can only be used with threads started with QThread

Thread 1 "application" received signal SIGSEGV, Segmentation fault.
0x00007fffe75bf2e2 in ?? () from /home/user/Qt/5.9/gcc_64/plugins/platforms/../../lib/libQt5XcbQpa.so.5
(gdb) bt
#0  0x00007fffe75bf2e2 in ?? () from /home/user/Qt/5.9/gcc_64/plugins/platforms/../../lib/libQt5XcbQpa.so.5
#1  0x00007fffe75bf5c4 in ?? () from /home/user/Qt/5.9/gcc_64/plugins/platforms/../../lib/libQt5XcbQpa.so.5
#2  0x00007fffe75b9669 in QXcbConnection::removeWindowEventListener(unsigned int) () from /home/user/Qt/5.9/gcc_64/plugins/platforms/../../lib/libQt5XcbQpa.so.5
#3  0x00007fffe75ceafa in QXcbWindow::destroy() () from /home/user/Qt/5.9/gcc_64/plugins/platforms/../../lib/libQt5XcbQpa.so.5
#4  0x00007fffe75cec07 in QXcbWindow::~QXcbWindow() () from /home/user/Qt/5.9/gcc_64/plugins/platforms/../../lib/libQt5XcbQpa.so.5
#5  0x00007fffe43ce2ee in ?? () from /home/user/Qt/5.9/gcc_64/plugins/xcbglintegrations/libqxcb-glx-integration.so
#6  0x00007ffff4b56f46 in QWindowPrivate::destroy() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Gui.so.5
#7  0x00007ffff534ecd7 in QWidgetPrivate::deleteTLSysExtra() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#8  0x00007ffff53524d8 in QWidget::destroy(bool, bool) () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#9  0x00007ffff53598b0 in QWidget::~QWidget() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#10 0x00007ffff541ae7a in ?? () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#11 0x00007ffff4580b83 in QObjectPrivate::deleteChildren() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Core.so.5
#12 0x00007ffff5359894 in QWidget::~QWidget() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#13 0x00007ffff540eac9 in QComboBox::~QComboBox() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#14 0x00007ffff4580b83 in QObjectPrivate::deleteChildren() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Core.so.5
#15 0x00007ffff5359894 in QWidget::~QWidget() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#16 0x00007ffff5359ab9 in QWidget::~QWidget() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#17 0x00007ffff4580b83 in QObjectPrivate::deleteChildren() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Core.so.5
#18 0x00007ffff5359894 in QWidget::~QWidget() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#19 0x00007ffff5359ab9 in QWidget::~QWidget() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#20 0x00007ffff4580b83 in QObjectPrivate::deleteChildren() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Core.so.5
#21 0x00007ffff5359894 in QWidget::~QWidget() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#22 0x0000000000421ed4 in MainWindow::~MainWindow() ()
#23 0x0000000000421f0e in MainWindow::~MainWindow() ()
#24 0x0000000000421698 in std::default_delete<MainWindow>::operator()(MainWindow*) const ()
#25 0x0000000000421171 in std::unique_ptr<MainWindow, std::default_delete<MainWindow> >::~unique_ptr() ()
#26 0x000000000042191c in Bridge::IMPL::~IMPL() ()
#27 0x0000000000421942 in std::default_delete<Bridge::IMPL>::operator()(Bridge::IMPL*) const ()
#28 0x0000000000421387 in std::unique_ptr<Bridge::IMPL, std::default_delete<Bridge::IMPL> >::~unique_ptr() ()
#29 0x0000000000420cb0 in Bridge::~Bridge() ()
#30 0x0000000000421c41 in main ()
</code>```

It should also be noted that this QApplication is run using a while loop and calls to app.processEvents() rather than calling exec(). I realize that's not the best way to do it, however this app is part of another application that polls for events from somewhere else and since the nature of this application is more "proof-of-concept" than anything else, I wanted to keep it simple by having it all in one thread. See below for a snippet of my run method:

```<code>while (isRunning()) {
    poller.poll(25);
    app.processEvents();
}
</code>```

EDIT:

In my constructor for MainWindow the this I'm passing is not being set as the parent (the parent is nullptr):

header:

```<code>class MainWindow: public QMainWindow
{
    Q_OBJECT
public:
    class BridgeInterface{
    public:
        // Some pure virtual methods here
    };

    explicit MainWindow(BridgeInterface* interface, QWidget* parent = nullptr);

// some more stuff...

private:
    class IMPL;
    std::unique_ptr<IMPL> pImpl;
};
</code>```

source:

```<code>MainWindow::MainWindow(BridgeInterface* interface, QWidget* parent) :
    QMainWindow(parent), pImpl(make_unique<IMPL>()) {

    pImpl->ui->setupUi(this);
    pImpl->bridgeInterface = interface;

    // Connect slots and stuff
}
</code>```

答:
Don't delete MainWindow after deleting QApplication instance. You need to somehow manage initialization and destruction order.

```<code>QApp::ctor Window::ctor Window::dtor QApp::dtor
</code>```

Possible solution: destroy MainWindow directly inside Bridge::~Bridge

P.S. you don't need to pass int argc via reference.

P.P.S. about processEvents() - you may create a separated thread and run your Qt part there. It is OK to use GUI not from main thread, ofc if you know, what you are doing :). Main rule - QApplication instance and all GUI should be created from one thread

Body:
I should clarify first, my question is, why does the segfault happen in the case where I use a std::unique_ptr but it doesn't when I change the code to use new and delete? I don't really have an issue here, since the segfault is fixed and I know I'm properly cleaning things up with new and delete. I just want to know why I couldn't use a std::unique_ptr.

If I create my QMainWindow instance in a std::unique_ptr and my MainWindow creates a child window (e.g. opening a QComboBox or ToolTip), my application will segfault on exit. In this case, if my MainWindow does not create any child windows, there is no segfault.

If I manage my QMainWindow instance myself with new and delete, there is no segfault regardless of whether or not I create a child window.

This is my main, it simply calls run on my Bridge class that handles creating the instance of my MainWindow class and starting it.

int main(int argc, char *argv[])
{
    Bridge bridge(argc, argv);
    bridge.run(); // Handles starting the main window
}

This is a shortened version of my Bridge class that results in a segfault (using std::unique_ptr I get a segfault on exit):

class Bridge::IMPL {
public:
    IMPL(int& argc, char ** argv) :
        mainwindow(), isRunning(true), app(argc, argv) {}
    ~IMPL() = default;
public:
    std::unique_ptr<MainWindow> mainwindow;
    bool isRunning;
    QApplication app;
};

Bridge::Bridge(int& argc, char ** argv) :
    pImpl(make_unique<IMPL>(argc, argv)) {

    pImpl->mainwindow.reset(new MainWindow(this));
}

This is the Bridge class with no segfault (slightly modified to remove the std::unique_ptr and instead use new and delete. This version of the Bridge class DOES NOT CRASH):

class Bridge::IMPL {
public:
    IMPL(int& argc, char ** argv) :
        mainwindow(nullptr), isRunning(true), app(argc, argv) {}
    ~IMPL() {
        if (mainwindow) {
            delete mainwindow;
        }
    }
public:
    MainWindow* mainwindow;
    bool isRunning;
    QApplication app;
};

Bridge::Bridge(int& argc, char ** argv) :
    pImpl(make_unique<IMPL>(argc, argv)) {

    pImpl->mainwindow= new MainWindow(this);
}

This is the back-trace when a segfault would happen:

Also there is a weird print-out about QBasicTimer that doesn't get printed after I changed the code to use new and delete instead of std::unique_ptr

QBasicTimer::start: QBasicTimer can only be used with threads started with QThread

Thread 1 "application" received signal SIGSEGV, Segmentation fault.
0x00007fffe75bf2e2 in ?? () from /home/user/Qt/5.9/gcc_64/plugins/platforms/../../lib/libQt5XcbQpa.so.5
(gdb) bt
#0  0x00007fffe75bf2e2 in ?? () from /home/user/Qt/5.9/gcc_64/plugins/platforms/../../lib/libQt5XcbQpa.so.5
#1  0x00007fffe75bf5c4 in ?? () from /home/user/Qt/5.9/gcc_64/plugins/platforms/../../lib/libQt5XcbQpa.so.5
#2  0x00007fffe75b9669 in QXcbConnection::removeWindowEventListener(unsigned int) () from /home/user/Qt/5.9/gcc_64/plugins/platforms/../../lib/libQt5XcbQpa.so.5
#3  0x00007fffe75ceafa in QXcbWindow::destroy() () from /home/user/Qt/5.9/gcc_64/plugins/platforms/../../lib/libQt5XcbQpa.so.5
#4  0x00007fffe75cec07 in QXcbWindow::~QXcbWindow() () from /home/user/Qt/5.9/gcc_64/plugins/platforms/../../lib/libQt5XcbQpa.so.5
#5  0x00007fffe43ce2ee in ?? () from /home/user/Qt/5.9/gcc_64/plugins/xcbglintegrations/libqxcb-glx-integration.so
#6  0x00007ffff4b56f46 in QWindowPrivate::destroy() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Gui.so.5
#7  0x00007ffff534ecd7 in QWidgetPrivate::deleteTLSysExtra() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#8  0x00007ffff53524d8 in QWidget::destroy(bool, bool) () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#9  0x00007ffff53598b0 in QWidget::~QWidget() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#10 0x00007ffff541ae7a in ?? () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#11 0x00007ffff4580b83 in QObjectPrivate::deleteChildren() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Core.so.5
#12 0x00007ffff5359894 in QWidget::~QWidget() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#13 0x00007ffff540eac9 in QComboBox::~QComboBox() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#14 0x00007ffff4580b83 in QObjectPrivate::deleteChildren() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Core.so.5
#15 0x00007ffff5359894 in QWidget::~QWidget() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#16 0x00007ffff5359ab9 in QWidget::~QWidget() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#17 0x00007ffff4580b83 in QObjectPrivate::deleteChildren() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Core.so.5
#18 0x00007ffff5359894 in QWidget::~QWidget() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#19 0x00007ffff5359ab9 in QWidget::~QWidget() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#20 0x00007ffff4580b83 in QObjectPrivate::deleteChildren() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Core.so.5
#21 0x00007ffff5359894 in QWidget::~QWidget() () from /home/user/Qt/5.9/gcc_64/lib/libQt5Widgets.so.5
#22 0x0000000000421ed4 in MainWindow::~MainWindow() ()
#23 0x0000000000421f0e in MainWindow::~MainWindow() ()
#24 0x0000000000421698 in std::default_delete<MainWindow>::operator()(MainWindow*) const ()
#25 0x0000000000421171 in std::unique_ptr<MainWindow, std::default_delete<MainWindow> >::~unique_ptr() ()
#26 0x000000000042191c in Bridge::IMPL::~IMPL() ()
#27 0x0000000000421942 in std::default_delete<Bridge::IMPL>::operator()(Bridge::IMPL*) const ()
#28 0x0000000000421387 in std::unique_ptr<Bridge::IMPL, std::default_delete<Bridge::IMPL> >::~unique_ptr() ()
#29 0x0000000000420cb0 in Bridge::~Bridge() ()
#30 0x0000000000421c41 in main ()

It should also be noted that this QApplication is run using a while loop and calls to app.processEvents() rather than calling exec(). I realize that's not the best way to do it, however this app is part of another application that polls for events from somewhere else and since the nature of this application is more "proof-of-concept" than anything else, I wanted to keep it simple by having it all in one thread. See below for a snippet of my run method:

while (isRunning()) {
    poller.poll(25);
    app.processEvents();
}

EDIT:

In my constructor for MainWindow the this I'm passing is not being set as the parent (the parent is nullptr):

header:

class MainWindow: public QMainWindow
{
    Q_OBJECT
public:
    class BridgeInterface{
    public:
        // Some pure virtual methods here
    };

    explicit MainWindow(BridgeInterface* interface, QWidget* parent = nullptr);

// some more stuff...

private:
    class IMPL;
    std::unique_ptr<IMPL> pImpl;
};

source:

MainWindow::MainWindow(BridgeInterface* interface, QWidget* parent) :
    QMainWindow(parent), pImpl(make_unique<IMPL>()) {

    pImpl->ui->setupUi(this);
    pImpl->bridgeInterface = interface;

    // Connect slots and stuff
}

Body:
Don't delete MainWindow after deleting QApplication instance. You need to somehow manage initialization and destruction order.

QApp::ctor Window::ctor Window::dtor QApp::dtor

Possible solution: destroy MainWindow directly inside Bridge::~Bridge

P.S. you don't need to pass int argc via reference.

P.P.S. about processEvents() - you may create a separated thread and run your Qt part there. It is OK to use GUI not from main thread, ofc if you know, what you are doing :). Main rule - QApplication instance and all GUI should be created from one thread


问:
Div leak parent container max width
I need to make a child div leak the parent container max width.
Now, i can only leak parent padding (knowing it).

I need this to wrap all the page on a container and make some sections leak.

Without this, i will need to set the container on every section.

Here is some snippets

Better snippet on codepen

.container {
  max-width: 500px;
  margin: 0 auto;
  padding: 0 30px;
  background: lightblue;
}

.child {
  background: lightcoral;
  height: 200px;
}

.child.cancel-padding {
  margin: 0 -30px;
}

.child.leaked {
}

html,
body {
  margin: 0;
  padding: 0;
}

* {
  text-align: center;
  font-family: sans-serif;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><small>note: see in fullscreen or on codepen</small>
<h1>what i have</h1>
<div class="container">
  <div class="child">A element inside a container</div>
</div>

<h1>what i need</h1>
<div class="container-leaked">
  <div class="child leaked">
    a element inside the container, but leaking all view width (100vw)
  </div>
</div>

<h1>what i can do now</h1>
<div class="container">
  <div class="child cancel-padding">Make the element cancel the parent padding, that's all</div>
</div>

<h1>Why i need</h1>
<p>
  i will wrap all the page in the container, but sometimes i need sections to leak the container with full view width.
</p></code>```

Note: on the demo, i've set the child height, but i will not have control of it. it's a dynamic content div, so height is dynamic.

答:
This may be a little bit of a hack, but I've done it before by adding ::before and ::after. Add position: relative to the .child and then add the following css</p>

```<code>.child.leaked:before{
  content:"";
  display: block;
  position: absolute;
  height: 100%;
  width: 100%;
  left: -100%;
  background-color: red;
  top: 0;
}

.child.leaked:after{
  content:"";
  display: block;
  position: absolute;
  height: 100%;
  width: 100%;
  right: -100%;
  background-color: red;
  top: 0;
}
</code>```

Title: Div leak parent container max width

Body:
I need to make a child div leak the parent container max width.
Now, i can only leak parent padding (knowing it).

I need this to wrap all the page on a container and make some sections leak.

Without this, i will need to set the container on every section.

Here is some snippets

Better snippet on codepen

.container {
  max-width: 500px;
  margin: 0 auto;
  padding: 0 30px;
  background: lightblue;
}

.child {
  background: lightcoral;
  height: 200px;
}

.child.cancel-padding {
  margin: 0 -30px;
}

.child.leaked {
}

html,
body {
  margin: 0;
  padding: 0;
}

* {
  text-align: center;
  font-family: sans-serif;
}

note: see in fullscreen or on codepen

what i have

A element inside a container

what i need

    a element inside the container, but leaking all view width (100vw)

what i can do now

Make the element cancel the parent padding, that's all

Why i need

  i will wrap all the page in the container, but sometimes i need sections to leak the container with full view width.

Note: on the demo, i've set the child height, but i will not have control of it. it's a dynamic content div, so height is dynamic.

Body:
This may be a little bit of a hack, but I've done it before by adding ::before and ::after. Add position: relative to the .child and then add the following css

.child.leaked:before{
  content:"";
  display: block;
  position: absolute;
  height: 100%;
  width: 100%;
  left: -100%;
  background-color: red;
  top: 0;
}

.child.leaked:after{
  content:"";
  display: block;
  position: absolute;
  height: 100%;
  width: 100%;
  right: -100%;
  background-color: red;
  top: 0;
}


问:
C# ListBox Selection Unchanged Event?
I want to be able to de-select an item in the ListBox if the user clicks the same item again. There is the SelectionChanged event that everyone uses with ListBoxes, but this obviously will not fire when the selection is unchanged.

There is also no Click event, something people recommend. Visual Studio C# 2015 does not contain such event.

I have tried using MouseLeftButtonDown event, but once the ListBox has been populated with ListBoxItems, this event does not fire anymore. In addition, I thought about attaching Mouse events to the ListBoxItems, but this does not seem practicable, as I would have to attach n number of new events every time I populate the ListBox.

Does anyone have a XAML solution to this inquiry?

答:
You could handle the PreviewMouseLeftButtonDown event for the ListBox container as I suggested here.

How to disable deselection of items in ListView?

Title: C# ListBox Selection Unchanged Event?


问:
Allow Free Users to search Spotify API
Hello we have a jukebox style iOS application named "Unifly Music" which uses Spotify API for the source of music. It seems Spotify now requires a premium account to even be able to search and view the catalogue.

Is there any way around this or special access tokens to be requested. Note only a session host actually plays the music. The Session guest simply view catalogue and suggest songs. Allowing more session guest to view catalogue and participate is great marketing to Spotify with no loss. Its a great feeder for Spotify to learn the likes of free users, own their contact information, and later convert those free account holders into premiums.

The spotify web API was updated 5/29/17 which caused the issue for our setup. Please help :) !

答:
The Spotify API was indeed changed to require authentication for all calls to the Web API. However, I have good news! The search endpoint is still available to free users! You simply need to follow one of the authorization flows described here and include an Authorization header in your call. This change is also reflected in the documentation of the search endpoint.

Read the announcement here: https://developer.spotify.com/news-stories/2017/01/27/removing-unauthenticated-calls-to-the-web-api/

Title: Allow Free Users to search Spotify API


问:
Conditional statement- compare to values store in array
Need help figuring out working perl code to put in place of "any of the elements in @array" </p>

```<code>%hash = (key1 => 'value1',key2 => 'value2',key3 => 'value3',);

@array= ('value3','value4','value6');

if ($hash{ 'key1' } ne <<any of the elements in @array>>) {print "YAY!";}
</code>```

答:
You could also use a hash:</p>

```<code>@hash{"value3","value4","value6"}=undef;
print "YAY" if exists $hash{key1};
</code>```

Body:
Need help figuring out working perl code to put in place of "any of the elements in @array"

%hash = (key1 => 'value1',key2 => 'value2',key3 => 'value3',);

@array= ('value3','value4','value6');

if ($hash{ 'key1' } ne <<any of the elements in @array>>) {print "YAY!";}

Body:
You could also use a hash:

@hash{"value3","value4","value6"}=undef;
print "YAY" if exists $hash{key1};


问:
Change handle color of QSplitter
I am using a QSplitter, but the handle color is not changing, it has always the default color:

```<code>m_pSplitMainWin = new QSplitter;
m_pSplitMainWin->setOrientation(Qt::Horizontal);

m_pSplitMainWin->setHandleWidth(10);
m_pSplitMainWin->setStyleSheet("QSplitter::handle:background-color: rgb(55, 100, 110);");
</code>```

I got some idea from previous post but I am not able to do it with m_pSplitMainWin object

答:
Your CSS syntax is wrong. It should read</p>

```<code>QSplitter::handle { background-color: rgb(55, 100, 110); }
</code>```

Title: Change handle color of QSplitter

Body:
I am using a QSplitter, but the handle color is not changing, it has always the default color:

m_pSplitMainWin = new QSplitter;
m_pSplitMainWin->setOrientation(Qt::Horizontal);

m_pSplitMainWin->setHandleWidth(10);
m_pSplitMainWin->setStyleSheet("QSplitter::handle:background-color: rgb(55, 100, 110);");

I got some idea from previous post but I am not able to do it with m_pSplitMainWin object

Body:
Your CSS syntax is wrong. It should read

QSplitter::handle { background-color: rgb(55, 100, 110); }