问:
Complex If statements; || not working as I hoped
I feel like this is a really dumb question but my brain is fried. Right now I'm working on a very complex set of if and else statements and I'm wondering if there is an easier way? I originally tried or statements but that didn't give me the desired result.

```<code>if(fields[0].value === '' && fields[1].value === '' && fields[2].value === '' && fields[3].value === '' ) {
    clusterGroup.addLayer(layer);
} else if(fields[0].value === '' && fields[1].value === city && fields[2].value === '' && fields[3].value === '') {
    clusterGroup.addLayer(layer);

} else if(fields[0].value === state && fields[1].value === '' && fields[2].value === '' && fields[3].value === '') {
    clusterGroup.addLayer(layer);

} else if(fields[0].value === state && fields[1].value === city && fields[2].value === '' && fields[3].value === ''){
    clusterGroup.addLayer(layer);

} else if(fields[0].value === '' && fields[1].value === '' && (fields[2].value <= sq && sq != null) && fields[3].value === '') {
    clusterGroup.addLayer(layer);

} else if(fields[0].value === '' && fields[1].value === '' && fields[2].value === '' && (fields[3].value >= sq  && sq != null)) {
    clusterGroup.addLayer(layer);

} else if(fields[0].value === '' && fields[1].value === city && (fields[2].value <= sq && sq != null) && fields[3].value === ''){
    clusterGroup.addLayer(layer);

} else if(fields[0].value === state && fields[1].value === '' && fields[2].value === '' && (fields[3].value >= sq  && sq != null)){
    clusterGroup.addLayer(layer);

} else if(fields[0].value === state && fields[1].value === city && (fields[2].value <= sq && sq != null) && fields[3].value === ''){
    clusterGroup.addLayer(layer);

} else if(fields[0].value === state && fields[1].value === city && fields[2].value === '' && (fields[3].value >= sq  && sq != null)){
    clusterGroup.addLayer(layer);

} else if(fields[0].value === state && fields[1].value === city && (fields[2].value <= sq && sq != null) && (fields[3].value >= sq  && sq != null)){
    clusterGroup.addLayer(layer);
}
</code>```

Thank you in advanced.

答:
I don't know how did you use OR Statement (||) but you can use one if statement.

```<code>if(
    (fields[0].value === '' && fields[1].value === ''       && fields[2].value === '' && fields[3].value === '') ||
    (fields[0].value === '' && fields[1].value === city     && fields[2].value === '' && fields[3].value === '')  ||
    (fields[0].value === state && fields[1].value === ''    && fields[2].value === '' && fields[3].value === '') ||
    (fields[0].value === state && fields[1].value === city  && fields[2].value === '' && fields[3].value === '') ||
    (fields[0].value === '' && fields[1].value === ''   && (fields[2].value <= sq && sq != null) && fields[3].value === '') ||
    (fields[0].value === '' && fields[1].value === ''   && fields[2].value === '' && (fields[3].value >= sq  && sq != null)) ||
    (fields[0].value === '' && fields[1].value === city && (fields[2].value <= sq && sq != null) && fields[3].value === '') ||
    (fields[0].value === state && fields[1].value === ''    && fields[2].value === '' && (fields[3].value >= sq  && sq != null)) ||
    (fields[0].value === state && fields[1].value === city  && (fields[2].value <= sq && sq != null) && fields[3].value === '') ||
    (fields[0].value === state && fields[1].value === city  && fields[2].value === '' && (fields[3].value >= sq  && sq != null)) ||
    (fields[0].value === state && fields[1].value === city  && (fields[2].value <= sq && sq != null) && (fields[3].value >= sq  && sq != null))
){
    clusterGroup.addLayer(layer);
}
</code>```

Body:
I feel like this is a really dumb question but my brain is fried. Right now I'm working on a very complex set of if and else statements and I'm wondering if there is an easier way? I originally tried or statements but that didn't give me the desired result.

if(fields[0].value === '' && fields[1].value === '' && fields[2].value === '' && fields[3].value === '' ) {
    clusterGroup.addLayer(layer);
} else if(fields[0].value === '' && fields[1].value === city && fields[2].value === '' && fields[3].value === '') {
    clusterGroup.addLayer(layer);

} else if(fields[0].value === state && fields[1].value === '' && fields[2].value === '' && fields[3].value === '') {
    clusterGroup.addLayer(layer);

} else if(fields[0].value === state && fields[1].value === city && fields[2].value === '' && fields[3].value === ''){
    clusterGroup.addLayer(layer);

} else if(fields[0].value === '' && fields[1].value === '' && (fields[2].value <= sq && sq != null) && fields[3].value === '') {
    clusterGroup.addLayer(layer);

} else if(fields[0].value === '' && fields[1].value === '' && fields[2].value === '' && (fields[3].value >= sq  && sq != null)) {
    clusterGroup.addLayer(layer);

} else if(fields[0].value === '' && fields[1].value === city && (fields[2].value <= sq && sq != null) && fields[3].value === ''){
    clusterGroup.addLayer(layer);

} else if(fields[0].value === state && fields[1].value === '' && fields[2].value === '' && (fields[3].value >= sq  && sq != null)){
    clusterGroup.addLayer(layer);

} else if(fields[0].value === state && fields[1].value === city && (fields[2].value <= sq && sq != null) && fields[3].value === ''){
    clusterGroup.addLayer(layer);

} else if(fields[0].value === state && fields[1].value === city && fields[2].value === '' && (fields[3].value >= sq  && sq != null)){
    clusterGroup.addLayer(layer);

} else if(fields[0].value === state && fields[1].value === city && (fields[2].value <= sq && sq != null) && (fields[3].value >= sq  && sq != null)){
    clusterGroup.addLayer(layer);
}

Thank you in advanced.

Body:
I don't know how did you use OR Statement (||) but you can use one if statement.

if(
    (fields[0].value === '' && fields[1].value === ''       && fields[2].value === '' && fields[3].value === '') ||
    (fields[0].value === '' && fields[1].value === city     && fields[2].value === '' && fields[3].value === '')  ||
    (fields[0].value === state && fields[1].value === ''    && fields[2].value === '' && fields[3].value === '') ||
    (fields[0].value === state && fields[1].value === city  && fields[2].value === '' && fields[3].value === '') ||
    (fields[0].value === '' && fields[1].value === ''   && (fields[2].value <= sq && sq != null) && fields[3].value === '') ||
    (fields[0].value === '' && fields[1].value === ''   && fields[2].value === '' && (fields[3].value >= sq  && sq != null)) ||
    (fields[0].value === '' && fields[1].value === city && (fields[2].value <= sq && sq != null) && fields[3].value === '') ||
    (fields[0].value === state && fields[1].value === ''    && fields[2].value === '' && (fields[3].value >= sq  && sq != null)) ||
    (fields[0].value === state && fields[1].value === city  && (fields[2].value <= sq && sq != null) && fields[3].value === '') ||
    (fields[0].value === state && fields[1].value === city  && fields[2].value === '' && (fields[3].value >= sq  && sq != null)) ||
    (fields[0].value === state && fields[1].value === city  && (fields[2].value <= sq && sq != null) && (fields[3].value >= sq  && sq != null))
){
    clusterGroup.addLayer(layer);
}


来源: stackexchange

问:
How to keep the login token so that it can be used by other components?
Let's say, I make a post request to create my token.

```<code>public tokenInfo: TokenInfo;

public login(creds){
   return this.http.post<TokenInfo>(this.baseUrl + "Account/CreateToken", creds)
          .map(res =>{
                this.tokenInfo = res;
                return true;
          })
  }
</code>```

I get back my token and the expiration date. something like:

