问:
ArrayList<Integer> table in data base
i have this code and i want  store my table ArrayList in my database

my code

```<code>public class globaleCollab {

public static void main(String[] args) throws ClassNotFoundException {
    long startTime = System.currentTimeMillis();
    System.out.println(" les rating  :  ");
    String idoperateur = "00000006092";//operateur cible njibh m session

    sort1 sor = new sort1();
    ArrayList<Integer> table = sor.tri();
    String resultat_final = null;
    for (int i = 0; i < table.size(); i++) {

        resultat_final = resultat_final + "," + table.get(i).toString();

    }

    System.out.println(table);
    System.out.println("-------" + resultat_final);
    //insrt id user, resultat_final, temps d'exe, k ,
    long stopTime = System.currentTimeMillis();
    long elapsedTime = stopTime - startTime;

    System.out.println("l temps est " + elapsedTime + "ms");
    Connection con = null;
    PreparedStatement ps;
    ResultSet rs;
    String query;
    try {

        Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection("jdbc:mysql://localhost:3306/bd_recommandation", "root", "");

        query = "insert into statistic (idoperateur,id) values(?,?)";
        ps = con.prepareStatement(query);
        ps.setString(1, idoperateur);
         ps.setString(2, resultat_final);
        //ps.setInt(3, k);
        //ps.setLong(4, elapsedTime);
        // ps.setString(2, resultat_final);
        System.out.println("000000000000000000000000000");
        ps.executeUpdate();

    } catch (Exception e) {

    }

}
</code>```

but it did not work

答: If you know the max size of the array before hand refer to: this page of the JDBC documentation. However, if the size of the array is unknown I would recommend creating a new table where each row is an index and has one column that holds the integer. </p>

Title: ArrayList<Integer> table in data base

Body:
i have this code and i want  store my table ArrayList in my database

my code

public class globaleCollab {

public static void main(String[] args) throws ClassNotFoundException {
    long startTime = System.currentTimeMillis();
    System.out.println(" les rating  :  ");
    String idoperateur = "00000006092";//operateur cible njibh m session

    sort1 sor = new sort1();
    ArrayList<Integer> table = sor.tri();
    String resultat_final = null;
    for (int i = 0; i < table.size(); i++) {

        resultat_final = resultat_final + "," + table.get(i).toString();

    }

    System.out.println(table);
    System.out.println("-------" + resultat_final);
    //insrt id user, resultat_final, temps d'exe, k ,
    long stopTime = System.currentTimeMillis();
    long elapsedTime = stopTime - startTime;

    System.out.println("l temps est " + elapsedTime + "ms");
    Connection con = null;
    PreparedStatement ps;
    ResultSet rs;
    String query;
    try {

        Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection("jdbc:mysql://localhost:3306/bd_recommandation", "root", "");

        query = "insert into statistic (idoperateur,id) values(?,?)";
        ps = con.prepareStatement(query);
        ps.setString(1, idoperateur);
         ps.setString(2, resultat_final);
        //ps.setInt(3, k);
        //ps.setLong(4, elapsedTime);
        // ps.setString(2, resultat_final);
        System.out.println("000000000000000000000000000");
        ps.executeUpdate();

    } catch (Exception e) {

    }

}

but it did not work


来源: stackexchange

问:
How to design a model to store dynamic field ResponseBody
When specifying a certain period, we prepare a Web API that returns data for each date in that period.

Specifically, POST

```<code>{"targetFrom": "2016-04-01", "targetTo": "2016-04-03"}}
</code>```

The following JSON data is returned.

```<code>{
    "meta": {
        "StartTime": "2017-06-01T06:50:28.001344102Z",
        "execute_time": 7532.0517,
        "host": "----",
        "rid": ""
    },
    "result": {
        "2016-04-01": {
            "0:num": 121,
            "0:price": 5244614,
            "1:num": 124,
            "1:price": 6324547,
            "2:num": 115,
            "2:price": 5604491
        },
        "2016-04-02": {
            "0:num": 125,
            "0:price": 6321222,
            "1:num": 117,
            "1:price": 5835030,
            "2:num": 118,
            "2:price": 5771826
        },
        "2016-04-03": {
            "0:num": 118,
            "0:price": 5486071,
            "1:num": 131,
            "1:price": 6563447,
            "2:num": 111,
            "2:price": 5740078
        },
        "subTotal": {
            "total_2016-04-01_num": 360,
            "total_2016-04-01_price": 17173652,
            "total_2016-04-02_num": 360,
            "total_2016-04-02_price": 17928078,
            "total_2016-04-03_num": 360,
            "total_2016-04-03_price": 17789596
            },
        "total": {
            "num": 1080,
            "price": 52891326
        }
    }
}
</code>```

The problem is the part of the date field like "2016-04-01".
I would like to accept this on the application side of SpringBoot, consider processing modifications, and want to define an appropriate model.
However, I can not find a good method.

First of all, I considered the following as the foolish way.

```<code>@JsonProperty("2016-04-01")
private ResAnalyzeResultDayDto result_20160401;
</code>```

This is stupid because it can not correspond to returned data that depends on the parameter targetFrom or targetTo at the time of inquiry.

So, how can we define a model to handle Response data with Field that dynamically changes according to request?
If you have a good idea, please let me know.

Additional notes:
I did not get along well as I wrote the following code.

```<code>@JsonProperty("[0-9]{4}-[0-9]{2}-[0-9]{2}")
private Map<String,ResAnalyzeResultSubTotalDayDto> maps;
</code>```

In the first place, "@ JsonProperty" seems not to be able to use regular expressions, and I do not think that it will automatically set the key of map.

The code of the request part uses "RestTemplate".

```<code>ReqTotalSalesStatusDto reqGoMonth = new ReqTotalSalesStatusDto();
reqGoMonth.setStrTo("2016-04-03");
reqGoMonth.setStrFrom("2016-04-01");

// Jackson2HttpMessage
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());

ResponseEntity<ResAnalyzeDto> resultGoMonth = restTemplate.exchange(
    "http://localhost:18000/analyze"
    , HttpMethod.POST
    , new HttpEntity<>(reqGoMonth)
    , ResAnalyzeDto.class);
</code>```

答:
Model

```<code>@Data
public class ResAnalyzeResultDayDto  {

@JsonProperty("0:num")
private int num0;

@JsonProperty("0:price")
private int price0;

@JsonProperty("1:num")
private int num1;

@JsonProperty("1:price")
private int price1;

@JsonProperty("2:num")
private int num2;

@JsonProperty("2:price")
private int price2;
}
</code>```

code

```<code>private ResponseEntity<TotalSalesStatus> createFinalResultObj3(TotalSalesStatus resultObj,
        List<ResponseEntity<ResAnalyzeDto3>> goResponseEntityList ,String disposalDate) {

    String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
    this.logger.info("■■UT:[{}] ", methodName);

    int sumTotalNum = 0;
    int sumTotalPrice = 0;

    TotalSalesStatusGrandson totalSalesStatusDay = new TotalSalesStatusGrandson();
    resultObj.setTotalSalesStatusDay(totalSalesStatusDay);

    TotalSalesStatusGrandson totalSalesStatusMonth = new TotalSalesStatusGrandson();
    resultObj.setTotalSalesStatusMonth(totalSalesStatusMonth);

    boolean targetMonthFlag = false;
    for(ResponseEntity<ResAnalyzeDto3> e : goResponseEntityList){
        ResAnalyzeDto3 dto = e.getBody();
        ResAnalyzeMetaDto meta = dto.getMeta();
        Map<String,Map<String,?>> resu = dto.getResult();
        this.logger.info("■■UT:[{}] ResAnalyzeMetaDto  :{}", methodName,meta.toString());
        this.logger.info("■■UT:[{}] ResAnalyzeResultDto:{}", methodName,resu.toString());
            resu.forEach((k,v)->{
                System.out.println("key: " + k + " value: " + v);
                System.out.println("v.toString(): " + v.toString());
                String val = v.toString();
                ObjectMapper mapper = new ObjectMapper();
                if("total".equals(k)){
//                        ResAnalyzeResultTotalDto total = (ResAnalyzeResultTotalDto) v;
                    try {
                        ResAnalyzeResultTotalDto total = mapper.readValue(val,ResAnalyzeResultTotalDto.class);
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }
                } else if("subTotal".equals(k)) {
//                        ResAnalyzeResultSubTotalDto subTotal = (ResAnalyzeResultSubTotalDto) v;
                    try {
                        ResAnalyzeResultSubTotalDto subTotal = mapper.readValue(val,ResAnalyzeResultSubTotalDto.class);
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }
                } else {
//                        ResAnalyzeResultDayDto resAnalyzeResultDayDto = (ResAnalyzeResultDayDto) v;
                    try {
                        ResAnalyzeResultDayDto resAnalyzeResultDayDto = mapper.readValue(val,ResAnalyzeResultDayDto.class);
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }
                }
            });
    }
    TotalSalesStatusGrandson totalSalesStatusYear = new TotalSalesStatusGrandson();
    totalSalesStatusYear.setTotal(new BigDecimal(sumTotalPrice));
    resultObj.setTotalSalesStatusYear(totalSalesStatusYear);
    resultObj.setUnitLabel("sample");
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    ResponseEntity<TotalSalesStatus> result = new ResponseEntity<TotalSalesStatus>(resultObj, headers, HttpStatus.CREATED);
    return result;
}
</code>```

log

```<code>2017-06-05 13:33:48.382 [maekawa-PC-http-nio-9999-exec-1]   INFO  SAMPLE:[id: tenant_id:] j.c.b.b.m.r.a.TotalSalesStatusCommandService ■■UT:[createFinalResultObj3]
2017-06-05 13:33:48.382 [maekawa-PC-http-nio-9999-exec-1]   INFO  SAMPLE:[id: tenant_id:] j.c.b.b.m.r.a.TotalSalesStatusCommandService ■■UT:[createFinalResultObj3] ResAnalyzeMetaDto  :ResAnalyzeMetaDto(startTime=2017-06-05T04:33:48.499791734Z, executeTime=2.1928, host=bb8bfd9acf04, rid=)
2017-06-05 13:33:48.382 [maekawa-PC-http-nio-9999-exec-1]   INFO  SAMPLE:[id: tenant_id:] j.c.b.b.m.r.a.TotalSalesStatusCommandService ■■UT:[createFinalResultObj3] ResAnalyzeResultDto:{2016-04-01={0:num=121, 0:price=5244614, 1:num=124, 1:price=6324547, 2:num=115, 2:price=5604491}, 2016-04-02={0:num=125, 0:price=6321222, 1:num=117, 1:price=5835030, 2:num=118, 2:price=5771826}, 2016-04-03={0:num=118, 0:price=5486071, 1:num=131, 1:price=6563447, 2:num=111, 2:price=5740078}, subTotal={total_2016-04-01_num=360, total_2016-04-01_price=17173652, total_2016-04-02_num=360, total_2016-04-02_price=17928078, total_2016-04-03_num=360, total_2016-04-03_price=17789596}, total={num=1080, price=52891326}}
key: 2016-04-01 value: {0:num=121, 0:price=5244614, 1:num=124, 1:price=6324547, 2:num=115, 2:price=5604491}
v.toString(): {0:num=121, 0:price=5244614, 1:num=124, 1:price=6324547, 2:num=115, 2:price=5604491}
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('0' (code 48)): was expecting double-quote to start field name
 at [Source: {0:num=121, 0:price=5244614, 1:num=124, 1:price=6324547, 2:num=115, 2:price=5604491}; line: 1, column: 3]
    at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702)
    at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:558)
    at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:456)
    at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddName(ReaderBasedJsonParser.java:1771)
    at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:684)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2842)
    at jp.co.temp.sample.management.report.api.TotalSalesStatusCommandService.lambda$createFinalResultObj3$3(TotalSalesStatusCommandService.java:636)
    at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
</code>```

ContentLicense: CC BY-SA 4.0

Body:
When specifying a certain period, we prepare a Web API that returns data for each date in that period.

Specifically, POST

{"targetFrom": "2016-04-01", "targetTo": "2016-04-03"}}

