Title: Create a multiline plot from a dataset with time on one axis and genes on the other

Body:
I have a dataset with mean gene counts for each decade as shown below:

structure(list(decade_0 = c(92.500989948184, 2788.27384875413,
28.6937227408861, 1988.03831525414, 1476.83143096418), decade_1 = c(83.4606306426572,
537.725421951383, 10.2747132062782, 235.380422949258, 685.043600629146
), decade_2 = c(188.414375201462, 2091.84249935145, 17.080858894829,
649.55107199935, 1805.3484565514), decade_3 = c(43.3316024314987,
141.64396529835, 2.77851259926935, 94.7748265692319, 413.248354335235
), decade_4 = c(54.4891626582901, 451.076574268175, 12.4298374245007,
346.102609621018, 769.215535857077), decade_5 = c(85.5621750431284,
131.822699578988, 13.3130607062134, 151.002200923853, 387.727911723968
), decade_6 = c(112.860998806804, 4844.59668489898, 19.7317645111144,
2084.76584309876, 766.375852567831), decade_7 = c(73.2198969730458,
566.042952305845, 3.2457873699886, 311.853982701609, 768.801733767044
), decade_8 = c(91.8161648275608, 115.161700090147, 10.7289451320065,
181.747670625714, 549.21661120626), decade_9 = c(123.31045087146,
648.23694540667, 17.7690326882018, 430.301803845829, 677.187054208271
)), row.names = c("ANK1", "NTN4", "PTPRH", "JAG1", "PLAT"), class = "data.frame")

I would like to plot a line graph with the changes in counts over time for each of >30 genes as shown here in excel.

To do this with ggplot I have to convert it to col1: decade, col2: gene, col3: counts.
My question is, either how to convert my table into this ggplot friendly table, or if there is a better way to produce the plot with a different tool?

Thanks!

Body:
One possibility: transpose your data frame, convert rownames to columns, then gather ("make long"). Plotting is then easy.

library(tidyverse)
mydat <- structure(list(decade_0 = c(92.500989948184, 2788.27384875413,
                            28.6937227408861, 1988.03831525414, 1476.83143096418), decade_1 = c(83.4606306426572,
                                                                                537.725421951383, 10.2747132062782, 235.380422949258, 685.043600629146
                            ), decade_2 = c(188.414375201462, 2091.84249935145, 17.080858894829,
                                            649.55107199935, 1805.3484565514), decade_3 = c(43.3316024314987,
                                                                                141.64396529835, 2.77851259926935, 94.7748265692319, 413.248354335235
                                            ), decade_4 = c(54.4891626582901, 451.076574268175, 12.4298374245007,
                                                            346.102609621018, 769.215535857077), decade_5 = c(85.5621750431284,
                                                                                131.822699578988, 13.3130607062134, 151.002200923853, 387.727911723968
                                                            ), decade_6 = c(112.860998806804, 4844.59668489898, 19.7317645111144,
                                                                            2084.76584309876, 766.375852567831), decade_7 = c(73.2198969730458,
                                                                                566.042952305845, 3.2457873699886, 311.853982701609, 768.801733767044
                                                                            ), decade_8 = c(91.8161648275608, 115.161700090147, 10.7289451320065,
                                                                                181.747670625714, 549.21661120626), decade_9 = c(123.31045087146,
                                                                                648.23694540667, 17.7690326882018, 430.301803845829, 677.187054208271
                                                                                )), row.names = c("ANK1", "NTN4", "PTPRH", "JAG1", "PLAT"), class = "data.frame")

newdat <- mydat %>% t() %>% as.data.frame() %>% tibble::rownames_to_column('decade') %>%
  pivot_longer(-decade, names_to = 'gene', values_to = 'count')

ggplot(newdat) + geom_line(aes(decade, count, color = gene, group = gene))

Created on 2020-02-14 by the reprex package (v0.3.0)


来源: stackexchange

问:
Taking the last five digits of a number from user input in REACT.jsx
Basically, I am currently using this.props.x (which is the user input) to get information from another page. So this.props.x is a number, for example "12345 12345 54321" in three groups of 5 digits. I want to replace the first 10 digits with asterisks and keep the last 5 digits. How do I manipulate this.props.x in such a way that I can make this possible?

Thanks.

This is what I've tried.

```<code>{this.props.x ? (
              <p>
                Card number: <br />
                {"***** *****" + this.props.x}
              </p>
            ) : (
              ""
            )
</code>```

I want the end result to look like
***** ***** 54321

答:
if x is a (whole) number then it can't have space and your all 15 digit will be together. In that case you can use something like

```<code>{"***** *****" + (this.props.x % 100000)}
</code>```

And if it is a string like you mentioned in your question with spaces after every 5 characters then you can use Array.prototype.slice()

```<code>{"***** *****" + (this.props.x.slice(12)}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Basically, I am currently using this.props.x (which is the user input) to get information from another page. So this.props.x is a number, for example "12345 12345 54321" in three groups of 5 digits. I want to replace the first 10 digits with asterisks and keep the last 5 digits. How do I manipulate this.props.x in such a way that I can make this possible?

Thanks.

This is what I've tried.

{this.props.x ? (

                Card number:

                {"***** *****" + this.props.x}

            ) : (
              ""
            )

I want the end result to look like
***** ***** 54321

Body:
if x is a (whole) number then it can't have space and your all 15 digit will be together. In that case you can use something like

{"***** *****" + (this.props.x % 100000)}

And if it is a string like you mentioned in your question with spaces after every 5 characters then you can use Array.prototype.slice()

{"***** *****" + (this.props.x.slice(12)}


问:
Vertical viewport was given unbounded height
This is my code:

@override
Widget build(BuildContext context) {
  return new Material(
    color: Colors.deepPurpleAccent,
    child: new Column(
     mainAxisAlignment: MainAxisAlignment.center,
        children:<Widget>[new GridView.count(crossAxisCount: _column,children: new List.generate(_row*_column, (index) {
          return new Center(
              child: new CellWidget()
          );
        }),)]
    )
  );
}
```
<p>Exception as follows:</p>
```I/flutter ( 9925): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 9925): The following assertion was thrown during performResize():
I/flutter ( 9925): Vertical viewport was given unbounded height.
I/flutter ( 9925): Viewports expand in the scrolling direction to fill their container.In this case, a vertical
I/flutter ( 9925): viewport was given an unlimited amount of vertical space in which to expand. This situation
I/flutter ( 9925): typically happens when a scrollable widget is nested inside another scrollable widget.
I/flutter ( 9925): If this widget is always nested in a scrollable widget there is no need to use a viewport because
I/flutter ( 9925): there will always be enough vertical space for the children. In this case, consider using a Column
I/flutter ( 9925): instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
I/flutter ( 9925): the height of the viewport to the sum of the heights of its children.
I/flutter ( 9925):
I/flutter ( 9925): When the exception was thrown, this was the stack:
I/flutter ( 9925): #0      RenderViewport.performResize.<anonymous closure> (package:flutter/src/rendering/viewport.dart:827:15)
I/flutter ( 9925): #1      RenderViewport.performResize (package:flutter/src/rendering/viewport.dart:880:6)
I/flutter ( 9925): #2      RenderObject.layout (package:flutter/src/rendering/object.dart:1555:9)
```

答:
This situation typically happens when a scrollable widget is nested inside another scrollable widget.

In my case i use GridView inside of Column and that error throws.

GridView widget has shrinkWrap property/named parameter, to set it true my problem is fixed.

```<code>GridView.count(
  shrinkWrap: true,
  // rest of code
)
</code>```

Body:
This is my code:

@override
Widget build(BuildContext context) {
  return new Material(
    color: Colors.deepPurpleAccent,
    child: new Column(
     mainAxisAlignment: MainAxisAlignment.center,
        children:<Widget>[new GridView.count(crossAxisCount: _column,children: new List.generate(_row*_column, (index) {
          return new Center(
              child: new CellWidget()
          );
        }),)]
    )
  );
}

Exception as follows:

I/flutter ( 9925): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 9925): The following assertion was thrown during performResize():
I/flutter ( 9925): Vertical viewport was given unbounded height.
I/flutter ( 9925): Viewports expand in the scrolling direction to fill their container.In this case, a vertical
I/flutter ( 9925): viewport was given an unlimited amount of vertical space in which to expand. This situation
I/flutter ( 9925): typically happens when a scrollable widget is nested inside another scrollable widget.
I/flutter ( 9925): If this widget is always nested in a scrollable widget there is no need to use a viewport because
I/flutter ( 9925): there will always be enough vertical space for the children. In this case, consider using a Column
I/flutter ( 9925): instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
I/flutter ( 9925): the height of the viewport to the sum of the heights of its children.
I/flutter ( 9925):
I/flutter ( 9925): When the exception was thrown, this was the stack:
I/flutter ( 9925): #0      RenderViewport.performResize.<anonymous closure> (package:flutter/src/rendering/viewport.dart:827:15)
I/flutter ( 9925): #1      RenderViewport.performResize (package:flutter/src/rendering/viewport.dart:880:6)
I/flutter ( 9925): #2      RenderObject.layout (package:flutter/src/rendering/object.dart:1555:9)

Body:
This situation typically happens when a scrollable widget is nested inside another scrollable widget.

In my case i use GridView inside of Column and that error throws.

GridView widget has shrinkWrap property/named parameter, to set it true my problem is fixed.

GridView.count(
  shrinkWrap: true,
  // rest of code
)


问:
How do I get "JRLbr6THaTI", the id of the link using regular expression?
link='https://www.youtube.com/watch?v=JRLbr6THaTI'
anotherlink='https://www.youtu.be/JRLbr6THaTI'

Get only the id of the above URLs using regex.

答: This should be sufficient: [\w]+$

Body: This should be sufficient: [\w]+$


问:
How to calculate exact average using arrays in Java
Regardless of what I try, the program outputs the average as the integer "4" when the average should be "4.78". I have tried changing the integers to doubles, but to no avail.

The rest of the program works as intended, though. It is supposed to print how many times each value in the text files appears by putting an asterisk next to it and it is supposed to indicate when a number is larger than the average by having a ">" appear next to it in the output.