{token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ...", expiration: "2017-12-04T03:40:55Z"}

How do I keep it around so that other component can take advantage of it? The first thing that comes to mind is to display the name of the logged user at the left corner of the menu bar and hide the Login item.

Thanks for helping

答:
You can save your token in the web storage like this:

```<code>window.localStorage.setItem('token', res.token);
</code>```

And you can get it later like this:

```<code>window.localStorage.getItem('token');
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Let's say, I make a post request to create my token.

public tokenInfo: TokenInfo;

public login(creds){
   return this.http.post<TokenInfo>(this.baseUrl + "Account/CreateToken", creds)
          .map(res =>{
                this.tokenInfo = res;
                return true;
          })
  }

I get back my token and the expiration date. something like:

{token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ...", expiration: "2017-12-04T03:40:55Z"}

How do I keep it around so that other component can take advantage of it? The first thing that comes to mind is to display the name of the logged user at the left corner of the menu bar and hide the Login item.

Thanks for helping

Body:
You can save your token in the web storage like this:

window.localStorage.setItem('token', res.token);

And you can get it later like this:

window.localStorage.getItem('token');


问:
R compare data.table elements by elements
Have two data.tables:

```<code>> aDT <- data.table(colA = "apple", colB = "banana", colC = "4")
> aDT
    colA   colB colC
1: apple banana    4

> bDT <- data.table(colA = c("purple","apple"), colB = c("pear","banana"), colC = c("4","2"))
> bDT
     colA   colB colC
1: purple   pear    4
2:  apple banana    2
</code>```

I would like to compare the only row in aDT with every row in bDT, element by element. The resulting data.table looks like:

```<code>> resultDT <- data.table(colA = c(FALSE,TRUE), colB = c(FALSE,TRUE), colC = c(TRUE,FALSE))
> resultDT
    colA  colB  colC
1: FALSE FALSE  TRUE
2:  TRUE  TRUE FALSE
</code>```

How to achieve it?

答:
```<code>aDT[rep(1, nrow(bDT))] == bDT
#       colA  colB  colC
# [1,] FALSE FALSE  TRUE
# [2,]  TRUE  TRUE FALSE
</code>```

Body:
Have two data.tables:

> aDT <- data.table(colA = "apple", colB = "banana", colC = "4")
> aDT
    colA   colB colC
1: apple banana    4

> bDT <- data.table(colA = c("purple","apple"), colB = c("pear","banana"), colC = c("4","2"))
> bDT
     colA   colB colC
1: purple   pear    4
2:  apple banana    2

I would like to compare the only row in aDT with every row in bDT, element by element. The resulting data.table looks like:

> resultDT <- data.table(colA = c(FALSE,TRUE), colB = c(FALSE,TRUE), colC = c(TRUE,FALSE))
> resultDT
    colA  colB  colC
1: FALSE FALSE  TRUE
2:  TRUE  TRUE FALSE

How to achieve it?


问:
IntelliJ says invalid item in dependencies list but it is present in maven repo
My IntelliJ says that

```<code>Module <redacted> : invalid item 'Maven: com.ibm:com.ibm.mq.commonservices:7.1.0.6' in the dependencies list
</code>```

But it is in the Maven repo. I tried this solution. But it didnt work. There are 107 such imports. What do I do ?

答: Its possible that you POM files might have a conflict. Ensure that the required JARs aren't in the exclusion list</p>

Body:
My IntelliJ says that

Module <redacted> : invalid item 'Maven: com.ibm:com.ibm.mq.commonservices:7.1.0.6' in the dependencies list

But it is in the Maven repo. I tried this solution. But it didnt work. There are 107 such imports. What do I do ?


问:
Is it possibile to create dashed border controlling the length and the spacing?
Is it possibile to control the length and the distance between the strokes?
I would like to create this effect without svg.
Is it possibile?

答:
No, you cannot customize these things with CSS. They are hardcoded into each browser implementation, and different browsers draw dashed borders in different ways.

If you'd rather not use SVG, your only other alternative is background images (SVG itself is an image format, anyway).


问:
Java Ragged Array, trying to display multiple Arrays
I am having trouble finding out what is the issue with my code,  Everything is fine till I get to the Jagged array. I want it to display the code as a jagged array but I dont know</p>
```<code>package ajk;

public class Test2
{

    public static void main(String[] args)
        int[][] twoD = {
            {1, 2},
            {3, 4, 5},
            {6},
            {7, 8, 9},
        };
        printArray(twoD);
    }
    public static void printArray(int[][] arr) {
        System.out.println("[");

        int r = 4;
        int c = 3;
        int i, j;

        for (i=0; i < r; i++ );
            System.out.print("[");
            for (j=0; j < c; j++ ) {
                System.out.print( arr[i][j]  + " " );
            }
        }
    }
}
</code>```

答:
You have some syntax errors and mistakes:

for (i=0; i < r; i++ );You can not use for loop like this. You have to write your code in the braces

Your array's column sizes are different from each other, so you can not determine the column size with one variable. Best way is array[i].length for this situation

You can define i and j inside the parantez of the for loop.

If you change the code as below: it will run

```<code>public class Test2
{

    public static void main(String[] args) {

    int[][] twoD = {
            {1, 2},
            {3, 4, 5},
            {6},
            {7, 8, 9},
    };
    printArray(twoD);
}
    public static void printArray(int[][] arr) {
        System.out.println("[");

        for (int i=0; i < arr.length; i++ ) {
            System.out.print("[");
            for (int j=0; j < arr[i].length; j++ ) {
                System.out.print( arr[i][j]  + " " );
            }
        }

    }
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I am having trouble finding out what is the issue with my code,  Everything is fine till I get to the Jagged array. I want it to display the code as a jagged array but I dont know

package ajk;

public class Test2
{

    public static void main(String[] args)
        int[][] twoD = {
            {1, 2},
            {3, 4, 5},
            {6},
            {7, 8, 9},
        };
        printArray(twoD);
    }
    public static void printArray(int[][] arr) {
        System.out.println("[");

        int r = 4;
        int c = 3;
        int i, j;

        for (i=0; i < r; i++ );
            System.out.print("[");
            for (j=0; j < c; j++ ) {
                System.out.print( arr[i][j]  + " " );
            }
        }
    }
}

Body:
You have some syntax errors and mistakes:

for (i=0; i < r; i++ );You can not use for loop like this. You have to write your code in the braces

Your array's column sizes are different from each other, so you can not determine the column size with one variable. Best way is array[i].length for this situation

You can define i and j inside the parantez of the for loop.

If you change the code as below: it will run

public class Test2
{

    public static void main(String[] args) {

    int[][] twoD = {
            {1, 2},
            {3, 4, 5},
            {6},
            {7, 8, 9},
    };
    printArray(twoD);
}
    public static void printArray(int[][] arr) {
        System.out.println("[");

        for (int i=0; i < arr.length; i++ ) {
            System.out.print("[");
            for (int j=0; j < arr[i].length; j++ ) {
                System.out.print( arr[i][j]  + " " );
            }
        }

    }
}


问:
Github release vs actual software version
Does anyone know what is the difference between a GitHub release and the actual release that software company announces?

I'm trying to find the different versions of vue.js, on the vue.js official website there are only two versions but on the GitHub repository many releases I was wondered if the two concepts are different?

答: When they release a GitHub version, it is supposed to be open source. The one the company releases may have more code they have not reeased yet or is confidential. </p>


问:
How to test machine learning model with real data in python
I am new to machine learning thing and python. I have created a simple linear regression model in python . I can test the accuracy of my model but only for the data in my data set , my data set is a csv file which contains a relation between salary and years of experience . But I want to use it in practical life . Like  I will input the years of experience and the output will be predicted salary .  Here is what I have done so far

```<code>import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# Importing the dataset
dataset = pd.read_csv('Salary_Data.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, 1].values

# Splitting the dataset into the Training set and Test set
from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 1/3, random_state = 0)

# Feature Scaling
"""from sklearn.preprocessing import StandardScaler
sc_X = StandardScaler()
X_train = sc_X.fit_transform(X_train)
X_test = sc_X.transform(X_test)
sc_y = StandardScaler()
y_train = sc_y.fit_transform(y_train)"""

# Fitting Simple Linear Regression to the Training set
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train, y_train)

# Predicting the Test set results
y_pred = regressor.predict(X_test)
</code>```

I want to modify the above code in such way, that I can give input years of experience and the output will expected salary .

Thanks in advance .

答:
After training the model, save your model to file and load it later in order to make predictions. In Python, you can use 'pickle' to achieve this.

References:

scikit-learn Model Persistence

save and load machine learning models, an example

Body:
I am new to machine learning thing and python. I have created a simple linear regression model in python . I can test the accuracy of my model but only for the data in my data set , my data set is a csv file which contains a relation between salary and years of experience . But I want to use it in practical life . Like  I will input the years of experience and the output will be predicted salary .  Here is what I have done so far

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# Importing the dataset
dataset = pd.read_csv('Salary_Data.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, 1].values

# Splitting the dataset into the Training set and Test set
from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 1/3, random_state = 0)

# Feature Scaling
"""from sklearn.preprocessing import StandardScaler
sc_X = StandardScaler()
X_train = sc_X.fit_transform(X_train)
X_test = sc_X.transform(X_test)
sc_y = StandardScaler()
y_train = sc_y.fit_transform(y_train)"""

# Fitting Simple Linear Regression to the Training set
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train, y_train)

# Predicting the Test set results
y_pred = regressor.predict(X_test)

I want to modify the above code in such way, that I can give input years of experience and the output will expected salary .

Thanks in advance .


问:
how to sort nested list without using optional argument `key`
im sort of stuck on a homework question.
Suppose I have a list as such:

[('Paul George', 1), ('Luke Skywalker', 2), ('Mitchell Piker', 3), ('Phil Dam', 1)]

I have to write a function such that the list will be ordered by the second element , which is the integer value. Also, if two people have the same integer, then i have to sort alphabetically. Also, i am allowed to use sort but i cannot use the optional argument, key. So i should have something like this:

[('Mitchell Piker', 3), ('Luke Skywalker', 2), ('Paul George', 1), ('Phil Dam', 1)]

```<code>>>> def sort(lst: List[Tuple[str, int]]):
    """Return the list of tuples from largest integer score to lowest
    integer score. If two people have the same score, then sort them by
    alphabetical order.
    """
    lst2 = []
    lst2.append(lst[0])
    for i in range(len(lst)):
        for j in range(len(lst2)):
            if lst[i][-1] > lst2[j][-1] and lst[i][-1] not in lst2:
                lst2.insert(0, lst2[i])
            if lst[i][-1] < lst2[j][-1] and lst[i][-1] not in lst2:
                lst2.append(lst2[i][-1])
    return lst2
</code>```

however i get an error. Can anyone help? Thank you very much

答:
If it can be assumed that the numbers are going to be always integers, you can use them to index the values, like this (it could also be achieved with sort instead of sorted)

```<code>groups = defaultdict(list)
max_id = -1
for name, idx in lst:
    groups[idx].append(name)
    if max_id < idx:
        max_id = idx
result = [(name, idx) for idx in range(max_id, -1, -1) for name in sorted(groups.get(idx, []))]
# [('Mitchell Piker', 3), ('Luke Skywalker', 2), ('Paul George', 1), ('Phil Dam', 1)]
</code>```

EDIT:

```<code>from collections import defaultdict
groups = defaultdict(list)
for name, idx in lst:
    groups[idx].append(name)
[(name, idx) for idx in sorted(groups.keys())[::-1] for name in sorted(groups[idx])]
</code>```

Note: if you are against using groups.keys() you can always use [x for x in groups] instead...

Body:
im sort of stuck on a homework question.
Suppose I have a list as such:

[('Paul George', 1), ('Luke Skywalker', 2), ('Mitchell Piker', 3), ('Phil Dam', 1)]

I have to write a function such that the list will be ordered by the second element , which is the integer value. Also, if two people have the same integer, then i have to sort alphabetically. Also, i am allowed to use sort but i cannot use the optional argument, key. So i should have something like this:

[('Mitchell Piker', 3), ('Luke Skywalker', 2), ('Paul George', 1), ('Phil Dam', 1)]

>>> def sort(lst: List[Tuple[str, int]]):
    """Return the list of tuples from largest integer score to lowest
    integer score. If two people have the same score, then sort them by
    alphabetical order.
    """
    lst2 = []
    lst2.append(lst[0])
    for i in range(len(lst)):
        for j in range(len(lst2)):
            if lst[i][-1] > lst2[j][-1] and lst[i][-1] not in lst2:
                lst2.insert(0, lst2[i])
            if lst[i][-1] < lst2[j][-1] and lst[i][-1] not in lst2:
                lst2.append(lst2[i][-1])
    return lst2

however i get an error. Can anyone help? Thank you very much

