问:
Can PHP determine the "genitive case" for a given string for a given locale?
I'm trying to be able to display something like:

```<code>$1 health is very low right now.
</code>```

Where $1 refers to a processed username/word/string. For example:

```<code>MagicalMage's health is very low right now.
</code>```

Or:

```<code>Susy_Suss' health is very low right now.
</code>```

Or (a difference case):

```<code>IBM's dominance is not as big as it once was.
</code>```

The problem is that, not only does it have to handle the simple English rule of doing "'s" in the end except for strings that end with "s", as seen above, but also any other language's special quirks!

For example, in Swedish, it would be:

```<code>MagicalMages hälsa är väldigt låg just nu.
</code>```

Or:

```<code>Susy_Suss hälsa är väldigt låg just nu.
</code>```

Or (which happens to be identical to the English version):

```<code>Susy_Suss' hälsa är väldigt låg just nu.
</code>```

Or (notice the colon instead of any apostrophe):

```<code>IBM:s dominans är inte så stor som den en gång var.
</code>```

I'm sure there are numerous other versions for many other languages/locales as well. There always are such minor differences, because each place/language likes to be unique.

To make it clear, I'm not expecting PHP to translate the whole sentences for me. I simply want to be able to input the locale and the string (the username or company name, in this case) to be "genitivized" and have it spit out the correctly "processed" version for that language/region.

That is, if I input the string "IBM" and the locale is "en_US", it gives back:

```<code>IBM's
</code>```

If I instead give it the locale "sv_SE", it gives back:

```<code>IBM:s
</code>```

Clear as a day, no?

答:
To get to the point: No.

PHP can not do that. Furthermore there are some composer packages that handle different kinds of grammar (which are mostly for specific languages) and things like pluralization in symfony - read up on ICU message format if you want to know more about that.

However, there do not seem to be any packages available to do what you are asking, especially not so for multiple (or all) languages. Languages (that we speak, not programming languages) are often surprisingly more complex then you would think if you speak them fluently.

Since there is no such package, my best recommendation would be to jump on the chance and create a library by yourself and offer it for others (e.g. as composer package) and earn some community karma!

Body:
I'm trying to be able to display something like:

$1 health is very low right now.

Where $1 refers to a processed username/word/string. For example:

MagicalMage's health is very low right now.

Or:

Susy_Suss' health is very low right now.

Or (a difference case):

IBM's dominance is not as big as it once was.

The problem is that, not only does it have to handle the simple English rule of doing "'s" in the end except for strings that end with "s", as seen above, but also any other language's special quirks!

For example, in Swedish, it would be:

MagicalMages hälsa är väldigt låg just nu.

Or:

Susy_Suss hälsa är väldigt låg just nu.

Or (which happens to be identical to the English version):

Susy_Suss' hälsa är väldigt låg just nu.

Or (notice the colon instead of any apostrophe):

IBM:s dominans är inte så stor som den en gång var.

I'm sure there are numerous other versions for many other languages/locales as well. There always are such minor differences, because each place/language likes to be unique.

To make it clear, I'm not expecting PHP to translate the whole sentences for me. I simply want to be able to input the locale and the string (the username or company name, in this case) to be "genitivized" and have it spit out the correctly "processed" version for that language/region.

That is, if I input the string "IBM" and the locale is "en_US", it gives back:

IBM's

If I instead give it the locale "sv_SE", it gives back:

IBM:s

Clear as a day, no?


来源: stackexchange

问:
Display the most common word in the text
I have a problem that I have been facing for two days.
I am given a text, which stretches over several lines and I have to display the most common word in the text, but the common words for example appear the same number of times in other words, to display the lexicographic minimum.
This is my code:

```<code>import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedHashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) {
    Map < String, Integer > map = new LinkedHashMap < String, Integer > ();
    BufferedReader reader = null;
    try {
        reader = new BufferedReader(new InputStreamReader(System.in));
        String currentLine = reader.readLine();
        while (currentLine != null) {
            String[] input = currentLine.replaceAll("[^a-zA-Z]", " ").toLowerCase().split(" ");
            for (int i = 0; i < input.length; i++) {
                if (map.containsKey(input[i])) {
                    int count = map.get(input[i]);
                    map.put(input[i], count + 1);

                } else {
                    map.put(input[i], 1);
                }

            }
            currentLine = reader.readLine();
        }

        String mostRepeatedWord = null;
        int count = 0;
        for (Map.Entry < String, Integer > m: map.entrySet()) {
            if (m.getValue() > count) {
                mostRepeatedWord = m.getKey();
                count = m.getValue();
            }
        }
        System.out.println(mostRepeatedWord);

    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
</code>```

My question is, how can I find the lexicographic minimum?

答:
Comparison in Java follows a standard that is a little tricky at first — lexicographic comparison is no exception, but once you’ve understood how it goes, there is support for it that makes it pretty easy.

I suggest that in your for loop at the end, if the counts are equal, you compare the current word to mostRepeatedWord, and if it is smaller (comes before), you store it into mostRepeatedWord. For lexicographic comparison use m.getKey().compareTo(mostRepeatedWord) (or m.getKey().compareToIgnoreCase(mostRepeatedWord) if you want to ignore the difference between upper and lower case in the comparison). The method will return a negative number (any number strictly less than 0, it’s not specified which) if m.getKey() comes lexicographically before mostRepeatedWord (is smaller than it).

In this way, after your loop mostRepeatedWord holds the lexicographically smallest of the words appearing the most frequently (having the highest counts in the map).

And in case you were wondering if I’d write the code for you, no, you will learn a lot more by doing that yourself. If you steer into trouble, do follow up in comments, though, I will reply.

The documentation of the compareTo method says:

Returns:

the value 0 if the argument string is equal to this string; a value
  less than 0 if this string is lexicographically less than the string
  argument; and a value greater than 0 if this string is
  lexicographically greater than the string argument.

Links

Documentation of String.compareTo()

Java String compareTo() Method with examples

Documentation of the Comparable interface specifying the convention of compareTo() returning a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

ContentLicense: CC BY-SA 4.0