The following JSON data is returned.

{
    "meta": {
        "StartTime": "2017-06-01T06:50:28.001344102Z",
        "execute_time": 7532.0517,
        "host": "----",
        "rid": ""
    },
    "result": {
        "2016-04-01": {
            "0:num": 121,
            "0:price": 5244614,
            "1:num": 124,
            "1:price": 6324547,
            "2:num": 115,
            "2:price": 5604491
        },
        "2016-04-02": {
            "0:num": 125,
            "0:price": 6321222,
            "1:num": 117,
            "1:price": 5835030,
            "2:num": 118,
            "2:price": 5771826
        },
        "2016-04-03": {
            "0:num": 118,
            "0:price": 5486071,
            "1:num": 131,
            "1:price": 6563447,
            "2:num": 111,
            "2:price": 5740078
        },
        "subTotal": {
            "total_2016-04-01_num": 360,
            "total_2016-04-01_price": 17173652,
            "total_2016-04-02_num": 360,
            "total_2016-04-02_price": 17928078,
            "total_2016-04-03_num": 360,
            "total_2016-04-03_price": 17789596
            },
        "total": {
            "num": 1080,
            "price": 52891326
        }
    }
}

The problem is the part of the date field like "2016-04-01".
I would like to accept this on the application side of SpringBoot, consider processing modifications, and want to define an appropriate model.
However, I can not find a good method.

First of all, I considered the following as the foolish way.

@JsonProperty("2016-04-01")
private ResAnalyzeResultDayDto result_20160401;

This is stupid because it can not correspond to returned data that depends on the parameter targetFrom or targetTo at the time of inquiry.

So, how can we define a model to handle Response data with Field that dynamically changes according to request?
If you have a good idea, please let me know.

Additional notes:
I did not get along well as I wrote the following code.

@JsonProperty("[0-9]{4}-[0-9]{2}-[0-9]{2}")
private Map<String,ResAnalyzeResultSubTotalDayDto> maps;

In the first place, "@ JsonProperty" seems not to be able to use regular expressions, and I do not think that it will automatically set the key of map.

The code of the request part uses "RestTemplate".

ReqTotalSalesStatusDto reqGoMonth = new ReqTotalSalesStatusDto();
reqGoMonth.setStrTo("2016-04-03");
reqGoMonth.setStrFrom("2016-04-01");

// Jackson2HttpMessage
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());

ResponseEntity<ResAnalyzeDto> resultGoMonth = restTemplate.exchange(
    "http://localhost:18000/analyze"
    , HttpMethod.POST
    , new HttpEntity<>(reqGoMonth)
    , ResAnalyzeDto.class);

Body:
Model

@Data
public class ResAnalyzeResultDayDto  {

@JsonProperty("0:num")
private int num0;

@JsonProperty("0:price")
private int price0;

@JsonProperty("1:num")
private int num1;

@JsonProperty("1:price")
private int price1;

@JsonProperty("2:num")
private int num2;

@JsonProperty("2:price")
private int price2;
}

code

private ResponseEntity<TotalSalesStatus> createFinalResultObj3(TotalSalesStatus resultObj,
        List<ResponseEntity<ResAnalyzeDto3>> goResponseEntityList ,String disposalDate) {

    String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
    this.logger.info("■■UT:[{}] ", methodName);

    int sumTotalNum = 0;
    int sumTotalPrice = 0;

    TotalSalesStatusGrandson totalSalesStatusDay = new TotalSalesStatusGrandson();
    resultObj.setTotalSalesStatusDay(totalSalesStatusDay);

    TotalSalesStatusGrandson totalSalesStatusMonth = new TotalSalesStatusGrandson();
    resultObj.setTotalSalesStatusMonth(totalSalesStatusMonth);

    boolean targetMonthFlag = false;
    for(ResponseEntity<ResAnalyzeDto3> e : goResponseEntityList){
        ResAnalyzeDto3 dto = e.getBody();
        ResAnalyzeMetaDto meta = dto.getMeta();
        Map<String,Map<String,?>> resu = dto.getResult();
        this.logger.info("■■UT:[{}] ResAnalyzeMetaDto  :{}", methodName,meta.toString());
        this.logger.info("■■UT:[{}] ResAnalyzeResultDto:{}", methodName,resu.toString());
            resu.forEach((k,v)->{
                System.out.println("key: " + k + " value: " + v);
                System.out.println("v.toString(): " + v.toString());
                String val = v.toString();
                ObjectMapper mapper = new ObjectMapper();
                if("total".equals(k)){
//                        ResAnalyzeResultTotalDto total = (ResAnalyzeResultTotalDto) v;
                    try {
                        ResAnalyzeResultTotalDto total = mapper.readValue(val,ResAnalyzeResultTotalDto.class);
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }
                } else if("subTotal".equals(k)) {
//                        ResAnalyzeResultSubTotalDto subTotal = (ResAnalyzeResultSubTotalDto) v;
                    try {
                        ResAnalyzeResultSubTotalDto subTotal = mapper.readValue(val,ResAnalyzeResultSubTotalDto.class);
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }
                } else {
//                        ResAnalyzeResultDayDto resAnalyzeResultDayDto = (ResAnalyzeResultDayDto) v;
                    try {
                        ResAnalyzeResultDayDto resAnalyzeResultDayDto = mapper.readValue(val,ResAnalyzeResultDayDto.class);
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }
                }
            });
    }
    TotalSalesStatusGrandson totalSalesStatusYear = new TotalSalesStatusGrandson();
    totalSalesStatusYear.setTotal(new BigDecimal(sumTotalPrice));
    resultObj.setTotalSalesStatusYear(totalSalesStatusYear);
    resultObj.setUnitLabel("sample");
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    ResponseEntity<TotalSalesStatus> result = new ResponseEntity<TotalSalesStatus>(resultObj, headers, HttpStatus.CREATED);
    return result;
}

log

2017-06-05 13:33:48.382 [maekawa-PC-http-nio-9999-exec-1]   INFO  SAMPLE:[id: tenant_id:] j.c.b.b.m.r.a.TotalSalesStatusCommandService ■■UT:[createFinalResultObj3]
2017-06-05 13:33:48.382 [maekawa-PC-http-nio-9999-exec-1]   INFO  SAMPLE:[id: tenant_id:] j.c.b.b.m.r.a.TotalSalesStatusCommandService ■■UT:[createFinalResultObj3] ResAnalyzeMetaDto  :ResAnalyzeMetaDto(startTime=2017-06-05T04:33:48.499791734Z, executeTime=2.1928, host=bb8bfd9acf04, rid=)
2017-06-05 13:33:48.382 [maekawa-PC-http-nio-9999-exec-1]   INFO  SAMPLE:[id: tenant_id:] j.c.b.b.m.r.a.TotalSalesStatusCommandService ■■UT:[createFinalResultObj3] ResAnalyzeResultDto:{2016-04-01={0:num=121, 0:price=5244614, 1:num=124, 1:price=6324547, 2:num=115, 2:price=5604491}, 2016-04-02={0:num=125, 0:price=6321222, 1:num=117, 1:price=5835030, 2:num=118, 2:price=5771826}, 2016-04-03={0:num=118, 0:price=5486071, 1:num=131, 1:price=6563447, 2:num=111, 2:price=5740078}, subTotal={total_2016-04-01_num=360, total_2016-04-01_price=17173652, total_2016-04-02_num=360, total_2016-04-02_price=17928078, total_2016-04-03_num=360, total_2016-04-03_price=17789596}, total={num=1080, price=52891326}}
key: 2016-04-01 value: {0:num=121, 0:price=5244614, 1:num=124, 1:price=6324547, 2:num=115, 2:price=5604491}
v.toString(): {0:num=121, 0:price=5244614, 1:num=124, 1:price=6324547, 2:num=115, 2:price=5604491}
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('0' (code 48)): was expecting double-quote to start field name
 at [Source: {0:num=121, 0:price=5244614, 1:num=124, 1:price=6324547, 2:num=115, 2:price=5604491}; line: 1, column: 3]
    at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702)
    at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:558)
    at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:456)
    at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddName(ReaderBasedJsonParser.java:1771)
    at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:684)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2842)
    at jp.co.temp.sample.management.report.api.TotalSalesStatusCommandService.lambda$createFinalResultObj3$3(TotalSalesStatusCommandService.java:636)
    at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)

ContentLicense: CC BY-SA 3.0


问:
This page isn’t working HTTP ERROR 500
I am trying to use a php post method in my  project but I don't know why it isn't working.

Basically I have 2 pages: index.php and data.php

From index.php a php form is there through which one can enter his details and click submit , the other page data.php should retrieve it but it isn't doing so.I'm getting error

This page isn't working ... HTTP ERROR 500

index.php

```<code><html>
<body>
    <form action="data.php" method="post">
        Enter your tt: <input type="text" name="token"><br>
        <input type="submit">
    </form>
</body>
</html>
</code>```

JsFiddle Link

data.php

```<code><?php

if(isset($_POST['token'])){
    $abc = explode('token=',$_POST['token']);

    if($abc[1]){

        $test = explode('&expires_in=',$abc[1]);
    }
    else
    {
        $test[0] =$_POST['token'];
    }

    include 'qwert1.php';
}

else{}

$titror ='?><script>alert("Sorry, Its Invalid");document.location="/";</script><?';

?>
</code>```

JsFiddle Link

答:
Line 8 of data.php has:

```<code>$tes = explode('&expires_in=',$abc[1]);
</code>```

$tes should read $test.

Title: This page isn’t working HTTP ERROR 500

Body:
I am trying to use a php post method in my  project but I don't know why it isn't working.

Basically I have 2 pages: index.php and data.php

From index.php a php form is there through which one can enter his details and click submit , the other page data.php should retrieve it but it isn't doing so.I'm getting error

This page isn't working ... HTTP ERROR 500

index.php

    <form action="data.php" method="post">
        Enter your tt: <input type="text" name="token">

        <input type="submit">
    </form>

JsFiddle Link

data.php

<?php

if(isset($_POST['token'])){
    $abc = explode('token=',$_POST['token']);

    if($abc[1]){

        $test = explode('&expires_in=',$abc[1]);
    }
    else
    {
        $test[0] =$_POST['token'];
    }

    include 'qwert1.php';
}

else{}

$titror ='?><?';

?>

JsFiddle Link

Body:
Line 8 of data.php has:

$tes = explode('&expires_in=',$abc[1]);

$tes should read $test.


问:
What measurement do you use in your development process to determine *Doneness* of your software?
I just finished listening to a very eye-opening podcast on Hanselminutes about the definition of "Done". So my question to everyone is "When do you consider a piece of software to be "Done"? Is it when it's fully unit tested? Is it when it's completely documented? What measurement do you use in your development process to determine Doneness of your software?

答: When the customer thinks it is.</p>

OwnerDisplayName: Micah

ContentLicense: CC BY-SA 2.5

Body: When the customer thinks it is.

OwnerDisplayName: HermanD


问:
How "perfect" does a database have to be?
I'm designing a website to track weight lifting and calories. I've never designed my own database before and I figured I should get is as spot on as possible before I start coding. Every time I think I'm done, I get antsy that it's not perfect. I've mostly fleshed it out in MySQL Workbench but I still have a few questions.

How important is it to make the
database "perfect" before hand? How
hard is it to re-factor a database
later?

What does the engine option do? Right
now all tables are defaulting to
InnoDB engine? Any issues with this?

Are dataypes changeable after data
entry? Maybe not going from VARCHAR
to INT, but what about VARCHAR(45) to
VARCHAR(255)?

What are basic database rules that HAVE to
be followed for a successful design?