Body:
If it can be assumed that the numbers are going to be always integers, you can use them to index the values, like this (it could also be achieved with sort instead of sorted)

groups = defaultdict(list)
max_id = -1
for name, idx in lst:
    groups[idx].append(name)
    if max_id < idx:
        max_id = idx
result = [(name, idx) for idx in range(max_id, -1, -1) for name in sorted(groups.get(idx, []))]
# [('Mitchell Piker', 3), ('Luke Skywalker', 2), ('Paul George', 1), ('Phil Dam', 1)]

EDIT:

from collections import defaultdict
groups = defaultdict(list)
for name, idx in lst:
    groups[idx].append(name)
[(name, idx) for idx in sorted(groups.keys())[::-1] for name in sorted(groups[idx])]

Note: if you are against using groups.keys() you can always use [x for x in groups] instead...


问:
Cant set width element using jquery
Im using jquery:
$(".mce-content-body p")

and return

"text"

But i cant use: $(".mce-content-body p").width(300) will rerturn VM9281:1 Uncaught TypeError: Cannot read property 'width' of null at <anonymous>:1:39

How i set witdh for all
 in idv

答:
You need to set it as a CSS property in jQuery.

HTML tag should be set like

```<code><p class="mce-content-body"> text <p>
</code>```

jQuery

```<code>$(".mce-content-body").css("width","12px");
</code>```

Title: Cant set width element using jquery

Body:
You need to set it as a CSS property in jQuery.

HTML tag should be set like

<p class="mce-content-body"> text <p>

jQuery

$(".mce-content-body").css("width","12px");


问:
Printing a 2D character array read in from a file
Currently working on a school project involving a 2D char array representing a top-down view of a room, where 'W' = walls, 'F' = furniture, and ' ' = free space.  The array is meant to be read in from a file (contents of the file are below).

FILE:

```<code>2
W   W   W   W   W   W   W   W   W   W
W       F       F   F               W
W       F       F   F       F   F   W
W       F       F   F       F   F   W
W       F       F   F       F   F   W
W       F       F   F       F   F   W
W       F       F   F       F   F   W
W       F       F   F       F   F   W
W       F                   F   F   W
W       F                   F   F   W
W           F               F   F   W
W   F       F               F   F   W
W   F       F               F   F   W
W                           F   F   W
W   W   W   W   W   W   W   W   W   W

W   W   W   W   W   W   W   W   W   W
W   F   F   F   F   F       F       W
W   F   F   F   F   F       F       W
W   F   F   F   F   F       F       W
W   F   F   F       F       F       W
W   F   F   F       F       F       W
W   F   F   F       F       F       W
W                   F               W
W                   F       F       W
W   F   F   F               F       W
W   F   F   F   F           F       W
W   F   F   F   F           F       W
W   F   F   F   F   F       F       W
W   F   F   F   F   F       F       W
W   W   W   F   W   W   W   W   W   W
</code>```

The '2' is irrelevant for now - it represents the number of room configurations.  I know that I will have to make a loop with that number later in the project.

Before I even begin the project, though, I wanted to print out my input to be sure that I am correctly reading in the file.  No matter what I try, I cant seem to get the correct configuration.  I have tried >> skipws as well as file.get() at multiple points in my code, and using these gives me different outputs but none match the original file.

My current code:

```<code>    int main()
{
    //Variables
    int i;
    int j;
    char room_array[room_height][room_width];
    char piece_of_room;
    int num_of_room_configurations;

//Create File, Open File, and Check File
ifstream room_file;
room_file.open("C:\\(path)\\rooms.txt");
if (room_file.fail())
    {
        cout << "Could not open file." << endl;
        system("pause");
        return 0;
    }

//Loop Control / Use File; The Number of Room Configs (will need to put this in a loop later)
room_file >> num_of_room_configurations;
cout << "Number of different room layouts: " << num_of_room_configurations << endl << endl;

//Create Room Array / Use File
for (i = 0; i < room_height; i++) //moves through rows
{
    cout << endl;
    for (j = 0; j < room_width; j++) //moves through columns
    {
        room_file >> piece_of_room; //reading in values from file
        room_array[i][j] = piece_of_room;
    }
}

//Echo Original Room Layout
cout << endl << "ORIGINAL ARRAY:" << endl;
for (i = 0; i < room_height; i++) //moves through rows
{
    cout << endl;
    for (j = 0; j < room_width; j++) //moves through columns
    {
        cout << room_array[i][j]; //formatting
    }
}
cout << endl << endl;

system("pause");
    return 0;
</code>```

I've taken out my attempts at including white spaces to make the code less complicated, so with this specific code I get this as an output:

link to output screencap

Apologies for such a long question but I wanted to be sure I didn't leave out anything that could assist in somebody helping me.  I do not have a good understanding of C++ by any means so it is more than possible that I's missing something very basic.  Any help at all would be very appreciated, thank you in advance.

Also, this is my first post - if I've done anything incorrectly please let me know and I'll edit this if possible.

答:
While reading a file, you use >> operator to get a each character. But somehow it is not recognizing the space or skipping it. I'm not sure why. Instead of space if you try with other character say 'B', your code will work perfectly fine i believe.
You can refer to the below link how >> operator work on ifstream

http://www.cplusplus.com/reference/fstream/ifstream/

I would suggest you to use getline() function to read the input file, this would be easier and simpler. Your code may look like below (for example)

```<code>for (i = 0; i < room_height; i++) //moves through rows
{
    room_file.getline (&room_array[i][0],9);
}
</code>```

Body:
Currently working on a school project involving a 2D char array representing a top-down view of a room, where 'W' = walls, 'F' = furniture, and ' ' = free space.  The array is meant to be read in from a file (contents of the file are below).

FILE:

2
W   W   W   W   W   W   W   W   W   W
W       F       F   F               W
W       F       F   F       F   F   W
W       F       F   F       F   F   W
W       F       F   F       F   F   W
W       F       F   F       F   F   W
W       F       F   F       F   F   W
W       F       F   F       F   F   W
W       F                   F   F   W
W       F                   F   F   W
W           F               F   F   W
W   F       F               F   F   W
W   F       F               F   F   W
W                           F   F   W
W   W   W   W   W   W   W   W   W   W

W   W   W   W   W   W   W   W   W   W
W   F   F   F   F   F       F       W
W   F   F   F   F   F       F       W
W   F   F   F   F   F       F       W
W   F   F   F       F       F       W
W   F   F   F       F       F       W
W   F   F   F       F       F       W
W                   F               W
W                   F       F       W
W   F   F   F               F       W
W   F   F   F   F           F       W
W   F   F   F   F           F       W
W   F   F   F   F   F       F       W
W   F   F   F   F   F       F       W
W   W   W   F   W   W   W   W   W   W

The '2' is irrelevant for now - it represents the number of room configurations.  I know that I will have to make a loop with that number later in the project.

Before I even begin the project, though, I wanted to print out my input to be sure that I am correctly reading in the file.  No matter what I try, I cant seem to get the correct configuration.  I have tried >> skipws as well as file.get() at multiple points in my code, and using these gives me different outputs but none match the original file.