Body:
I have a problem that I have been facing for two days.
I am given a text, which stretches over several lines and I have to display the most common word in the text, but the common words for example appear the same number of times in other words, to display the lexicographic minimum.
This is my code:

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedHashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) {
    Map < String, Integer > map = new LinkedHashMap < String, Integer > ();
    BufferedReader reader = null;
    try {
        reader = new BufferedReader(new InputStreamReader(System.in));
        String currentLine = reader.readLine();
        while (currentLine != null) {
            String[] input = currentLine.replaceAll("[^a-zA-Z]", " ").toLowerCase().split(" ");
            for (int i = 0; i < input.length; i++) {
                if (map.containsKey(input[i])) {
                    int count = map.get(input[i]);
                    map.put(input[i], count + 1);

                } else {
                    map.put(input[i], 1);
                }

            }
            currentLine = reader.readLine();
        }

        String mostRepeatedWord = null;
        int count = 0;
        for (Map.Entry < String, Integer > m: map.entrySet()) {
            if (m.getValue() > count) {
                mostRepeatedWord = m.getKey();
                count = m.getValue();
            }
        }
        System.out.println(mostRepeatedWord);

    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

My question is, how can I find the lexicographic minimum?


问:
How to convert localized date string to date object using moment
Using moment how can we convert localized date string to javascript date object?
Followed below steps, but got Current Output(check below).

How can we get Expected Output?

Could you please help me.

Ex: Setting moment locale as 'fr'

```<code>moment.defineLocale('fr', [localeObject][1]);
</code>```

Now we get the date string as "27 févr. 2020 18:23:50"

How can we convert it as dateobject?

```<code>moment("27 févr. 2020 18:23:50")
</code>```

Expected output:

Thu Feb 27 2020 18:23:50 GMT+0530 (India Standard Time)

Current Output:

Invalid Date

答:
You are getting Invalid Date because "27 févr. 2020 18:23:50" is not in ISO 8601 nor in RFC 2822 compliant form, so you have to use moment(String, String). Moreover you have to use french locale, see i18n section of the doc.

As described in the docs, you can use DD for days of the month, MMM for month name (locale aware), YYYY for 4 digit year, HH for 0-23 hours (lowercase hh for 1-12 hours), mm for minutes and ss for seconds.

Then you can use toDate() to get a JavaScript date from a moment object:

To get a copy of the native Date object that Moment.js wraps, use moment#toDate.

Snippet with working code sample:

console.log( moment("27 févr. 2020 18:23:50", "DD MMM YYYY HH:mm:ss").toDate());```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/fr.js"></script></code>```

Body:
Using moment how can we convert localized date string to javascript date object?
Followed below steps, but got Current Output(check below).

How can we get Expected Output?

Could you please help me.

Ex: Setting moment locale as 'fr'

moment.defineLocale('fr', [localeObject][1]);

Now we get the date string as "27 févr. 2020 18:23:50"

How can we convert it as dateobject?

moment("27 févr. 2020 18:23:50")

Expected output:

Thu Feb 27 2020 18:23:50 GMT+0530 (India Standard Time)

Current Output:

Invalid Date

Body:
You are getting Invalid Date because "27 févr. 2020 18:23:50" is not in ISO 8601 nor in RFC 2822 compliant form, so you have to use moment(String, String). Moreover you have to use french locale, see i18n section of the doc.

As described in the docs, you can use DD for days of the month, MMM for month name (locale aware), YYYY for 4 digit year, HH for 0-23 hours (lowercase hh for 1-12 hours), mm for minutes and ss for seconds.

Then you can use toDate() to get a JavaScript date from a moment object:

To get a copy of the native Date object that Moment.js wraps, use moment#toDate.

Snippet with working code sample:

console.log( moment("27 févr. 2020 18:23:50", "DD MMM YYYY HH:mm:ss").toDate());

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/fr.js"></script>


问:
Why am I able to click "behind" the bottomsheet in Android?
I have a BottomSheet in my Activity.

I'm calling behavior.setState(BottomSheetBehavior.STATE_EXPANDED); to show the bottom sheet and it works fine, but the problem I have is that I can somehow click on the empty space of my bottom sheet to trigger onClick event of a view that is behind the bottom sheet.

Is there a way to prevent this from happening?

答:
I faced same issue !

Add android:clickable=true to your BottomSheet ! Should look like below !

```<code><LinearLayout
    android:clickable="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/materialWhite"
    android:orientation="vertical"
    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
</LinearLayout>
</code>```

Body:
I faced same issue !

Add android:clickable=true to your BottomSheet ! Should look like below !

<LinearLayout
    android:clickable="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/materialWhite"
    android:orientation="vertical"
    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
</LinearLayout>


问:
Creating a simple app, can't get clear button to work
So, I'm trying to follow along this website's tutorial.

https://developer.android.com/training/basics/firstapp/starting-activity.html#BuildIntent

I did the first part where I got the text box and a send button.  I can enter text in the text box and click send.  But the text box's text stays there.  It doesn't disappear.  So, the next part of the tutorial is how to get the text to disappear.  I'm trying to follow along, but I can't get it to work.

Here's my code.

activity_main.xml

```<code><?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <EditText
        android:id="@+id/editText"
        android:layout_width="183dp"
        android:layout_height="46dp"
        android:layout_marginStart="16dp"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="16dp"
        android:ems="10"
        android:hint="@string/edit_message"
        android:inputType="textPersonName"
        app:layout_constraintEnd_toStartOf="@+id/button_clear"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/button_clear"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginLeft="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginRight="16dp"
        android:text="@string/button_send"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/editText"
        tools:layout_editor_absoluteY="14dp" />
</androidx.constraintlayout.widget.ConstraintLayout>

strings.xml

<resources>
    <string name="app_name">The Most Useless App</string>
    <string name="edit_message">Enter a message</string>
    <string name="button_send">Send</string>
</resources>

MainActivity.xml

package com.example.myfirstapp;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_display_message);

        // Get the Intent that started this activity and extract the string
        Intent intent = getIntent();
        String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

        // Capture the layout's TextView and set the string as its text
        TextView textView = findViewById(R.id.textView);
        textView.setText(message);

    }

}
</code>```

AndroidManifest.xml

```<code>    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.myfirstapp">

        <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
            <activity android:name=".DisplayMessageActivity"
                android:parentActivityName=".MainActivity">
                <!-- The meta-data tag is required if you support API level 15 and lower -->
                <meta-data
                    android:name="android.support.PARENT_ACTIVITY"
                    android:value=".MainActivity" />
            </activity>

        </application>

    </manifest>
</code>```

MainActivity.java

```<code>    package com.example.myfirstapp;

    import androidx.appcompat.app.AppCompatActivity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.widget.TextView;

    public class MainActivity extends AppCompatActivity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_display_message);

            // Get the Intent that started this activity and extract the string
            Intent intent = getIntent();
            String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

            // Capture the layout's TextView and set the string as its text
            TextView textView = findViewById(R.id.textView);
            textView.setText(message);

        }

    }
</code>```

Errors I get

Cannot resolve symbol textView

Cannot resolve symbol activity_display_message

Cannot resolve symbol EXTRA_MESSAGE

The activity com.example.myfirstapp.MainActivity is not registered in
  the manifest.

Any help would be appreciated.

答:
Is a setting problem,  the first thing you should do is
to do a clean build, you can select above android studio the option buld and then clean build. If does not work please post the output of your build.gradle file

There is also the possibility that you are just starting with android, and you do not know that have to import sometimes the needed libraries

Point your mouse to MainActivity and press alt+enter if you are in windows, and select add Activity to AndroidManifest, then do a clean build.

I suggest you to use the wizard building a new project, you go to Android studio and select file new project and follow the project, so MainActivity will be automatically added to your manifest

Body:
So, I'm trying to follow along this website's tutorial.

https://developer.android.com/training/basics/firstapp/starting-activity.html#BuildIntent

I did the first part where I got the text box and a send button.  I can enter text in the text box and click send.  But the text box's text stays there.  It doesn't disappear.  So, the next part of the tutorial is how to get the text to disappear.  I'm trying to follow along, but I can't get it to work.

Here's my code.

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <EditText
        android:id="@+id/editText"
        android:layout_width="183dp"
        android:layout_height="46dp"
        android:layout_marginStart="16dp"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="16dp"
        android:ems="10"
        android:hint="@string/edit_message"
        android:inputType="textPersonName"
        app:layout_constraintEnd_toStartOf="@+id/button_clear"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/button_clear"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginLeft="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginRight="16dp"
        android:text="@string/button_send"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/editText"
        tools:layout_editor_absoluteY="14dp" />
</androidx.constraintlayout.widget.ConstraintLayout>

strings.xml

<resources>
    <string name="app_name">The Most Useless App</string>
    <string name="edit_message">Enter a message</string>
    <string name="button_send">Send</string>
</resources>

MainActivity.xml

package com.example.myfirstapp;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_display_message);

        // Get the Intent that started this activity and extract the string
        Intent intent = getIntent();
        String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

        // Capture the layout's TextView and set the string as its text
        TextView textView = findViewById(R.id.textView);
        textView.setText(message);

    }

}

AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.myfirstapp">

        <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
            <activity android:name=".DisplayMessageActivity"
                android:parentActivityName=".MainActivity">

                <meta-data
                    android:name="android.support.PARENT_ACTIVITY"
                    android:value=".MainActivity" />
            </activity>

        </application>

    </manifest>

MainActivity.java

    package com.example.myfirstapp;

    import androidx.appcompat.app.AppCompatActivity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.widget.TextView;

    public class MainActivity extends AppCompatActivity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_display_message);

            // Get the Intent that started this activity and extract the string
            Intent intent = getIntent();
            String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

            // Capture the layout's TextView and set the string as its text
            TextView textView = findViewById(R.id.textView);
            textView.setText(message);

        }

    }

Errors I get

Cannot resolve symbol textView

Cannot resolve symbol activity_display_message

Cannot resolve symbol EXTRA_MESSAGE

The activity com.example.myfirstapp.MainActivity is not registered in
  the manifest.

Any help would be appreciated.


问:
pd.read_csv:comment sign in header line
I try to import the file data.csv into a pd.DataFrame where the column names are placed in a commented line. Using data = pd.read_csv ('data.csv', sep = ',', skiprows = 1, thousands = None, decimal = '.') doesn't remove the comment sign (//) from the header. When I say comment = '//', I don't get the column names, which can vary from file to file.

How do I remove the comment sign from the first column name?

My data.csv:

```<code>//general comment, shouldn't pe parsed
//<d_d>,<a_d>,<a_a>
7199.71,173.965,7279.85
5671.23,1576.78,5272.2
6905.44,-1008.56,6864.76
7701.41,-90.0966,8611.31
7253.81,-377.103,2863.48
4745.01,1951.36,4020.75
</code>```

The resulting pd.DataFrame:

      //<d_d>      <a_d>     <a_a>