```<code>import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class Main {

    public static void main(String args[]) throws IOException {

        int i = 0, count = 0, sum = 0;

        Scanner file = new Scanner(new File("input3.txt"));

        int[] frequency = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

        int[] arr = new int[50];

        int current_num;

        while (file.hasNext()) {

            current_num = file.nextInt();

            sum += current_num;

            arr[i++] = current_num;

            count++;

            frequency[current_num]++;

        }

        int average = sum / count;

        for(i=0; i<arr.length; i++){
            if(arr[i] > average){
                System.out.print(arr[i] + " > " );
            }
            else{
                System.out.print(arr[i] + " ");
            }

            if(i%5==4){
                System.out.println();
                }
            }

        System.out.println("\n***** Frequency Graph *****\n");
        for(i=0; i<frequency.length; i++){
        System.out.print(i + " = ");
        for(int j=0; j<frequency[i]; j++){
        System.out.print("*");
        }
        System.out.println();
        }

        System.out.println("\nAverage of the numbers in the text file is : " + average);

        }

    }
</code>```

The numbers in the "input3.txt" file are:

```<code>5
8
8
1
5
0
6
6
5
3
4
0
6
8
5
4
9
5
8
0
4
7
4
2
0
9
8
3
5
5
5
7
5
7
1
4
4
0
7
4
8
4
2
4
9
8
8
2
3
4
</code>```

Any help would be appreciated!

答:
I think your problem is that your using integer division. In your code, sum and count are integers. By instead multiplying sum by 1.0, the sum will be converted to a double. And the result of the division will be a double also.</p>

```<code>double average = 1.0*sum/count;
</code>```

Body:
Regardless of what I try, the program outputs the average as the integer "4" when the average should be "4.78". I have tried changing the integers to doubles, but to no avail.

The rest of the program works as intended, though. It is supposed to print how many times each value in the text files appears by putting an asterisk next to it and it is supposed to indicate when a number is larger than the average by having a ">" appear next to it in the output.

import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class Main {

    public static void main(String args[]) throws IOException {

        int i = 0, count = 0, sum = 0;

        Scanner file = new Scanner(new File("input3.txt"));

        int[] frequency = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

        int[] arr = new int[50];

        int current_num;

        while (file.hasNext()) {

            current_num = file.nextInt();

            sum += current_num;

            arr[i++] = current_num;

            count++;

            frequency[current_num]++;

        }

        int average = sum / count;

        for(i=0; i<arr.length; i++){
            if(arr[i] > average){
                System.out.print(arr[i] + " > " );
            }
            else{
                System.out.print(arr[i] + " ");
            }

            if(i%5==4){
                System.out.println();
                }
            }

        System.out.println("\n***** Frequency Graph *****\n");
        for(i=0; i<frequency.length; i++){
        System.out.print(i + " = ");
        for(int j=0; j<frequency[i]; j++){
        System.out.print("*");
        }
        System.out.println();
        }

        System.out.println("\nAverage of the numbers in the text file is : " + average);

        }

    }

The numbers in the "input3.txt" file are:

5
8
8
1
5
0
6
6
5
3
4
0
6
8
5
4
9
5
8
0
4
7
4
2
0
9
8
3
5
5
5
7
5
7
1
4
4
0
7
4
8
4
2
4
9
8
8
2
3
4

Any help would be appreciated!

Body:
I think your problem is that your using integer division. In your code, sum and count are integers. By instead multiplying sum by 1.0, the sum will be converted to a double. And the result of the division will be a double also.

double average = 1.0*sum/count;


问:
postgis How do I find results within a given bounding box that are close to the center?
I'm learning postgis and saw that there is ST_MakeEnvelope to which I can pass my bounding box coordinates:

ST_MakeEnvelope(${params.swLng},${params.swLat},${params.neLng},${params.neLat}, 4326)

However, is there a way to get the results that are closest to the center of the bounding box?  Is it possible to combine the bounding box with a radius query?

答:
You can order by distance between your geometries and the centroid of the envelope

SELECT *
FROM myTable
WHERE st_intersects(geom, ST_makeEnvelope(...))
ORDER BY geom <-> st_centroid(ST_makeEnvelope(...))
```


问:
How to remove whitespace from a expression using a function with const char* pointer
I am working with a small piece of code and want to remove all the whitespaces from a simple expression. I am taking char array expression and passing it to an function with const char* pointer,but i am not able to remove the whitespace. here is what i tried, but didn't get desired output.

```<code>#include <iostream>

using namespace std;

void evaluate(const char *expression){

if (*expression == '\0') cout<<"Invalid"<<endl;

while(*expression){
    if(*expression == ' '){
        *expression++ ;
    }
    expression++;
 }

cout<<expression;

}

int main()
{
    char expr[] = "1 + 2 * 3";
    evaluate(expr);
    return 0;
}
</code>```

It will be great if someone can help me with this.
Thanks in advance.

答:
Use std::string and the erase-remove idiom

```<code>#include <iostream>
#include <string>

void evaluate(const char *expression){
    if (*expression == '\0') std::cout << "Invalid\n";

    std::cout << expression;
}

int main()
{
    char expr[] = "1 + 2 * 3";
    std::string exprString = expr;
    exprString.erase(
        std::remove(std::begin(exprString), std::end(exprString), ' '),
        std::end(exprString));
    evaluate(exprString.c_str());
    return 0;
}
</code>```

In this code I added string but I recommend to completely remove the C-strings in this code and replace them by std::string.

You can't change the C-string inside the function because it's const.

Body:
I am working with a small piece of code and want to remove all the whitespaces from a simple expression. I am taking char array expression and passing it to an function with const char* pointer,but i am not able to remove the whitespace. here is what i tried, but didn't get desired output.

#include <iostream>

using namespace std;

void evaluate(const char *expression){

if (*expression == '\0') cout<<"Invalid"<<endl;

while(*expression){
    if(*expression == ' '){
        *expression++ ;
    }
    expression++;
 }

cout<<expression;

}

int main()
{
    char expr[] = "1 + 2 * 3";
    evaluate(expr);
    return 0;
}

It will be great if someone can help me with this.
Thanks in advance.

Body:
Use std::string and the erase-remove idiom

#include <iostream>
#include <string>

void evaluate(const char *expression){
    if (*expression == '\0') std::cout << "Invalid\n";

    std::cout << expression;
}

int main()
{
    char expr[] = "1 + 2 * 3";
    std::string exprString = expr;
    exprString.erase(
        std::remove(std::begin(exprString), std::end(exprString), ' '),
        std::end(exprString));
    evaluate(exprString.c_str());
    return 0;
}

In this code I added string but I recommend to completely remove the C-strings in this code and replace them by std::string.

You can't change the C-string inside the function because it's const.


问:
Running python script on client side using Vue.js
Due to computation limitations, I have to run a python script on the client side.

Actually, my website is using Vue.js for frontend and Django for backend.

Would you know how I could run this specific task only on the client side (Python + Vue.js) without having to interact with the server ?

All the sites that found only talked about doing the computation on the server side by using Flask or Django.

Thank you for your advice.

Kind regards.

答:
There's some tools that let you do this... I've never used them and they're fairly uncommon. https://skulpt.org/ or https://pythontips.com/2019/05/22/running-python-in-the-browser/

In theory, you would need to port the Python code into JavaScript or WebAssembly (WebAssembly will likely be harder). But this will depend largely on the code you're trying to execute.

If I were in your shoes, depending on my experience, I would rethink the problem or reimplement the code in JavaScript.

The Vue part isn't really relevant, you'll have this issue with Vanilla JS or React.


问:
How do I update the PATH in bash_profile on OSX
I'm trying to install flutter on my Mac, in order to do so I need to add a path to the .bash_profile. But when I run the command vim .bash_profile in the terminal ,I'm met with the following message.

```<code># The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH

export M2_HOME=/Applications/apache-maven-3.6.3
export PATH=$PATH:$M2_HOME/bin# added by Anaconda3 2019.10 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/sofie-amaliepetersen/opt/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/Users/sofie-amaliepetersen/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/sofie-amaliepetersen/opt/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/Users/sofie-amaliepetersen/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<
</code>```

This is my first time adding a PATH, I've tried looking at setting path in terminal
But I'm not sure how it applies to my problem.

Any suggestions would be appreciated. Thanks

答:
Something important to note, is that if you're using Catalina (Or any of the newer forms os osx) your computer won't be using the bash shell by default (Although you'll still be able to update your bash_profile, it won't work, as the computer doesn't care).  You'll need to update your zshrc instead of the bash profile.  (just typing zsh in your terminal should be able to switch between them, showing you a % instead of a $)

The same process as with the bash profile can be used, and the same line too.  Also if you WANT the computer to use the bash profile instead you can force it, but there's no realistic functionality changes between the two in 99% of applications.

Body:
I'm trying to install flutter on my Mac, in order to do so I need to add a path to the .bash_profile. But when I run the command vim .bash_profile in the terminal ,I'm met with the following message.

# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH

export M2_HOME=/Applications/apache-maven-3.6.3
export PATH=$PATH:$M2_HOME/bin# added by Anaconda3 2019.10 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/sofie-amaliepetersen/opt/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/Users/sofie-amaliepetersen/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/sofie-amaliepetersen/opt/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/Users/sofie-amaliepetersen/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

This is my first time adding a PATH, I've tried looking at setting path in terminal
But I'm not sure how it applies to my problem.

Any suggestions would be appreciated. Thanks


问:
SQL insert choice of column name dependant on select value
Hope the title is a reasonable description.

I have 2 tables in a db (sqlite).

```<code>CREATE TABLE files (
  name TEXT,
  sha256 TEXT,
  fsno INT
);