My current code:

    int main()
{
    //Variables
    int i;
    int j;
    char room_array[room_height][room_width];
    char piece_of_room;
    int num_of_room_configurations;

//Create File, Open File, and Check File
ifstream room_file;
room_file.open("C:\\(path)\\rooms.txt");
if (room_file.fail())
    {
        cout << "Could not open file." << endl;
        system("pause");
        return 0;
    }

//Loop Control / Use File; The Number of Room Configs (will need to put this in a loop later)
room_file >> num_of_room_configurations;
cout << "Number of different room layouts: " << num_of_room_configurations << endl << endl;

//Create Room Array / Use File
for (i = 0; i < room_height; i++) //moves through rows
{
    cout << endl;
    for (j = 0; j < room_width; j++) //moves through columns
    {
        room_file >> piece_of_room; //reading in values from file
        room_array[i][j] = piece_of_room;
    }
}

//Echo Original Room Layout
cout << endl << "ORIGINAL ARRAY:" << endl;
for (i = 0; i < room_height; i++) //moves through rows
{
    cout << endl;
    for (j = 0; j < room_width; j++) //moves through columns
    {
        cout << room_array[i][j]; //formatting
    }
}
cout << endl << endl;

system("pause");
    return 0;

I've taken out my attempts at including white spaces to make the code less complicated, so with this specific code I get this as an output:

link to output screencap

Apologies for such a long question but I wanted to be sure I didn't leave out anything that could assist in somebody helping me.  I do not have a good understanding of C++ by any means so it is more than possible that I's missing something very basic.  Any help at all would be very appreciated, thank you in advance.

Also, this is my first post - if I've done anything incorrectly please let me know and I'll edit this if possible.

Body:
While reading a file, you use >> operator to get a each character. But somehow it is not recognizing the space or skipping it. I'm not sure why. Instead of space if you try with other character say 'B', your code will work perfectly fine i believe.
You can refer to the below link how >> operator work on ifstream

http://www.cplusplus.com/reference/fstream/ifstream/

I would suggest you to use getline() function to read the input file, this would be easier and simpler. Your code may look like below (for example)

for (i = 0; i < room_height; i++) //moves through rows
{
    room_file.getline (&room_array[i][0],9);
}


答:
Wrong Syntax.Try,

```<code>$(".mce-content-body p").css("width","300px");
</code>```

Note: The difference between .css(width) and .width() is that the latter returns a unit-less pixel value (for example, 400) while the former returns a value with units intact (for example, 400px). The .width() method is recommended when an element's width needs to be used in a mathematical calculation.

Thanks !

Title: Cant set width element using jquery

Body:
Im using jquery:
$(".mce-content-body p")

and return

"text"

But i cant use: $(".mce-content-body p").width(300) will rerturn VM9281:1 Uncaught TypeError: Cannot read property 'width' of null at <anonymous>:1:39

How i set witdh for all
 in idv

Body:
Wrong Syntax.Try,

$(".mce-content-body p").css("width","300px");

Note: The difference between .css(width) and .width() is that the latter returns a unit-less pixel value (for example, 400) while the former returns a value with units intact (for example, 400px). The .width() method is recommended when an element's width needs to be used in a mathematical calculation.

Thanks !


问:
Can I add a mask to an svg-element without using an id?
I want to assign a svg-mask to a svg-image. I can make this work using an id on the mask like this:

<svg id="svg1" width="5cm" height="5cm" viewBox="0 0 200 200"
     xmlns="http://www.w3.org/2000/svg" version="1.1">
     <defs>
       <mask id="mask">
         <circle cx="100" cy="100" r="100" fill="white"></circle>
       </mask>
     </defs>
     <rect x="0" y="0" width="200" height="200" fill="red" mask="url(#mask)"></rect>
</svg>```
</div>
</div>
</p>

<p>However I want to load this svg multiple times, with a different id in the svg-tag. Therefore I will generate duplicates of the '#mask'-id. Using multiple id's is invalid code. So I want to use a class to refer to the appropriate mask. That means I cannot use the <code>mask=url()</code>-technique.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><svg id="svg2" width="5cm" height="5cm" viewBox="0 0 200 200"
     xmlns="http://www.w3.org/2000/svg" version="1.1">
     <defs>
       <mask class="mask">
         <circle cx="100" cy="100" r="100" fill="white"></circle>
       </mask>
     </defs>
     <rect x="0" y="0" width="200" height="200" fill="red" mask="url(can't use this)"></rect>
</svg></code>```

Is there a way I can apply a mask to the rect element if the mask has a class instead of id? Maybe using javaScript or some other way I didn't think of.

The full story/context:
I am actually making an svg image slider-module for Joomla with php. This php generates a module containing javascript, css and an svg. I use the javascript to animate the mask.
I do actually have it working with unique id's. I was just wondering if there is a way to assign a mask to an element without referring to id's. I may want to do this because my code is getting a bit more confusing to read, because I have to use some php in my javascript/svg and css for each unique id.

答: No. You can only reference masks via an id. You cannot reference SVG masks any other way.

Body:
I want to assign a svg-mask to a svg-image. I can make this work using an id on the mask like this:

<svg id="svg1" width="5cm" height="5cm" viewBox="0 0 200 200"
     xmlns="http://www.w3.org/2000/svg" version="1.1">
     <defs>
       <mask id="mask">
         <circle cx="100" cy="100" r="100" fill="white"></circle>
       </mask>
     </defs>
     <rect x="0" y="0" width="200" height="200" fill="red" mask="url(#mask)"></rect>
</svg>

However I want to load this svg multiple times, with a different id in the svg-tag. Therefore I will generate duplicates of the '#mask'-id. Using multiple id's is invalid code. So I want to use a class to refer to the appropriate mask. That means I cannot use the mask=url()-technique.

<svg id="svg2" width="5cm" height="5cm" viewBox="0 0 200 200"
     xmlns="http://www.w3.org/2000/svg" version="1.1">
     <defs>
       <mask class="mask">
         <circle cx="100" cy="100" r="100" fill="white"></circle>
       </mask>
     </defs>
     <rect x="0" y="0" width="200" height="200" fill="red" mask="url(can't use this)"></rect>
</svg>

Is there a way I can apply a mask to the rect element if the mask has a class instead of id? Maybe using javaScript or some other way I didn't think of.

The full story/context:
I am actually making an svg image slider-module for Joomla with php. This php generates a module containing javascript, css and an svg. I use the javascript to animate the mask.
I do actually have it working with unique id's. I was just wondering if there is a way to assign a mask to an element without referring to id's. I may want to do this because my code is getting a bit more confusing to read, because I have to use some php in my javascript/svg and css for each unique id.


问:
RenderLoop vs Stage when using Juggler in StageXL
I am really new to StageXL, so still struggling with the basic concepts.  I have the following code from Stagehand web-stagexl:

```<code>import 'dart:async';
import 'dart:html' as html;
import 'package:stagexl/stagexl.dart';
import 'dart:math';

Future<Null> main() async {
  var canvas = html.querySelector('#stage');
  var stage = new Stage(canvas, width: 1280, height: 800);

  var renderLoop = new RenderLoop();
  renderLoop.addStage(stage);

  var resourceManager = new ResourceManager();
  resourceManager.addBitmapData("dart", "images/dart@1x.png");
  await resourceManager.load();
  var logoData = resourceManager.getBitmapData("dart");

  var logo = new Sprite();
  logo.addChild(new Bitmap(logoData));
  stage.addChild(logo);

  var tween = renderLoop.juggler.addTween(logo, 3, Transition.easeOutBounce);
// var tween = stage.juggler... works just as well
  tween.animate.y.to(800 / 2);
}
</code>```

At the bottom, we can use either var tween=stage.juggler or renderLoop.juggler and the code seems to behave the same.  The documentation can point to either way, but my understanding is that renderLoop is a stream, and not a node, and so stage.juggler makes more sense to me.  Is there a difference in use, and are there other instances where one is preferred to another?  Thanks.

答:
You can either use the Stage.juggler or the RenderLoop.juggler. The Juggler from the RenderLoop is driven by the browser (see RequestAnimationFrame), and the Juggler from the Stage is driven by RenderLoop.juggler. So the Stage.juggler is more for your convenience. You can also create your own instance of Juggler and add the instance (since Juggler implements the Animatable interface) to the RenderLoop.juggler.

You can learn more about this here:

http://www.stagexl.org/docs/wiki-articles.html?article=juggler

Body:
I am really new to StageXL, so still struggling with the basic concepts.  I have the following code from Stagehand web-stagexl:

import 'dart:async';
import 'dart:html' as html;
import 'package:stagexl/stagexl.dart';
import 'dart:math';

Future<Null> main() async {
  var canvas = html.querySelector('#stage');
  var stage = new Stage(canvas, width: 1280, height: 800);

  var renderLoop = new RenderLoop();
  renderLoop.addStage(stage);

  var resourceManager = new ResourceManager();
  resourceManager.addBitmapData("dart", "images/dart@1x.png");
  await resourceManager.load();
  var logoData = resourceManager.getBitmapData("dart");

  var logo = new Sprite();
  logo.addChild(new Bitmap(logoData));
  stage.addChild(logo);

  var tween = renderLoop.juggler.addTween(logo, 3, Transition.easeOutBounce);
// var tween = stage.juggler... works just as well
  tween.animate.y.to(800 / 2);
}

At the bottom, we can use either var tween=stage.juggler or renderLoop.juggler and the code seems to behave the same.  The documentation can point to either way, but my understanding is that renderLoop is a stream, and not a node, and so stage.juggler makes more sense to me.  Is there a difference in use, and are there other instances where one is preferred to another?  Thanks.


问:
Python condensing tuple's to first value
I have a list of tuples that output </p>

```<code>[('city 1', '#' ), ('city 1', '#' ), ('city 2', '#' ), ('city 2', '#'), etc...]
</code>```

<p>What I need to do is to add up all of each city's # value and output a list such that: </p>

```<code>[('city 1', 'sumof#' ), ('city 2', 'sumof#' ), ('city 3', 'sumof#' ), ('city 4', 'sumof#'), etc...]
</code>```

答:
Not sure what you want. May be this?:</p>

```<code>>>> d = [('city 1', 2 ), ('city 1', 1 ), ('city 2', 2 ), ('city 2', 4)]
# Have an empty dictionary to calculate and store result
>>> r = {}
# Iterate through the list
# As the list contains tuples with 2 elements, we can just
# make use of unpacking
>>> for city,count in d:
        # dict.setdefault will try to get the city count, but
        # if not exists (first time) it will return the provided
        # default value; 0 here. Just add up.
        r[city] = r.setdefault(city,0) + count

# items() contains the key-value pair. May be this is the result?
>>> r.items()
[('city 2', 6), ('city 1', 3)]
</code>```

Body:
I have a list of tuples that output

[('city 1', '#' ), ('city 1', '#' ), ('city 2', '#' ), ('city 2', '#'), etc...]

What I need to do is to add up all of each city's # value and output a list such that:

[('city 1', 'sumof#' ), ('city 2', 'sumof#' ), ('city 3', 'sumof#' ), ('city 4', 'sumof#'), etc...]

Body:
Not sure what you want. May be this?:

>>> d = [('city 1', 2 ), ('city 1', 1 ), ('city 2', 2 ), ('city 2', 4)]
# Have an empty dictionary to calculate and store result
>>> r = {}
# Iterate through the list
# As the list contains tuples with 2 elements, we can just
# make use of unpacking
>>> for city,count in d:
        # dict.setdefault will try to get the city count, but
        # if not exists (first time) it will return the provided
        # default value; 0 here. Just add up.
        r[city] = r.setdefault(city,0) + count

# items() contains the key-value pair. May be this is the result?
>>> r.items()
[('city 2', 6), ('city 1', 3)]


问:
how to fetch value based from two table with help of another table using sql
Here is my sql schema:

```<code>Table 1: scan_1             Table 2: scan_2          Table 3: scan_detail

P_no        work            P_no        work           P_no       work_date
 1          YES              1          YES             1         2017/11/03
 2          YES              2          NO              2         2017/12/31
 3          NO               3          NO              3         2017/12/13
</code>```

I want to count P_no from scan_1 and scan_2 where date range is belongs to scan_detail.
I use this query to count P_no from scan_1 and scan_2, but not able to add scan_detail in my query.

```<code>SELECT COUNT(*) AS pick FROM (SELECT P_no, work FROM scan_1 WHERE work = 'YES' UNION SELECT P_no, work FROM scan_2 WHERE work = 'YES') AS total
</code>```

In above query i want to add date range from scan_detail like

```<code>  select count(P_no) from scan_detail where work_date >='2017/11/03' and work_date <= '2017/12/31'
</code>```

答:
You can do a join with your union result set of scan 1 & 2</p>

```<code>SELECT
  COUNT(*) AS pick
FROM scan_detail d
JOIN (SELECT P_no,`work` FROM scan_1 WHERE `work` = 'YES'
      UNION
      SELECT P_no,`work` FROM scan_2 WHERE `work` = 'YES'
  ) AS s  USING(P_no)
WHERE d.work_date >='2017/11/03' AND d.work_date <= '2017/12/31'
</code>```

Body:
Here is my sql schema:

Table 1: scan_1             Table 2: scan_2          Table 3: scan_detail

P_no        work            P_no        work           P_no       work_date
 1          YES              1          YES             1         2017/11/03
 2          YES              2          NO              2         2017/12/31
 3          NO               3          NO              3         2017/12/13

I want to count P_no from scan_1 and scan_2 where date range is belongs to scan_detail.
I use this query to count P_no from scan_1 and scan_2, but not able to add scan_detail in my query.

SELECT COUNT(*) AS pick FROM (SELECT P_no, work FROM scan_1 WHERE work = 'YES' UNION SELECT P_no, work FROM scan_2 WHERE work = 'YES') AS total

In above query i want to add date range from scan_detail like

  select count(P_no) from scan_detail where work_date >='2017/11/03' and work_date <= '2017/12/31'

Body:
You can do a join with your union result set of scan 1 & 2

SELECT
  COUNT(*) AS pick
FROM scan_detail d
JOIN (SELECT P_no,`work` FROM scan_1 WHERE `work` = 'YES'
      UNION
      SELECT P_no,`work` FROM scan_2 WHERE `work` = 'YES'
  ) AS s  USING(P_no)
WHERE d.work_date >='2017/11/03' AND d.work_date <= '2017/12/31'


问:
PHP initialize variable with loop
I want to be able to initialize variable in PHP like in Java

```<code>$x=1;

while($x<10)
{
    $Num$x=$x;
    $x++;
}
</code>```

And yes it does not work, my purpose is to make a function to initialize $result=mysqli_query($X,$y)

Let's say i know there is table ID and Name, and want to initialize as $ID1,$ID2,$Name1,$Name2 and so on according to the table size, i know you can use while($row=mysqli_fetch_array($result))
 loop but i don't see this is a way to do it with $x cannot work as counter.

答:
As mentioned in comments, use an array instead.

Keeping track of X variables will be hard for you later.

Arrays can be foreach looped unlike variables.

```<code>$x=1;

while($x<10)
{
    $arr['num' . $x]=$x;
    $x++; // added this in case you don't like the infinite loop
}
</code>```

This will create an array with keys named 'num1' to 'num9' with value 1-9.

Title: PHP initialize variable with loop

Body:
I want to be able to initialize variable in PHP like in Java

$x=1;

while($x<10)
{
    $Num$x=$x;
    $x++;
}

And yes it does not work, my purpose is to make a function to initialize $result=mysqli_query($X,$y)

Let's say i know there is table ID and Name, and want to initialize as $ID1,$ID2,$Name1,$Name2 and so on according to the table size, i know you can use while($row=mysqli_fetch_array($result))
 loop but i don't see this is a way to do it with $x cannot work as counter.

Body:
As mentioned in comments, use an array instead.

Keeping track of X variables will be hard for you later.

Arrays can be foreach looped unlike variables.

$x=1;

while($x<10)
{
    $arr['num' . $x]=$x;
    $x++; // added this in case you don't like the infinite loop
}

This will create an array with keys named 'num1' to 'num9' with value 1-9.


问:
Java requestFocus() not working at the constructor
In my Java Swing Application Reuestfocus method not working at the Constructor. But it works if I used requestfocus along with button action listener. I want set Requestfocus at the form load. I dont understand whats the wrong here. P.S I use JInternal Frame

```<code>  txtItemName.requestFocusInWindow (); // did not work
  txtItemName.requestFocus ();  // did not work
</code>```

```<code>  public ItemMgt() {

        initComponents();

        SwingUtilities.invokeLater(new Runnable() {
              @Override
              public void run() {
                    txtItemName.requestFocus(); // did not work
              }
        });
  }
</code>```

```<code>  private void formInternalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
        txtItemName.requestFocus(); // did not work.
  }
</code>```

答: If you are using Netbeans IDE, then its much easier. Just make sure that all controls before your textbox are not focusable by unchecking the 'focusable' property in the Properties window. This will leave your textbox as the first focusable control thus allowing it to receive focus when the internal frame is opened</p>

Body:
In my Java Swing Application Reuestfocus method not working at the Constructor. But it works if I used requestfocus along with button action listener. I want set Requestfocus at the form load. I dont understand whats the wrong here. P.S I use JInternal Frame

  txtItemName.requestFocusInWindow (); // did not work
  txtItemName.requestFocus ();  // did not work

  public ItemMgt() {

        initComponents();

        SwingUtilities.invokeLater(new Runnable() {
              @Override
              public void run() {
                    txtItemName.requestFocus(); // did not work
              }
        });
  }

  private void formInternalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
        txtItemName.requestFocus(); // did not work.
  }