0     7199.71   173.9650   7279.85
1     5671.23  1576.7800   5272.20
2     6905.44 -1008.5600   6864.76
3     7701.41   -90.0966   8611.31
4     7253.81  -377.1030   2863.48
5     4745.01  1951.3600   4020.75
```

答:
If we have a dataframe, data, that looks like this:

```<code>   //col1  col2
0       1     1
1       2     2
2       3     3
3       4     4
</code>```

And then we do this:

```<code>data.columns = data.columns.str.replace('//','')
</code>```

We will get this:

```<code>   col1  col2
0     1     1
1     2     2
2     3     3
3     4     4
</code>```

Title: pd.read_csv:comment sign in header line

Body:
I try to import the file data.csv into a pd.DataFrame where the column names are placed in a commented line. Using data = pd.read_csv ('data.csv', sep = ',', skiprows = 1, thousands = None, decimal = '.') doesn't remove the comment sign (//) from the header. When I say comment = '//', I don't get the column names, which can vary from file to file.

How do I remove the comment sign from the first column name?

My data.csv:

//general comment, shouldn't pe parsed
//<d_d>,<a_d>,<a_a>
7199.71,173.965,7279.85
5671.23,1576.78,5272.2
6905.44,-1008.56,6864.76
7701.41,-90.0966,8611.31
7253.81,-377.103,2863.48
4745.01,1951.36,4020.75

The resulting pd.DataFrame:

      //<d_d>      <a_d>     <a_a>
0     7199.71   173.9650   7279.85
1     5671.23  1576.7800   5272.20
2     6905.44 -1008.5600   6864.76
3     7701.41   -90.0966   8611.31
4     7253.81  -377.1030   2863.48
5     4745.01  1951.3600   4020.75

Body:
If we have a dataframe, data, that looks like this:

   //col1  col2
0       1     1
1       2     2
2       3     3
3       4     4

And then we do this:

data.columns = data.columns.str.replace('//','')

We will get this:

   col1  col2
0     1     1
1     2     2
2     3     3
3     4     4


问:
My JTextArea's are not respecting the size of the component and are being cut off
I have been working on this for hours. I honestly cannot figure it out. I have JTextArea's inside a JSplitPane which is inside a JPanel with a JButton and all that is put in my JFrame. I am using Layout managers. I have tried using pack(). I have tried using preferred sizes. Without the JPanel my button does not display in the proper location or switch buttons in other Tabs. With the JPanel it cuts off all my text, stops the scroll function(yes I have tried setting the TextAreas to always have horizontal and vertical scroll bars...does not solve the problem where text just stops wrapping for no apparent reason).</p>

```<code>public static void main(String[] args) throws IOException
{
    JFrame frame = new JFrame();

    Deck blackjack = new Deck(Deck.TYPE[0]);

    JTextArea textBlackjackUnshuffled = new JTextArea();
    JTextArea textBlackjackShuffle = new JTextArea();

    JButton shuffleButtonBlackjack = new JButton(new ImageIcon(ImageIO.read(new File("res/shuffle.png"))));

    JToolBar toolBarBlackjack = new JToolBar("Blackjack");

    JSplitPane splitPaneBlackjack = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);

    JPanel panel = new JPanel();

    JTabbedPane tabbedPaneBlackJack = new JTabbedPane();
    JTabbedPane tabbedPaneCanasta = new JTabbedPane();
    JTabbedPane tabbedPanePinochle = new JTabbedPane();

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());

    textBlackjackUnshuffled.setColumns(10);
    textBlackjackUnshuffled.setLineWrap(true);
    textBlackjackUnshuffled.setWrapStyleWord(true);
    textBlackjackUnshuffled.setEditable(false);
    textBlackjackUnshuffled.setFont(new Font("DejaVu Sans", Font.PLAIN, 100));
    textBlackjackUnshuffled.append(blackjack.toString());

    textBlackjackShuffle.setColumns(10);
    textBlackjackShuffle.setLineWrap(true);
    textBlackjackShuffle.setWrapStyleWord(true);
    textBlackjackShuffle.setEditable(false);
    textBlackjackShuffle.setFont(new Font("DejaVu Sans", Font.PLAIN, 100));
    textBlackjackShuffle.append(blackjack.toString());

    shuffleButtonBlackjack.setBorderPainted(false);
    shuffleButtonBlackjack.setFocusPainted(false);
    shuffleButtonBlackjack.setContentAreaFilled(false);

    splitPaneBlackjack.add(new JScrollPane(textBlackjackUnshuffled));
    splitPaneBlackjack.add(new JScrollPane(textBlackjackShuffle));

    panel.add(splitPaneBlackjack, BorderLayout.CENTER);
    panel.add(shuffleButtonBlackjack, BorderLayout.PAGE_END);

    tabbedPaneBlackJack.addTab("Blackjack", panel);

    frame.add(tabbedPaneBlackJack);
    frame.setSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize()));
    frame.setVisible(true);
}
</code>```

答:
You're adding the JScrollPanes to the panel in BorderLayout positions, but have not set the layout manager of panel to BorderLayout. In this situation, panel will be using JPanel's default layout manager, FlowLayout, a manager which is not smart enough to respect the scroll pane's preferred sizes.

Your code needs:

```<code>panel.setLayout(new BorderLayout());
</code>```

Body:
I have been working on this for hours. I honestly cannot figure it out. I have JTextArea's inside a JSplitPane which is inside a JPanel with a JButton and all that is put in my JFrame. I am using Layout managers. I have tried using pack(). I have tried using preferred sizes. Without the JPanel my button does not display in the proper location or switch buttons in other Tabs. With the JPanel it cuts off all my text, stops the scroll function(yes I have tried setting the TextAreas to always have horizontal and vertical scroll bars...does not solve the problem where text just stops wrapping for no apparent reason).

public static void main(String[] args) throws IOException
{
    JFrame frame = new JFrame();

    Deck blackjack = new Deck(Deck.TYPE[0]);

    JTextArea textBlackjackUnshuffled = new JTextArea();
    JTextArea textBlackjackShuffle = new JTextArea();

    JButton shuffleButtonBlackjack = new JButton(new ImageIcon(ImageIO.read(new File("res/shuffle.png"))));

    JToolBar toolBarBlackjack = new JToolBar("Blackjack");

    JSplitPane splitPaneBlackjack = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);

    JPanel panel = new JPanel();

    JTabbedPane tabbedPaneBlackJack = new JTabbedPane();
    JTabbedPane tabbedPaneCanasta = new JTabbedPane();
    JTabbedPane tabbedPanePinochle = new JTabbedPane();

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());

    textBlackjackUnshuffled.setColumns(10);
    textBlackjackUnshuffled.setLineWrap(true);
    textBlackjackUnshuffled.setWrapStyleWord(true);
    textBlackjackUnshuffled.setEditable(false);
    textBlackjackUnshuffled.setFont(new Font("DejaVu Sans", Font.PLAIN, 100));
    textBlackjackUnshuffled.append(blackjack.toString());

    textBlackjackShuffle.setColumns(10);
    textBlackjackShuffle.setLineWrap(true);
    textBlackjackShuffle.setWrapStyleWord(true);
    textBlackjackShuffle.setEditable(false);
    textBlackjackShuffle.setFont(new Font("DejaVu Sans", Font.PLAIN, 100));
    textBlackjackShuffle.append(blackjack.toString());

    shuffleButtonBlackjack.setBorderPainted(false);
    shuffleButtonBlackjack.setFocusPainted(false);
    shuffleButtonBlackjack.setContentAreaFilled(false);

    splitPaneBlackjack.add(new JScrollPane(textBlackjackUnshuffled));
    splitPaneBlackjack.add(new JScrollPane(textBlackjackShuffle));

    panel.add(splitPaneBlackjack, BorderLayout.CENTER);
    panel.add(shuffleButtonBlackjack, BorderLayout.PAGE_END);

    tabbedPaneBlackJack.addTab("Blackjack", panel);

    frame.add(tabbedPaneBlackJack);
    frame.setSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize()));
    frame.setVisible(true);
}

Body:
You're adding the JScrollPanes to the panel in BorderLayout positions, but have not set the layout manager of panel to BorderLayout. In this situation, panel will be using JPanel's default layout manager, FlowLayout, a manager which is not smart enough to respect the scroll pane's preferred sizes.

Your code needs:

panel.setLayout(new BorderLayout());


问:
How to implement Facebook Post Type objects in GAE?
I a new programmer and trying to implement a facebook type "feed" in my application. Like Whenever a user do some changes in his profile his linked profiles will get to know that in the form of news feed.

But I am stuck on that as I thought whenever any user saves any data (like "News", "Blog", "Event" or any "Comment") just send the id of the respective classes to the linked profiles and they will see it. Since the id is not generated before the object is saved , the problem is how can I send them. I thought of following workarounds but each have some problem.

Whenever a user posts a news .... a Post object will be made and added to User's Post Collection.
But How do the other users will knew about it.....

1) Send them the id .... but when the id is not created how can you send them the id.

2) Send them the post message and when ever they will click them ... the latest post to   them from the particular user will be               shown.. but if more than 3 messages then which will be shown??   Shown by the post creation Date no post greater than that date is shownn....but he needs to be shown newer posts..

3) Save the post in all followers feed. the data will be much larger then

4) all the followers on login will check all the persons they are following and save their feed after the time stamp? How to implement this as the Post is saved in  User's Profile so I would have to check all the following person and then just check the feed and show them on his feed box; I think I would have to use batch Processes. Processing will take much longer.

I am using objectify-appengine to do operations on GAE.

Any help is appreciated

答: This talk at Google I/O 2009 by Brett Slatkin describes exactly the pattern you should use for this.</p>

ContentLicense: CC BY-SA 3.0


问:
Text inside floated div not responsive
In the following code:

<!DOCTYPE html>

  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Grid View</title>

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nesciunt cupiditate, ullam, illum magnam quidem ipsam laudantium dicta autem fugit cumque laboriosam et neque consequuntur beatae? Molestiae sed id ipsam distinctio molestias asperiores,
          labore officia! Maxime dolor illo, beatae cumque rerum sint corrupti possimus sed labore.

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nesciunt cupiditate, ullam, illum magnam quidem ipsam laudantium dicta autem fugit cumque laboriosam et neque consequuntur beatae? Molestiae sed id ipsam distinctio molestias asperiores,
          labore officia! Maxime dolor illo, beatae cumque rerum sint corrupti possimus sed labore.

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nesciunt cupiditate, ullam, illum magnam quidem ipsam laudantium dicta autem fugit cumque laboriosam et neque consequuntur beatae? Molestiae sed id ipsam distinctio molestias asperiores,
          labore officia! Maxime dolor illo, beatae cumque rerum sint corrupti possimus sed labore.

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nesciunt cupiditate, ullam, illum magnam quidem ipsam laudantium dicta autem fugit cumque laboriosam et neque consequuntur beatae? Molestiae sed id ipsam distinctio molestias asperiores,
          labore officia! Maxime dolor illo, beatae cumque rerum sint corrupti possimus sed labore.

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nesciunt cupiditate, ullam, illum magnam quidem ipsam laudantium dicta autem fugit cumque laboriosam et neque consequuntur beatae? Molestiae sed id ipsam distinctio molestias asperiores,
          labore officia! Maxime dolor illo, beatae cumque rerum sint corrupti possimus sed labore.

```

The web page breaks at around 470px (checked through device toolbar using chrome inspect). This happens as the text inside the 4 floated divs in the second row is not responsive and gets out of the div at 470px. This is only happening when the text is inside a floated element, when I make the divs block element again, the text becomes responsive.

Can someone tell me why this happens ?

答: Changing the font-size to a 'vw' value of text inside floating elements resolves the issue. But i still can't figure out why.</p>

Title: Text inside floated div not responsive

Body:
In the following code:

<!DOCTYPE html>

  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Grid View</title>

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nesciunt cupiditate, ullam, illum magnam quidem ipsam laudantium dicta autem fugit cumque laboriosam et neque consequuntur beatae? Molestiae sed id ipsam distinctio molestias asperiores,
          labore officia! Maxime dolor illo, beatae cumque rerum sint corrupti possimus sed labore.

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nesciunt cupiditate, ullam, illum magnam quidem ipsam laudantium dicta autem fugit cumque laboriosam et neque consequuntur beatae? Molestiae sed id ipsam distinctio molestias asperiores,
          labore officia! Maxime dolor illo, beatae cumque rerum sint corrupti possimus sed labore.

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nesciunt cupiditate, ullam, illum magnam quidem ipsam laudantium dicta autem fugit cumque laboriosam et neque consequuntur beatae? Molestiae sed id ipsam distinctio molestias asperiores,
          labore officia! Maxime dolor illo, beatae cumque rerum sint corrupti possimus sed labore.

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nesciunt cupiditate, ullam, illum magnam quidem ipsam laudantium dicta autem fugit cumque laboriosam et neque consequuntur beatae? Molestiae sed id ipsam distinctio molestias asperiores,
          labore officia! Maxime dolor illo, beatae cumque rerum sint corrupti possimus sed labore.

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nesciunt cupiditate, ullam, illum magnam quidem ipsam laudantium dicta autem fugit cumque laboriosam et neque consequuntur beatae? Molestiae sed id ipsam distinctio molestias asperiores,
          labore officia! Maxime dolor illo, beatae cumque rerum sint corrupti possimus sed labore.

The web page breaks at around 470px (checked through device toolbar using chrome inspect). This happens as the text inside the 4 floated divs in the second row is not responsive and gets out of the div at 470px. This is only happening when the text is inside a floated element, when I make the divs block element again, the text becomes responsive.

Can someone tell me why this happens ?


问:
Compile Errors vs. Runtime errors
I understand the difference between a compiler error and a runtime error and what examples are for each of them. My question is, computationally speaking, which is better? Does a statically typed language that catches an error at compile time save any more space or increase efficiency for the computer than a dynamically typed language that catches errors at run time? </p>

答:
Compiler errors get detected by compiler at the time of code development.

Runtime time errors are not get detected by compiler and hence identified at the time of code execution.