CREATE TABLE sha256 (
  sha256 TEXT,
  fs1 INT,
  fs2 INT,
  fs3 INT,
  fs4 INT
);
</code>```

files.fsno ranges from 2 to 5.

I am doing:

```<code>INSERT OR IGNORE INTO sha256sums (sha256)  select sha256 from files;
</code>```

Then:

```<code>update sha256sums set fs2 = 1 where sha256 in (select sha256 from files where fsno = 2);
update sha256sums set fs3 = 1 where sha256 in (select sha256 from files where fsno = 3);
update sha256sums set fs4 = 1 where sha256 in (select sha256 from files where fsno = 4);
update sha256sums set fs5 = 1 where sha256 in (select sha256 from files where fsno = 5);
</code>```

Is there a way to replace these 4 updates with something in the INSERT OR IGNORE? Something like:

```<code>INSERT OR IGNORE INTO sha256sums (sha256, fs2, fs3, fs4, fs5)
select
sha256, fsno==2?1:0, fsno==3?1:0, fsno==4?1:0, fsno==5?1:0
from files;
</code>```

The DB is Sqlite.

TIA, Pete

答:
Include the fs? columns in the INSERT statement and set all their values to 1:

```<code>INSERT OR IGNORE INTO sha256sums(sha256, fs1, fs2, fs3, fs4)
SELECT sha256, fsno = 2, fsno = 3, fsno = 4, fsno = 5
FROM files;
</code>```

Body:
Hope the title is a reasonable description.

I have 2 tables in a db (sqlite).

CREATE TABLE files (
  name TEXT,
  sha256 TEXT,
  fsno INT
);

CREATE TABLE sha256 (
  sha256 TEXT,
  fs1 INT,
  fs2 INT,
  fs3 INT,
  fs4 INT
);

files.fsno ranges from 2 to 5.

I am doing:

INSERT OR IGNORE INTO sha256sums (sha256)  select sha256 from files;

Then:

update sha256sums set fs2 = 1 where sha256 in (select sha256 from files where fsno = 2);
update sha256sums set fs3 = 1 where sha256 in (select sha256 from files where fsno = 3);
update sha256sums set fs4 = 1 where sha256 in (select sha256 from files where fsno = 4);
update sha256sums set fs5 = 1 where sha256 in (select sha256 from files where fsno = 5);

Is there a way to replace these 4 updates with something in the INSERT OR IGNORE? Something like:

INSERT OR IGNORE INTO sha256sums (sha256, fs2, fs3, fs4, fs5)
select
sha256, fsno==2?1:0, fsno==3?1:0, fsno==4?1:0, fsno==5?1:0
from files;

The DB is Sqlite.

TIA, Pete

Body:
Include the fs? columns in the INSERT statement and set all their values to 1:

INSERT OR IGNORE INTO sha256sums(sha256, fs1, fs2, fs3, fs4)
SELECT sha256, fsno = 2, fsno = 3, fsno = 4, fsno = 5
FROM files;


问:
Android - Numeric (float) soft keyboard
I need to insert in an EditText some numeric data with decimal. I know that i could insert this:

```<code>android:inputType="numberDecimal"
</code>```

in my xml file. But I'd like a different keyboard with only numeric (and point) keys. Something like the "phone" keyboard (android:inputType="phone").

I know, this is a duplicated question (here the original) but i decided to open a new one because the first one doesn't look to have a good solution.

答:
It depends on keyboard app, which is installed on your device, which buttons are visible for different inputTypes. You can't simply override default keyboard due to security issues. But you can create your own implementation. But it needs to be registered by user in settings.

There is how to do it:

http://android-developers.blogspot.com/2009/04/creating-input-method.html

And sample keyboard:

http://developer.android.com/resources/samples/SoftKeyboard/index.html

ContentLicense: CC BY-SA 3.0

Title: Android - Numeric (float) soft keyboard

Body:
I need to insert in an EditText some numeric data with decimal. I know that i could insert this:

android:inputType="numberDecimal"

in my xml file. But I'd like a different keyboard with only numeric (and point) keys. Something like the "phone" keyboard (android:inputType="phone").

I know, this is a duplicated question (here the original) but i decided to open a new one because the first one doesn't look to have a good solution.


问:
Azure devops, how to deny access to all but one repo to a new team
we have permission groups such as reader and contributor.

We have two teams and about 20 repos.

The new team should only have access to one of the repos.

Because all the repos have full access to the contributors permission group, and because the new team also is a member of contributors, the new group can see all repos.

I can go into each repo one by one, and search for the team, then "deny" all the rights (except it doesn't let you change the last three: read, remove others locks and rename repositoryfor some reason), but this is would take a long time.

Is there another way?  I tried removing the new team from the contributors group, so that I could add the team to the repo directly, but this doesn't work - it wont let you assign any permissions to the one repo they need to the team unless they are all in the contributors group first which is not intuitive.

Any suggestions?

答:
You have your answer already. Create a new group for your new team Foo-Contributors and add that team to the specific repository only. Keep in mind that any users you leave as members of the Contributors group will continue to have access to all those other repos.

If you want to be extra pragmatic you could assign that group to the Git repositories node (aka all) and assign Not set to all the permissions.

it wont let you assign any permissions to the one repo they need to the team unless they are all in the contributors group first which is not intuitive.

I'm not sure what about your setup is giving you this impression, but it should not be true.

This new group

Should be just as assignable to a repository as any other, and the group permissions for that repository should also be assignable.

Perhaps the comment on this answer will give you insight into why you see the group being "removed". Originally my comment was:

if the user being added is already a part of the groups that are added to the repo, and the permissions for the user aren't different than that of the group, then the user is removed because their "explicit" permissions are no different than their inherited permissions

In actuality I think it has more to do with the initial settings of a group added.

When a group or user is initially added to the repo, all permissions are Not set (at least in this case, b/c this group is not inheriting any permissions from any other nodes), which is effectively identical to not having that group in the permission graph for that object at all.

The linked post was mentioning that the save button needed clicking, now permission changes are auto saved line by line, so if you add the group, and then close the filter before changing the permissions, the group will be removed from the permission graph.

"add" the group but don't change permissions before X-ing the search filter

causes the group to be removed from the object's (repo) permission graph


问:
String ArrayList being ignored when saving/loading with SharedPreferences?
I've been trying several things in order to save and load an ArrayList, and the most I can get saved/loaded is the final string within the arrayList. I've run out of ideas on what else to try:

```<code>    public void SaveData() {
    SharedPreferences sharedPreferences = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    saveGameList = new ArrayList<String>(gameList);

    for (int i = 0; i < gameList.size(); i++) {

        editor.putString(saveGameList.get(i), gameList.get(i));// THIS DOESN'T GET SAVED
        editor.putString(TEXT, saveGameList.get(i)); //THIS SAVES THE LAST THING IN THE ARRAYLIST
    }
    editor.apply();
}

public void LoadData() {
    SharedPreferences sharedPreferences = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
    Toast.makeText(this, "Trying to load data from " + saveGameList.size() + " or from " + gameList.size(), Toast.LENGTH_SHORT).show();

    loadText = sharedPreferences.getString(TEXT, null);

    for (int i = 0; i < saveGameList.size(); i++) {
        Toast.makeText(this, "am i called?", Toast.LENGTH_SHORT).show(); // THE ANSWER IS NO
        //loadText = sharedPreferences.getString(TEXT, null); // NOT NEEDED. WAS FOR A TEST
        gameList.add(sharedPreferences.getString(saveGameList.get(i), null));
    }

    Toast.makeText(this, "Done loading data?", Toast.LENGTH_SHORT).show();

    gamesListTextView.setText(loadText);
    gameList.add(loadText);
}
</code>```

So, within the SaveData method I have a for loop which goes through every element within the gameList ArrayList, and the putString that is using the saveGameList ArrayList is trying to pass everything from the gameList over to saveGameList, both being String ArrayLists, which works. The second putString is passing the final element of the gameList into a TEXT variable. The TEXT variable is being saved, but not the saveGameList. So, when I load up the program, TEXT is being loaded, but saveGameList loads empty.

Then, within the LoadData method, the for loop is never called, because saveGameList always loads as empty, rather than with the strings I tried adding within the SaveData method. I feel like I'm very close to getting this to work, but there is something I'm missing in getting the elements within saveGameList saved. What I was thinking was that if putString requires a variable to store whatever I'm passing, i figured I can use each element within the ArrayList as those variables. This works when I use a Toast message to check each element, but not when saving. Anyone have anything that can guide me in the right direction?

答:
SharedPreferences accept Sets. You could convert your List into a HashSet or something similar and store it like that. When your read it back, convert it into an ArrayList

```<code>//Retrieve the values
Set<String> set = sharedPreferences.getStringSet("key", null);

//Set the values
Set<String> set = new HashSet<String>();
set.addAll(saveGameList);
editor.putStringSet("key", set);
editor.commit();
</code>```

Body:
I've been trying several things in order to save and load an ArrayList, and the most I can get saved/loaded is the final string within the arrayList. I've run out of ideas on what else to try:

    public void SaveData() {
    SharedPreferences sharedPreferences = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    saveGameList = new ArrayList<String>(gameList);

    for (int i = 0; i < gameList.size(); i++) {

        editor.putString(saveGameList.get(i), gameList.get(i));// THIS DOESN'T GET SAVED
        editor.putString(TEXT, saveGameList.get(i)); //THIS SAVES THE LAST THING IN THE ARRAYLIST
    }
    editor.apply();
}

public void LoadData() {
    SharedPreferences sharedPreferences = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
    Toast.makeText(this, "Trying to load data from " + saveGameList.size() + " or from " + gameList.size(), Toast.LENGTH_SHORT).show();

    loadText = sharedPreferences.getString(TEXT, null);

    for (int i = 0; i < saveGameList.size(); i++) {
        Toast.makeText(this, "am i called?", Toast.LENGTH_SHORT).show(); // THE ANSWER IS NO
        //loadText = sharedPreferences.getString(TEXT, null); // NOT NEEDED. WAS FOR A TEST
        gameList.add(sharedPreferences.getString(saveGameList.get(i), null));
    }

    Toast.makeText(this, "Done loading data?", Toast.LENGTH_SHORT).show();

    gamesListTextView.setText(loadText);
    gameList.add(loadText);
}

So, within the SaveData method I have a for loop which goes through every element within the gameList ArrayList, and the putString that is using the saveGameList ArrayList is trying to pass everything from the gameList over to saveGameList, both being String ArrayLists, which works. The second putString is passing the final element of the gameList into a TEXT variable. The TEXT variable is being saved, but not the saveGameList. So, when I load up the program, TEXT is being loaded, but saveGameList loads empty.

Then, within the LoadData method, the for loop is never called, because saveGameList always loads as empty, rather than with the strings I tried adding within the SaveData method. I feel like I'm very close to getting this to work, but there is something I'm missing in getting the elements within saveGameList saved. What I was thinking was that if putString requires a variable to store whatever I'm passing, i figured I can use each element within the ArrayList as those variables. This works when I use a Toast message to check each element, but not when saving. Anyone have anything that can guide me in the right direction?

Body:
SharedPreferences accept Sets. You could convert your List into a HashSet or something similar and store it like that. When your read it back, convert it into an ArrayList

//Retrieve the values
Set<String> set = sharedPreferences.getStringSet("key", null);

//Set the values
Set<String> set = new HashSet<String>();
set.addAll(saveGameList);
editor.putStringSet("key", set);
editor.commit();


问:
How to combine css with selectors
I need to clean up my CSS file and remove some bloat.  I know it's possible to combine classes and ids by separating them with commas.  However, I'm not sure how to go about combining them when they have more complex selectors like the ones below.

Any help would be appreciated.  Thank you.

```<code>body #gform_wrapper_14 .gform_footer input[type=submit] {
    border-radius:0px;
    background:#e89d53;
}
body #gform_wrapper_15 .gform_footer input[type=submit] {
    border-radius:0px;
    background:#e89d53;
}
body #gform_wrapper_17 .gform_footer input[type=submit] {
    border-radius:0px;
    background:#e89d53;
}
</code>```

or

```<code>@media only screen and (min-width: 641px) {
    body #gform_wrapper_14 {
      max-width: 80%;
      margin: 0 auto;
     }
    body #gform_wrapper_15 {
      max-width: 80%;
      margin: 0 auto;
     }
    body #gform_wrapper_17 {
      max-width: 80%;
      margin: 0 auto;
     }
    .hor-address {
        width:500px;
    }
}
</code>```

Clarification:  I have multiple #gform_wrapper_xx objects (generated by 3rd party Wordpress plugin) and but I don't want to change all of them.  I just want to change these 3.

答:
Since all of your target elements are prefixed. You can use an attribute selector to cut down on redundancy. By using something like this [id^="gform_wrapper_"] you essentially target all of the elements with an id that starts with gform_wrapper_

You can read more about attribute selectors here

[id^="gform_wrapper_"] input[type=submit] {
  border-radius: 0px;
  background: #e89d53;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="gform_wrapper_14">
  <div class=".gform_footer">
    <input type="submit">
  </div>
</div>
<div id="gform_wrapper_15">
  <div class=".gform_footer">
    <input type="submit">
  </div>
</div>
<div id="gform_wrapper_16">
  <div class=".gform_footer">
    <input type="submit">
  </div>
</div></code>```