I've also attached my ERM diagram. If anyone could point out any obvious irregularities it would be greatly appreciated.

答:
Database change is to be expected, the question is how to manage it. Designing to at least Boyce-Codd / 5th Normal Form helps avoid in-built bias in the design and makes the schema easier to evolve when you have to.

Be careful about adding too much to the design before it is needed. If you design the schema too far ahead of the applications and other data consumers who use it then you will very possibly have to make more changes later. Apply the YAGNI principle and apply Agile, iterative approaches to your project if you can.

During development I find that it makes sense to start by being as restrictive as possible with the schema and then ease those restrictions if you need to later. For instance if you aren't sure whether some business rule should always apply or not then it's better to enforce it anyway. It's easy to relax a constraint or make something optional later but once dependent code has been built it is much harder to implement new rules that the code was not designed to accommodate.

Be careful with the word "refactoring". Database schema changes generally alter the meaning and behaviour of the database. It may be a refactoring from the application point of view but as far as the database is concerned most schema change is functional rather than nonfunctional change.


问:
How do I discard unstaged changes in Git?
How do I discard changes in my working copy that are not in the index?</p>

答:
You could create your own alias which describes how to do it in a descriptive way.

I use the next alias to discard changes.

Discard changes in a (list of) file(s) in working tree

```<code>discard = checkout --
</code>```

Then you can use it as next to discard all changes:

```<code>discard .
</code>```

Or just a file:

```<code>discard filename
</code>```

Otherwise, if you want to discard all changes and also the untracked files, I use a mix of checkout and clean:

Clean and discard changes and untracked files in working tree

```<code>cleanout = !git clean -df && git checkout -- .
</code>```

So the use is simple as next:

```<code>cleanout
</code>```

Now is available in the next Github repo which contains a lot of aliases:

https://github.com/GitAlias/gitalias

OwnerDisplayName: Tim

Body:
You could create your own alias which describes how to do it in a descriptive way.

I use the next alias to discard changes.

Discard changes in a (list of) file(s) in working tree

discard = checkout --

Then you can use it as next to discard all changes:

discard .

Or just a file:

discard filename

Otherwise, if you want to discard all changes and also the untracked files, I use a mix of checkout and clean:

Clean and discard changes and untracked files in working tree

cleanout = !git clean -df && git checkout -- .

So the use is simple as next:

cleanout

Now is available in the next Github repo which contains a lot of aliases:

https://github.com/GitAlias/gitalias


问:
How do I create scalable horizontal and vertical images?
I am working with several images that are set up as inline-block and overflow:scroll.

Currently all images are within the same class = "parent-container" but only the horizontal images are scaling, my vertical images are staying the same size when the screen changes size.

I am looking for all my images to scale.

My HTML

```<code><div class="parent-container">

<div class="container">
<img src="1.jpg" alt="" class="image" style="width:100%">
</div>

<div class="container">
<img src="2.jpg" alt="" class="image" style="width:100%">
</div>

 <div class="container">
<img src="3.jpg" alt="" class="image" style="width:100%">
</div>

 <div class="container">
<img src="4.jpg" alt="" class="image" style="width:100%">
</div>

 <div class="container">
<img src="5.jpg" alt="" class="image" style="width:100%">
</div>

</div>
</code>```

My CSS

```<code>.parent-container {
 width: 100%;
 max-width: 1175px;
 height: auto;
 padding: auto;
 overflow: scroll;
 overflow-y: hidden;
 margin-left: 35px;
 margin-top: 5px;
 white-space: nowrap;
 display: inline-block;
}

.container {
position: relative;
display: inline-block;
padding-right: 15px;
padding-left: 15px;
}

.image {
opacity: 1;
display: inline-block;
width: 100%;
height: auto;
transition: .5s ease;
backface-visibility: hidden;
padding-right: 15px;
}

.parent-container .container .image {
width: auto\9; /* IE8 */
}
</code>```

Thank you!

Working Example: https://jsfiddle.net/kjfomeze/

答:
You can try adding object-fit: cover; to your images, with a fixed height. This should scale your images.

.parent-container {
   width: 100%;
   max-width: 1175px;
   height: auto;
   padding: auto;
   overflow: scroll;
   overflow-y: hidden;
   margin-left: 35px;
   margin-top: 5px;
   white-space: nowrap;
   display: inline-block;
}

.container {
  position: relative;
  display: inline-block;
  padding-right: 15px;
  padding-left: 15px;
}