asking which is better is irrelevant =)

Title: Compile Errors vs. Runtime errors


问:
Fast taps (clicks) on RecyclerView opens multiple Fragments
I have implemented onClick listener to my ViewHolder for my RecyclerView

But when I perform very fast double taps or mouse clicks, it performs the task (opens a seperate fragment in this case) twice or three times.

here is my code

```<code>    public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
    TextView tvTitle, tvDescription;

    public ViewHolder(View itemView) {
        super(itemView);
        itemView.setClickable(true);
        itemView.setOnClickListener(this);

        tvTitle = (TextView) itemView.findViewById(R.id.tv_title);
        tvDescription = (TextView) itemView.findViewById(R.id.tv_description);
    }

    @Override
    public void onClick(View v) {
        mListener.onClick(FRAGMENT_VIEW, getAdapterPosition()); // open FRAGMENT_VIEW
    }
}
</code>```

Any ideas on how to prevent such behaviour?

答:
Too late but it can work for other people:

```<code>recyclerAdapter.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            int id = ....
            if(id == 1){
                view.setClickable(false); //add this
                Intent a = new Intent...
                startActivity(a);

            }else if(id == 2){
                view.setClickable(false);
                Intent b = ...
                startActivity(b);
            }
        }
    });
</code>```

Fragment - onResume()

```<code>@Override
public void onResume() {
    super.onResume();
    Objects.requireNonNull(getActivity()).invalidateOptionsMenu();
    recyclerView.setAdapter(recyclerAdapter); //add this
}
</code>```

It works for me, i don't know if it's correct.

Body:
I have implemented onClick listener to my ViewHolder for my RecyclerView

But when I perform very fast double taps or mouse clicks, it performs the task (opens a seperate fragment in this case) twice or three times.

here is my code

    public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
    TextView tvTitle, tvDescription;

    public ViewHolder(View itemView) {
        super(itemView);
        itemView.setClickable(true);
        itemView.setOnClickListener(this);

        tvTitle = (TextView) itemView.findViewById(R.id.tv_title);
        tvDescription = (TextView) itemView.findViewById(R.id.tv_description);
    }

    @Override
    public void onClick(View v) {
        mListener.onClick(FRAGMENT_VIEW, getAdapterPosition()); // open FRAGMENT_VIEW
    }
}

Any ideas on how to prevent such behaviour?

Body:
Too late but it can work for other people:

recyclerAdapter.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            int id = ....
            if(id == 1){
                view.setClickable(false); //add this
                Intent a = new Intent...
                startActivity(a);

            }else if(id == 2){
                view.setClickable(false);
                Intent b = ...
                startActivity(b);
            }
        }
    });

Fragment - onResume()

@Override
public void onResume() {
    super.onResume();
    Objects.requireNonNull(getActivity()).invalidateOptionsMenu();
    recyclerView.setAdapter(recyclerAdapter); //add this
}

It works for me, i don't know if it's correct.


问:
Whats a good approach/pattern to solve this scheduling problem
I have an object

```<code>public class Task
{
    public TimeSpan Length { get; set; }
    public IList<Task> Dependencies { get; set; }

    public DateTime? StartDate { get; set; }
}
</code>```

which has dependencies on other instances. For example:

(read "<-" as "depends on")

B <- A

C <- A

D <- B,C

and

Q <- P

R <- Q

Given a list of Tasks* and an EndDate, I need to set the StartDate on each task such that they will all be completed by the EndDate. Tasks may run in parallel where possible, so....

A has to be completed before B and C (which can be done at the same time), and D can only be run after B and C are both complete.

R must run after Q, after P, but these can be run in parelell to A B C and D.

* the list will be complete, all dependencies will be present in the list

Thanks for any advice
Andrew

答:
Thanks for everyones' advice, the Topological sort stuff was useful, but I think i've solved it an easier way...</p>

```<code>public class Scheduler
{
    private readonly IEnumerable<Task> tasks;
    private readonly DateTime endDate;

    public Scheduler(IEnumerable<Task> tasks, DateTime endDate)
    {
        this.tasks = tasks;
        this.endDate = endDate;
    }

    public void Schedule()
    {
        var terminators = FindTerminators();
        SetStartDatesRecursively(terminators, endDate);
    }

    public ICollection<Task> FindTerminators()
    {
        IList<Task> terminators = new List<Task>();

        foreach(var task in tasks)
        {
            var dependencies = this.tasks.Where(x => x.Dependencies.Contains(task));
            if (dependencies.Count() == 0)
                terminators.Add(task);
        }

        return terminators;
    }

    public void SetStartDatesRecursively(IEnumerable<Task> tasks, DateTime endDate)
    {
        foreach(var task in tasks)
        {
            var startDate = endDate - task.Length;

            if (task.StartDate.HasValue)
                task.StartDate = startDate < task.StartDate ? startDate : task.StartDate;
            else
                task.StartDate = startDate;

            SetStartDatesRecursively(task.Dependencies, task.StartDate.Value);
        }
    }
}
</code>```

OwnerDisplayName: Andrew Bullock

ContentLicense: CC BY-SA 2.5

Body:
I have an object

public class Task
{
    public TimeSpan Length { get; set; }
    public IList<Task> Dependencies { get; set; }

    public DateTime? StartDate { get; set; }
}

which has dependencies on other instances. For example:

(read "<-" as "depends on")

B <- A

C <- A

D <- B,C

and

Q <- P

R <- Q

Given a list of Tasks* and an EndDate, I need to set the StartDate on each task such that they will all be completed by the EndDate. Tasks may run in parallel where possible, so....

A has to be completed before B and C (which can be done at the same time), and D can only be run after B and C are both complete.

R must run after Q, after P, but these can be run in parelell to A B C and D.

* the list will be complete, all dependencies will be present in the list

Thanks for any advice
Andrew

LastEditorDisplayName: Andrew Bullock

Body:
Thanks for everyones' advice, the Topological sort stuff was useful, but I think i've solved it an easier way...

public class Scheduler
{
    private readonly IEnumerable<Task> tasks;
    private readonly DateTime endDate;

    public Scheduler(IEnumerable<Task> tasks, DateTime endDate)
    {
        this.tasks = tasks;
        this.endDate = endDate;
    }

    public void Schedule()
    {
        var terminators = FindTerminators();
        SetStartDatesRecursively(terminators, endDate);
    }

    public ICollection<Task> FindTerminators()
    {
        IList<Task> terminators = new List<Task>();

        foreach(var task in tasks)
        {
            var dependencies = this.tasks.Where(x => x.Dependencies.Contains(task));
            if (dependencies.Count() == 0)
                terminators.Add(task);
        }

        return terminators;
    }

    public void SetStartDatesRecursively(IEnumerable<Task> tasks, DateTime endDate)
    {
        foreach(var task in tasks)
        {
            var startDate = endDate - task.Length;

            if (task.StartDate.HasValue)
                task.StartDate = startDate < task.StartDate ? startDate : task.StartDate;
            else
                task.StartDate = startDate;

            SetStartDatesRecursively(task.Dependencies, task.StartDate.Value);
        }
    }
}


问:
Use JS to add browser version to  or  as class
I'm trying to find a tried and tested script that sniffs the browser version and adds a suitably named class to the  or the  tags... like  or  or .

I don't mind if it's "firefox4" or "ff4" or "firefox_4"... just as long as I can use the class to scope my css.

I could write a script to do this myself but I was wondering if there was a widely used one out there...

Thanks.

答: My strong suggestion is to use well-known and proof libs as Modernizr to do that for you.</p>

Title: Use JS to add browser version to <html> or <body> as class


问:
transfer variable betweet two php page
i have 3 page the first is html where i use  then i send the data to the second page (php) with post where i have some condition, then i will send the data again for the third php page where i will put it in table (html)
my probleme is the data don't send to the third php page

the 2nd page

```<code>if(isset($_POST['matier']) and isset($_POST['semaine']))
{
    $matier = $_POST['matier'] ;
    $semain = $_POST['semaine'] ;

    header('Location:EmploiMetierSemaine.php?'.$matier.' & '.$semaine);
}
</code>```

the third page

```<code><?php

                $matier = $_GET['m'] ;
                $semaine = $_GET['s'] ;
?>
</code>```

any help please

答:
You are not passing the params as parameters again but only values here:

```<code>header('Location:EmploiMetierSemaine.php?'.$matier.' & '.$semaine);
</code>```

If you want to pass them as m and s you have to tell your location header so:

```<code>header('Location:EmploiMetierSemaine.php?m='.$matier.'&s='.$semaine);
</code>```

Note that I also removed the spaces around the & since they don't make any sense in the URL.

Title: transfer variable betweet two php page

Body:
i have 3 page the first is html where i use  then i send the data to the second page (php) with post where i have some condition, then i will send the data again for the third php page where i will put it in table (html)
my probleme is the data don't send to the third php page

the 2nd page

if(isset($_POST['matier']) and isset($_POST['semaine']))
{
    $matier = $_POST['matier'] ;
    $semain = $_POST['semaine'] ;

    header('Location:EmploiMetierSemaine.php?'.$matier.' & '.$semaine);
}

the third page

<?php

                $matier = $_GET['m'] ;
                $semaine = $_GET['s'] ;
?>

any help please

Body:
You are not passing the params as parameters again but only values here:

header('Location:EmploiMetierSemaine.php?'.$matier.' & '.$semaine);

If you want to pass them as m and s you have to tell your location header so:

header('Location:EmploiMetierSemaine.php?m='.$matier.'&s='.$semaine);

Note that I also removed the spaces around the & since they don't make any sense in the URL.


答:
in second page  url should be like this EmploiMetierSemaine.php?m=matier&s=semaine </p>

```<code>if(isset($_POST['matier']) and isset($_POST['semaine']))
{
    $matier = $_POST['matier'] ;
    $semaine = $_POST['semaine'] ;

    header('Location:EmploiMetierSemaine.php?m='.$matier.'&s='.$semaine);
}
</code>```

Title: transfer variable betweet two php page

Body:
in second page  url should be like this EmploiMetierSemaine.php?m=matier&s=semaine

if(isset($_POST['matier']) and isset($_POST['semaine']))
{
    $matier = $_POST['matier'] ;
    $semaine = $_POST['semaine'] ;

    header('Location:EmploiMetierSemaine.php?m='.$matier.'&s='.$semaine);
}