Title: How to combine css with selectors

Body:
I need to clean up my CSS file and remove some bloat.  I know it's possible to combine classes and ids by separating them with commas.  However, I'm not sure how to go about combining them when they have more complex selectors like the ones below.

Any help would be appreciated.  Thank you.

body #gform_wrapper_14 .gform_footer input[type=submit] {
    border-radius:0px;
    background:#e89d53;
}
body #gform_wrapper_15 .gform_footer input[type=submit] {
    border-radius:0px;
    background:#e89d53;
}
body #gform_wrapper_17 .gform_footer input[type=submit] {
    border-radius:0px;
    background:#e89d53;
}

or

@media only screen and (min-width: 641px) {
    body #gform_wrapper_14 {
      max-width: 80%;
      margin: 0 auto;
     }
    body #gform_wrapper_15 {
      max-width: 80%;
      margin: 0 auto;
     }
    body #gform_wrapper_17 {
      max-width: 80%;
      margin: 0 auto;
     }
    .hor-address {
        width:500px;
    }
}

Clarification:  I have multiple #gform_wrapper_xx objects (generated by 3rd party Wordpress plugin) and but I don't want to change all of them.  I just want to change these 3.

Body:
Since all of your target elements are prefixed. You can use an attribute selector to cut down on redundancy. By using something like this [id^="gform_wrapper_"] you essentially target all of the elements with an id that starts with gform_wrapper_

You can read more about attribute selectors here

[id^="gform_wrapper_"] input[type=submit] {
  border-radius: 0px;
  background: #e89d53;
}

<div id="gform_wrapper_14">
  <div class=".gform_footer">
    <input type="submit">
  </div>
</div>
<div id="gform_wrapper_15">
  <div class=".gform_footer">
    <input type="submit">
  </div>
</div>
<div id="gform_wrapper_16">
  <div class=".gform_footer">
    <input type="submit">
  </div>
</div>


问:
MongoDB - How to Update/push the objects in an array which is contained by another object which in turn is contained by another array
Here is a code snippet,

```<code>{
    "summary":[
        {
            "chem_id":"5e18c858c88e1e2328771593",
            "chem_sale": [
                {
                    "product_id": "5e3c5042ac7e0d67c3b5ae6f",
                    "product_sale": 8900
                },
                {
                    "product_id": "5e3c5029ac7e0d67c3b5ae6e",
                    "product_sale": 6500
                }
            ]
        },
        {
            "chem_id":"5e1b1cb5f3123a3a74f014f5",
            "chem_sale": [
                {
                    "product_id": "5e3c5042ac7e0d67c3b5ae6f",
                    "product_sale": 2900
                },
                {
                    "product_id": "5e3c5029ac7e0d67c3b5ae6e",
                    "product_sale": 3500
                }
            ]
        }
    ]
}
</code>```

how to add new product object to chem_sale array if its id is unique and
how to update the product_sale ?

I have tried this to add new product object to summary array

```<code> let saleRecord = await saleRecordModel.findOneAndUpdate(
      { emp_id: req.params.id },
      { $addToSet: { summary: req.body.summary } },
      { new: true, upsert: false }
    );
</code>```

I'm using mongoose version 5.9.0
But I'm getting duplicated results. Please help me.

答:
What you need here is the arrayFilters option. https://docs.mongodb.com/manual/reference/method/db.collection.update/index.html#update-array-filters

see more example for the identifier $[<identifier>]
https://docs.mongodb.com/manual/reference/operator/update/positional-filtered/#up.S[%3Cidentifier%3E]

```<code>db.saleRecord.update(
    { emp_id: '<EMP_ID>' },
    { $set: {'summary.$[].chem_sale.$[chemSaleElement].product_sale': 1000 }},
    { arrayFilters: [{ 'chemSaleElement.product_id': '5e3c5029ac7e0d67c3b5ae6e' }] }
)
</code>```

Body:
Here is a code snippet,

{
    "summary":[
        {
            "chem_id":"5e18c858c88e1e2328771593",
            "chem_sale": [
                {
                    "product_id": "5e3c5042ac7e0d67c3b5ae6f",
                    "product_sale": 8900
                },
                {
                    "product_id": "5e3c5029ac7e0d67c3b5ae6e",
                    "product_sale": 6500
                }
            ]
        },
        {
            "chem_id":"5e1b1cb5f3123a3a74f014f5",
            "chem_sale": [
                {
                    "product_id": "5e3c5042ac7e0d67c3b5ae6f",
                    "product_sale": 2900
                },
                {
                    "product_id": "5e3c5029ac7e0d67c3b5ae6e",
                    "product_sale": 3500
                }
            ]
        }
    ]
}

how to add new product object to chem_sale array if its id is unique and
how to update the product_sale ?

I have tried this to add new product object to summary array

 let saleRecord = await saleRecordModel.findOneAndUpdate(
      { emp_id: req.params.id },
      { $addToSet: { summary: req.body.summary } },
      { new: true, upsert: false }
    );

I'm using mongoose version 5.9.0
But I'm getting duplicated results. Please help me.

Body:
What you need here is the arrayFilters option. https://docs.mongodb.com/manual/reference/method/db.collection.update/index.html#update-array-filters

see more example for the identifier $[<identifier>]
https://docs.mongodb.com/manual/reference/operator/update/positional-filtered/#up.S[%3Cidentifier%3E]

db.saleRecord.update(
    { emp_id: '<EMP_ID>' },
    { $set: {'summary.$[].chem_sale.$[chemSaleElement].product_sale': 1000 }},
    { arrayFilters: [{ 'chemSaleElement.product_id': '5e3c5029ac7e0d67c3b5ae6e' }] }
)


问:
Please help with adding sound to my website- on mouse-click
I am trying to add sound to my web-site, when a link is clicked.
I added this javascript into the head of my doc:

```<code><script language="javascript" type="text/javascript">
 function playSound('Swoosh 3-SoundBible.com-1573211927.wav') {
 document.getElementById("dummy").innerHTML=
 "embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
 }
</script>
</code>```

And I added this code into the body:
span id="dummy">

And this is what I added by the li that I want the sound to be heard on:
 onclick="playSound('Swoosh 3-SoundBible.com-1573211927.wav');

I got this from http://webdesign.about.com/od/sound/a/play_sound_oncl.htm. But this does NOT work when I tested it my browser. NO sound is heard on the mouse-click.
Can anyone help please?
Thank you!

答: It doesn't appear that the function knows what to make of "soundfile" because instead of naming the variable in your function header, you've replaced it with an explicit filename.  Try rewriting the function name as function playSound(soundfile){}.

Body:
I am trying to add sound to my web-site, when a link is clicked.
I added this javascript into the head of my doc:

And I added this code into the body:
span id="dummy">

And this is what I added by the li that I want the sound to be heard on:
 onclick="playSound('Swoosh 3-SoundBible.com-1573211927.wav');

I got this from http://webdesign.about.com/od/sound/a/play_sound_oncl.htm. But this does NOT work when I tested it my browser. NO sound is heard on the mouse-click.
Can anyone help please?
Thank you!


问:
Truncation of deferred-length string when passing as optional
I am passing optional deferred-length strings (character(len=:), allocatable, optional) between subroutines and getting unexpected behavior in GCC.

Here is my minimal example, where I pass an optional string through an interface routine to a routine that sets it:

```<code>$ cat main.f90
module deepest_call_m
   implicit none
contains
subroutine deepest_call(str)
   character(len=:), allocatable, intent(OUT), optional :: str

   if (present(str)) str = '12345'
   write(*,*) 'at bot of deepest_call, str is "'//trim(str)//'"'
end subroutine deepest_call
end module deepest_call_m

module interface_call_m
   implicit none
contains
subroutine interface_call(str)
   use deepest_call_m, only : deepest_call
   character(len=:), allocatable, intent(OUT), optional :: str

   call deepest_call(str=str)
   write(*,*) 'at bot of interface_call, str is "'//trim(str)//'"'
end subroutine interface_call
end module interface_call_m

program main
   use interface_call_m, only : interface_call
   implicit none

   character(len=:), allocatable :: str

   call interface_call(str=str)
   write(*,*) 'at bot of main, str is "'//trim(str)//'"'
end program main
</code>```