.image {
  opacity: 1;
  display: inline-block;
  width: 100%;
  height: 100px;
  transition: .5s ease;
  backface-visibility: hidden;
  object-fit: cover;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="parent-container">

  <div class="container">
    <img src="https://dummyimage.com/100x100/000/fff" alt="" class="image" style="width:100%">
  </div>

  <div class="container">
    <img src="https://dummyimage.com/200x150/000/fff" alt="" class="image" style="width:100%">
  </div>

   <div class="container">
    <img src="https://dummyimage.com/200x100/000/fff" alt="" class="image" style="width:100%">
  </div>

</div></code>```

Body:
I am working with several images that are set up as inline-block and overflow:scroll.

Currently all images are within the same class = "parent-container" but only the horizontal images are scaling, my vertical images are staying the same size when the screen changes size.

I am looking for all my images to scale.

My HTML

My CSS

.parent-container {
 width: 100%;
 max-width: 1175px;
 height: auto;
 padding: auto;
 overflow: scroll;
 overflow-y: hidden;
 margin-left: 35px;
 margin-top: 5px;
 white-space: nowrap;
 display: inline-block;
}

.container {
position: relative;
display: inline-block;
padding-right: 15px;
padding-left: 15px;
}

.image {
opacity: 1;
display: inline-block;
width: 100%;
height: auto;
transition: .5s ease;
backface-visibility: hidden;
padding-right: 15px;
}

.parent-container .container .image {
width: auto\9; /* IE8 */
}

Thank you!

Working Example: https://jsfiddle.net/kjfomeze/

Body:
You can try adding object-fit: cover; to your images, with a fixed height. This should scale your images.

.parent-container {
   width: 100%;
   max-width: 1175px;
   height: auto;
   padding: auto;
   overflow: scroll;
   overflow-y: hidden;
   margin-left: 35px;
   margin-top: 5px;
   white-space: nowrap;
   display: inline-block;
}

.container {
  position: relative;
  display: inline-block;
  padding-right: 15px;
  padding-left: 15px;
}

.image {
  opacity: 1;
  display: inline-block;
  width: 100%;
  height: 100px;
  transition: .5s ease;
  backface-visibility: hidden;
  object-fit: cover;
}

<div class="parent-container">

  <div class="container">
    <img src="https://dummyimage.com/100x100/000/fff" alt="" class="image" style="width:100%">
  </div>

  <div class="container">
    <img src="https://dummyimage.com/200x150/000/fff" alt="" class="image" style="width:100%">
  </div>

   <div class="container">
    <img src="https://dummyimage.com/200x100/000/fff" alt="" class="image" style="width:100%">
  </div>

</div>


问:
Ember model Not Bind Dynamically using Link-to
I created an ember demo,A parent view and it's child
this is the parent view

```<code><h1>A list of Todo Tasks</h1>
<ul>
{{#each model as |todo|}}
<li>{{#link-to "todos.details" todo}}{{todo.desc}}{{/link-to}}</li>
{{/each}}
</ul>

{{outlet}}
</code>```

and Its js login is
import Ember from 'ember';

```<code>export default Ember.Route.extend({
    model (){
        return [{
            "id" : 1,
            "desc" : "Try use ember"
        },
        {
            "id" : 2,
            "desc" : "Add it to github"
        },
        ];

    }
});
</code>```

but when i use the link-to and navigate the data didn't show unless i refresh the page
This is the child view

```<code><h2>The Details for <span style="color: green;">{{model.name}}</span> is : </h2>
{{#if model.error}}
<p>{{model.message}}</p>
{{else}}
<ul>
 {{#each model.steps as |task|}}
    <li>{{task.do}}</li>
    {{/each}}
</ul>
{{/if}}

{{outlet}}
</code>```

and its js logic

```<code>import Ember from 'ember';

export default Ember.Route.extend({
    model(params){

        if(params.id == "1"){
            return {
                name : "Ember SetUp",
                steps : [{
                    id :1,
                    do : "Download Ember Cli"
            },
            {
                    id :2,
                    do : "Generate New Project"
            },
            {
                    id :3,
                    do : "Generate Pages&Routes"
            }
                ]
            };
        }
        else{
            return {
                error : true,
                name : "Not Found",
                message : "There is no task with this id"
            }
        }
    }
});
</code>```

iam using ember 2.5 and this is part of the router

```<code>this.route('todos', function() {
    this.route('details',{path : "/:id"});
  });
</code>```

答:
```<code>{{#link-to "todos.details" todo}}
</code>```

Since you are providing the object todo, so it will not execute the model hook.
so try

```<code>{{#link-to "todos.details" todo.id}}
</code>```

Refer here: https://guides.emberjs.com/v2.13.0/routing/specifying-a-routes-model/#toc_dynamic-models

Note: A route with a dynamic segment will always have its model hook
  called when it is entered via the URL. If the route is entered through
  a transition (e.g. when using the link-to Handlebars helper), and a
  model context is provided (second argument to link-to), then the hook
  is not executed. If an identifier (such as an id or slug) is provided
  instead then the model hook will be executed.

Body:
I created an ember demo,A parent view and it's child
this is the parent view

A list of Todo Tasks

{{#each model as |todo|}}

{{#link-to "todos.details" todo}}{{todo.desc}}{{/link-to}}

{{/each}}

{{outlet}}

and Its js login is
import Ember from 'ember';

export default Ember.Route.extend({
    model (){
        return [{
            "id" : 1,
            "desc" : "Try use ember"
        },
        {
            "id" : 2,
            "desc" : "Add it to github"
        },
        ];

    }
});

but when i use the link-to and navigate the data didn't show unless i refresh the page
This is the child view

The Details for {{model.name}} is :

{{#if model.error}}

{{model.message}}

{{else}}

 {{#each model.steps as |task|}}

{{task.do}}

    {{/each}}

{{/if}}

{{outlet}}

and its js logic

import Ember from 'ember';

export default Ember.Route.extend({
    model(params){

        if(params.id == "1"){
            return {
                name : "Ember SetUp",
                steps : [{
                    id :1,
                    do : "Download Ember Cli"
            },
            {
                    id :2,
                    do : "Generate New Project"
            },
            {
                    id :3,
                    do : "Generate Pages&Routes"
            }
                ]
            };
        }
        else{
            return {
                error : true,
                name : "Not Found",
                message : "There is no task with this id"
            }
        }
    }
});

iam using ember 2.5 and this is part of the router

this.route('todos', function() {
    this.route('details',{path : "/:id"});
  });

Body:
{{#link-to "todos.details" todo}}

Since you are providing the object todo, so it will not execute the model hook.
so try

{{#link-to "todos.details" todo.id}}

Refer here: https://guides.emberjs.com/v2.13.0/routing/specifying-a-routes-model/#toc_dynamic-models

Note: A route with a dynamic segment will always have its model hook
  called when it is entered via the URL. If the route is entered through
  a transition (e.g. when using the link-to Handlebars helper), and a
  model context is provided (second argument to link-to), then the hook
  is not executed. If an identifier (such as an id or slug) is provided
  instead then the model hook will be executed.


问:
Central style sheet for react native?
I am learning how develop react native development and I am curious if you could put all the styles into one style.js file and then export it which allow all the components to be able to use the styles.</p>

答:
Yes you can. u can write styles in seperate file.

```<code>import React, { Component, PropTypes } from 'react';
import { StyleSheet } from 'react-native';

var styles = StyleSheet.create({
  ...
});

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

Then import it in componnet class like

```<code>import styles from './styles'
</code>```

Title: Central style sheet for react native?

Body:
Yes you can. u can write styles in seperate file.

import React, { Component, PropTypes } from 'react';
import { StyleSheet } from 'react-native';

var styles = StyleSheet.create({
  ...
});

module.exports = styles;

Then import it in componnet class like

import styles from './styles'


问:
Always Null returned after cropping a photo from a Uri in Android Lollipop?
I tried to crop an image from a Uri after taking a photo or picking a picture. And my codes are like these:

```<code>public static void cropImage(Uri uri, Activity activity, int action_code) {
    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setDataAndType(uri, "image/*");
    intent.putExtra("crop", "true");
    intent.putExtra("aspectX", 1);
    intent.putExtra("aspectY", 1);
    intent.putExtra("outputX", 600);
    intent.putExtra("outputY", 600);
    intent.putExtra("scale", true);
    intent.putExtra("return-data", true);
    if (intent.resolveActivity(activity.getPackageManager()) != null) {
        activity.startActivityForResult(intent, action_code);
    } else {
        Toast.makeText(activity, "No Crop App Available", Toast.LENGTH_SHORT).show();
    }
}
</code>```

And overridding onActivityResult() like this:

```<code>if (resultCode == Activity.RESULT_OK && requestCode == Utils.CODE_CROP_IMAGE) {
    Bundle extras = data.getExtras();
    showCenterToast("ccc");
    if (extras != null) {
        showCenterToast("CCC");
        Bitmap photo = extras.getParcelable("data");
        ivAvatar.setImageBitmap(photo); // display image in ImageView
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(Utils.AVATAR_FILE);
            photo.compress(Bitmap.CompressFormat.PNG, 100, fos);// (0-100)compressing file
            showCenterToast("DDD");
            Utils.AVATAR_FILE_TMP.delete();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } finally {
           IoUtil.closeSilently(fos);
        }
    }
}
</code>```

On devices in Android Pre-Lollipop, I was able to obtain Bitmap photo and display it in an ImageView. But, on Android Lollipop, I always got null from data.getExtras();.

I googled a lot but got few useful things about cropping an image on Android Lollipop.

Android changed its returning mechanism of cropping of com.android.camera.action.CROP on Lollipop. So, what is the new mechanism? How could I get the returned Bitmap after cropping on Lollipop?

Any tips will be appreciated. Thanks in advance.

答:
Use intent to get image:

```<code>Intent pickImageIntent = new Intent(Intent.ACTION_PICK,
        android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickImageIntent.setType("image/*");
startActivityForResult(pickImageIntent, 100);
</code>```

Use Activity Result to receiver data and get Uri.

Use android-crop to crop and get image.

Body:
I tried to crop an image from a Uri after taking a photo or picking a picture. And my codes are like these:

public static void cropImage(Uri uri, Activity activity, int action_code) {
    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setDataAndType(uri, "image/*");
    intent.putExtra("crop", "true");
    intent.putExtra("aspectX", 1);
    intent.putExtra("aspectY", 1);
    intent.putExtra("outputX", 600);
    intent.putExtra("outputY", 600);
    intent.putExtra("scale", true);
    intent.putExtra("return-data", true);
    if (intent.resolveActivity(activity.getPackageManager()) != null) {
        activity.startActivityForResult(intent, action_code);
    } else {
        Toast.makeText(activity, "No Crop App Available", Toast.LENGTH_SHORT).show();
    }
}

And overridding onActivityResult() like this:

if (resultCode == Activity.RESULT_OK && requestCode == Utils.CODE_CROP_IMAGE) {
    Bundle extras = data.getExtras();
    showCenterToast("ccc");
    if (extras != null) {
        showCenterToast("CCC");
        Bitmap photo = extras.getParcelable("data");
        ivAvatar.setImageBitmap(photo); // display image in ImageView
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(Utils.AVATAR_FILE);
            photo.compress(Bitmap.CompressFormat.PNG, 100, fos);// (0-100)compressing file
            showCenterToast("DDD");
            Utils.AVATAR_FILE_TMP.delete();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } finally {
           IoUtil.closeSilently(fos);
        }
    }
}

On devices in Android Pre-Lollipop, I was able to obtain Bitmap photo and display it in an ImageView. But, on Android Lollipop, I always got null from data.getExtras();.

I googled a lot but got few useful things about cropping an image on Android Lollipop.

Android changed its returning mechanism of cropping of com.android.camera.action.CROP on Lollipop. So, what is the new mechanism? How could I get the returned Bitmap after cropping on Lollipop?

Any tips will be appreciated. Thanks in advance.

Body:
Use intent to get image:

Intent pickImageIntent = new Intent(Intent.ACTION_PICK,
        android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickImageIntent.setType("image/*");
startActivityForResult(pickImageIntent, 100);

Use Activity Result to receiver data and get Uri.

Use android-crop to crop and get image.


问:
How to connect to local host using JDBC?
I installed MySql on my own machine. I created database, create table, ... using MySql CommandLine Client. When working on a project in school, I connected to school's database using this syntax:

```<code>public static Statement connect() {
  try {
   Class.forName( "com.mysql.jdbc.Driver" ).newInstance();
   conn = DriverManager.getConnection( "1", "2", "3" );
   stmt = conn.createStatement();
  }
  catch( Exception e ) {
   System.out.println( "Connection Error:  " + e );
  }
  return stmt;
 }
</code>```

In my local machine, I don't have to type in user name, all I did is just login with my password as root user:

```<code>Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.53-community MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use chandb;
Database changed
mysql> show tables;
+------------------+
| Tables_in_chandb |
+------------------+
| another          |
| cars             |
| employees        |
+------------------+
3 rows in set (0.03 sec)

mysql> select * from Another;
+----+-----------+----------+
| Id | GoldValue | Model    |
+----+-----------+----------+
|  0 |       100 | Civic DX |
+----+-----------+----------+
1 row in set (0.00 sec)

mysql>
</code>```

I would like to know how can I connect to my local machine's database? what should I put as parameters within method .getConnection

```<code>conn = DriverManager.getConnection(
   "1", // ?
   "2", // ?
   "3"  ); // ?
</code>```

Best regards,

Chan

答:
It looks like you left your username and password in the source you posted.

I don't see why you can't just do

```<code>DriverManager.getConnection("jdbc:mysql://localhost/chandb", "user, "pass");
</code>```

Body:
I installed MySql on my own machine. I created database, create table, ... using MySql CommandLine Client. When working on a project in school, I connected to school's database using this syntax:

public static Statement connect() {
  try {
   Class.forName( "com.mysql.jdbc.Driver" ).newInstance();
   conn = DriverManager.getConnection( "1", "2", "3" );
   stmt = conn.createStatement();
  }
  catch( Exception e ) {
   System.out.println( "Connection Error:  " + e );
  }
  return stmt;
 }

In my local machine, I don't have to type in user name, all I did is just login with my password as root user:

Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.53-community MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use chandb;
Database changed
mysql> show tables;
+------------------+
| Tables_in_chandb |
+------------------+
| another          |
| cars             |
| employees        |
+------------------+
3 rows in set (0.03 sec)

mysql> select * from Another;
+----+-----------+----------+
| Id | GoldValue | Model    |
+----+-----------+----------+
|  0 |       100 | Civic DX |
+----+-----------+----------+
1 row in set (0.00 sec)

mysql>

I would like to know how can I connect to my local machine's database? what should I put as parameters within method .getConnection

conn = DriverManager.getConnection(
   "1", // ?
   "2", // ?
   "3"  ); // ?

Best regards,

Chan

Body:
It looks like you left your username and password in the source you posted.

I don't see why you can't just do

DriverManager.getConnection("jdbc:mysql://localhost/chandb", "user, "pass");


问:
Grab ticker codes and company name from Bloomberg [r]
I have grabbed ticker codes for the S&P500 using HistIndexTickers("SPX", startdate="19980101", freq="MONTHLY") in the RbbgExtension package

How can I get the company name using the corresponding ticker codes? (Some companies have been acquired or ticker has been delisted etc. but I still would like to have the company name as I am backtesting)

Thanks in advance!

答:
Maybe like this:</p>

```<code>HistIndexTickers(index = "SPX", field = "ticker", startdate="19980101", freq="MONTHLY")
</code>```

Body:
Maybe like this:

HistIndexTickers(index = "SPX", field = "ticker", startdate="19980101", freq="MONTHLY")


问:
How to get the content of ComboBox.SelectedItem?
I thought ComboBox.SelectedItem.ToString() would work, but it's always returning this string: Windows.UI.Xaml.Controls.ComboBoxItem, while the selected item's content is different.

答:
Well this is a simple one.
What you're looking for is the dataContext of the ComboboxItem's Selected item. To get this,

Create a SelectionChanged event for the Combobox.

Now that you have the event it'll be providing two method parameters (object sender and  EventArgs e).

Cast the sender to a combobox (var container = sender as ComboBox).

Now, Pull out the selected item as a comboboxItem (var selected = container.SelectedItem as ComboBoxItem).

Now pull out the DataContext from the selectedItem and Cast it to the type you've provided (a string or some class type that you've provided).

```<code>if (selected != null)
{
    var dataYouNeed = selected.DataContext as TypeYouDefined; //(string or a class)
    if (dataYouNeed != null)
    {
        //Do your stuff here
    }
}
</code>```

if you do have an access to the combobox directly, then you don't need the event.
Simply follow the below Code.

```<code> var selected = MyComboBox.SelectedItem as ComboBoxItem;
        if(selected!=null)
        {
            var dataYouNeed = selected.DataContext as TypeOfDataYouDifined; //string or some Class
            if(dataYouNeed!=null)
            {
                //do your stuff here...
            }
        }
</code>```

Body:
Well this is a simple one.
What you're looking for is the dataContext of the ComboboxItem's Selected item. To get this,

Create a SelectionChanged event for the Combobox.

Now that you have the event it'll be providing two method parameters (object sender and  EventArgs e).

Cast the sender to a combobox (var container = sender as ComboBox).

Now, Pull out the selected item as a comboboxItem (var selected = container.SelectedItem as ComboBoxItem).

Now pull out the DataContext from the selectedItem and Cast it to the type you've provided (a string or some class type that you've provided).

if (selected != null)
{
    var dataYouNeed = selected.DataContext as TypeYouDefined; //(string or a class)
    if (dataYouNeed != null)
    {
        //Do your stuff here
    }
}

if you do have an access to the combobox directly, then you don't need the event.
Simply follow the below Code.

 var selected = MyComboBox.SelectedItem as ComboBoxItem;
        if(selected!=null)
        {
            var dataYouNeed = selected.DataContext as TypeOfDataYouDifined; //string or some Class
            if(dataYouNeed!=null)
            {
                //do your stuff here...
            }
        }


问:
Text field in same line HTML
How to make multiple text fields in the same line.

This is my code:

```<code><div class="col-lg-2">
    <div class="form-group">
        <label>Working experience</label>
        <input type="text" class="form-control  " placeholder="Year"/>Year
        <input type="text" class="form-control " placeholder="Month"/>Month
        <input type="text" class="form-control  " placeholder="Day" />Day
    </div>
</div>
</code>```

答:
It seems, you are using Bootstrap, if yes, then;

Add class .form-inline to the <form> element.

else, Add these css properties to <form>,

```<code>display: inline-block;
width: auto;
</code>```

Title: Text field in same line HTML

Body:
How to make multiple text fields in the same line.

This is my code:

        Working experience
        <input type="text" class="form-control  " placeholder="Year"/>Year
        <input type="text" class="form-control " placeholder="Month"/>Month
        <input type="text" class="form-control  " placeholder="Day" />Day

Body:
It seems, you are using Bootstrap, if yes, then;

Add class .form-inline to the <form> element.

else, Add these css properties to <form>,

display: inline-block;
width: auto;


问:
CSS Animation Not Recognizing Nested Spans
I have some HTML, animated by CSS, that nth-child iterates through a list of spans.

/*Body*/
body{
 background-color: #fff;
 font-family: 'Century Gothic', sans-serif;
  font-weight:300;
/*   white-space: pre-wrap; */
}
/*Sentence*/
.sentence{
     color: #222;
     font-size: 20px;
     text-align: left;
}

.orange{
  color: orange !important;
}

/*Vertical Flip*/
.verticalFlip{
 display: inline;
 text-indent: 8px;
}
.verticalFlip span{
 animation: vertical 15s linear infinite 0s;
 -ms-animation: vertical 15s linear infinite 0s;
 -webkit-animation: vertical 15s linear infinite 0s;
 color: #000;
 opacity: 0;
 overflow: hidden;
 position: absolute;
}
.verticalFlip span:nth-child(2){
 animation-delay: 2.5s;
 -ms-animation-delay: 2.5s;
 -webkit-animation-delay: 2.5s;
}
.verticalFlip span:nth-child(3){
 animation-delay: 5s;
 -ms-animation-delay: 5s;
 -webkit-animation-delay: 5s;
}
.verticalFlip span:nth-child(4){
 animation-delay: 7.5s;
 -ms-animation-delay: 7.5s;
 -webkit-animation-delay: 7.5s;
}
.verticalFlip span:nth-child(5){
 animation-delay: 10s;
 -ms-animation-delay: 10s;
 -webkit-animation-delay: 10s;
}

.verticalFlip span:nth-child(6){
 animation-delay: 12.5s;
 -ms-animation-delay: 12.5s;
 -webkit-animation-delay: 12.5s;
}

/*Vertical Flip Animation*/
@-moz-keyframes vertical{
 0% { opacity: 0; }
 5% { opacity: 0; -moz-transform: rotateX(180deg); }
 10% { opacity: 1; -moz-transform: translateY(0px); }
 25% { opacity: 1; -moz-transform: translateY(0px); }
 30% { opacity: 0; -moz-transform: translateY(0px); }
 80% { opacity: 0; }
 100% { opacity: 0;}
}
@-webkit-keyframes vertical{
 0% { opacity: 0; }
 5% { opacity: 0; -webkit-transform: rotateX(180deg); }
 10% { opacity: 1; -webkit-transform: translateY(0px); }
 25% { opacity: 1; -webkit-transform: translateY(0px); }
 30% { opacity: 0; -webkit-transform: translateY(0px); }
 80% { opacity: 0; }
 100% { opacity: 0; }
}
@-ms-keyframes vertical{
 0% { opacity: 0; }
 5% { opacity: 0; -ms-transform: rotateX(180deg); }
 10% { opacity: 1; -ms-transform: translateY(0px); }
 25% { opacity: 1; -ms-transform: translateY(0px); }
 30% { opacity: 0; -ms-transform: translateY(0px); }
 80% { opacity: 0; }
 100% { opacity: 0; }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><section class="wrapper">

 <h2 class="sentence">
    <div class="verticalFlip">
      <span>1.  Write a Blog post </span>
      <span>2. Click <span class="orange"></span> to open it</span>
      <span>3. ✎ Edit it. </span>
      <span>4. ⇧ Readers upvote best writers</span>
        <span> (✿◠‿◠)  </span>
      <span> ☆</span>
    </div>
  </h2>

</section></code>```

I nested a span inside a span to color one character orange:

```<code>Click <span class="orange"></span> to open it</span>
</code>```

Nth-child triggers the spans one by one, but the colored span throws the timing off. I can see an orange flash, but the character doesn't come up in the sentence. I can retime the nth child animations, but I'm looking for a CSS property like 'not', 'ignore', 'skip this span' or 'recognize this span is nested'.

https://codepen.io/Teeke/pen/Mmdboe

答:
Instead of  you can use  tag.

Since your are nesting span. The nested span also inherits the
  property from parents.

HTML:

```<code> <span>2. Click <i class="orange"></i> to open it</span>
</code>```

CSS :

```<code>i.orange {
 font-style: normal;
}
</code>```

Body:
I have some HTML, animated by CSS, that nth-child iterates through a list of spans.

/*Body*/
body{
 background-color: #fff;
 font-family: 'Century Gothic', sans-serif;
  font-weight:300;
/*   white-space: pre-wrap; */
}
/*Sentence*/
.sentence{
     color: #222;
     font-size: 20px;
     text-align: left;
}

.orange{
  color: orange !important;
}

/*Vertical Flip*/
.verticalFlip{
 display: inline;
 text-indent: 8px;
}
.verticalFlip span{
 animation: vertical 15s linear infinite 0s;
 -ms-animation: vertical 15s linear infinite 0s;
 -webkit-animation: vertical 15s linear infinite 0s;
 color: #000;
 opacity: 0;
 overflow: hidden;
 position: absolute;
}
.verticalFlip span:nth-child(2){
 animation-delay: 2.5s;
 -ms-animation-delay: 2.5s;
 -webkit-animation-delay: 2.5s;
}
.verticalFlip span:nth-child(3){
 animation-delay: 5s;
 -ms-animation-delay: 5s;
 -webkit-animation-delay: 5s;
}
.verticalFlip span:nth-child(4){
 animation-delay: 7.5s;
 -ms-animation-delay: 7.5s;
 -webkit-animation-delay: 7.5s;
}
.verticalFlip span:nth-child(5){
 animation-delay: 10s;
 -ms-animation-delay: 10s;
 -webkit-animation-delay: 10s;
}

.verticalFlip span:nth-child(6){
 animation-delay: 12.5s;
 -ms-animation-delay: 12.5s;
 -webkit-animation-delay: 12.5s;
}

/*Vertical Flip Animation*/
@-moz-keyframes vertical{
 0% { opacity: 0; }
 5% { opacity: 0; -moz-transform: rotateX(180deg); }
 10% { opacity: 1; -moz-transform: translateY(0px); }
 25% { opacity: 1; -moz-transform: translateY(0px); }
 30% { opacity: 0; -moz-transform: translateY(0px); }
 80% { opacity: 0; }
 100% { opacity: 0;}
}
@-webkit-keyframes vertical{
 0% { opacity: 0; }
 5% { opacity: 0; -webkit-transform: rotateX(180deg); }
 10% { opacity: 1; -webkit-transform: translateY(0px); }
 25% { opacity: 1; -webkit-transform: translateY(0px); }
 30% { opacity: 0; -webkit-transform: translateY(0px); }
 80% { opacity: 0; }
 100% { opacity: 0; }
}
@-ms-keyframes vertical{
 0% { opacity: 0; }
 5% { opacity: 0; -ms-transform: rotateX(180deg); }
 10% { opacity: 1; -ms-transform: translateY(0px); }
 25% { opacity: 1; -ms-transform: translateY(0px); }
 30% { opacity: 0; -ms-transform: translateY(0px); }
 80% { opacity: 0; }
 100% { opacity: 0; }
}

      1.  Write a Blog post
      2. Click  to open it
      3. ✎ Edit it.
      4. ⇧ Readers upvote best writers
         (✿◠‿◠)
       ☆

I nested a span inside a span to color one character orange:

Click  to open it

Nth-child triggers the spans one by one, but the colored span throws the timing off. I can see an orange flash, but the character doesn't come up in the sentence. I can retime the nth child animations, but I'm looking for a CSS property like 'not', 'ignore', 'skip this span' or 'recognize this span is nested'.

https://codepen.io/Teeke/pen/Mmdboe

Body:
Instead of <span> you can use <i> tag.

Since your are nesting span. The nested span also inherits the
  property from parents.

HTML:

 <span>2. Click <i class="orange"></i> to open it</span>

CSS :

i.orange {
 font-style: normal;
}


问:
Why the number of threads growing higher than expected?
I have a test case with just one HTTP request. The number of threads and Ramp Up period is set to 30. And i planning to do the test for 600 seconds.

But looking at the JMeter output, i could see a huge number of requests generated. Why is this so? I am expecting only 60 threads in a minute to generate. Can someone suggest me how to do this?

```<code>S:\roshTests\apache-jmeter-3.1\bin>jmeter -n -t
S:\roshTests\LivePerformance\June1\PPS-Proxy\catalog\catalog.jmx  -l
S:\roshTests\LivePerformance\June1\PPS-Proxy\catalog\Output\results.csv
Writing log file to: S:\roshTests\apache-jmeter-3.1\bin\jmeter.log
Creating summariser <summary>
Created the tree successfully using S:\roshTests\LivePerformance\June1\PPS-Proxy\catalog\catalog.jmx
Starting the test @ Fri Jun 02 05:18:04 IDT 2017 (1496369884546)
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary +    377 in 00:00:25 =   15.3/s Avg:   766 Min:   106 Max:  3114 Err:   198 (52.52%) Active: 25 Started: 25 Finished: 0
summary +   1364 in 00:00:30 =   45.5/s Avg:   647 Min:   144 Max:  4385 Err:  1180 (86.51%) Active: 30 Started: 30 Finished: 0
summary =   1741 in 00:00:55 =   31.9/s Avg:   673 Min:   106 Max:  4385 Err:  1378 (79.15%)
summary +    985 in 00:00:30 =   32.8/s Avg:   643 Min:    88 Max:  4918 Err:   752 (76.35%) Active: 30 Started: 30 Finished: 0
summary =  12859 in 00:05:25 =   39.6/s Avg:   616 Min:    88 Max:  6149 Err: 10562 (82.14%)
summary +    984 in 00:00:30 =   32.8/s Avg:   675 Min:   113 Max:  5070 Err:   762 (77.44%) Active: 30 Started: 30 Finished: 0
summary =  11874 in 00:04:55 =   40.3/s Avg:   614 Min:   100 Max:  6149 Err:  9810 (82.62%)
summary +   1103 in 00:00:30 =   36.7/s Avg:   624 Min:   104 Max:  4935 Err:   884 (80.15%) Active: 30 Started: 30 Finished: 0
summary =  10890 in 00:04:25 =   41.2/s Avg:   609 Min:   100 Max:  6149 Err:  9048 (83.09%)
summary +   1220 in 00:00:30 =   40.6/s Avg:   584 Min:   100 Max:  6149 Err:  1001 (82.05%) Active: 30 Started: 30 Finished: 0
summary =   9787 in 00:03:55 =   41.7/s Avg:   607 Min:   100 Max:  6149 Err:  8164 (83.42%)
summary +   1336 in 00:00:30 =   44.5/s Avg:   570 Min:   106 Max:  5296 Err:  1106 (82.78%) Active: 30 Started: 30 Finished: 0
summary =   8567 in 00:03:25 =   41.9/s Avg:   610 Min:   106 Max:  5643 Err:  7163 (83.61%)
summary +   1320 in 00:00:30 =   44.0/s Avg:   587 Min:   116 Max:  5187 Err:  1111 (84.17%) Active: 30 Started: 30 Finished: 0
summary =   7231 in 00:02:55 =   41.4/s Avg:   618 Min:   106 Max:  5643 Err:  6057 (83.76%)
summary +   1273 in 00:00:30 =   42.5/s Avg:   637 Min:   106 Max:  5383 Err:  1072 (84.21%) Active: 30 Started: 30 Finished: 0
summary =   5911 in 00:02:25 =   40.9/s Avg:   625 Min:   106 Max:  5643 Err:  4946 (83.67%)
summary +   1430 in 00:00:30 =   47.6/s Avg:   591 Min:   116 Max:  5643 Err:  1229 (85.94%) Active: 30 Started: 30 Finished: 0
summary =   4638 in 00:01:55 =   40.5/s Avg:   621 Min:   106 Max:  5643 Err:  3874 (83.53%)
summary +   1467 in 00:00:30 =   48.9/s Avg:   589 Min:   119 Max:  4691 Err:  1267 (86.37%) Active: 30 Started: 30 Finished: 0
summary =   3208 in 00:01:25 =   37.9/s Avg:   635 Min:   106 Max:  4691 Err:  2645 (82.45%)
summary +   1070 in 00:00:30 =   35.7/s Avg:   651 Min:    99 Max:  7324 Err:   862 (80.56%) Active: 30 Started: 30 Finished: 0
summary =  13929 in 00:05:55 =   39.3/s Avg:   619 Min:    88 Max:  7324 Err: 11424 (82.02%)
summary +   1531 in 00:00:30 =   51.1/s Avg:   594 Min:   106 Max:  5194 Err:  1332 (87.00%) Active: 30 Started: 30 Finished: 0
summary =  15460 in 00:06:25 =   40.2/s Avg:   617 Min:    88 Max:  7324 Err: 12756 (82.51%)
</code>```

答:
You are running 30 virtual users for 10 minutes. Each virtual user is executing samplers as fast as it can (the speed mostly depends on your application response time) this is why you have a lot of requests.

If you need to limit JMeter throughput to 60 requests per second only you can do it using Constant Throughput Timer:

Add Constant Throughput Timer to your Test Plan

Set "Target Troughput" to 60

Set "Calculate Troughput based on" to All active threads

This way JMeter will "pause" its threads (virtual users) to slow them down to 60 requests per minute.

Body:
I have a test case with just one HTTP request. The number of threads and Ramp Up period is set to 30. And i planning to do the test for 600 seconds.

But looking at the JMeter output, i could see a huge number of requests generated. Why is this so? I am expecting only 60 threads in a minute to generate. Can someone suggest me how to do this?

S:\roshTests\apache-jmeter-3.1\bin>jmeter -n -t
S:\roshTests\LivePerformance\June1\PPS-Proxy\catalog\catalog.jmx  -l
S:\roshTests\LivePerformance\June1\PPS-Proxy\catalog\Output\results.csv
Writing log file to: S:\roshTests\apache-jmeter-3.1\bin\jmeter.log
Creating summariser
Created the tree successfully using S:\roshTests\LivePerformance\June1\PPS-Proxy\catalog\catalog.jmx
Starting the test @ Fri Jun 02 05:18:04 IDT 2017 (1496369884546)
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary +    377 in 00:00:25 =   15.3/s Avg:   766 Min:   106 Max:  3114 Err:   198 (52.52%) Active: 25 Started: 25 Finished: 0
summary +   1364 in 00:00:30 =   45.5/s Avg:   647 Min:   144 Max:  4385 Err:  1180 (86.51%) Active: 30 Started: 30 Finished: 0
summary =   1741 in 00:00:55 =   31.9/s Avg:   673 Min:   106 Max:  4385 Err:  1378 (79.15%)
summary +    985 in 00:00:30 =   32.8/s Avg:   643 Min:    88 Max:  4918 Err:   752 (76.35%) Active: 30 Started: 30 Finished: 0
summary =  12859 in 00:05:25 =   39.6/s Avg:   616 Min:    88 Max:  6149 Err: 10562 (82.14%)
summary +    984 in 00:00:30 =   32.8/s Avg:   675 Min:   113 Max:  5070 Err:   762 (77.44%) Active: 30 Started: 30 Finished: 0
summary =  11874 in 00:04:55 =   40.3/s Avg:   614 Min:   100 Max:  6149 Err:  9810 (82.62%)
summary +   1103 in 00:00:30 =   36.7/s Avg:   624 Min:   104 Max:  4935 Err:   884 (80.15%) Active: 30 Started: 30 Finished: 0
summary =  10890 in 00:04:25 =   41.2/s Avg:   609 Min:   100 Max:  6149 Err:  9048 (83.09%)
summary +   1220 in 00:00:30 =   40.6/s Avg:   584 Min:   100 Max:  6149 Err:  1001 (82.05%) Active: 30 Started: 30 Finished: 0
summary =   9787 in 00:03:55 =   41.7/s Avg:   607 Min:   100 Max:  6149 Err:  8164 (83.42%)
summary +   1336 in 00:00:30 =   44.5/s Avg:   570 Min:   106 Max:  5296 Err:  1106 (82.78%) Active: 30 Started: 30 Finished: 0
summary =   8567 in 00:03:25 =   41.9/s Avg:   610 Min:   106 Max:  5643 Err:  7163 (83.61%)
summary +   1320 in 00:00:30 =   44.0/s Avg:   587 Min:   116 Max:  5187 Err:  1111 (84.17%) Active: 30 Started: 30 Finished: 0
summary =   7231 in 00:02:55 =   41.4/s Avg:   618 Min:   106 Max:  5643 Err:  6057 (83.76%)
summary +   1273 in 00:00:30 =   42.5/s Avg:   637 Min:   106 Max:  5383 Err:  1072 (84.21%) Active: 30 Started: 30 Finished: 0
summary =   5911 in 00:02:25 =   40.9/s Avg:   625 Min:   106 Max:  5643 Err:  4946 (83.67%)
summary +   1430 in 00:00:30 =   47.6/s Avg:   591 Min:   116 Max:  5643 Err:  1229 (85.94%) Active: 30 Started: 30 Finished: 0
summary =   4638 in 00:01:55 =   40.5/s Avg:   621 Min:   106 Max:  5643 Err:  3874 (83.53%)
summary +   1467 in 00:00:30 =   48.9/s Avg:   589 Min:   119 Max:  4691 Err:  1267 (86.37%) Active: 30 Started: 30 Finished: 0
summary =   3208 in 00:01:25 =   37.9/s Avg:   635 Min:   106 Max:  4691 Err:  2645 (82.45%)
summary +   1070 in 00:00:30 =   35.7/s Avg:   651 Min:    99 Max:  7324 Err:   862 (80.56%) Active: 30 Started: 30 Finished: 0
summary =  13929 in 00:05:55 =   39.3/s Avg:   619 Min:    88 Max:  7324 Err: 11424 (82.02%)
summary +   1531 in 00:00:30 =   51.1/s Avg:   594 Min:   106 Max:  5194 Err:  1332 (87.00%) Active: 30 Started: 30 Finished: 0
summary =  15460 in 00:06:25 =   40.2/s Avg:   617 Min:    88 Max:  7324 Err: 12756 (82.51%)


问:
Rotating part of an image in 3D space
Here's the setup: This is for an ecommerce art site where some paintings are canvas transfers. The painting wraps around the sides and top and bottom of the canvas. We have high-res images of the entire painting, but what we want to display is a quasi-3D representation of the image in which you can see how the sides of the painting wrap around the canvas. Here's a rough sketch of what I'm talking about:

My question is, how can I rotate an image in 3D space? The approach I think I'd like to take, is to cut off a portion of the top and side of the image, and rotate then in 3D and then stich it back on to the top and side to give it the 3D look. How do I go about about doing that? It can be done using any .Net technology (GDI+, WPF etc.).

答:
The brute force approach (which might be the easiest approach), is to map the u,v texture coordinates for each of the three faces, onto three billboards representing three sides of the canvas (a billboard is just two triangles that make a rectangle).  Then, rotate the whole canvas (all three billboards) using matrix transforms.  Tada!

Alternately, you can move the 3-space camera position with a transform, rather than the canvas.  Six of one, half the other - as they say.

Title: Rotating part of an image in 3D space


问:
What can be done to make a perfect paraphrase?
With reference from the answer: https://stackoverflow.com/a/3592020/4948889, I have tried to modify the example as below. The Google API in the answer in above link is not working for me.So I modify the example as given below:

```<code>import sys
import json
import goslate

def translate(text,lang1,lang2):

    gs = goslate.Goslate()
    content= gs.translate(text, lang2)
    try:
        trans_dict=json.loads(content)
    except AttributeError:
        try:
            trans_dict=json.load(content)
        except AttributeError:
            trans_dict=json.read(content)
    return trans_dict['responseData']['translatedText']

languages='de da nl zh-tw ko es pt el'.split()
# text=(' '.join(sys.argv[1:])).decode('utf-8')
text = "Hi, We have a requirement in which we need to change the words or phrases in the sentence while keeping its meaning intact."

for lang in languages:
    result=translate(text,'en',lang)
    result=translate(result,lang,'en')
    print(result)
    print
</code>```

After running the program, I am getting the follwoing error:

```<code>Traceback (most recent call last):
  File "C:\Users\PC\Desktop\testrephrase.py", line 25, in <module>
    result=translate(text,'en',lang)
  File "C:\Users\PC\Desktop\testrephrase.py", line 10, in translate
    content= gs.translate(text, lang2)
  File "C:\Python36\lib\site-packages\goslate.py", line 409, in translate
    return _unwrapper_single_element(self._translate_single_text(text, target_language, source_language))
  File "C:\Python36\lib\site-packages\goslate.py", line 334, in _translate_single_text
    results = list(self._execute(make_task(i) for i in split_text(text)))
  File "C:\Python36\lib\site-packages\goslate.py", line 203, in _execute
    yield each()
  File "C:\Python36\lib\site-packages\goslate.py", line 332, in <lambda>
    return lambda: self._basic_translate(text, target_language, source_lauguage)[0]
  File "C:\Python36\lib\site-packages\goslate.py", line 251, in _basic_translate
    response_content = self._open_url(url)
  File "C:\Python36\lib\site-packages\goslate.py", line 191, in _open_url
    raise e
  File "C:\Python36\lib\site-packages\goslate.py", line 181, in _open_url
    response = self._opener.open(request, timeout=self._TIMEOUT)
  File "C:\Python36\lib\urllib\request.py", line 532, in open
    response = meth(req, response)
  File "C:\Python36\lib\urllib\request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python36\lib\urllib\request.py", line 570, in error
    return self._call_chain(*args)
  File "C:\Python36\lib\urllib\request.py", line 504, in _call_chain
    result = func(*args)
  File "C:\Python36\lib\urllib\request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 503: Service Unavailable
</code>```

I do not what to do so tat my code run efficiently and create the paraphrases without changing the meaning of the sentence.

I am using Python 3.6 and Windows 10 as OS.

Kindly, help me.

答:
The following link shows the following:

Google has updated its translation service recently with a ticket
  mechanism to prevent simple crawler program like goslate from
  accessing. Though a more sophisticated crawler may still work
  technically, however it would have crossed the fine line between using
  the service and breaking the service. goslate will not be updated to
  break google’s ticket mechanism. Free lunch is over. Thanks for using.

So the library I do not currently work, consequently the example is useless.

Body:
With reference from the answer: https://stackoverflow.com/a/3592020/4948889, I have tried to modify the example as below. The Google API in the answer in above link is not working for me.So I modify the example as given below:

import sys
import json
import goslate

def translate(text,lang1,lang2):

    gs = goslate.Goslate()
    content= gs.translate(text, lang2)
    try:
        trans_dict=json.loads(content)
    except AttributeError:
        try:
            trans_dict=json.load(content)
        except AttributeError:
            trans_dict=json.read(content)
    return trans_dict['responseData']['translatedText']

languages='de da nl zh-tw ko es pt el'.split()
# text=(' '.join(sys.argv[1:])).decode('utf-8')
text = "Hi, We have a requirement in which we need to change the words or phrases in the sentence while keeping its meaning intact."

for lang in languages:
    result=translate(text,'en',lang)
    result=translate(result,lang,'en')
    print(result)
    print

After running the program, I am getting the follwoing error:

Traceback (most recent call last):
  File "C:\Users\PC\Desktop\testrephrase.py", line 25, in <module>
    result=translate(text,'en',lang)
  File "C:\Users\PC\Desktop\testrephrase.py", line 10, in translate
    content= gs.translate(text, lang2)
  File "C:\Python36\lib\site-packages\goslate.py", line 409, in translate
    return _unwrapper_single_element(self._translate_single_text(text, target_language, source_language))
  File "C:\Python36\lib\site-packages\goslate.py", line 334, in _translate_single_text
    results = list(self._execute(make_task(i) for i in split_text(text)))
  File "C:\Python36\lib\site-packages\goslate.py", line 203, in _execute
    yield each()
  File "C:\Python36\lib\site-packages\goslate.py", line 332, in <lambda>
    return lambda: self._basic_translate(text, target_language, source_lauguage)[0]
  File "C:\Python36\lib\site-packages\goslate.py", line 251, in _basic_translate
    response_content = self._open_url(url)
  File "C:\Python36\lib\site-packages\goslate.py", line 191, in _open_url
    raise e
  File "C:\Python36\lib\site-packages\goslate.py", line 181, in _open_url
    response = self._opener.open(request, timeout=self._TIMEOUT)
  File "C:\Python36\lib\urllib\request.py", line 532, in open
    response = meth(req, response)
  File "C:\Python36\lib\urllib\request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python36\lib\urllib\request.py", line 570, in error
    return self._call_chain(*args)
  File "C:\Python36\lib\urllib\request.py", line 504, in _call_chain
    result = func(*args)
  File "C:\Python36\lib\urllib\request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 503: Service Unavailable

I do not what to do so tat my code run efficiently and create the paraphrases without changing the meaning of the sentence.

I am using Python 3.6 and Windows 10 as OS.

Kindly, help me.


问:
Need help getting this batch to VBS conversion to work properly
I am trying to convert a batch file to VBS. This is what I have so far. Looking for advice on proper formatting, as well as any help as to why this VBS script isn't working at the moment. Here's what I've got so far:

```<code>OPTION EXPLICIT
DIM strComputer,strSCVA,strDOSBox

strComputer = "." ' local computer
strSCVA = "scva.exe"
strDOSBox = "dosbox.exe"

' Check if scva.exe is running at startup (. = local computer)
IF isProcessRunning(strComputer,strSCVA) THEN
    Call LoopStart
ELSE
    cd "%~dp0../"
    start /min "" "scva.exe"
    Call LoopStart
END IF

Sub LoopStart
' Exits script if scva.exe is manually terminated, otherwise, calls CheckDOSBox
IF isProcessRunning(strComputer,strSCVA) THEN
    Call CheckDOSBox
ELSE
    WScript.Quit
END IF

Sub CheckDOSBox
' Goes to LoopStart while dosbox.exe is running, otherwise, calls Kill
IF isProcessRunning(strComputer,strDOSBox) THEN
    Call LoopStart
ELSE
    Call Kill
END IF

Sub Kill
' Sends command to terminate scva.exe while scva.exe is running, otherwise, exits script
IF isProcessRunning(strComputer,strSCVA) THEN
    taskkill /IM scva.exe
    Call Kill
ELSE
    WScript.Quit
END IF

' Function to check if a process is running
FUNCTION isProcessRunning(BYVAL strComputer,BYVAL strProcessName)

    DIM objWMIService, strWMIQuery

    strWMIQuery = "Select * from Win32_Process where name like '" & strProcessName & "'"

    SET objWMIService = GETOBJECT("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" _
            & strComputer & "\root\cimv2")

    IF objWMIService.ExecQuery(strWMIQuery).Count > 0 THEN
        isProcessRunning = TRUE
    ELSE
        isProcessRunning = FALSE
    END IF

END FUNCTION
</code>```

And here's the original batch file that's being converted (which I also wrote):

```<code>REM Runs scva.exe if it is not running; kills process after dosbox.exe is terminated

tasklist /FI "IMAGENAME eq scva.exe" 2>NUL | find /I /N "scva.exe">NUL
if "%ERRORLEVEL%"=="0" (
    goto LoopStart
) else (
    cd "%~dp0../"
    start /min "" "scva.exe"
    goto LoopStart
)

:LoopStart
REM Exits script if scva.exe is manually terminated, otherwise, goes to CheckDOSBox

tasklist /FI "IMAGENAME eq scva.exe" 2>NUL | find /I /N "scva.exe">NUL
if "%ERRORLEVEL%"=="0" (
    goto CheckDOSBox
) else (
    exit
)

:CheckDOSBox
REM Goes to LoopStart while dosbox.exe is running, otherwise, goes to Kill

tasklist /FI "IMAGENAME eq dosbox.exe" 2>NUL | find /I /N "dosbox.exe">NUL
if "%ERRORLEVEL%"=="0" (
    goto LoopStart
) else (
    goto Kill
)

:Kill
REM Sends command to terminate scva.exe while scva.exe is running, otherwise, exits script

tasklist /FI "IMAGENAME eq scva.exe" 2>NUL | find /I /N "scva.exe">NUL
if "%ERRORLEVEL%"=="0" (
    taskkill /IM scva.exe
    goto Kill
)
exit
</code>```

I think that my problem area is not knowing how to properly start a program in VBS. I have googled this but I don't understand the implementation and it would help if someone could show me how it works in my own code. Additionally, what is the equivalent of cd "%~dp0../" in VBS? In other words, the equivalent to relatively setting the working directory to the current directory of the VBS script?

答:
I guess I'll post my reservations first, then see if I can actually help.

It looks like the batch file works fine - why would you want to change it to vbscript?

Ok, enough of that.

When I wrote vbscript, I'd put the subroutines at the top, and the main logic at the bottom.  I'm not sure if that's what everyone does, but what it means is that I can scan down the program, see FUNCTION isProcessRunning, understand that dozen or so lines, and then carry on. This means that when I reach the part where it's called I already understand what it's for and roughly what it'll do.

The closest thing to cd that I've come across with vbscript is the WScript.CurrentDirectory property. http://www.vbsedit.com/html/a36f684c-efef-4069-9102-21b3d1d55e9e.asp    Personally, I don't tend to use it, because I generally write a batch file to launch my vb scripts anyway, and I'd cd to the right place in that, if necessary.

e.g. I have a listmounts.bat which is basically:

```<code>cscript %~dp0\listmounts.vbs
</code>```

I do that because I do lots of stuff in the shell, and like this, to launch it, I just type listmounts to run it, instead of cscript \path\to\listmounts.vbs.  But that's just me.

Call in vbscript works very differently from goto in a batch file.  Call expects to call a subroutine or function (like IsProcessRunning) and reach the end of that subroutine, then it returns to where it was called from.  That's obviously not how goto works in the batch file.  Each time you do call it uses up some memory managing where you called from, and when it returns, it reclaims that memory.  So with what you've set up, with the cross-over of calls, you'll probably eventually run out of memory, if it runs long enough.  Might take a while though.

So here's how I'd structure it.  You'll have to tweak it to make it work (partly because I have neither svca or dosbox on my machine, and partly because I'm running Linux ATM and can't test it at all).

```<code>OPTION EXPLICIT
DIM strComputer,strSCVA,strDOSBox

' start scva if it's not already running.  Kill it if dosbox dies.
' Author: Lucas 5 June 2017

' Function to check if a process is running
FUNCTION isProcessRunning(BYVAL strComputer,BYVAL strProcessName)

    DIM objWMIService, strWMIQuery

    strWMIQuery = "Select * from Win32_Process where name like '" & strProcessName & "'"

    SET objWMIService = GETOBJECT("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" _
            & strComputer & "\root\cimv2")

    IF objWMIService.ExecQuery(strWMIQuery).Count > 0 THEN
        isProcessRunning = TRUE
    ELSE
        isProcessRunning = FALSE
    END IF

END FUNCTION

' kill the svca executable.
SUB KillSvca()

    ' Keep trying to kill scva until it actually has exited.
    WHILE isProcessRunning(strComputer,strSCVA)
        ' this won't actually work - see below for an alternative
        taskkill /IM scva.exe
    WEND
END SUB

' ------  MAIN PROGRAM ----

strComputer = "." ' local computer
strSCVA = "scva.exe"
strDOSBox = "dosbox.exe"

' Start SCVA if it's not already running.

IF NOT isProcessRunning(strComputer,strSCVA) THEN
    ' As above, I'd make sure it's in the correct folder first
    cd "%~dp0../"
    ' And this won't work either. see below.
    start /min "" "scva.exe"
END IF

WHILE isProcessRunning (strComputer, strSCVA)

    IF NOT isProcessRunning(strComputer,strDOSBox) THEN
        KIllScva
    END IF

WEND
</code>```

A couple of points:

I've assumed your isProcessRunning function works. I haven't mucked with it.

Ideally I'd DIM strComputer,strSCVA,strDOSBox just under my MAIN PROGRAM comment, but that would require passing them as parameters to the KillSvca subroutine.

the taskkill becomes significantly trickier in vbscript. This looks like a vbscript only solution: Killing processes in Vbscript, but this one looks simpler How to terminate a process in vbscript

Launching your app is a bit trickier too, but here's a suggestion: Launch programs whose path contains spaces

Body:
I am trying to convert a batch file to VBS. This is what I have so far. Looking for advice on proper formatting, as well as any help as to why this VBS script isn't working at the moment. Here's what I've got so far:

OPTION EXPLICIT
DIM strComputer,strSCVA,strDOSBox

strComputer = "." ' local computer
strSCVA = "scva.exe"
strDOSBox = "dosbox.exe"

' Check if scva.exe is running at startup (. = local computer)
IF isProcessRunning(strComputer,strSCVA) THEN
    Call LoopStart
ELSE
    cd "%~dp0../"
    start /min "" "scva.exe"
    Call LoopStart
END IF

Sub LoopStart
' Exits script if scva.exe is manually terminated, otherwise, calls CheckDOSBox
IF isProcessRunning(strComputer,strSCVA) THEN
    Call CheckDOSBox
ELSE
    WScript.Quit
END IF

Sub CheckDOSBox
' Goes to LoopStart while dosbox.exe is running, otherwise, calls Kill
IF isProcessRunning(strComputer,strDOSBox) THEN
    Call LoopStart
ELSE
    Call Kill
END IF

Sub Kill
' Sends command to terminate scva.exe while scva.exe is running, otherwise, exits script
IF isProcessRunning(strComputer,strSCVA) THEN
    taskkill /IM scva.exe
    Call Kill
ELSE
    WScript.Quit
END IF

' Function to check if a process is running
FUNCTION isProcessRunning(BYVAL strComputer,BYVAL strProcessName)

    DIM objWMIService, strWMIQuery

    strWMIQuery = "Select * from Win32_Process where name like '" & strProcessName & "'"

    SET objWMIService = GETOBJECT("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" _
            & strComputer & "\root\cimv2")

    IF objWMIService.ExecQuery(strWMIQuery).Count > 0 THEN
        isProcessRunning = TRUE
    ELSE
        isProcessRunning = FALSE
    END IF

END FUNCTION

And here's the original batch file that's being converted (which I also wrote):

REM Runs scva.exe if it is not running; kills process after dosbox.exe is terminated

tasklist /FI "IMAGENAME eq scva.exe" 2>NUL | find /I /N "scva.exe">NUL
if "%ERRORLEVEL%"=="0" (
    goto LoopStart
) else (
    cd "%~dp0../"
    start /min "" "scva.exe"
    goto LoopStart
)

:LoopStart
REM Exits script if scva.exe is manually terminated, otherwise, goes to CheckDOSBox

tasklist /FI "IMAGENAME eq scva.exe" 2>NUL | find /I /N "scva.exe">NUL
if "%ERRORLEVEL%"=="0" (
    goto CheckDOSBox
) else (
    exit
)

:CheckDOSBox
REM Goes to LoopStart while dosbox.exe is running, otherwise, goes to Kill

tasklist /FI "IMAGENAME eq dosbox.exe" 2>NUL | find /I /N "dosbox.exe">NUL
if "%ERRORLEVEL%"=="0" (
    goto LoopStart
) else (
    goto Kill
)

:Kill
REM Sends command to terminate scva.exe while scva.exe is running, otherwise, exits script

tasklist /FI "IMAGENAME eq scva.exe" 2>NUL | find /I /N "scva.exe">NUL
if "%ERRORLEVEL%"=="0" (
    taskkill /IM scva.exe
    goto Kill
)
exit

I think that my problem area is not knowing how to properly start a program in VBS. I have googled this but I don't understand the implementation and it would help if someone could show me how it works in my own code. Additionally, what is the equivalent of cd "%~dp0../" in VBS? In other words, the equivalent to relatively setting the working directory to the current directory of the VBS script?

Body:
I guess I'll post my reservations first, then see if I can actually help.

It looks like the batch file works fine - why would you want to change it to vbscript?

Ok, enough of that.

When I wrote vbscript, I'd put the subroutines at the top, and the main logic at the bottom.  I'm not sure if that's what everyone does, but what it means is that I can scan down the program, see FUNCTION isProcessRunning, understand that dozen or so lines, and then carry on. This means that when I reach the part where it's called I already understand what it's for and roughly what it'll do.

The closest thing to cd that I've come across with vbscript is the WScript.CurrentDirectory property. http://www.vbsedit.com/html/a36f684c-efef-4069-9102-21b3d1d55e9e.asp    Personally, I don't tend to use it, because I generally write a batch file to launch my vb scripts anyway, and I'd cd to the right place in that, if necessary.

e.g. I have a listmounts.bat which is basically:

cscript %~dp0\listmounts.vbs

I do that because I do lots of stuff in the shell, and like this, to launch it, I just type listmounts to run it, instead of cscript \path\to\listmounts.vbs.  But that's just me.

Call in vbscript works very differently from goto in a batch file.  Call expects to call a subroutine or function (like IsProcessRunning) and reach the end of that subroutine, then it returns to where it was called from.  That's obviously not how goto works in the batch file.  Each time you do call it uses up some memory managing where you called from, and when it returns, it reclaims that memory.  So with what you've set up, with the cross-over of calls, you'll probably eventually run out of memory, if it runs long enough.  Might take a while though.

So here's how I'd structure it.  You'll have to tweak it to make it work (partly because I have neither svca or dosbox on my machine, and partly because I'm running Linux ATM and can't test it at all).

OPTION EXPLICIT
DIM strComputer,strSCVA,strDOSBox

' start scva if it's not already running.  Kill it if dosbox dies.
' Author: Lucas 5 June 2017

' Function to check if a process is running
FUNCTION isProcessRunning(BYVAL strComputer,BYVAL strProcessName)

    DIM objWMIService, strWMIQuery

    strWMIQuery = "Select * from Win32_Process where name like '" & strProcessName & "'"

    SET objWMIService = GETOBJECT("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" _
            & strComputer & "\root\cimv2")

    IF objWMIService.ExecQuery(strWMIQuery).Count > 0 THEN
        isProcessRunning = TRUE
    ELSE
        isProcessRunning = FALSE
    END IF

END FUNCTION

' kill the svca executable.
SUB KillSvca()

    ' Keep trying to kill scva until it actually has exited.
    WHILE isProcessRunning(strComputer,strSCVA)
        ' this won't actually work - see below for an alternative
        taskkill /IM scva.exe
    WEND
END SUB

' ------  MAIN PROGRAM ----

strComputer = "." ' local computer
strSCVA = "scva.exe"
strDOSBox = "dosbox.exe"

' Start SCVA if it's not already running.

IF NOT isProcessRunning(strComputer,strSCVA) THEN
    ' As above, I'd make sure it's in the correct folder first
    cd "%~dp0../"
    ' And this won't work either. see below.
    start /min "" "scva.exe"
END IF

WHILE isProcessRunning (strComputer, strSCVA)

    IF NOT isProcessRunning(strComputer,strDOSBox) THEN
        KIllScva
    END IF

WEND

A couple of points:

I've assumed your isProcessRunning function works. I haven't mucked with it.

Ideally I'd DIM strComputer,strSCVA,strDOSBox just under my MAIN PROGRAM comment, but that would require passing them as parameters to the KillSvca subroutine.

the taskkill becomes significantly trickier in vbscript. This looks like a vbscript only solution: Killing processes in Vbscript, but this one looks simpler How to terminate a process in vbscript

Launching your app is a bit trickier too, but here's a suggestion: Launch programs whose path contains spaces


问:
Deploying create-react-app - Statically vs. Dynamically?
I don't understand the difference of deploying a site "statically" vs. using express.  The docs in create-react-app says you don't need express to spin up a server?  So where and how do you deploy this app?  I don't get it.  I'm used to creating a server.js with express and then deploying to something like Heroku in the past.

Deployment

npm run build creates a build directory with a production build of your app. Set up your favourite HTTP server so that a visitor to your site is served index.html, and requests to static paths like /static/js/main.<hash>.js are served with the contents of the /static/js/main.<hash>.js file.

From their docs:

Static Server

For environments using Node, the easiest way to handle this would be to install serve and let it handle the rest:

```<code>npm install -g serve
serve -s build
</code>```

The last command shown above will serve your static site on the port 5000. Like many of serve’s internal settings, the port can be adjusted using the -p or --port flags.

Run this command to get a full list of the options available:

```<code>serve -h
</code>```

Other Solutions

You don’t necessarily need a static server in order to run a Create React App project in production. It works just as fine integrated into an existing dynamic one.

Here’s a programmatic example using Node and Express:

```<code>const express = require('express');
const path = require('path');
const app = express();

app.use(express.static(path.join(__dirname, 'build')));

app.get('/', function (req, res) {
  res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

app.listen(9000);
</code>```

I don't understand why you wouldn't want to run it with express (what I guess is called "dynamically"?).  How would that work if you don't have express setup anyway?  I don't get "running this statically".  I've only ever run apps with express in the past.

答:
Deploying your site statically means you already have a mean to serve static files using HTTP in your production server (Apache, Nginx, Heroku, S3 etc). These can handle point 2 and 3 in my explanation below, so you don't need to spin up Express or Serve in your production server.

There are several reasons why you might need to spin an HTTP Server in  your production machine, and this is not limited to create-react-app.

You can use Webpack Dev Middleware and Webpack Hot Middleware attached to express server to have hot module reloading. Webpack hot module reloading works by injecting code in the client that listens to change in your file using WebSocket endpoint served by the HTTP server.

Sometimes you need to dynamically load static assets (images, fonts) using AJAX alongside your HTML and JavaScript. Most browsers does not allow this due to Cross Origin Requests being limited to HTTP.

If you need client side routing with clean URL using BrowserHistory, you need to use HTTP server with rewrite rule, which you can do pretty easily using Express.

Body:
I don't understand the difference of deploying a site "statically" vs. using express.  The docs in create-react-app says you don't need express to spin up a server?  So where and how do you deploy this app?  I don't get it.  I'm used to creating a server.js with express and then deploying to something like Heroku in the past.

Deployment

npm run build creates a build directory with a production build of your app. Set up your favourite HTTP server so that a visitor to your site is served index.html, and requests to static paths like /static/js/main.<hash>.js are served with the contents of the /static/js/main.<hash>.js file.

From their docs:

Static Server

For environments using Node, the easiest way to handle this would be to install serve and let it handle the rest:

npm install -g serve
serve -s build

The last command shown above will serve your static site on the port 5000. Like many of serve’s internal settings, the port can be adjusted using the -p or --port flags.

Run this command to get a full list of the options available:

serve -h

Other Solutions

You don’t necessarily need a static server in order to run a Create React App project in production. It works just as fine integrated into an existing dynamic one.

Here’s a programmatic example using Node and Express:

const express = require('express');
const path = require('path');
const app = express();

app.use(express.static(path.join(__dirname, 'build')));

app.get('/', function (req, res) {
  res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

app.listen(9000);

I don't understand why you wouldn't want to run it with express (what I guess is called "dynamically"?).  How would that work if you don't have express setup anyway?  I don't get "running this statically".  I've only ever run apps with express in the past.


问:
Delete all rows in an HTML table
How can I delete all rows of an HTML table except the 's using Javascript, and without looping through all the rows in the table? I have a very huge table and I don't want to freeze the UI while I'm looping through the rows to delete them

答:
this would work iteration deletetion in HTML table in native</p>

```<code>document.querySelectorAll("table tbody tr").forEach(function(e){e.remove()})
</code>```

Title: Delete all rows in an HTML table

Body:
this would work iteration deletetion in HTML table in native

document.querySelectorAll("table tbody tr").forEach(function(e){e.remove()})


问:
what is the actual use of interface in java?

Possible Duplicates:

  Abstract class and Interface class?

  Java: interface / abstract classes / abstract method

In Java, whatever use of interface is fulfilled by abstract class. I know one advantage of interfaces is that if we implement an interface then we can also extend another class. Is there any other use or advantage of interface in Java?

答:
Interfaces allow you to use classes in different hierarchies, polymorphically.

For example, say you have the following interface:

```<code>public interface Movable {
    void move();
}
</code>```

Any number of classes, across class hierarchies could implement Movable in their own specific way, yet still be used by some caller in a uniform way.

So if you have the following two classes:

```<code>public class Car extends Vehicle implements Movable {
    public void move() {
       //implement move, vroom, vroom!
    }
}

public class Horse extends Animal implements Movable {
    public void move() {
       //implement move, neigh!
    }
}
</code>```

From the perspective of the caller, it's just a Movable

```<code>Movable movable = ...;
movable.move();  //who am I?
</code>```

I hope this helps.

Body:
Interfaces allow you to use classes in different hierarchies, polymorphically.

For example, say you have the following interface:

public interface Movable {
    void move();
}

Any number of classes, across class hierarchies could implement Movable in their own specific way, yet still be used by some caller in a uniform way.

So if you have the following two classes:

public class Car extends Vehicle implements Movable {
    public void move() {
       //implement move, vroom, vroom!
    }
}

public class Horse extends Animal implements Movable {
    public void move() {
       //implement move, neigh!
    }
}

From the perspective of the caller, it's just a Movable

Movable movable = ...;
movable.move();  //who am I?

I hope this helps.


问:
Looking for alternative to sleep(30) in watir
I am trying to apply sleep on page loading that works completely fine, but I want to avoid using it and looking for an alternative.

I have tried these options:

```<code>@browser.element(:class => 'oo-pricing').wait_until(:timeout => 30)

Watir::Wait @browser.span(:class => 'oo-blp-price').wait_until(:timeout => 30)
</code>```

My goal is to wait until the text in span is updated.

```<code>browser.goto('https://secure.bestprice.rankingsandreviews.com/nc/configurator/307715')

browser.element(:id => 's2id_select_style').click

browser.element(xpath: ".//*[@id='select2-drop']/div/input").send_keys('Convertible LT 1LT', :tab)

browser.element(id: 'edit_color').click

browser.span(text: 'Incentives').click

browser.element(text: "2017 GM Conquest Cash").parent.preceding_sibling.span.click
</code>```

答:
Find the element that you want, for example:

```<code>@browser.element(:class => 'oo-pricing')
</code>```

Call the wait_until_present method on it:

```<code>@browser.element(:class => 'oo-pricing').wait_until_present
</code>```

Body:
I am trying to apply sleep on page loading that works completely fine, but I want to avoid using it and looking for an alternative.

I have tried these options:

@browser.element(:class => 'oo-pricing').wait_until(:timeout => 30)

Watir::Wait @browser.span(:class => 'oo-blp-price').wait_until(:timeout => 30)

My goal is to wait until the text in span is updated.

browser.goto('https://secure.bestprice.rankingsandreviews.com/nc/configurator/307715')

browser.element(:id => 's2id_select_style').click

browser.element(xpath: ".//*[@id='select2-drop']/div/input").send_keys('Convertible LT 1LT', :tab)

browser.element(id: 'edit_color').click

browser.span(text: 'Incentives').click

browser.element(text: "2017 GM Conquest Cash").parent.preceding_sibling.span.click

Body:
Find the element that you want, for example:

@browser.element(:class => 'oo-pricing')

Call the wait_until_present method on it:

@browser.element(:class => 'oo-pricing').wait_until_present