答: Check out Modernizr.  It does that plus a whole lot more!

Body:
I'm trying to find a tried and tested script that sniffs the browser version and adds a suitably named class to the  or the  tags... like  or  or .

I don't mind if it's "firefox4" or "ff4" or "firefox_4"... just as long as I can use the class to scope my css.

I could write a script to do this myself but I was wondering if there was a widely used one out there...

Thanks.


问:
Cannot use unique_ptr inside a map in a vector?
I would like to use unique_ptr inside map in vector. But I got an error message.
I am not sure why and how to solve this problem.

This is the code.

#include <memory>

int main(int argc, char** argv)
{
    std::vector<std::map<int, std::unique_ptr<std::string>>> outputContainers;
    std::map<int, std::unique_ptr<std::string>> outputContainer;
    outputContainer[0] = std::make_unique<std::string>("test");
    outputContainers.push_back(std::move(outputContainer));
}
```

<p>This is an error message.</p>

```Error C2280 'std::pair<const int,std::unique_ptr<std::string,std::default_delete<std::string>>>::pair(const std::pair<const int,std::unique_ptr<std::string,std::default_delete<std::string>>> &)': attempting to reference a deleted function test C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\include\xmemory  671
```

答:
When a vector needs to reallocate, it may move elements to the new storage if the element's type is_nothrow_move_constructible; otherwise, it has to copy (so it can unwind back to the original state if any constructor throws an exception).

std::map's move constructor is not required to be noexcept. Some implementations may provide stronger guarantees than required by the standard, and make it noexcept; others may not.

The interaction of these two facts leads to a vector of maps of move-only type being non-portable - it may compile with some implementations but not others.

Body:
I would like to use unique_ptr inside map in vector. But I got an error message.
I am not sure why and how to solve this problem.

This is the code.

#include <memory>

int main(int argc, char** argv)
{
    std::vector<std::map<int, std::unique_ptr<std::string>>> outputContainers;
    std::map<int, std::unique_ptr<std::string>> outputContainer;
    outputContainer[0] = std::make_unique<std::string>("test");
    outputContainers.push_back(std::move(outputContainer));
}

This is an error message.

Error C2280 'std::pair<const int,std::unique_ptr<std::string,std::default_delete<std::string>>>::pair(const std::pair<const int,std::unique_ptr<std::string,std::default_delete<std::string>>> &)': attempting to reference a deleted function test C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\include\xmemory  671


问:
how to set combo box default value as session logged in user id in sap ui5
I am using comboBox control in sap ui5. I need to show default logged in user id. How can I achieve so?
This default user id is the part of odata service. For example I have 10 data(INC0001 to INC0010). If user INC0004 logged in then by default I want to show that in the comboBox. I am getting only first blank right now.

XML Code :

```<code><Select id="select1"
        items="{ path: '/UserSet', sorter: { path: 'zuserid' } }"
        change="handleChange">

     <core:Item text="{zuserid}" key="{zuserid}"/>
     <layoutData>
         <l:GridData span="XL2 L2"/>
     </layoutData>

</Select>
</code>```

Session user in sap ui5:

```<code>var userId = sap.ushell.Container.getService("UserInfo").getUser().getId();
</code>```

答:
This is the solution for this issue.
This will help anyone is looking out for the same.</p>

```<code> var oData ={
                recipient :{
                   name :"TCS0001"}};

    var oModel =newJSONModel(oData);
    this.getView().setModel(oModel,"NamedModel");

    <ComboBox id="combo1" selectedKey="{NamedModel>/recipient/name}" items="{ path: '/UserSet', sorter: { path: 'zuserid' } }" change="handleChange">
            <core:Item text="{zuserid}" key="{zuserid}"/>
            <layoutData>
             <l:GridData span="XL3 L3"/>
            </layoutData>
           </ComboBox><br>
</code>```

Body:
I am using comboBox control in sap ui5. I need to show default logged in user id. How can I achieve so?
This default user id is the part of odata service. For example I have 10 data(INC0001 to INC0010). If user INC0004 logged in then by default I want to show that in the comboBox. I am getting only first blank right now.

XML Code :

<Select id="select1"
        items="{ path: '/UserSet', sorter: { path: 'zuserid' } }"
        change="handleChange">

     <core:Item text="{zuserid}" key="{zuserid}"/>
     <layoutData>
         <l:GridData span="XL2 L2"/>
     </layoutData>

</Select>

Session user in sap ui5:

var userId = sap.ushell.Container.getService("UserInfo").getUser().getId();

Body:
This is the solution for this issue.
This will help anyone is looking out for the same.

 var oData ={
                recipient :{
                   name :"TCS0001"}};

    var oModel =newJSONModel(oData);
    this.getView().setModel(oModel,"NamedModel");

    <ComboBox id="combo1" selectedKey="{NamedModel>/recipient/name}" items="{ path: '/UserSet', sorter: { path: 'zuserid' } }" change="handleChange">
            <core:Item text="{zuserid}" key="{zuserid}"/>
            <layoutData>
             <l:GridData span="XL3 L3"/>
            </layoutData>
           </ComboBox><br>


问:
Attempting to understand Python (for translation to C)
I've been trying to understand the following Python program to translate it in C, but I meet some difficulties, here it is :

```<code>ROB = '\x00\xA1\x0F\xC0'

def my_function(f):
  for c in range(0,len(f),4):
    if f[c:c+4] == ROB:
      f = f[:c] + f[c+4:] # What does it even means ???
      print '%p' % c
      return f
  print 'ERR'
  sys.exit(-1)
</code>```

I mean, I understood the most of the function but one of these lines is literally hard to translate (I talk about f[:c] + f[c+4:]) ...

Does someone know what this line is doing or how it should looks like in C ?

答:
Those are "slices", and the + simply concatenates them. This is the simplest case of slicing, [start:end] creates a subsequence of a sequence, starting from position start inclusive, ending at position end, exclusive. If one of them is missing (but the : is there), it is considered to be the beginning/end of the complete sequence. Indices are zero based.

Examples with string:

'Hello World'[1:5]: 'ello'

'Hello World'[:5]: 'Hello'

'Hello World'[1:]: 'ello World'

'Hello World'[:1]+'Hello World'[5:]: 'H World'

Your loop steps through your data in 4-byte steps, comparing the 4-byte chunk at the current position with the sequence you have in ROB, and it returns a new sequence without it when it is found (so the f=... part does not actually modify the existing sequence).

In C you could do that with memcmp, then malloc and a pair of memcpy calls, as you correctly noticed that this data is binary (contains null-characters), so string functions would likely break it.

Hopefully I did not messed up the indices, and then it could look like this:

```<code>void* my_function(const void* f, int len){
  for(int i=0;i<len;i+=4)
    if(memcmp(f+i,ROB,4)==0){
      void* ret=malloc(len-4);
      memcpy(ret,f,i);
      memcpy(ret+i,f+i+4,len-i-4);
      return ret;
    }
  return NULL; // or have it die somehow
}
</code>```

Body:
I've been trying to understand the following Python program to translate it in C, but I meet some difficulties, here it is :

ROB = '\x00\xA1\x0F\xC0'

def my_function(f):
  for c in range(0,len(f),4):
    if f[c:c+4] == ROB:
      f = f[:c] + f[c+4:] # What does it even means ???
      print '%p' % c
      return f
  print 'ERR'
  sys.exit(-1)

I mean, I understood the most of the function but one of these lines is literally hard to translate (I talk about f[:c] + f[c+4:]) ...

Does someone know what this line is doing or how it should looks like in C ?

Body:
Those are "slices", and the + simply concatenates them. This is the simplest case of slicing, [start:end] creates a subsequence of a sequence, starting from position start inclusive, ending at position end, exclusive. If one of them is missing (but the : is there), it is considered to be the beginning/end of the complete sequence. Indices are zero based.

Examples with string:

'Hello World'[1:5]: 'ello'

'Hello World'[:5]: 'Hello'

'Hello World'[1:]: 'ello World'

'Hello World'[:1]+'Hello World'[5:]: 'H World'

Your loop steps through your data in 4-byte steps, comparing the 4-byte chunk at the current position with the sequence you have in ROB, and it returns a new sequence without it when it is found (so the f=... part does not actually modify the existing sequence).

In C you could do that with memcmp, then malloc and a pair of memcpy calls, as you correctly noticed that this data is binary (contains null-characters), so string functions would likely break it.

Hopefully I did not messed up the indices, and then it could look like this:

void* my_function(const void* f, int len){
  for(int i=0;i<len;i+=4)
    if(memcmp(f+i,ROB,4)==0){
      void* ret=malloc(len-4);
      memcpy(ret,f,i);
      memcpy(ret+i,f+i+4,len-i-4);
      return ret;
    }
  return NULL; // or have it die somehow
}


问:
List all values used in a session from a variable in Django
I did a simple search view to query based on this inputs.

```<code>def search(request):
    try:
        query_x = request.GET.get('query_x')
        query_y = request.GET.get('query_y')
        points_returned = request.GET.get('points_returned')
        distance_condition = request.GET.get('distance_condition')

        object_list = Points.objects.filter(
            geom_point__distance_lte=('POINT({0} {1})'.format(query_x, query_y), D(km=10))
            ).order_by('geom_point')[:int(points_returned)]

        request.session['query_x'] = query_x

        return render_to_response('search_results.html', {'object_list': object_list})
    except KeyError:
        return render_to_response('home.html')