(Note that, for simplicity, I'm not wrapping the write statements in if(present) and if(allocated), although that would be necessary for a real implementation.)

In Intel 16.0 and 2019_U4, and PGI 15.10, this routine gives the expected result: str is set in deepest_call and remains the same through interface_call and in main:

```<code>$ ifort --version
ifort (IFORT) 16.0.0 20150815
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

$ ifort main.f90 && ./a.out
 at bot of deepest_call, str is "12345"
 at bot of interface_call, str is "12345"
 at bot of main, str is "12345"
</code>```

However, with gfortran 4.8.5:

```<code>$ gfortran --version
GNU Fortran (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright (C) 2015 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING

$ gfortran main.f90 && ./a.out
 at bot of deepest_call, str is "12345"
 at bot of interface_call, str is ""
 at bot of main, str is ""
</code>```

The string has been truncated when returning from the deepest_call in interface_call. With gfortran 7.3.0 and 8.2.0, the code crashes at runtime when no compile-time options are provided:

```<code>[chaud106@epyc-login-1-0 Testing]$ gfortran --version && gfortran main.f90 && ./a.out
GNU Fortran (GCC) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 at bot of deepest_call, str is "12345"

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x2af39a82733f in ???
#1  0x400c68 in ???
#2  0x400d9c in ???
#3  0x400f0e in ???
#4  0x2af39a813494 in ???
#5  0x400878 in ???
#6  0xffffffffffffffff in ???
Segmentation fault
</code>```

However, adding compile-time checking recovers the previous truncation behavior:

```<code>$ gfortran --version
GNU Fortran (GCC) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gfortran -g -fbacktrace -Wall -Wextra -std=f2008 -fcheck=all -Og main.f90 && ./a.out
 at bot of deepest_call, str is "12345"
 at bot of interface_call, str is ""
 at bot of main, str is ""
</code>```

This looks a lot like a compiler bug to me, so perhaps I just need to post on the bugzilla. But I would like some feedback here first, specifically:

Is my test case standard-conforming? I'm specifically curious about the str=str argument to deepest_call. I use this structure often to pass an argument as optional if and only if it's optional in the present scope, but I couldn't easily find this in the standard and I'm not sure if it's really valid. Passing just str seemed to give the same behavior, though.

Are there any simple workarounds? Given that this issue affects a wide range of versions (4.8.5 to 8.2.0) simply avoiding them is not feasible.

Is anybody aware of this behavior for other versions of gfortran, or other compilers? I only have easy access to GCC, Intel, and PGI.

答:
Your code is standard compliant.

An optional dummy argument may be an actual dummy argument in a subsequent call without the keyword, and whether or not it is present. (Of course, it may only be not present in the case that the following dummy argument is optional.)  That is:

```<code>call  interface_call(str)
</code>```

is just as correct as

```<code>call  interface_call(str=str)
</code>```

As to (suboptimal) workarounds (I see this fail with gfortran 9.1.0, but working with gfortran 10.0.0 20190625), you could consider having the arguments as not deferred-length.  After all, you're using trim everywhere, so trailing whitespace would be chomped.

Your code is just one small change away from not being compliant: the write statements aren't protected by a presence check for the optional dummy.  If the optional dummy is not present in the call chain then the program would be invalid.

Body:
I am passing optional deferred-length strings (character(len=:), allocatable, optional) between subroutines and getting unexpected behavior in GCC.

Here is my minimal example, where I pass an optional string through an interface routine to a routine that sets it:

$ cat main.f90
module deepest_call_m
   implicit none
contains
subroutine deepest_call(str)
   character(len=:), allocatable, intent(OUT), optional :: str

   if (present(str)) str = '12345'
   write(*,*) 'at bot of deepest_call, str is "'//trim(str)//'"'
end subroutine deepest_call
end module deepest_call_m

module interface_call_m
   implicit none
contains
subroutine interface_call(str)
   use deepest_call_m, only : deepest_call
   character(len=:), allocatable, intent(OUT), optional :: str

   call deepest_call(str=str)
   write(*,*) 'at bot of interface_call, str is "'//trim(str)//'"'
end subroutine interface_call
end module interface_call_m

program main
   use interface_call_m, only : interface_call
   implicit none

   character(len=:), allocatable :: str

   call interface_call(str=str)
   write(*,*) 'at bot of main, str is "'//trim(str)//'"'
end program main

(Note that, for simplicity, I'm not wrapping the write statements in if(present) and if(allocated), although that would be necessary for a real implementation.)

In Intel 16.0 and 2019_U4, and PGI 15.10, this routine gives the expected result: str is set in deepest_call and remains the same through interface_call and in main:

$ ifort --version
ifort (IFORT) 16.0.0 20150815
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

$ ifort main.f90 && ./a.out
 at bot of deepest_call, str is "12345"
 at bot of interface_call, str is "12345"
 at bot of main, str is "12345"

However, with gfortran 4.8.5:

$ gfortran --version
GNU Fortran (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright (C) 2015 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING

$ gfortran main.f90 && ./a.out
 at bot of deepest_call, str is "12345"
 at bot of interface_call, str is ""
 at bot of main, str is ""

The string has been truncated when returning from the deepest_call in interface_call. With gfortran 7.3.0 and 8.2.0, the code crashes at runtime when no compile-time options are provided:

[chaud106@epyc-login-1-0 Testing]$ gfortran --version && gfortran main.f90 && ./a.out
GNU Fortran (GCC) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 at bot of deepest_call, str is "12345"

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x2af39a82733f in ???
#1  0x400c68 in ???
#2  0x400d9c in ???
#3  0x400f0e in ???
#4  0x2af39a813494 in ???
#5  0x400878 in ???
#6  0xffffffffffffffff in ???
Segmentation fault

However, adding compile-time checking recovers the previous truncation behavior:

$ gfortran --version
GNU Fortran (GCC) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gfortran -g -fbacktrace -Wall -Wextra -std=f2008 -fcheck=all -Og main.f90 && ./a.out
 at bot of deepest_call, str is "12345"
 at bot of interface_call, str is ""
 at bot of main, str is ""

This looks a lot like a compiler bug to me, so perhaps I just need to post on the bugzilla. But I would like some feedback here first, specifically:

Is my test case standard-conforming? I'm specifically curious about the str=str argument to deepest_call. I use this structure often to pass an argument as optional if and only if it's optional in the present scope, but I couldn't easily find this in the standard and I'm not sure if it's really valid. Passing just str seemed to give the same behavior, though.

Are there any simple workarounds? Given that this issue affects a wide range of versions (4.8.5 to 8.2.0) simply avoiding them is not feasible.

Is anybody aware of this behavior for other versions of gfortran, or other compilers? I only have easy access to GCC, Intel, and PGI.

Body:
Your code is standard compliant.

An optional dummy argument may be an actual dummy argument in a subsequent call without the keyword, and whether or not it is present. (Of course, it may only be not present in the case that the following dummy argument is optional.)  That is:

call  interface_call(str)

is just as correct as

call  interface_call(str=str)

As to (suboptimal) workarounds (I see this fail with gfortran 9.1.0, but working with gfortran 10.0.0 20190625), you could consider having the arguments as not deferred-length.  After all, you're using trim everywhere, so trailing whitespace would be chomped.

Your code is just one small change away from not being compliant: the write statements aren't protected by a presence check for the optional dummy.  If the optional dummy is not present in the call chain then the program would be invalid.


问:
Flux. Is there a way to retry on the last element?
Does Flux allow to retry an operation on an occurred exception without taking the pointer to the initial position? I mean from the "problematic" element.

For example:

```<code>Flux.fromArray(new Integer[]{1, 2, 3})
        .delayElements(Duration.ofSeconds(1))
        .doOnNext(i -> {
            System.out.println("i: " + i);
            if (i == 2) {
                System.out.println("2 found");
                throw new RuntimeException("2!!!!!!!1");
            }
        })
        .retry(2)
        .subscribe();
</code>```

will have the following output:

```<code>i: 1
i: 2
2 found
i: 1
i: 2
2 found
i: 1
i: 2
2 found
</code>```

when I would wish to see such an output:

```<code>i: 1
i: 2
2 found
i: 2
2 found
i: 2
2 found
</code>```

P.S. skipUntil is not what I am looking for

答:
Not that I know of, but I could be wrong.

However, you could provide that logic yourself for that particular step. For instance, but creating your own Consumer and wrapping the retry logic in it

```<code>public class RetryConsumer<T> implements Consumer<T> {

    private int                 retryCount;
    private Consumer<? super T> delegate;

    public RetryConsumer(int retryCount, Consumer<? super T> delegate) {
        this.retryCount = retryCount;
        this.delegate = delegate;
    }

    @Override
    public void accept(T value) {

        int currentAttempts = 0;
        while (currentAttempts < retryCount) {
            try {
                delegate.accept(value);
                break;
            } catch (Throwable e) {
                currentAttempts++;
                if (currentAttempts == retryCount) {
                    throw e;
                }
                //Still have some attempts left
            }
        }

    }
}
</code>```

You could then reuse this in your Flux steps, i.e.

```<code>Flux.fromArray(new Integer[]{1, 2, 3})
    .doOnNext(new RetryConsumer<>(2 , i -> {
        System.out.println("i: " + i);
        if (i == 2) {
            System.out.println("2 found");
            throw new RuntimeException("Error");
        }
     }))
     .subscribe();
</code>```

Body:
Does Flux allow to retry an operation on an occurred exception without taking the pointer to the initial position? I mean from the "problematic" element.

For example:

Flux.fromArray(new Integer[]{1, 2, 3})
        .delayElements(Duration.ofSeconds(1))
        .doOnNext(i -> {
            System.out.println("i: " + i);
            if (i == 2) {
                System.out.println("2 found");
                throw new RuntimeException("2!!!!!!!1");
            }
        })
        .retry(2)
        .subscribe();

will have the following output:

i: 1
i: 2
2 found
i: 1
i: 2
2 found
i: 1
i: 2
2 found

when I would wish to see such an output:

i: 1
i: 2
2 found
i: 2
2 found
i: 2
2 found

P.S. skipUntil is not what I am looking for

Body:
Not that I know of, but I could be wrong.

However, you could provide that logic yourself for that particular step. For instance, but creating your own Consumer and wrapping the retry logic in it

public class RetryConsumer<T> implements Consumer<T> {

    private int                 retryCount;
    private Consumer<? super T> delegate;

    public RetryConsumer(int retryCount, Consumer<? super T> delegate) {
        this.retryCount = retryCount;
        this.delegate = delegate;
    }

    @Override
    public void accept(T value) {

        int currentAttempts = 0;
        while (currentAttempts < retryCount) {
            try {
                delegate.accept(value);
                break;
            } catch (Throwable e) {
                currentAttempts++;
                if (currentAttempts == retryCount) {
                    throw e;
                }
                //Still have some attempts left
            }
        }

    }
}

You could then reuse this in your Flux steps, i.e.

Flux.fromArray(new Integer[]{1, 2, 3})
    .doOnNext(new RetryConsumer<>(2 , i -> {
        System.out.println("i: " + i);
        if (i == 2) {
            System.out.println("2 found");
            throw new RuntimeException("Error");
        }
     }))
     .subscribe();


问:
Error pasting data from other workbook|worksheet VBA
I have an error when pasting the data into the new workbook, the workbook where i'm pasting the data has a header and it's pasting it from there.
The first edit didn't have the wbCopyFrom, wsCopyFrom, wbCopyTo, wsCopyTo set because when i first tried the macro it didn't take it in consideration and just pasted the data to the workbook i'm refering to

```<code>Sub RechazosOnline()
Dim rsh As Worksheet, wb As Workbook
Dim wbCopyFrom As Workbook, wsCopyFrom As Worksheet

Set wb = Workbooks("2. Detalle_Transacciones_pendientes_rechazadas_MDM_27Ene20.xlsx")
Set wbCopyFrom = Workbooks("1. ReporteGeneral_TransaccionesDiariasMDM_20200115")
Set wsCopyFrom = wbCopyFrom.Worksheets("Detalle")
wsCopyFrom.Range("A2:I" & wsCopyFrom.Range("A" & Rows.Count).End(xlUp).row).Copy

For Each rsh In wb.Sheets
         rsh.Range("A2:I" & rsh.Range("A" & rsh.Cells.Rows.Count).End(xlUp).row).PasteSpecial xlPasteValues
     Next
End Sub
</code>```

In the second edit i setted wbCopyFrom, wsCopyFrom, wbCopyTo, wsCopyTo but had the same result

```<code>Sub RechazosOnline()
    * Im pasting the same data into the two sheets of the workbook, so rsh is generic
    Dim rsh As Worksheet
    Dim wbCopyFrom As Workbook, wsCopyFrom As Worksheet, wbCopyTo As Workbook

    Set wbCopyTo = Workbooks("2. Detalle_Transacciones_pendientes_rechazadas_MDM_27Ene20.xlsx")
    Set wbCopyFrom = Workbooks("1. ReporteGeneral_TransaccionesDiariasMDM_20200115")
    Set wsCopyFrom = wbCopyFrom.Worksheets("Detalle")
    wsCopyFrom.Range("A2:I" & wsCopyFrom.Range("A" & Rows.Count).End(xlUp).row).Copy

    For Each rsh In wbCopyTo.Sheets
             rsh.Range("A2:I" & rsh.Range("A" & rsh.Cells.Rows.Count).End(xlUp).row).PasteSpecial xlPasteValues
         Next
    End Sub
</code>```

答:
Is the issue just that the data is being pasted over the header? If so, just Offset the paste row by one.

```<code>rsh.Range("A2:I" & rsh.Range("A" & rsh.Cells.Rows.Count).End(xlUp).Offset(1).Row).PasteSpecial xlPasteValues
</code>```

I believe this is a little cleaner

```<code>Dim LR as Long

For Each rsh In wbCopyTo.Sheets
    LR = rsh.Range("A" & rsh.Rows.Count).End(xlUp).Offset(1).Row
    rsh.Range("A" & LR).PasteSpecial xlPasteValues
Next rsh
</code>```

Body:
I have an error when pasting the data into the new workbook, the workbook where i'm pasting the data has a header and it's pasting it from there.
The first edit didn't have the wbCopyFrom, wsCopyFrom, wbCopyTo, wsCopyTo set because when i first tried the macro it didn't take it in consideration and just pasted the data to the workbook i'm refering to

Sub RechazosOnline()
Dim rsh As Worksheet, wb As Workbook
Dim wbCopyFrom As Workbook, wsCopyFrom As Worksheet

Set wb = Workbooks("2. Detalle_Transacciones_pendientes_rechazadas_MDM_27Ene20.xlsx")
Set wbCopyFrom = Workbooks("1. ReporteGeneral_TransaccionesDiariasMDM_20200115")
Set wsCopyFrom = wbCopyFrom.Worksheets("Detalle")
wsCopyFrom.Range("A2:I" & wsCopyFrom.Range("A" & Rows.Count).End(xlUp).row).Copy

For Each rsh In wb.Sheets
         rsh.Range("A2:I" & rsh.Range("A" & rsh.Cells.Rows.Count).End(xlUp).row).PasteSpecial xlPasteValues
     Next
End Sub

In the second edit i setted wbCopyFrom, wsCopyFrom, wbCopyTo, wsCopyTo but had the same result

Sub RechazosOnline()
    * Im pasting the same data into the two sheets of the workbook, so rsh is generic
    Dim rsh As Worksheet
    Dim wbCopyFrom As Workbook, wsCopyFrom As Worksheet, wbCopyTo As Workbook

    Set wbCopyTo = Workbooks("2. Detalle_Transacciones_pendientes_rechazadas_MDM_27Ene20.xlsx")
    Set wbCopyFrom = Workbooks("1. ReporteGeneral_TransaccionesDiariasMDM_20200115")
    Set wsCopyFrom = wbCopyFrom.Worksheets("Detalle")
    wsCopyFrom.Range("A2:I" & wsCopyFrom.Range("A" & Rows.Count).End(xlUp).row).Copy

    For Each rsh In wbCopyTo.Sheets
             rsh.Range("A2:I" & rsh.Range("A" & rsh.Cells.Rows.Count).End(xlUp).row).PasteSpecial xlPasteValues
         Next
    End Sub

Body:
Is the issue just that the data is being pasted over the header? If so, just Offset the paste row by one.

rsh.Range("A2:I" & rsh.Range("A" & rsh.Cells.Rows.Count).End(xlUp).Offset(1).Row).PasteSpecial xlPasteValues

I believe this is a little cleaner

Dim LR as Long

For Each rsh In wbCopyTo.Sheets
    LR = rsh.Range("A" & rsh.Rows.Count).End(xlUp).Offset(1).Row
    rsh.Range("A" & LR).PasteSpecial xlPasteValues
Next rsh


问:
Typescript: what is the best way to copy *some* (not all) properties from one class instance to another object?
Suppose I have a Typescript class like the following:

```<code>class MyClass {
  constructor(public x: boolean, public y: string, public z: number) {}
}
</code>```

I create an instance of the class:

```<code>const myInstance = new MyClass(true, 'hi', 45);
</code>```

If I want to copy the values of only the properties x and z to another object, I could do the following:

```<code>const myInstance = new MyClass(true, 'hi', 45);
const { x, z } = myInstance;
const myObject = { x, z };
</code>```

Is there any better (and simple) way of achieving this?

Or is this the simplest way?

Note, the above example class is small. Imagine if the class has, say, 20 properties, and I want to get only 5 of them.

It would be good to see a generic solution to the problem.

答:
If this is a one-off copy, then I suggest just doing what Fernando Bravo Diaz suggests. If this is something you need to do often, then you want to employ an adapter:</p>

```<code>function someAdapter(someObj: MyClass): NewObj {
    return {
        x: someObj.x,
        z: someObj.z
    }
}
</code>```

Body:
Suppose I have a Typescript class like the following:

class MyClass {
  constructor(public x: boolean, public y: string, public z: number) {}
}

I create an instance of the class:

const myInstance = new MyClass(true, 'hi', 45);

If I want to copy the values of only the properties x and z to another object, I could do the following:

const myInstance = new MyClass(true, 'hi', 45);
const { x, z } = myInstance;
const myObject = { x, z };

Is there any better (and simple) way of achieving this?

Or is this the simplest way?

Note, the above example class is small. Imagine if the class has, say, 20 properties, and I want to get only 5 of them.

It would be good to see a generic solution to the problem.

Body:
If this is a one-off copy, then I suggest just doing what Fernando Bravo Diaz suggests. If this is something you need to do often, then you want to employ an adapter:

function someAdapter(someObj: MyClass): NewObj {
    return {
        x: someObj.x,
        z: someObj.z
    }
}


问:
TF2 padded_batch on supervised dataset

Problem setting

I am following this tutorial. The tutorial first loads a supervised dataset (using tfds.load with as_supervised=True):

(train_data, test_data), info = tfds.load(
    'imdb_reviews/subwords8k',
    split = (tfds.Split.TRAIN, tfds.Split.TEST),
    with_info=True, as_supervised=True)
```

<p>Then the tutorial suggests to shuffle and pad the dataset like this:</p>

<blockquote>
  <p>Movie reviews can be different lengths. We will use the <code>padded_batch</code> method to standardize the lengths of the reviews.</p>
</blockquote>

<pre class="lang-py prettyprint-override"><code>train_batches = train_data.shuffle(1000).padded_batch(10)
test_batches = test_data.shuffle(1000).padded_batch(10)
</code>```

... but unfortunately the padded_batch method needs an extra argument that the tutorial seems to have forgotten:

```<code>Traceback (most recent call last):
  File "imdb_reviews.py", line 14, in <module>
    train_batches = train_data.shuffle(1000).padded_batch(10)
TypeError: padded_batch() missing 1 required positional argument: 'padded_shapes'
</code>```

Important assumption

Although the errors stack says that padded_shapes is the missing argument, from the tutorial I think it's fair to deduce that the missing argument is in fact batch_size (that should precede padded_shapes).

What I have tried

I thought this might be easily fixed like this:

batch_sz = 100 # arbitrary number
train_batches = train_data.shuffle(1000).padded_batch(batch_sz, ([10],[None]))
test_batches = test_data.shuffle(1000).padded_batch(batch_sz, ([10],[None]))
```

<p>... but my solution is apparently wrong:</p>

```Traceback (most recent call last):
  File "imdb_reviews.py", line 15, in <module>
    train_batches = train_data.shuffle(1000).padded_batch(batch_sz, ([10],[None]))
  File "/home/ggiuffre/.local/lib/python3.7/site-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 2298, in padded_batch
    batch_size, padded_shapes, padding_values, drop_remainder))
  File "/home/ggiuffre/.local/lib/python3.7/site-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 1481, in padded_batch
    drop_remainder)
  File "/home/ggiuffre/.local/lib/python3.7/site-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 3813, in __init__
    _padded_shape_to_tensor(padded_shape, input_component_shape))
  File "/home/ggiuffre/.local/lib/python3.7/site-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 3741, in _padded_shape_to_tensor
    % (padded_shape_as_shape, input_component_shape))