问:
Laravel 5.0 is having issue with Predis dependency
While running composer update. I am geting this error list. Kindly suggest me solution as soon as possible.

Problem 1
      - illuminate/support v5.5.2 requires php >=7.0 -> your PHP version (5.5.9) does not satisfy that requirement.
      - illuminate/support v5.5.17 requires php >=7.0 -> your PHP version (5.5.9) does not satisfy that requirement.
      - illuminate/support v5.5.16 requires php >=7.0 -> your PHP version (5.5.9) does not satisfy that requirement.
      - illuminate/support v5.5.0 requires php >=7.0 -> your PHP version (5.5.9) does not satisfy that requirement.
      - illuminate/support v5.4.9 requires php >=5.6.4 -> your PHP version (5.5.9) does not satisfy that requirement.
      - illuminate/support v5.4.36 requires php >=5.6.4 -> your PHP version (5.5.9) does not satisfy that requirement.
      - illuminate/support v5.4.27 requires php >=5.6.4 -> your PHP version (5.5.9) does not satisfy that requirement.
      - illuminate/support v5.4.19 requires php >=5.6.4 -> your PHP version (5.5.9) does not satisfy that requirement.
      - illuminate/support v5.4.17 requires php >=5.6.4 -> your PHP version (5.5.9) does not satisfy that requirement.
      - illuminate/support v5.4.13 requires php >=5.6.4 -> your PHP version (5.5.9) does not satisfy that requirement.
      - illuminate/support v5.4.0 requires php >=5.6.4 -> your PHP version (5.5.9) does not satisfy that requirement.
      - illuminate/support v5.3.4 requires php >=5.6.4 -> your PHP version (5.5.9) does not satisfy that requirement.
      - illuminate/support v5.3.23 requires php >=5.6.4 -> your PHP version (5.5.9) does not satisfy that requirement.
      - illuminate/support v5.3.16 requires php >=5.6.4 -> your PHP version (5.5.9) does not satisfy that requirement.
      - illuminate/support v5.3.0 requires php >=5.6.4 -> your PHP version (5.5.9) does not satisfy that requirement.
      - illuminate/support v5.2.25 requires php >=5.6.4 -> your PHP version (5.5.9) does not satisfy that requirement.
      - Conclusion: remove laravel/framework v5.0.35
      - Conclusion: don't install laravel/framework v5.0.35
      - Conclusion: don't install laravel/framework v5.0.34
      - Conclusion: don't install laravel/framework v5.0.33
      - Conclusion: don't install laravel/framework v5.0.32
      - Conclusion: don't install laravel/framework v5.0.31
      - Conclusion: don't install laravel/framework 5.0.30
      - Conclusion: don't install laravel/framework v5.0.29
      - Conclusion: don't install laravel/framework v5.0.28
      - Conclusion: don't install laravel/framework v5.0.27
      - Conclusion: don't install laravel/framework v5.0.26
      - Conclusion: don't install laravel/framework v5.0.25
      - Conclusion: don't install laravel/framework v5.0.24
      - Conclusion: don't install laravel/framework v5.0.23
      - Conclusion: don't install laravel/framework v5.0.22
      - Conclusion: don't install laravel/framework v5.0.21
      - Conclusion: don't install laravel/framework v5.0.20
      - Conclusion: don't install laravel/framework v5.0.19
      - Conclusion: don't install laravel/framework v5.0.18
      - Conclusion: don't install laravel/framework v5.0.17
      - Conclusion: don't install laravel/framework v5.0.16
      - Conclusion: don't install laravel/framework v5.0.15
      - Conclusion: don't install laravel/framework v5.0.14
      - Conclusion: don't install laravel/framework v5.0.13
      - Conclusion: don't install laravel/framework v5.0.12
      - Conclusion: don't install laravel/framework v5.0.11
      - Conclusion: don't install laravel/framework v5.0.10
      - Conclusion: don't install laravel/framework v5.0.9
      - Conclusion: don't install laravel/framework v5.0.8
      - Conclusion: don't install laravel/framework v5.0.7
      - Conclusion: don't install laravel/framework v5.0.6
      - Conclusion: don't install laravel/framework v5.0.5
      - Conclusion: don't install laravel/framework v5.0.4
      - Conclusion: don't install laravel/framework v5.0.3
      - Conclusion: don't install laravel/framework v5.0.2
      - Conclusion: don't install laravel/framework v5.0.1
      - barryvdh/laravel-debugbar v2.4.0 requires illuminate/support 5.1.|5.2.|5.3.|5.4.|5.5.* -> satisfiable by illuminate/support[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22,
  v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0,
  v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28,
  v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0,
  v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27,
  v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2].
      - barryvdh/laravel-debugbar v2.4.1 requires illuminate/support 5.1.|5.2.|5.3.|5.4.|5.5.* -> satisfiable by illuminate/support[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22,
  v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0,
  v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28,
  v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0,
  v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27,
  v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2].
      - barryvdh/laravel-debugbar v2.4.2 requires illuminate/support 5.1.|5.2.|5.3.|5.4.|5.5.* -> satisfiable by illuminate/support[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22,
  v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0,
  v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28,
  v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0,
  v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27,
  v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2].
      - barryvdh/laravel-debugbar v2.4.3 requires illuminate/support 5.1.|5.2.|5.3.|5.4.|5.5.* -> satisfiable by illuminate/support[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22,
  v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0,
  v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28,
  v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0,
  v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27,
  v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2].
      - don't install illuminate/support v5.1.1|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.1.13|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.1.16|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.1.2|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.1.20|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.1.22|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.1.25|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.1.28|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.1.30|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.1.31|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.1.41|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.1.6|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.1.8|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.2.0|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.2.19|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.2.21|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.2.24|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.2.26|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.2.27|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.2.28|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.2.31|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.2.32|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.2.37|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.2.43|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.2.45|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.2.6|don't install laravel/framework v5.0.0
      - don't install illuminate/support v5.2.7|don't install laravel/framework v5.0.0
      - Installation request for laravel/framework 5.0.* -> satisfiable by laravel/framework[5.0.30, v5.0.0, v5.0.1, v5.0.10, v5.0.11,
  v5.0.12, v5.0.13, v5.0.14, v5.0.15, v5.0.16, v5.0.17, v5.0.18,
  v5.0.19, v5.0.2, v5.0.20, v5.0.21, v5.0.22, v5.0.23, v5.0.24, v5.0.25,
  v5.0.26, v5.0.27, v5.0.28, v5.0.29, v5.0.3, v5.0.31, v5.0.32, v5.0.33,
  v5.0.34, v5.0.35, v5.0.4, v5.0.5, v5.0.6, v5.0.7, v5.0.8, v5.0.9].
      - Installation request for barryvdh/laravel-debugbar ~2.4 -> satisfiable by barryvdh/laravel-debugbar[v2.4.0, v2.4.1, v2.4.2,
  v2.4.3].