</code>```

This search will be used many times (probably with same values) so I want to save and list all the inputs used to do the query by the user (for query_x and query_y variables). I already achieved to get the value in template, but just the last one input appear when I put {{request.session.query_x}} in the template to see the results - I need to get all values used.

答:
From wherever you are calling search function you can create a session variable of list there before calling search
request.session['query_x'] = list().
instead of doing request.session['query_x'] = query_x you can simply do request.session['query_x'].append(query_x) and access all query_x using request.session['query_x']

Body:
I did a simple search view to query based on this inputs.

def search(request):
    try:
        query_x = request.GET.get('query_x')
        query_y = request.GET.get('query_y')
        points_returned = request.GET.get('points_returned')
        distance_condition = request.GET.get('distance_condition')

        object_list = Points.objects.filter(
            geom_point__distance_lte=('POINT({0} {1})'.format(query_x, query_y), D(km=10))
            ).order_by('geom_point')[:int(points_returned)]

        request.session['query_x'] = query_x

        return render_to_response('search_results.html', {'object_list': object_list})
    except KeyError:
        return render_to_response('home.html')

This search will be used many times (probably with same values) so I want to save and list all the inputs used to do the query by the user (for query_x and query_y variables). I already achieved to get the value in template, but just the last one input appear when I put {{request.session.query_x}} in the template to see the results - I need to get all values used.


问:
NSZombieEnabled does not work
When I set NSZombieEnabled = Yes nothing is written to the console. How can I fix this? Or can you advise me any other tools for an EXC_BAD_ACCESS?

答:
i don't understand how the answer to this question really answers the question..

i am asking myself the same thing. using xcode4 i have enabled NSZobmieEnabled = YES to halt when i access an object that has been released, instead of crashing with EXC_BAD_ACCESS - which is very helpful.

the question at hand was:

"When I set NSZombieEnabled = Yes nothing is written to the console. How can I fix this...".

simple and straight forward.

i am experiencing the same issue. xcode halts with the debugger but the console does not produce any message. i would expect something along the lines of:

"message sent to deallocated instance...".

Title: NSZombieEnabled does not work


问:
Installing fftw--Unable to guess build type
I'm trying to install FFTW and when I get to the ./configure --enable-mpi --enable-type-prefix --enable-float command and when I run it, this is the error I get. How do I overcome this? I'm in Cygwin on windows 10 if that helps.

```<code>$ ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for gawk... gawk checking whether make sets $(MAKE)... yes checking type prefix for installed files... (none) checking for vendor's cc to be used instead of gcc... checking for cc... cc checking for C compiler default output... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether cc accepts -g... yes checking for cc option to accept ANSI C... none needed checking for style of include used by make... GNU checking dependency style of cc... gcc3 checking whether we are using gcc 2.90 or later... yes checking for a BSD-compatible install... /usr/bin/install -c checking whether make sets $(MAKE)... (cached) yes checking for ranlib... ranlib checking whether ln -s works... yes checking build system type... ./config.guess: unable to guess system type

This script, last modified 2003-02-22, has failed to recognize the operating system you are using. It is advised that you download the most up to date version of the config scripts from

    ftp://ftp.gnu.org/pub/gnu/config/

If the version you run (./config.guess) is already up to date, please send the following data and any information you think might be pertinent to <config-patches@gnu.org> in order to provide the needed information to handle your system.

config.guess timestamp = 2003-02-22

uname -m = x86_64 uname -r = 3.1.2(0.340/5/3) uname -s = CYGWIN_NT-10.0 uname -v = 2019-12-21 15:25

/usr/bin/uname -p = unknown /bin/uname -X     =

hostinfo               = /bin/universe          = /usr/bin/arch -k
= /bin/arch              = x86_64 /usr/bin/oslevel       = /usr/convex/getsysinfo =

UNAME_MACHINE = x86_64 UNAME_RELEASE = 3.1.2(0.340/5/3) UNAME_SYSTEM
= CYGWIN_NT-10.0 UNAME_VERSION = 2019-12-21 15:25 configure: error: cannot guess build type; you must specify one

configure: error: cannot guess build type; you must specify one
</code>```

I now Get the error:

I now get the error:

```<code>> mpicc    main.o  run.o  predict.o begrun.o endrun.o global.o
> timestep.o  init.o restart.o  io.o accel.o   read_ic.o  ngb.o system.o
> allocate.o  density.o gravtree.o hydra.o  driftfac.o domain.o
> allvars.o potential.o forcetree.o   peano.o gravtree_forcetest.o
> pm_periodic.o pm_nonperiodic.o longrange.o   -g  -L/usr/lib
> -L/usr/local/lib -lgsl -lgslcblas -lm -L/usr/local/lib -lsrfftw_mpi -lsfftw_mpi -lsrfftw -lsfftw    -o  Gadget2 /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/bin/ld:
> cannot find -lsrfftw_mpi
> /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/bin/ld:
> cannot find -lsfftw_mpi collect2: error: ld returned 1 exit status
> make: *** [Makefile:243: Gadget2] Error 1
</code>```

答:
fftw-2.1.5 is so old that it requires a suggestion to properly configure under a recent Cygwin.

```<code>$ ./configure --enable-mpi --enable-type-prefix --enable-float  --build=x86_64-pc-cygwin

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
....
config.status: creating mpi/Makefile
config.status: creating fftw.spec
config.status: creating fftw/config.h
config.status: creating fftw/fftw.h
config.status: executing depfiles commands
</code>```

I will not bet that you will have clean run with MPI and HDF5 as they also are more recent than those tested on Gadget2

Body:
I'm trying to install FFTW and when I get to the ./configure --enable-mpi --enable-type-prefix --enable-float command and when I run it, this is the error I get. How do I overcome this? I'm in Cygwin on windows 10 if that helps.

$ ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for gawk... gawk checking whether make sets $(MAKE)... yes checking type prefix for installed files... (none) checking for vendor's cc to be used instead of gcc... checking for cc... cc checking for C compiler default output... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether cc accepts -g... yes checking for cc option to accept ANSI C... none needed checking for style of include used by make... GNU checking dependency style of cc... gcc3 checking whether we are using gcc 2.90 or later... yes checking for a BSD-compatible install... /usr/bin/install -c checking whether make sets $(MAKE)... (cached) yes checking for ranlib... ranlib checking whether ln -s works... yes checking build system type... ./config.guess: unable to guess system type

This script, last modified 2003-02-22, has failed to recognize the operating system you are using. It is advised that you download the most up to date version of the config scripts from

    ftp://ftp.gnu.org/pub/gnu/config/

If the version you run (./config.guess) is already up to date, please send the following data and any information you think might be pertinent to <config-patches@gnu.org> in order to provide the needed information to handle your system.

config.guess timestamp = 2003-02-22

uname -m = x86_64 uname -r = 3.1.2(0.340/5/3) uname -s = CYGWIN_NT-10.0 uname -v = 2019-12-21 15:25

/usr/bin/uname -p = unknown /bin/uname -X     =

hostinfo               = /bin/universe          = /usr/bin/arch -k
= /bin/arch              = x86_64 /usr/bin/oslevel       = /usr/convex/getsysinfo =

UNAME_MACHINE = x86_64 UNAME_RELEASE = 3.1.2(0.340/5/3) UNAME_SYSTEM
= CYGWIN_NT-10.0 UNAME_VERSION = 2019-12-21 15:25 configure: error: cannot guess build type; you must specify one

configure: error: cannot guess build type; you must specify one

I now Get the error:

I now get the error:

> mpicc    main.o  run.o  predict.o begrun.o endrun.o global.o
> timestep.o  init.o restart.o  io.o accel.o   read_ic.o  ngb.o system.o
> allocate.o  density.o gravtree.o hydra.o  driftfac.o domain.o
> allvars.o potential.o forcetree.o   peano.o gravtree_forcetest.o
> pm_periodic.o pm_nonperiodic.o longrange.o   -g  -L/usr/lib
> -L/usr/local/lib -lgsl -lgslcblas -lm -L/usr/local/lib -lsrfftw_mpi -lsfftw_mpi -lsrfftw -lsfftw    -o  Gadget2 /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/bin/ld:
> cannot find -lsrfftw_mpi
> /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/bin/ld:
> cannot find -lsfftw_mpi collect2: error: ld returned 1 exit status
> make: *** [Makefile:243: Gadget2] Error 1

Body:
fftw-2.1.5 is so old that it requires a suggestion to properly configure under a recent Cygwin.

$ ./configure --enable-mpi --enable-type-prefix --enable-float  --build=x86_64-pc-cygwin

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
....
config.status: creating mpi/Makefile
config.status: creating fftw.spec
config.status: creating fftw/config.h
config.status: creating fftw/fftw.h
config.status: executing depfiles commands

I will not bet that you will have clean run with MPI and HDF5 as they also are more recent than those tested on Gadget2


问:
Div Cards Overlapping
Div Card overlap each other when I reduce the screen size on certain degree. But after I reduce it even more, it works as I want it to be . this is how it looks when I reduce it to the point so bootstrap can work on col-md

This is problem

This is how it normaly is:

.cards {
  margin-top: 100px;
}

.cards h1 {
  text-align: center;
}

html {
  font-family: "Source Sans Pro", sans-serif;
  font-size: 16px;
  font-smooth: auto;
  font-weight: 300;
  line-height: 1.5;
  color: #444;
}

a {
  text-decoration: none;
}

figure {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 265px;
  height: 360px;
  margin-left: 25px;
  padding: 20px 20px;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  border-radius: 10px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
  transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
  overflow: hidden;
}

figure:before,
figure:after {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

figure:before {
  content: "";
  background-color: rgba(0, 0, 0, 0.1);
  z-index: 0;
}

figure:after {
  content: "";
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
  overflow: hidden;
}

figure:hover {
  background-size: 175%;
}

figure:hover:after {
  content: "read more";
  background-color: rgba(191, 191, 191, 0.9);
  color: white;
  font-size: 32px;
  z-index: 2;
}

figure:hover .date {
  bottom: -59px;
}

figure:hover figcaption {
  transform: translateY(-110%);
}

.cards p {
  display: none;
}

.cards p:hover {
  display: block;
  color: #999;
}

figure .date {
  position: absolute;
  bottom: 0;
  right: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 10px;
  background-color: rgba(241, 196, 15, 0.8);
  text-shadow: 1px 1px rgba(0, 0, 0, 0.7);
  transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

figure .date span {
  color: white;
  line-height: 1;
}

figure .date span:first-child {
  font-family: "Source Code Pro", sans-serif;
  font-size: 20px;
  font-weight: 900;
}

figure .date span:last-child {
  font-size: 14px;
  font-weight: 400;
}

figure figcaption {
  color: #333;
  text-align: center;
  transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
  z-index: 1;
}

figure figcaption h4 {
  margin: 0 0 5px;
  font-family: "Source Code Pro", sans-serif;
  font-size: 24px;
  line-height: 1.35;
  text-shadow: 1px 1px rgba(0, 0, 0, 0.7);
}

figure figcaption h4>span {
  /* background-color: rgba(241, 196, 15, 0.8); */
}

figure figcaption p {
  margin: 0;
  line-height: 1.5;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="cards">
  <h1>What We Offer</h1>
  <div class="row">
    <div class="col-lg-3 col-md-6">

        <figure style='background-image: url("offers/conference.jpg")'>
          <figcaption>
            <h4> <span>Conference halls</span></h4>
            <p></p>
          </figcaption>
        </figure>

    </div>
    <div class="col-lg-3 col-md-6">

        <figure style='background-image: url("offers/restaurant.jpg")'>
          <figcaption>
            <h4> <span>Restaurant & Bar</span></h4>
            <p></p>
          </figcaption>
        </figure>

    </div>
    <div class="col-lg-3 col-md-6">

        <figure style='background-image: url("offers/entertainment.jpg")'>
          <figcaption>
            <h4> <span>Entertainment room</span></h4>
            <p></p>
          </figcaption>
        </figure>

    </div>
    <div class="col-lg-3 col-md-6">

        <figure style='background-image: url("offers/spa.jpg")'>
          <figcaption>
            <h4> <span>Spa & Wellness</span></h4>
            <p></p>
          </figcaption>
        </figure>

    </div>

  </div>
</div></code>```