ValueError: The padded shape (None,) is not compatible with the corresponding input component shape ().
```

Substituting None with () gives me ValueError: Padded shape [()] must be a 1-D tensor of tf.int64 values, but its shape was (1, 0).

Substituting None with 1 gives me ValueError: The padded shape (1,) is not compatible with the corresponding input component shape ().

Problem

What value should I give to the padded_shapes argument? Or, more generally, what am I doing wrong here?

Thank you very much for your help.

答:
Take a look at this blog. https://medium.com/@a.ydobon/tensorflow-2-0-word-embeddings-part3-964b2b9caf94

It recommends

```<code>padded_shapes = ([None],())
train_batches = train_data.shuffle(1000).padded_batch(10,padded_shapes=padded_shapes)
test_batches = test_data.shuffle(1000).padded_batch(10,padded_shapes=padded_shapes)
</code>```

This worked for me.

Title: TF2 padded_batch on supervised dataset

Body:
Problem setting

I am following this tutorial. The tutorial first loads a supervised dataset (using tfds.load with as_supervised=True):

(train_data, test_data), info = tfds.load(
    'imdb_reviews/subwords8k',
    split = (tfds.Split.TRAIN, tfds.Split.TEST),
    with_info=True, as_supervised=True)

Then the tutorial suggests to shuffle and pad the dataset like this:

Movie reviews can be different lengths. We will use the padded_batch method to standardize the lengths of the reviews.

train_batches = train_data.shuffle(1000).padded_batch(10)
test_batches = test_data.shuffle(1000).padded_batch(10)

... but unfortunately the padded_batch method needs an extra argument that the tutorial seems to have forgotten:

Traceback (most recent call last):
  File "imdb_reviews.py", line 14, in <module>
    train_batches = train_data.shuffle(1000).padded_batch(10)
TypeError: padded_batch() missing 1 required positional argument: 'padded_shapes'

Important assumption

Although the errors stack says that padded_shapes is the missing argument, from the tutorial I think it's fair to deduce that the missing argument is in fact batch_size (that should precede padded_shapes).

What I have tried

I thought this might be easily fixed like this:

batch_sz = 100 # arbitrary number
train_batches = train_data.shuffle(1000).padded_batch(batch_sz, ([10],[None]))
test_batches = test_data.shuffle(1000).padded_batch(batch_sz, ([10],[None]))

... but my solution is apparently wrong:

Traceback (most recent call last):
  File "imdb_reviews.py", line 15, in <module>
    train_batches = train_data.shuffle(1000).padded_batch(batch_sz, ([10],[None]))
  File "/home/ggiuffre/.local/lib/python3.7/site-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 2298, in padded_batch
    batch_size, padded_shapes, padding_values, drop_remainder))
  File "/home/ggiuffre/.local/lib/python3.7/site-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 1481, in padded_batch
    drop_remainder)
  File "/home/ggiuffre/.local/lib/python3.7/site-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 3813, in __init__
    _padded_shape_to_tensor(padded_shape, input_component_shape))
  File "/home/ggiuffre/.local/lib/python3.7/site-packages/tensorflow_core/python/data/ops/dataset_ops.py", line 3741, in _padded_shape_to_tensor
    % (padded_shape_as_shape, input_component_shape))
ValueError: The padded shape (None,) is not compatible with the corresponding input component shape ().

Substituting None with () gives me ValueError: Padded shape [()] must be a 1-D tensor of tf.int64 values, but its shape was (1, 0).

Substituting None with 1 gives me ValueError: The padded shape (1,) is not compatible with the corresponding input component shape ().

Problem

What value should I give to the padded_shapes argument? Or, more generally, what am I doing wrong here?

Thank you very much for your help.

Body:
Take a look at this blog. https://medium.com/@a.ydobon/tensorflow-2-0-word-embeddings-part3-964b2b9caf94

It recommends

padded_shapes = ([None],())
train_batches = train_data.shuffle(1000).padded_batch(10,padded_shapes=padded_shapes)
test_batches = test_data.shuffle(1000).padded_batch(10,padded_shapes=padded_shapes)

This worked for me.


问:
Jscroll not working on android device
I am facing a weird problem with this infinite scroll plugin.

This is my code:

```<code>$(function() {
    $('ul.pagination').hide();
    $('.scroll').jscroll({
        loadingHtml: '<div class="loading-icon"><i class="fa fa-spinner fa-2x fa-spin text-muted"></i></div>',
        autoTrigger: true,
        nextSelector: '.pagination li.active + li a',
        contentSelector: 'div.scroll',
        callback: function() {
            $('ul.pagination').remove();

            //Some extra code for lazyload and emoji
            $("img.lazy").lazyload({
                effect: "fadeIn",
            });
            $(".emojizone").each(function() {
                var original = $(this).html();
                var converted = emojione.toImage(original);
                $(this).html(converted);
            });
        }
    });
});
</code>```

The infinite works like a charm on laptop or desktop devices, but on mobile device it doesn't seems to work.

Full story:
On the first load on mobile device, when I scroll to the end of the page, the next page has to be loaded. But it doesn't. But when I minimize my mobile browser and return back to it, the next page is loaded(Weird but works)
Again when the end of the page is reached, I have to minimize the browser and maximize it again to get the next page loaded with infinite scroll.

I am using XAMPP for localhost development and using Chrome on Android for mobile testing.

Update:
This is the html part which is dynamically changed into infinite scroll with the above jQuery

```<code><ul class="pagination">
    <li class="disabled"><span>«</span></li>
    <li class="active"><span>1</span></li>
    <li><a href="http://127.0.0.1/awesome-images/public/home?page=2">2</a></li>
    <li><a href="http://127.0.0.1/awesome-images/public/home?page=3">3</a></li>
    <li><a href="http://127.0.0.1/awesome-images/public/home?page=4">4</a></li>
    <li><a href="http://127.0.0.1/awesome-images/public/home?page=2" rel="next">»</a></li>