答: Because of this line "barryvdh/laravel-debugbar" : "~2.4" in composer.json. I was getting the issue. After removing this issue got resolved.</p>


问:
MS Azure lab missing some information
In Experience D - Working with a Service Map of the official Azure lab titled Introducing Azure Management Solutions they are asking to follow the following steps. But, as shown in the image below, I'm not getting ServiceMap(SWMIAAS-OMS): in the search result. What I may be missing?

In the left menu of Azure Portal: Click on Monitor-->Log Analytics-->Log Search, then:

In the Search resources box near the top of the screen, type servicemap

In the search results, click ServiceMap(SWMIAAS-OMS)

On the ServiceMap(SWMIAAS-OMS) solution blade, click the Service Map tile

In the Machines list on the left, click non-swmiaas-vm1

Screen Shot of Log Search blade [You can click on the image for better readability:

答:
According to your description, I test in my lab.

In the Search resources box near the top of the screen, type
  servicemap

You should do as below:

Title: MS Azure lab missing some information


问:
ASP.NET Core 2.0.3 ClaimsTransformer in combination with HttpContextAccessor, claims are being cleared
In my Asp.Net Core application I want to add custom claims to my ClaimsIdentity so I can access these in different layers of my application. To achieve this I added following code

Startup

```<code>services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
        services.AddTransient<IPrincipal>(
            provider => provider.GetService<IHttpContextAccessor>().HttpContext.User);
        services.AddTransient<IClaimsTransformation, ClaimsTransformer>();
</code>```

ClaimsTransformer

```<code>public class ClaimsTransformer : IClaimsTransformation
{
    private readonly IUnitOfWork _unitOfWork;
    private readonly IPrincipal _principal;
    public ClaimsTransformer(IUnitOfWork unitOfWork, IPrincipal principal)
    {
        _unitOfWork = unitOfWork;
        _principal = principal;
    }
    public Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal)
    {
        var currentPrincipal  = (ClaimsIdentity)_principal.Identity;
        var identity = (ClaimsIdentity)principal.Identity;
        if (currentPrincipal.Claims.All(p => p.Type != "UserId"))
        {
            var person = _unitOfWork.PersonRepository.GetPersonBySubjectId(principal.Claims.First(p => p.Type == "sub").Value);
            person.Wait();
            if (person.Result != null)
            {
                currentPrincipal.AddClaim(new Claim("UserId", person.Result.Id.ToString()));
                currentPrincipal.AddClaim(new Claim("TenantId", person.Result.PersonTeams.FirstOrDefault(p => p.Team.TeamType == TeamType.OrganizationTeam)?.Team.OrganizationId.ToString()));
                if (principal.Claims.Any(p => p.Type == "Admin"))
                {
                    currentPrincipal.AddClaim(new Claim("Admin", "True"));
                }
            }
            foreach (var claim in identity.Claims)
            {
                currentPrincipal.AddClaim(claim);
            }
        }
        return Task.FromResult(principal);
    }
}
</code>```

What I don't understand is, when I run my Claimstransformation and I step through the code, all the needed claims are available, but when I inject my IPrincipal into a custom class, the claims collection is empty, when I don't use the ClaimsTransformation, the claims are available via the injected IPrincipal.

To resolve this issue, I add my IPrincipal to the ClaimsTransformer and duplicate the claims from the TransformAsync input parameter and add the UserId and TenantId.
This works, but the problem I have is that I don't understand why the Claims are being deleted when I run the ClaimsTransformer and why I need to add this hack

答:
I was in the same place.
I had to remove the IPrincipal DI

Startup

```<code>services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddTransient<IClaimsTransformation, ClaimsTransformer>();

services.AddAuthentication(IISDefaults.AuthenticationScheme);

services.AddAuthorization(options =>
        {
            options.AddPolicy("SystemAdminOnly", policy => policy.RequireClaim(ClaimTypes.Role, "SystemAdmin"));
        });
</code>```

ClaimsTransformer

```<code>public ClaimsTransformer(IRepository repository, IHttpContextAccessor httpContextAccessor/*, IPrincipal principal*/, IMemoryCache cache)
    {
        _repository = repository;
        _httpContextAccessor = httpContextAccessor;
       // _principal = principal;
        _cache = cache;
    }

public async Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal)
   {
        if (principal.Identity.IsAuthenticated)
        {
            var currentPrincipal = (ClaimsIdentity)principal.Identity;//_principal.Identity;

            var ci = (ClaimsIdentity)principal.Identity;
            var cacheKey = ci.Name;

            if (_cache.TryGetValue(cacheKey, out List<Claim> claims))
            {
                currentPrincipal.AddClaims(claims);
            }
            else
            {
                claims = new List<Claim>();
                var isUserSystemAdmin = await _repository.IsUserAdmin(ci.Name);
                if (isUserSystemAdmin)
                {
                    var c = new Claim(ClaimTypes.Role, "SystemAdmin");
                    claims.Add(c);
                }

                _cache.Set(cacheKey, claims);
                currentPrincipal.AddClaims(claims);
            }

            //foreach (var claim in ci.Claims)
            //{
            //    currentPrincipal.AddClaim(claim);
            //}
        }

        return await Task.FromResult(principal);
    }
</code>```

And it works!

Body:
In my Asp.Net Core application I want to add custom claims to my ClaimsIdentity so I can access these in different layers of my application. To achieve this I added following code

Startup

services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
        services.AddTransient<IPrincipal>(
            provider => provider.GetService<IHttpContextAccessor>().HttpContext.User);
        services.AddTransient<IClaimsTransformation, ClaimsTransformer>();

ClaimsTransformer

public class ClaimsTransformer : IClaimsTransformation
{
    private readonly IUnitOfWork _unitOfWork;
    private readonly IPrincipal _principal;
    public ClaimsTransformer(IUnitOfWork unitOfWork, IPrincipal principal)
    {
        _unitOfWork = unitOfWork;
        _principal = principal;
    }
    public Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal)
    {
        var currentPrincipal  = (ClaimsIdentity)_principal.Identity;
        var identity = (ClaimsIdentity)principal.Identity;
        if (currentPrincipal.Claims.All(p => p.Type != "UserId"))
        {
            var person = _unitOfWork.PersonRepository.GetPersonBySubjectId(principal.Claims.First(p => p.Type == "sub").Value);
            person.Wait();
            if (person.Result != null)
            {
                currentPrincipal.AddClaim(new Claim("UserId", person.Result.Id.ToString()));
                currentPrincipal.AddClaim(new Claim("TenantId", person.Result.PersonTeams.FirstOrDefault(p => p.Team.TeamType == TeamType.OrganizationTeam)?.Team.OrganizationId.ToString()));
                if (principal.Claims.Any(p => p.Type == "Admin"))
                {
                    currentPrincipal.AddClaim(new Claim("Admin", "True"));
                }
            }
            foreach (var claim in identity.Claims)
            {
                currentPrincipal.AddClaim(claim);
            }
        }
        return Task.FromResult(principal);
    }
}

What I don't understand is, when I run my Claimstransformation and I step through the code, all the needed claims are available, but when I inject my IPrincipal into a custom class, the claims collection is empty, when I don't use the ClaimsTransformation, the claims are available via the injected IPrincipal.

To resolve this issue, I add my IPrincipal to the ClaimsTransformer and duplicate the claims from the TransformAsync input parameter and add the UserId and TenantId.
This works, but the problem I have is that I don't understand why the Claims are being deleted when I run the ClaimsTransformer and why I need to add this hack

Body:
I was in the same place.
I had to remove the IPrincipal DI

Startup

services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddTransient<IClaimsTransformation, ClaimsTransformer>();

services.AddAuthentication(IISDefaults.AuthenticationScheme);

services.AddAuthorization(options =>
        {
            options.AddPolicy("SystemAdminOnly", policy => policy.RequireClaim(ClaimTypes.Role, "SystemAdmin"));
        });

ClaimsTransformer

public ClaimsTransformer(IRepository repository, IHttpContextAccessor httpContextAccessor/*, IPrincipal principal*/, IMemoryCache cache)
    {
        _repository = repository;
        _httpContextAccessor = httpContextAccessor;
       // _principal = principal;
        _cache = cache;
    }

public async Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal)
   {
        if (principal.Identity.IsAuthenticated)
        {
            var currentPrincipal = (ClaimsIdentity)principal.Identity;//_principal.Identity;

            var ci = (ClaimsIdentity)principal.Identity;
            var cacheKey = ci.Name;

            if (_cache.TryGetValue(cacheKey, out List<Claim> claims))
            {
                currentPrincipal.AddClaims(claims);
            }
            else
            {
                claims = new List<Claim>();
                var isUserSystemAdmin = await _repository.IsUserAdmin(ci.Name);
                if (isUserSystemAdmin)
                {
                    var c = new Claim(ClaimTypes.Role, "SystemAdmin");
                    claims.Add(c);
                }

                _cache.Set(cacheKey, claims);
                currentPrincipal.AddClaims(claims);
            }

            //foreach (var claim in ci.Claims)
            //{
            //    currentPrincipal.AddClaim(claim);
            //}
        }

        return await Task.FromResult(principal);
    }

And it works!


问:
How to do POST in FORM Submit using reactjs and pass the object value into REST service?
I have created a login page using reactjs, when I send my user input/password through a post method rest api call to authenticate I am receiving an error. Can somebody help me on whats going wrong here please!!