答:
I have seen your snippet, what I have noticed that you have given fixed width value to "figure" tag in CSS (265px). Due to which it is causing overlay on column parent div. Just update width with "auto" or make it "100%", i hope it will resolve. I have added updated snippet below, please try it.</p>

```<code>figure {

position: relative;
display: flex;
align-items: flex-start;
justify-content: center;
width: 100%;
height: 360px;
margin-left: 25px;
padding: 20px 20px;
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
border-radius: 10px;
box-shadow: 0 14px 28px}
</code>```

Title: Div Cards Overlapping

Body:
Div Card overlap each other when I reduce the screen size on certain degree. But after I reduce it even more, it works as I want it to be . this is how it looks when I reduce it to the point so bootstrap can work on col-md

This is problem

This is how it normaly is:

.cards {
  margin-top: 100px;
}

.cards h1 {
  text-align: center;
}

html {
  font-family: "Source Sans Pro", sans-serif;
  font-size: 16px;
  font-smooth: auto;
  font-weight: 300;
  line-height: 1.5;
  color: #444;
}

a {
  text-decoration: none;
}

figure {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 265px;
  height: 360px;
  margin-left: 25px;
  padding: 20px 20px;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  border-radius: 10px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
  transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
  overflow: hidden;
}

figure:before,
figure:after {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

figure:before {
  content: "";
  background-color: rgba(0, 0, 0, 0.1);
  z-index: 0;
}

figure:after {
  content: "";
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
  overflow: hidden;
}

figure:hover {
  background-size: 175%;
}

figure:hover:after {
  content: "read more";
  background-color: rgba(191, 191, 191, 0.9);
  color: white;
  font-size: 32px;
  z-index: 2;
}

figure:hover .date {
  bottom: -59px;
}

figure:hover figcaption {
  transform: translateY(-110%);
}

.cards p {
  display: none;
}

.cards p:hover {
  display: block;
  color: #999;
}

figure .date {
  position: absolute;
  bottom: 0;
  right: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 10px;
  background-color: rgba(241, 196, 15, 0.8);
  text-shadow: 1px 1px rgba(0, 0, 0, 0.7);
  transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

figure .date span {
  color: white;
  line-height: 1;
}

figure .date span:first-child {
  font-family: "Source Code Pro", sans-serif;
  font-size: 20px;
  font-weight: 900;
}

figure .date span:last-child {
  font-size: 14px;
  font-weight: 400;
}

figure figcaption {
  color: #333;
  text-align: center;
  transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
  z-index: 1;
}

figure figcaption h4 {
  margin: 0 0 5px;
  font-family: "Source Code Pro", sans-serif;
  font-size: 24px;
  line-height: 1.35;
  text-shadow: 1px 1px rgba(0, 0, 0, 0.7);
}

figure figcaption h4>span {
  /* background-color: rgba(241, 196, 15, 0.8); */
}

figure figcaption p {
  margin: 0;
  line-height: 1.5;
}

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>

What We Offer

 Conference halls

 Restaurant & Bar

 Entertainment room

 Spa & Wellness

Body:
I have seen your snippet, what I have noticed that you have given fixed width value to "figure" tag in CSS (265px). Due to which it is causing overlay on column parent div. Just update width with "auto" or make it "100%", i hope it will resolve. I have added updated snippet below, please try it.

figure {

position: relative;
display: flex;
align-items: flex-start;
justify-content: center;
width: 100%;
height: 360px;
margin-left: 25px;
padding: 20px 20px;
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
border-radius: 10px;
box-shadow: 0 14px 28px}


问:
Query function suddenly returning `None` instead of the item it should be retruning
I did some minor refactoring to some working code. All I did was add 2 functions to clean up how input and it's assignment was handled. I did not change anything about the query_pswd_by_name function but now it doesn't return the password, it returns None. Everything else works perfectly. Any ideas what is going on? Here is the code:

```<code>import secrets
import string
import sqlite3
import pyperclip
import optparse

#CREATE PASSWORD OF GIVEN LENGTH
def get_pass(length):
    return "".join(secrets.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits + string.punctuation) for x in range(length))

def get_pass_length():
    length = int(input("Enter the length of password: "))
    password= get_pass(length)
    print(password)
    pyperclip.copy(password)
    print('Password copied to clipboard')

def create_and_store_pwsd():
    password = get_pass_length()
    name = str(input("Enter name for password: "))

    #CREATE DATABASE CONNECTION
    conn = sqlite3.connect("managerDB.db")

    #CREATE CURSOR OBJECT
    c = conn.cursor()

    #CREATE TABLE IN DISK FILE BASED DATABASE
    c.execute("""CREATE TABLE IF NOT EXISTS password_table (
                            name TEXT,
                            pswd TEXT
                            )""")
    #c.execute("DELETE FROM password_table")
    c.execute("INSERT INTO password_table (name, pswd) VALUES (?, ?)", (name, password))

    #COMMIT CHANGES
    conn.commit()
    conn.close()

def query_pswd_by_name(name):

    conn = sqlite3.connect('managerDB.db')
    c = conn.cursor()
    query_password = "SELECT pswd FROM password_table WHERE name = ?"
    c.execute(query_password,(name,))
    result = c.fetchall()
    for row in result:
        pyperclip.copy(str(row[0]))
        print("Password copied to clipboard")
        print(str(row[0]))
    conn.commit()
    conn.close()

def input_name_and_query():
    name = input('Name of password you wish to query: ')
    query_pswd_by_name(name)

create_and_store_pwsd()

input_name_and_query()```
```

答:
I mean, at face value, it returns None because you never return anything from the function. You are copying it to the clip board.

A bit more detail would be good. What functions were refactored? What is the output to the console of all your print statements?

As an aside, I'd recommend wrapping the module functionality (last two calls) in an if __name__ == "__main__" block

Body:
I did some minor refactoring to some working code. All I did was add 2 functions to clean up how input and it's assignment was handled. I did not change anything about the query_pswd_by_name function but now it doesn't return the password, it returns None. Everything else works perfectly. Any ideas what is going on? Here is the code:

import secrets
import string
import sqlite3
import pyperclip
import optparse

#CREATE PASSWORD OF GIVEN LENGTH
def get_pass(length):
    return "".join(secrets.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits + string.punctuation) for x in range(length))

def get_pass_length():
    length = int(input("Enter the length of password: "))
    password= get_pass(length)
    print(password)
    pyperclip.copy(password)
    print('Password copied to clipboard')

def create_and_store_pwsd():
    password = get_pass_length()
    name = str(input("Enter name for password: "))

    #CREATE DATABASE CONNECTION
    conn = sqlite3.connect("managerDB.db")

    #CREATE CURSOR OBJECT
    c = conn.cursor()

    #CREATE TABLE IN DISK FILE BASED DATABASE
    c.execute("""CREATE TABLE IF NOT EXISTS password_table (
                            name TEXT,
                            pswd TEXT
                            )""")
    #c.execute("DELETE FROM password_table")
    c.execute("INSERT INTO password_table (name, pswd) VALUES (?, ?)", (name, password))

    #COMMIT CHANGES
    conn.commit()
    conn.close()

def query_pswd_by_name(name):

    conn = sqlite3.connect('managerDB.db')
    c = conn.cursor()
    query_password = "SELECT pswd FROM password_table WHERE name = ?"
    c.execute(query_password,(name,))
    result = c.fetchall()
    for row in result:
        pyperclip.copy(str(row[0]))
        print("Password copied to clipboard")
        print(str(row[0]))
    conn.commit()
    conn.close()

def input_name_and_query():
    name = input('Name of password you wish to query: ')
    query_pswd_by_name(name)

create_and_store_pwsd()

input_name_and_query()```


问:
Ruby: Delete and return an array value based on block find condition
Is there a built-in way to delete a value from an array, based on a block condition returning true, and return the value that was deleted?

This is a simplified version of what I'm trying to do, but it seems like there has to be a better way:

```<code>array = [1,2,3,4,5,6,7,8,9,10]

index = array.index {|v| v == 5} # returns index if block is true

value = array.delete_at(index) # deletes and returns element at index
</code>```

value is then 5

答:
Array#extract (Rails 6+)

If you are using Rails, then starting from version 6, there is a method Array#extract!, which does almost what you need.

It removes and returns the elements for which the block returns a true value and modifies the original array.

Please, have a look at the following example:

```<code>array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

values = array.extract! { |value| value == 5 }

# array
# => [1, 2, 3, 4, 6, 7, 8, 9, 10]

# values
# => [5]
</code>```

Body:
Is there a built-in way to delete a value from an array, based on a block condition returning true, and return the value that was deleted?

This is a simplified version of what I'm trying to do, but it seems like there has to be a better way:

array = [1,2,3,4,5,6,7,8,9,10]

index = array.index {|v| v == 5} # returns index if block is true

value = array.delete_at(index) # deletes and returns element at index

value is then 5

Body:
Array#extract (Rails 6+)

If you are using Rails, then starting from version 6, there is a method Array#extract!, which does almost what you need.

It removes and returns the elements for which the block returns a true value and modifies the original array.

Please, have a look at the following example:

array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

values = array.extract! { |value| value == 5 }

# array
# => [1, 2, 3, 4, 6, 7, 8, 9, 10]

# values
# => [5]


问:
How to insert 1 interval numbers between given irregular numbers in python
I've generated index number list what I do find data using for-loop.

That numbers are as follows.

I want to generate 1 interval index numbers between each given numbers

```<code>Int64Index([ 2343,  2913,  5466,  8589, 10151, 11713, 13275, 14837, 15618,7961, 19523, 21624, 21700],dtype='int64')
</code>```

for e.g) 2343,2344,2345,2346 ......,2911,2912,2913,2914....5464,5465,5466 some thing like that.

Is there any method that i generate 1 interval numbers do not use for-loop?

答:
Did you try:</p>

```<code>>>> range(1,10)
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> range(1,10,1)
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> range(1,10,2)
[1, 3, 5, 7, 9]
>>> range(1,10,3)
[1, 4, 7]
>>> help(range)
Help on built-in function range in module __builtin__:

range(...)
    range(stop) -> list of integers
    range(start, stop[, step]) -> list of integers

    Return a list containing an arithmetic progression of integers.
    range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.
    When step is given, it specifies the increment (or decrement).
    For example, range(4) returns [0, 1, 2, 3].  The end point is omitted!
    These are exactly the valid indices for a list of 4 elements.
(END)
</code>```

Body:
I've generated index number list what I do find data using for-loop.

That numbers are as follows.

I want to generate 1 interval index numbers between each given numbers

Int64Index([ 2343,  2913,  5466,  8589, 10151, 11713, 13275, 14837, 15618,7961, 19523, 21624, 21700],dtype='int64')

for e.g) 2343,2344,2345,2346 ......,2911,2912,2913,2914....5464,5465,5466 some thing like that.