</ul>
</code>```

This code is present at the end of the page.

答:
jScroll has a padding option that allows you to set the distance from the bottom of the page at which to start loading the next set of content. Initialize with this as something above the default value of 0 to trigger the auto-load sooner and it will fix your issue on mobile.

$('.jscroll').jscroll({
    loadingHtml: ' Loading...',
    padding: 20,
    nextSelector: 'a.jscroll-next:last',
    contentSelector: 'li'
});
```

Full options list here:
https://github.com/pklauzinski/jscroll#options

Title: Jscroll not working on android device

Body:
I am facing a weird problem with this infinite scroll plugin.

This is my code:

$(function() {
    $('ul.pagination').hide();
    $('.scroll').jscroll({
        loadingHtml: '

',
        autoTrigger: true,
        nextSelector: '.pagination li.active + li a',
        contentSelector: 'div.scroll',
        callback: function() {
            $('ul.pagination').remove();

            //Some extra code for lazyload and emoji
            $("img.lazy").lazyload({
                effect: "fadeIn",
            });
            $(".emojizone").each(function() {
                var original = $(this).html();
                var converted = emojione.toImage(original);
                $(this).html(converted);
            });
        }
    });
});

The infinite works like a charm on laptop or desktop devices, but on mobile device it doesn't seems to work.

Full story:
On the first load on mobile device, when I scroll to the end of the page, the next page has to be loaded. But it doesn't. But when I minimize my mobile browser and return back to it, the next page is loaded(Weird but works)
Again when the end of the page is reached, I have to minimize the browser and maximize it again to get the next page loaded with infinite scroll.

I am using XAMPP for localhost development and using Chrome on Android for mobile testing.

Update:
This is the html part which is dynamically changed into infinite scroll with the above jQuery

«

1

2

3

4

»

This code is present at the end of the page.

Body:
jScroll has a padding option that allows you to set the distance from the bottom of the page at which to start loading the next set of content. Initialize with this as something above the default value of 0 to trigger the auto-load sooner and it will fix your issue on mobile.

$('.jscroll').jscroll({
    loadingHtml: '<img src="loading.gif" alt="Loading" /> Loading...',
    padding: 20,
    nextSelector: 'a.jscroll-next:last',
    contentSelector: 'li'
});

Full options list here:
https://github.com/pklauzinski/jscroll#options


问:
Trying to add class to an attribute based on current string in current URL
I've been trying to get this to work all morning, with no luck.

If I do the following code:

```<code>    $('.persist-header a').each(function () {
       var $this = $(this);
       if (window.location.href.indexOf('signage') !== -1) {
          $this.addClass('active');
       }
    });
</code>```

It applies the active2 class to all a href's under .persist-header.

I want it to only apply it to the one URL in the bunch with the term indicated (signage) in it.

I've tried all sorts of combos, but none are achieving the desired effect. This, for instance, returns nothing at all:

```<code>    $('.persist-header a').each(function () {
       var $this = $(this);
       if ($this.attr('href').window.location.href.indexOf('signage') > -1) {
          $this.addClass('active');
       }
    });
</code>```

jQuery is not my strong suit. Any help you can afford will be much appreciated.

Thanks in advance.

EDIT:
The first suggestion below worked for me. But the 2nd throws an 'active' state on all of the links. So I'm providing my html below:

```<code>    <div class="cblNavMenu--wrap static persist-header ">
       <a class="cblNavMenu--link navBtn max menu-item zero active" href="path/imagetags/library/" role="button">
          <div class="cblNavMenu--link__content block">
             <div class="cblNavMenu--icon">
                <figure class="cblNavMenu--icon__imgwrap">
                   <img class="cblNavMenu--icon__img" src="path/image.jpg" alt="Library"/>
                </figure>
             </div>
             <span class="cblNavMenu--label">Library</span>
          </div>
       </a>

       <a class="cblNavMenu--link navBtn max menu-item one active" href="path/imagetags/this_that/" role="button">
          <div class="cblNavMenu--link__content block">
             <div class="cblNavMenu--icon">
                <figure class="cblNavMenu--icon__imgwrap">
                   <img class="cblNavMenu--icon__img" src="path/image.jpg" alt="This & That"/>
                </figure>
             </div>
             <span class="cblNavMenu--label">This/That</span>
          </div>
       </a>

       <a class="cblNavMenu--link navBtn max menu-item two active" href="path/imagetags/socialmedia/" role="button">
          <div class="cblNavMenu--link__content block">
             <div class="cblNavMenu--icon">
                <figure class="cblNavMenu--icon__imgwrap">
                   <img class="cblNavMenu--icon__img" src="path/image.jpg" alt="Social Media"/>
                </figure>
             </div>
             <span class="cblNavMenu--label">Social</span>
          </div>
       </a>

       <a class="cblNavMenu--link navBtn max menu-item three active" href="path/imagetags/signage/" role="button">
          <div class="cblNavMenu--link__content block">
             <div class="cblNavMenu--icon">
                <figure class="cblNavMenu--icon__imgwrap">
                   <img class="cblNavMenu--icon__img" src="path/image.jpg" alt="Signage"/>
                </figure>
             </div>
             <span class="cblNavMenu--label">Signage</span>
          </div>
       </a>

       <a class="cblNavMenu--link navBtn max menu-item four active" href="path/imagetags/properties/" role="button">
          <div class="cblNavMenu--link__content block">
             <div class="cblNavMenu--icon">
                <figure class="cblNavMenu--icon__imgwrap">
                   <img class="cblNavMenu--icon__img" src="path/image.jpg" alt="Properties"/>
                </figure>
             </div>
             <span class="cblNavMenu--label">Properties</span>
          </div>
       </a>
    </div>
</code>```