I guess this is because I am unable to send username and password strings in a json format.

This is the error,

```<code><br />
<b>Notice</b>: Undefined variable: error in <b>/var/www/html/app/Controllers/Hafka/HAFKAController.php</b> on line <b>27</b><br />
<br />
<b>Notice</b>: Undefined variable: id in <b>/var/www/html/app/Controllers/Hafka/HAFKAController.php</b> on line <b>29</b><br />
<br />
<b>Notice</b>: Undefined variable: error in <b>/var/www/html/app/Controllers/Hafka/HAFKAController.php</b> on line <b>29</b><br />
{"code":"INVALID_JSON_INPUT","message":"Error decoding JSON input"}
</code>```

This is my app.js file,

```<code>    import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

export default class App extends Component {

    render() {
        return (
            <div className="App">
                <div className="App-header"></div>
                <form
                    id="main-login"
                    action="http://don.healthedata.com/admin/login"
                    method="post">
                    <h2>
                        Admin UI Login
                    </h2>
                    <label>
                        <span class="text">user:</span>
                        <input type="email" name="email"/><br/>
                    </label>
                    <br/>
                    <label>
                        <span class="text">password:</span>
                        <input type="password" name="password"/><br/>
                    </label><br/>
                    <div class="align-right">
                        <button type="submit">Submit</button>
                    </div>
                </form>

            </div>

        );
    }

}
</code>```

Solution:

Modified and working App.js file:

```<code>import React, {Component} from 'react';
import logo from './logo.svg';
import './App.css';

export default class App extends Component {

    constructor(props, context) {
        super(props, context);

        this.state = { description: '' };
    }

    onChange(e) {
        this.setState({
            [e.target.name]: e.target.value
        });
    }

    onSubmit(e) {
        e.preventDefault();

        fetch(this.props.formAction, {
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({description: this.state.description})
        });

        this.setState({description: ''});
    }

    render() {
        return (
            <div className="App">
                <form
                    id="main-login"
                    action={this.props.action}
                    method={this.props.method}
                    onSubmit={this.onSubmit}>
                    <h2>Admin UI Login</h2>
                    <label>
                        <span class="text">user:</span>
                        <input type="email" name="email"/><br/>
                    </label>
                    <br/>
                    <label>
                        <span class="text">password:</span>
                        <input type="password" name="password"/><br/>
                    </label>
                    <br/>
                    <div class="align-right">
                        <button>Submit</button>
                    </div>
                </form>
            </div>
        );
    }

}

// App.propTypes = { action: React.PropTypes.string.isRequired, method: React.PropTypes.string}
App.defaultProps = {
    action: 'http://don.healthedata.com/admin/login',
    method: 'post'
};

module.exports = App;
</code>```

When I provide user input/password and hit submit, nothing is happening.

答:
First of all fetch the url in which u want to insert data.Here first create todoadd.js file:

```<code> import fetch from 'isomorphic-fetch';

export function createBlogPost(data) {
return fetch('Your Rest url', {
    method: 'POST',
    body: JSON.stringify(data),
    headers: {
        'Content-Type': 'application/json'
    }
}).then(response => {
    if (response.status >= 200 && response.status < 300) {
        return response;
        console.log(response);
        window.location.reload();
      } else {
       console.log('Somthing happened wrong');
      }
}).catch(err => err);
}
</code>```

after that control Your UI submit in tododialouge.js:

```<code> import React, { Component, PropTypes } from 'react'
 import { connect } from 'react-redux'
 import { createBlogPost } from '../../actions/todoadd';
 import { addTodo } from '../../actions/todo'
 import { setTodoDialogOpen, setErrorText } from '../../actions/todoDialog';
 import Dialog from 'material-ui/Dialog';
 import FlatButton from 'material-ui/FlatButton';
 import RaisedButton from 'material-ui/RaisedButton';
 import TextField from 'material-ui/TextField';

const initialstate = {
title: '',
desc: '',
type: '',
imageurl: ''
}

class TodoDialog extends Component {
constructor(props) {
    super(props)
    this.state = initialstate;
    this.onChange = this.onChange.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
};

onChange(e) {
    if (e.target.id === 'title') {
        this.setState({ title: e.target.value });
    } else if (e.target.id === 'desc') {
        this.setState({ desc: e.target.value });
    } else if (e.target.id === 'type') {
        this.setState({ type: e.target.value });
    } else if (e.target.id === 'image') {
        this.setState({ imageurl: e.target.value});
        console.log(e.target.value);
    }
}

handleSubmit() {
    const text = {
        news_title: this.state.title,
        news_description: this.state.desc,
        news_type: this.state.type,
        news_src_url: this.state.imageurl,
        operation:"insert"
    }
    alert(text.news_src_url);
    createBlogPost(text);
    setErrorText(undefined);
    setTodoDialogOpen(false);

};

render() {
    const { messages, todoDialog, setTodoDialogOpen, addTodo, setErrorText } = this.props;
    const styles = {
        button: {
            margin: 12,
        },
        exampleImageInput: {
            cursor: 'pointer',
            position: 'absolute',
            top: 0,
            bottom: 0,
            right: 0,
            left: 0,
            width: '100%',
            opacity: 0,
        },
    };

    function handleClose() {
        setErrorText(undefined);
        setTodoDialogOpen(false);
    };

    const actions = [< FlatButton label={
        messages.cancel || 'cancel'
    }
        primary={
            true
        }
        onTouchTap={
            handleClose
        } />, < FlatButton label={
            messages.submit || 'submit'
        }
            primary={
                true
            }
            onTouchTap={this.handleSubmit} />
    ];

    return (
        <div>
            <Dialog title={messages.todo_add || 'todo_add'} actions={actions} modal={false} open={todoDialog.open} onRequestClose={handleClose}>
                <form>
                    <TextField ref="todoText1" onChange={this.onChange} id='title' hintText={messages.todo_hint1 || 'todo_hint'} errorText={todoDialog.errorText} floatingLabelText={messages.todo_label1 || 'todo_label1'} fullWidth={true} />
                    <TextField ref="todoText2" onChange={this.onChange} id='desc' hintText={messages.todo_hint2 || 'todo_hint'} errorText={todoDialog.errorText} floatingLabelText={messages.todo_label2 || 'todo_label2'} fullWidth={true} multiLine={true} rows={1} rowsMax={3} />
                    <TextField ref="todoText3" onChange={this.onChange} id='type' hintText={messages.todo_hint3 || 'todo_hint'} errorText={todoDialog.errorText} floatingLabelText={messages.todo_label3 || 'todo_label3'} fullWidth={true} />
                    <RaisedButton label='ADD Photo' style={styles.button} labelPosition="before" containerElement="label"><input type='file' onChange={this.onChange} id='image' style={styles.exampleImageInput} /></RaisedButton>
                </form>
            </Dialog>
        </div>
    )
}
}
</code>```

some other file u handle as Your requirment.
I hope this one is helpful for You.

Body:
I have created a login page using reactjs, when I send my user input/password through a post method rest api call to authenticate I am receiving an error. Can somebody help me on whats going wrong here please!!

I guess this is because I am unable to send username and password strings in a json format.

This is the error,

Notice: Undefined variable: error in /var/www/html/app/Controllers/Hafka/HAFKAController.php on line 27

Notice: Undefined variable: id in /var/www/html/app/Controllers/Hafka/HAFKAController.php on line 29

Notice: Undefined variable: error in /var/www/html/app/Controllers/Hafka/HAFKAController.php on line 29

{"code":"INVALID_JSON_INPUT","message":"Error decoding JSON input"}

This is my app.js file,

    import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

export default class App extends Component {

    render() {
        return (

                <form
                    id="main-login"
                    action="http://don.healthedata.com/admin/login"
                    method="post">

                        Admin UI Login

                        user:
                        <input type="email" name="email"/>

                        password:
                        <input type="password" name="password"/>

                        <button type="submit">Submit</button>

                </form>

        );
    }

}

Solution:

Modified and working App.js file:

import React, {Component} from 'react';
import logo from './logo.svg';
import './App.css';

export default class App extends Component {

    constructor(props, context) {
        super(props, context);

        this.state = { description: '' };
    }

    onChange(e) {
        this.setState({
            [e.target.name]: e.target.value
        });
    }

    onSubmit(e) {
        e.preventDefault();

        fetch(this.props.formAction, {
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({description: this.state.description})
        });

        this.setState({description: ''});
    }

    render() {
        return (

                <form
                    id="main-login"
                    action={this.props.action}
                    method={this.props.method}
                    onSubmit={this.onSubmit}>

Admin UI Login

                        user:
                        <input type="email" name="email"/>

                        password:
                        <input type="password" name="password"/>

                        <button>Submit</button>

                </form>

        );
    }

}

// App.propTypes = { action: React.PropTypes.string.isRequired, method: React.PropTypes.string}
App.defaultProps = {
    action: 'http://don.healthedata.com/admin/login',
    method: 'post'
};

module.exports = App;

When I provide user input/password and hit submit, nothing is happening.

Body:
First of all fetch the url in which u want to insert data.Here first create todoadd.js file:

 import fetch from 'isomorphic-fetch';

export function createBlogPost(data) {
return fetch('Your Rest url', {
    method: 'POST',
    body: JSON.stringify(data),
    headers: {
        'Content-Type': 'application/json'
    }
}).then(response => {
    if (response.status >= 200 && response.status < 300) {
        return response;
        console.log(response);
        window.location.reload();
      } else {
       console.log('Somthing happened wrong');
      }
}).catch(err => err);
}

after that control Your UI submit in tododialouge.js:

 import React, { Component, PropTypes } from 'react'
 import { connect } from 'react-redux'
 import { createBlogPost } from '../../actions/todoadd';
 import { addTodo } from '../../actions/todo'
 import { setTodoDialogOpen, setErrorText } from '../../actions/todoDialog';
 import Dialog from 'material-ui/Dialog';
 import FlatButton from 'material-ui/FlatButton';
 import RaisedButton from 'material-ui/RaisedButton';
 import TextField from 'material-ui/TextField';

const initialstate = {
title: '',
desc: '',
type: '',
imageurl: ''
}