Is there any method that i generate 1 interval numbers do not use for-loop?

Body:
Did you try:

>>> range(1,10)
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> range(1,10,1)
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> range(1,10,2)
[1, 3, 5, 7, 9]
>>> range(1,10,3)
[1, 4, 7]
>>> help(range)
Help on built-in function range in module __builtin__:

range(...)
    range(stop) -> list of integers
    range(start, stop[, step]) -> list of integers

    Return a list containing an arithmetic progression of integers.
    range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.
    When step is given, it specifies the increment (or decrement).
    For example, range(4) returns [0, 1, 2, 3].  The end point is omitted!
    These are exactly the valid indices for a list of 4 elements.
(END)


问:
Problem with Lists and Queue.Queue Python 3
I'm working in an application where I have to receive data from a stream (Serial port) and plot it. I have two three threads, the main thread, the serial read thread and a thread that I will use to refresh the plots @ 10 to 30 hz.

Since the data is being received faster than 30hz I want to put the received data in a Queue so that when the plot refresher thread has to refresh can take all the new data and plot it.

The problem is that the data I receive, a list with ten values one for each data signal, I put it in my queue with q.put(data) but when I do a q.get() in the refresher thread, I can only read the last value i put in the queue and not the ones before.

So I simulated the incoming stream to send data every 100ms and the refresher to 1 second.

Lets say that the data I have put in is:

[1,1,1,1,1,1]

[2,2,2,2,2,2]
...

[10,10,10,10,10,10]

When I get the data in the Queue of the refreshing thread with

```<code>while not self.q.empty():
 print(q.get())
</code>```

I get 10 times:

[10,10,10,10,10,10]

So is like it does save the last value but for all the put operations.

When I try with a integer instead of a list it works as expected.

I also tried encapsulating the list in a class but when I read the list inside the class I get the same result.

Example to test it:

```<code>import queue
from threading import Thread
import time

class PlotsManager(object):
    def __init__(self):
        simulator = Simulator(self)
        simulator.startSimulator()
        self.samplesQueue = queue.Queue()

        thread = Thread(target=self.plotSamples)
        thread.start()

    def putSamples(self, samples):    #Puts the samples in the queue
        print("Samples in:  {}".format(samples))
        self.samplesQueue.put(samples)

    def plotSamples(self): #Pops the samples from the queue
        while (1):
            time.sleep(1)
            while not self.samplesQueue.empty():
                lastSamples = self.samplesQueue.get()
                print("Samples out: {}".format(lastSamples))

class Simulator():

    def __init__(self, PlotsManager):
        self.plotManager = PlotsManager

    def simulateNewData(self):
        counter = 0
        samples = [None] * 5
        while (True):
            # counter += 0.4
            counter += 1
            if counter > 100:
                counter = 0

            time.sleep(0.1)

            for i in range(5):
                samples[i] = counter
            self.plotManager.putSamples(samples)

    def startSimulator(self):
        thread = Thread(target=self.simulateNewData)
        thread.start()

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

Output:

```<code>Samples in:  [1, 1, 1, 1, 1]
Samples in:  [2, 2, 2, 2, 2]
Samples in:  [3, 3, 3, 3, 3]
Samples in:  [4, 4, 4, 4, 4]
Samples in:  [5, 5, 5, 5, 5]
Samples in:  [6, 6, 6, 6, 6]
Samples in:  [7, 7, 7, 7, 7]
Samples in:  [8, 8, 8, 8, 8]
Samples in:  [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples in:  [10, 10, 10, 10, 10]
Samples out: [10, 10, 10, 10, 10]
Samples in:  [11, 11, 11, 11, 11]
Samples in:  [12, 12, 12, 12, 12]
Samples in:  [13, 13, 13, 13, 13]
Samples in:  [14, 14, 14, 14, 14]
Samples in:  [15, 15, 15, 15, 15]
Samples in:  [16, 16, 16, 16, 16]
Samples in:  [17, 17, 17, 17, 17]
Samples in:  [18, 18, 18, 18, 18]
Samples in:  [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
</code>```

If it is changed by a number instead of a list of samples it works as expected.

答:
well basically the solution es to use deepcopy.

putSamples(copy.deepcopy(samples))

As far as I understand this is cause by the fact that the list is passed as reference and not as value so I'm adding the same value to the queue many times. With deepcopy I'm actually copy the actual value to the queue every time I add a value to the queue.

Body:
I'm working in an application where I have to receive data from a stream (Serial port) and plot it. I have two three threads, the main thread, the serial read thread and a thread that I will use to refresh the plots @ 10 to 30 hz.

Since the data is being received faster than 30hz I want to put the received data in a Queue so that when the plot refresher thread has to refresh can take all the new data and plot it.

The problem is that the data I receive, a list with ten values one for each data signal, I put it in my queue with q.put(data) but when I do a q.get() in the refresher thread, I can only read the last value i put in the queue and not the ones before.

So I simulated the incoming stream to send data every 100ms and the refresher to 1 second.

Lets say that the data I have put in is:

[1,1,1,1,1,1]

[2,2,2,2,2,2]
...

[10,10,10,10,10,10]

When I get the data in the Queue of the refreshing thread with

while not self.q.empty():
 print(q.get())

I get 10 times:

[10,10,10,10,10,10]

So is like it does save the last value but for all the put operations.

When I try with a integer instead of a list it works as expected.

I also tried encapsulating the list in a class but when I read the list inside the class I get the same result.

Example to test it:

import queue
from threading import Thread
import time

class PlotsManager(object):
    def __init__(self):
        simulator = Simulator(self)
        simulator.startSimulator()
        self.samplesQueue = queue.Queue()

        thread = Thread(target=self.plotSamples)
        thread.start()

    def putSamples(self, samples):    #Puts the samples in the queue
        print("Samples in:  {}".format(samples))
        self.samplesQueue.put(samples)

    def plotSamples(self): #Pops the samples from the queue
        while (1):
            time.sleep(1)
            while not self.samplesQueue.empty():
                lastSamples = self.samplesQueue.get()
                print("Samples out: {}".format(lastSamples))

class Simulator():

    def __init__(self, PlotsManager):
        self.plotManager = PlotsManager

    def simulateNewData(self):
        counter = 0
        samples = [None] * 5
        while (True):
            # counter += 0.4
            counter += 1
            if counter > 100:
                counter = 0

            time.sleep(0.1)

            for i in range(5):
                samples[i] = counter
            self.plotManager.putSamples(samples)

    def startSimulator(self):
        thread = Thread(target=self.simulateNewData)
        thread.start()

if __name__ == "__main__":
    pm = PlotsManager()

Output:

Samples in:  [1, 1, 1, 1, 1]
Samples in:  [2, 2, 2, 2, 2]
Samples in:  [3, 3, 3, 3, 3]
Samples in:  [4, 4, 4, 4, 4]
Samples in:  [5, 5, 5, 5, 5]
Samples in:  [6, 6, 6, 6, 6]
Samples in:  [7, 7, 7, 7, 7]
Samples in:  [8, 8, 8, 8, 8]
Samples in:  [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples out: [9, 9, 9, 9, 9]
Samples in:  [10, 10, 10, 10, 10]
Samples out: [10, 10, 10, 10, 10]
Samples in:  [11, 11, 11, 11, 11]
Samples in:  [12, 12, 12, 12, 12]
Samples in:  [13, 13, 13, 13, 13]
Samples in:  [14, 14, 14, 14, 14]
Samples in:  [15, 15, 15, 15, 15]
Samples in:  [16, 16, 16, 16, 16]
Samples in:  [17, 17, 17, 17, 17]
Samples in:  [18, 18, 18, 18, 18]
Samples in:  [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]
Samples out: [19, 19, 19, 19, 19]

If it is changed by a number instead of a list of samples it works as expected.


问:
fading in and fading out a dropdown an unordered list
I am trying to fade in and fade out a
 on a click. I know the method I am using is wrong because it doesn't work, but also because I am pretty sure it's because I need to use $(this) instead of the current $('#innerList') but I am just not sure what I have to do.

http://jsfiddle.net/kyllle/tfZXE/

答:
Try this:

```<code>$(document).ready(function() {
    $('.innerList').hide();
    $('.dropLink').click(function(e) {
        e.stopPropagation();
        var inner = $('.innerList', $(this).parent());
        inner.fadeToggle(200);
    });
});
</code>```

Fiddle: http://jsfiddle.net/maniator/tfZXE/12/

I changed the HTML so that every li can have its own innerList

Body:
Try this:

$(document).ready(function() {
    $('.innerList').hide();
    $('.dropLink').click(function(e) {
        e.stopPropagation();
        var inner = $('.innerList', $(this).parent());
        inner.fadeToggle(200);
    });
});

Fiddle: http://jsfiddle.net/maniator/tfZXE/12/

I changed the HTML so that every li can have its own innerList