答:
Don't use window.location.href in the second version.

```<code>if ($this.attr('href').indexOf('signage') > -1)
</code>```

You can also put that in the selector and get rid of the loop:

$('.persist-header a[href*=signage]').addClass('active');```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.active {
  background-color: pink;
  color: red;
}</code>```

      Library

      This/That

      Social

      Signage

      Properties

```

Body:
I've been trying to get this to work all morning, with no luck.

If I do the following code:

    $('.persist-header a').each(function () {
       var $this = $(this);
       if (window.location.href.indexOf('signage') !== -1) {
          $this.addClass('active');
       }
    });

It applies the active2 class to all a href's under .persist-header.

I want it to only apply it to the one URL in the bunch with the term indicated (signage) in it.

I've tried all sorts of combos, but none are achieving the desired effect. This, for instance, returns nothing at all:

    $('.persist-header a').each(function () {
       var $this = $(this);
       if ($this.attr('href').window.location.href.indexOf('signage') > -1) {
          $this.addClass('active');
       }
    });

jQuery is not my strong suit. Any help you can afford will be much appreciated.

Thanks in advance.

EDIT:
The first suggestion below worked for me. But the 2nd throws an 'active' state on all of the links. So I'm providing my html below:

             Library

             This/That

             Social

             Signage

             Properties

Body:
Don't use window.location.href in the second version.

if ($this.attr('href').indexOf('signage') > -1)

You can also put that in the selector and get rid of the loop:

$('.persist-header a[href*=signage]').addClass('active');

.active {
  background-color: pink;
  color: red;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="cblNavMenu--wrap static persist-header">
  <a class="cblNavMenu--link navBtn max menu-item zero" href="path/imagetags/library/" role="button">
    <div class="cblNavMenu--link__content block">
      <div class="cblNavMenu--icon">
        <figure class="cblNavMenu--icon__imgwrap">
          <img class="cblNavMenu--icon__img" src="path/image.jpg" alt="Library" />
        </figure>
      </div>
      <span class="cblNavMenu--label">Library</span>
    </div>
  </a>

  <a class="cblNavMenu--link navBtn max menu-item one" href="path/imagetags/this_that/" role="button">
    <div class="cblNavMenu--link__content block">
      <div class="cblNavMenu--icon">
        <figure class="cblNavMenu--icon__imgwrap">
          <img class="cblNavMenu--icon__img" src="path/image.jpg" alt="This &amp; That" />
        </figure>
      </div>
      <span class="cblNavMenu--label">This/That</span>
    </div>
  </a>

  <a class="cblNavMenu--link navBtn max menu-item two" href="path/imagetags/socialmedia/" role="button">
    <div class="cblNavMenu--link__content block">
      <div class="cblNavMenu--icon">
        <figure class="cblNavMenu--icon__imgwrap">
          <img class="cblNavMenu--icon__img" src="path/image.jpg" alt="Social Media" />
        </figure>
      </div>
      <span class="cblNavMenu--label">Social</span>
    </div>
  </a>

  <a class="cblNavMenu--link navBtn max menu-item three" href="path/imagetags/signage/" role="button">
    <div class="cblNavMenu--link__content block">
      <div class="cblNavMenu--icon">
        <figure class="cblNavMenu--icon__imgwrap">
          <img class="cblNavMenu--icon__img" src="path/image.jpg" alt="Signage" />
        </figure>
      </div>
      <span class="cblNavMenu--label">Signage</span>
    </div>
  </a>

  <a class="cblNavMenu--link navBtn max menu-item four" href="path/imagetags/properties/" role="button">
    <div class="cblNavMenu--link__content block">
      <div class="cblNavMenu--icon">
        <figure class="cblNavMenu--icon__imgwrap">
          <img class="cblNavMenu--icon__img" src="path/image.jpg" alt="Properties" />
        </figure>
      </div>
      <span class="cblNavMenu--label">Properties</span>
    </div>
  </a>
</div>


问:
Handling file uploads within SVN
I'm constantly having to propset svn:ignore on my uploaded files directories simply because svn:ignore doesn't work as expected. I'm working in NetBeans and our site is constantly under heavy development. I'm sick of "ignoring" the folders because it simply doesn't work how I expect it to. We have several upload directories and would like them to be completely ignored from version control. I thought of possibly using symlinks to store the files in a separate folder on my local machine, while leaving the actual directory empty. Does this sound like a logical solution?</p>

答:
Have you tried:</p>

```<code>svn propset --recursive svn:ignore upload_directory_name *
</code>```

Title: Handling file uploads within SVN

Body:
Have you tried:

svn propset --recursive svn:ignore upload_directory_name *


问:
Understanding purpose of and difference between given recursive functions
Below are the two pieces of code. I could not understand how the pre-decrement operator in the first code functions. And I also could not understand how both of the codes differ in their functionality.

Code 1:

int foo (int val) {
  int x = 0;
  while (val > 0) {
    x = x + foo(--val);
  }
  return val;
}
```

<hr>

<p><strong>Code 2:</strong></p>

<pre class="lang-c prettyprint-override"><code>int bar (int val) {
  int x = 0;
  while (val > 0) {
    x = x + bar(val - 1);
  }
  return val;
}
</code>```

答:
Consider the original code:

```<code>int foo(int val) {
    int x = 0;
    while (val > 0) {
        x = x + foo(val--);  // Post-decrement
    }
    return val;
}
</code>```

When foo() calls itself recursively, the value passed to the recursive call is the same as the value passed to the current call, so the program will eventually exceed the stack limit and crash.  It won't terminate normally.

Now consider the revised code:

```<code>int foo(int val) {
    int x = 0;
    while (val > 0) {
        x = x + foo(--val);  // Pre-decrement
    }
    return val;
}
</code>```

Now the recursion is finite; if val is positive, then the recursive call is made with a smaller value, so the recursion stops.  If val is negative, there is no recursion, of course.

However, since the code returns val, it will always return either 0 (for a non-negative input, because the loop counts down until val == 0) or what was provided (for a negative input; the loop body is never executed).  The recursion keeps adding 0 to x, so x remains 0 too (but it's a 'set but unread' variable so it could be eliminated, and writing x += foo(val--); would be more idiomatic C).  It would be accurate to say the revised code is equivalent to:

```<code>int foo(int val) { return (val < 0) ? val : 0; }
</code>```

Even returning x doesn't fix all the problems.  It returns 0 for non-negative inputs and 0 for negative inputs (but it doesn't crash):

```<code>int foo(int val) {
    int x = 0;
    while (val > 0) {
        x += foo(--val);  // Pre-decrement
    }
    return x;
}
</code>```

Body:
Below are the two pieces of code. I could not understand how the pre-decrement operator in the first code functions. And I also could not understand how both of the codes differ in their functionality.

Code 1:

int foo (int val) {
  int x = 0;
  while (val > 0) {
    x = x + foo(--val);
  }
  return val;
}

Code 2:

int bar (int val) {
  int x = 0;
  while (val > 0) {
    x = x + bar(val - 1);
  }
  return val;
}

Body:
Consider the original code:

int foo(int val) {
    int x = 0;
    while (val > 0) {
        x = x + foo(val--);  // Post-decrement
    }
    return val;
}

When foo() calls itself recursively, the value passed to the recursive call is the same as the value passed to the current call, so the program will eventually exceed the stack limit and crash.  It won't terminate normally.

Now consider the revised code:

int foo(int val) {
    int x = 0;
    while (val > 0) {
        x = x + foo(--val);  // Pre-decrement
    }
    return val;
}

Now the recursion is finite; if val is positive, then the recursive call is made with a smaller value, so the recursion stops.  If val is negative, there is no recursion, of course.

However, since the code returns val, it will always return either 0 (for a non-negative input, because the loop counts down until val == 0) or what was provided (for a negative input; the loop body is never executed).  The recursion keeps adding 0 to x, so x remains 0 too (but it's a 'set but unread' variable so it could be eliminated, and writing x += foo(val--); would be more idiomatic C).  It would be accurate to say the revised code is equivalent to:

int foo(int val) { return (val < 0) ? val : 0; }

Even returning x doesn't fix all the problems.  It returns 0 for non-negative inputs and 0 for negative inputs (but it doesn't crash):

int foo(int val) {
    int x = 0;
    while (val > 0) {
        x += foo(--val);  // Pre-decrement
    }
    return x;
}


问:
ETL batch processing
I'm looking for some open source technology that will allow me to create scheduled batch processing (e.g. Query every 1 hour some SQL DB like Oracle, and insert to Kafka. It is possible that some transformation will be done to the data between). The thing is that I need to be able to transport large amount of data ("big data" - Oracle queries could return 10GB or more).

I read about Apache Airflow for example, but it does not seem to fit for large amount of data.

What other technologies can I use for that purpose?

答:
One simple and easy solution to this is to use an open-source ETL tool like Talend Open Studio for Big Data to create an ETL that reads your data from oracle and then writes it to Kafka. Considering that's all you need, you can get this done with talend using three components;

tOracleInput

tMap

tKafkaOutput

Talend - Kafka Documentation

Another solution would be to code your ETL in an spark job to write to Kafka directly from your spark code. Spark provides really really fast in-memory processing if you have enough memory so you can leverage that.

Also, since you are to do this in an hourly batch, you should filter your oracle input based on time to only fetch the incremental rows, not the entire snapshot.

Title: ETL batch processing