class TodoDialog extends Component {
constructor(props) {
    super(props)
    this.state = initialstate;
    this.onChange = this.onChange.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
};

onChange(e) {
    if (e.target.id === 'title') {
        this.setState({ title: e.target.value });
    } else if (e.target.id === 'desc') {
        this.setState({ desc: e.target.value });
    } else if (e.target.id === 'type') {
        this.setState({ type: e.target.value });
    } else if (e.target.id === 'image') {
        this.setState({ imageurl: e.target.value});
        console.log(e.target.value);
    }
}

handleSubmit() {
    const text = {
        news_title: this.state.title,
        news_description: this.state.desc,
        news_type: this.state.type,
        news_src_url: this.state.imageurl,
        operation:"insert"
    }
    alert(text.news_src_url);
    createBlogPost(text);
    setErrorText(undefined);
    setTodoDialogOpen(false);

};

render() {
    const { messages, todoDialog, setTodoDialogOpen, addTodo, setErrorText } = this.props;
    const styles = {
        button: {
            margin: 12,
        },
        exampleImageInput: {
            cursor: 'pointer',
            position: 'absolute',
            top: 0,
            bottom: 0,
            right: 0,
            left: 0,
            width: '100%',
            opacity: 0,
        },
    };

    function handleClose() {
        setErrorText(undefined);
        setTodoDialogOpen(false);
    };

    const actions = [< FlatButton label={
        messages.cancel || 'cancel'
    }
        primary={
            true
        }
        onTouchTap={
            handleClose
        } />, < FlatButton label={
            messages.submit || 'submit'
        }
            primary={
                true
            }
            onTouchTap={this.handleSubmit} />
    ];

    return (
        <div>
            <Dialog title={messages.todo_add || 'todo_add'} actions={actions} modal={false} open={todoDialog.open} onRequestClose={handleClose}>
                <form>
                    <TextField ref="todoText1" onChange={this.onChange} id='title' hintText={messages.todo_hint1 || 'todo_hint'} errorText={todoDialog.errorText} floatingLabelText={messages.todo_label1 || 'todo_label1'} fullWidth={true} />
                    <TextField ref="todoText2" onChange={this.onChange} id='desc' hintText={messages.todo_hint2 || 'todo_hint'} errorText={todoDialog.errorText} floatingLabelText={messages.todo_label2 || 'todo_label2'} fullWidth={true} multiLine={true} rows={1} rowsMax={3} />
                    <TextField ref="todoText3" onChange={this.onChange} id='type' hintText={messages.todo_hint3 || 'todo_hint'} errorText={todoDialog.errorText} floatingLabelText={messages.todo_label3 || 'todo_label3'} fullWidth={true} />
                    <RaisedButton label='ADD Photo' style={styles.button} labelPosition="before" containerElement="label"><input type='file' onChange={this.onChange} id='image' style={styles.exampleImageInput} /></RaisedButton>
                </form>
            </Dialog>
        </div>
    )
}
}

some other file u handle as Your requirment.
I hope this one is helpful for You.


问:
How should I use mysql_query?
I'm having some problems with this function in the next code:

```<code>if(!($_SESSION['autenticado']))
    if($_POST["user"] && $_POST["pass"])
    {
        $user=$_POST["user"];
        $con=mysql_connect("localhost","root","3270");

            mysql_select_db("futbol",$con);
            $query = "SELECT us_pass FROM user WHERE us_nom = '$user'";
            print_r($query);
            mysql_real_escape_string($query);
            mysql_query($query)or die mysql_error();
            //print_r($pas);
            //$_SESSION["autenticado"]=1;
     }
</code>```

Am I using it wrowng?

答:
Based on your comments to the other answers: You are sending your form using POST and not GET right?

The only reasons that you're not seeing anything are your if conditions not being met, a problem connecting to the database or an error in your php (with errors suppressed); the script does not reach your print_r statement.

I´m not sure, but you also might want to use {} for your first if statement and clean-up your code a bit: I'd recommend isset() instead of just feeding strings to if statements.

And check your error log.

ContentLicense: CC BY-SA 2.5

Title: How should I use mysql_query?

Body:
I'm having some problems with this function in the next code:

if(!($_SESSION['autenticado']))
    if($_POST["user"] && $_POST["pass"])
    {
        $user=$_POST["user"];
        $con=mysql_connect("localhost","root","3270");

            mysql_select_db("futbol",$con);
            $query = "SELECT us_pass FROM user WHERE us_nom = '$user'";
            print_r($query);
            mysql_real_escape_string($query);
            mysql_query($query)or die mysql_error();
            //print_r($pas);
            //$_SESSION["autenticado"]=1;
     }

Am I using it wrowng?


问:
images wont line up and the text wont go under the img
I am trying to get some images to line up in my content box, but they wont go side by side. Instead they go on each their line. The text are also supposed to go under the image and not to the right of it. Can anyone see the reason why?

I also need to find a way to get them lined up horizontally even if the text under the image are in different lengths up to 30 characters.

Fiddle link: https://fiddle.jshell.net/jkyq9y0u/

```<code><div id="content_box">
  <div id="img">
    <a href="link" class="style_title" target="_blank">
      <div id="image_id" class="image_box">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>
    </a>
    <a href="link" class="style_title" target="_blank">
      <div id="image_id" class="image_box">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>
    </a>
    <a href="link" class="style_title" target="_blank">
      <div id="image_id" class="image_box">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>
    </a>
    <a href="link" class="style_title" target="_blank">
      <div id="image_id" class="image_box">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>
    </a>
    <a href="link" class="style_title" target="_blank">
      <div id="image_id" class="image_box">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>
    </a>
    <a href="link" class="style_title" target="_blank">
      <div id="image_id" class="image_box">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>
    </a>
  </div>
</div>

#content_box {
  background-color: #ffffff;
  min-width: 100%;
  min-height: 75vh;
  text-align: center;
  overflow-y: auto;
  display: inline-block;
}

/* styling for the movie images and titles */

#img {
  min-height: 100%;
  max-width: 60%;
  display: inline-block;
}

.image_box {
  min-width: 100%;
  min-height: 100%;
  display: inline-block;
}

.movie_img {
  max-width: 20%;
  height: auto;
  border-radius: 10px;
  display: inline-block;
}

.title {
  min-height: 100px;
  max-width: 100%;
  margin-bottom: 100px;
  display: inline-block;
}
</code>```

答:
You need to make the style_title tag your container that defines the rest of it's content. By making it inline-block and styling the inner elements appropriatedly you will get what you need.

#content_box {
  background-color: #ffffff;
  min-width: 100%;
  min-height: 75vh;
  text-align: center;
  overflow-y: auto;
  display: inline-block;
}

/* styling for the movie images and titles */

#img {
  /*max-width: 60%;
  display: inline-block;*/
}

.image_box {
  display: inline-block;
  width:30%;
}

.style_title
{
  display:inline-block;
}

.movie_img {
  height: auto;
  border-radius: 10px;
  display: inline-block;
}

.title {
  min-height: 100px;
  max-width: 100%;
  margin-bottom: 100px;
  display: block;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="content">
  <div id="img">

      <div  class="image_box image_id">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>

      <div class="image_box image_id">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>

      <div class="image_box image_id">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>

      <div  class="image_box image_id">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>

      <div  class="image_box image_id">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>

      <div id="image_id" class="image_box">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>

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

Body:
I am trying to get some images to line up in my content box, but they wont go side by side. Instead they go on each their line. The text are also supposed to go under the image and not to the right of it. Can anyone see the reason why?

I also need to find a way to get them lined up horizontally even if the text under the image are in different lengths up to 30 characters.

Fiddle link: https://fiddle.jshell.net/jkyq9y0u/

The Disaster Artist (2017)

The Disaster Artist (2017)

The Disaster Artist (2017)

The Disaster Artist (2017)

The Disaster Artist (2017)

The Disaster Artist (2017)

#content_box {
  background-color: #ffffff;
  min-width: 100%;
  min-height: 75vh;
  text-align: center;
  overflow-y: auto;
  display: inline-block;
}

/* styling for the movie images and titles */

#img {
  min-height: 100%;
  max-width: 60%;
  display: inline-block;
}

.image_box {
  min-width: 100%;
  min-height: 100%;
  display: inline-block;
}

.movie_img {
  max-width: 20%;
  height: auto;
  border-radius: 10px;
  display: inline-block;
}

.title {
  min-height: 100px;
  max-width: 100%;
  margin-bottom: 100px;
  display: inline-block;
}

Body:
You need to make the style_title tag your container that defines the rest of it's content. By making it inline-block and styling the inner elements appropriatedly you will get what you need.

#content_box {
  background-color: #ffffff;
  min-width: 100%;
  min-height: 75vh;
  text-align: center;
  overflow-y: auto;
  display: inline-block;
}

/* styling for the movie images and titles */

#img {
  /*max-width: 60%;
  display: inline-block;*/
}

.image_box {
  display: inline-block;
  width:30%;
}

.style_title
{
  display:inline-block;
}

.movie_img {
  height: auto;
  border-radius: 10px;
  display: inline-block;
}

.title {
  min-height: 100px;
  max-width: 100%;
  margin-bottom: 100px;
  display: block;
}

<div id="content">
  <div id="img">
    <a href="link" class="style_title" target="_blank">
      <div  class="image_box image_id">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>
    </a>
    <a href="link" class="style_title" target="_blank">
      <div class="image_box image_id">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>
    </a>
    <a href="link" class="style_title" target="_blank">
      <div class="image_box image_id">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>
    </a>
    <a href="link" class="style_title" target="_blank">
      <div  class="image_box image_id">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>
    </a>
    <a href="link" class="style_title" target="_blank">
      <div  class="image_box image_id">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>
    </a>
    <a href="link" class="style_title" target="_blank">
      <div id="image_id" class="image_box">
        <img class="movie_img" src="https://images-na.ssl-images-amazon.com/images/M/MV5BOGNkMzliMGMtMDI5Ni00OTZkLTgyMTYtNzk5ZTY1NjVhYjVmXkEyXkFqcGdeQXVyNTAzMTY4MDA@._V1_UY209_CR0,0,140,209_AL_.jpg">
      </div>
      <div class="title">The Disaster Artist (2017)</div>
    </a>
  </div>
</div>