答:
Based on your question above, it seems the problem you are having are variables that have labels and are not numerical in some way? The easiest way to deal with this is to add another variable in your matrix for all 5 variables that are labels and have them have corresponding numbers. So Acer = 1, Alnus = 2 and so forth (class becomes class.id)

Now, with the randomforest package, categorical predictor variables must be specified as factors or else they will be wrongly treated as continuous. So to convert these, just add the code:

converts to factor

as.factor(class.id)

checks to see

is.factor(class.id)

Then you can use your random forest code from the randomforest package. I can't really figure out from your matrix of variables you have listed above, which variables determine whether a tree/species is sick or not, but in essence:

predicts sickness based on your variables

```<code>sickness<-randomforest(class.id~variable1, variable2, etc., data=matrix, ntree=4000, importance=TRUE, proximity=TRUE
</code>```

this code allows you to see importance values as well as plot them

```<code>print(sickness)
importance(sickness)
varImpPlot(sickness)
</code>```

Title: Multi-Label Classification R

Body:
I am trying to learn R. I have the following dataset, 28 variables, and 5 of them are labels (Class, crown, root, trunk, collar). First of all, I tried to use RandomForest to predict based on the class if a tree is sick or not.

Next,
I need to predict which part of the tree is sick (crown, root, collar, trunk)

I need to use multi-label classification (randomForestSRC) or other packages.

If someone could provide an example how to use multi-label classification (or transform the label classes into binary form) , I would really appreciate.

Thank you in advance!

dput(ML)
structure(list(Sector = c(5L, 3L, 3L, 2L, 1L, 3L, 6L, 2L, 2L,
5L, 3L, 4L, 5L, 1L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 3L, 5L, 4L, 2L,
4L, 4L, 2L, 1L, 2L, 5L, 6L, 3L, 3L, 6L, 2L, 3L, 3L, 6L, 3L, 5L,
6L, 3L, 4L, 5L, 1L, 3L, 5L, 3L, 2L, 3L, 6L, 5L), Plantation.year = c(2014L,
2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L,
2009L, 2004L, 2004L, 2005L, 2004L, 2004L, 2004L, 2004L, 2009L,
2004L, 2006L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L,
2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L,
2009L, 2004L, 2005L, 2004L, 2004L, 2004L, 2004L, 2004L, 2014L,
2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L), Diagnosis.year = c(2014L,
2013L, NA, 2014L, 2013L, 2015L, 2013L, 2014L, 2013L, 2015L, 2015L,
2014L, 2013L, 2015L, 2015L, 2015L, 2013L, 2015L, 2013L, 2013L,
2015L, 2014L, 2013L, 2013L, 2014L, 2013L, 2014L, 2015L, 2014L,
2014L, 2013L, 2014L, 2014L, 2013L, 2015L, 2014L, 2014L, 2013L,
2014L, 2015L, 2015L, 2015L, 2015L, 2013L, 2015L, 2014L, 2014L,
2013L, 2013L, 2013L, 2013L, 2013L, 2013L), Next.diagnosis.year = c(2019L,
NA, 2014L, 2014L, NA, 2018L, 2020L, 2014L, NA, 2017L, NA, 2014L,
2016L, 2018L, 2020L, NA, NA, 2016L, NA, 2018L, 2018L, 2014L,
2016L, 2014L, 2014L, NA, 2015L, NA, 2014L, NA, NA, 2014L, NA,
NA, 2018L, 2017L, 2014L, NA, 2014L, 2020L, 2017L, 2017L, 2016L,
NA, 2018L, 2020L, 2019L, NA, NA, NA, NA, 2017L, 2018L), Stump.diameter = structure(c(2L,
6L, 2L, 7L, 5L, 7L, 6L, 6L, 7L, 7L, 2L, 7L, 5L, 2L, 5L, 2L, 5L,
5L, 1L, 6L, 4L, 1L, 6L, 6L, 2L, 7L, 3L, 5L, 2L, 7L, 6L, 6L, 2L,
10L, 2L, 7L, 6L, 2L, 5L, 2L, 5L, 2L, 6L, 5L, 5L, 2L, 6L, 1L,
8L, 2L, 9L, 8L, 11L), .Label = c("0 Ã  10 cm", "10 Ã  20 cm",
"100 Ã  110 cm", "110 Ã  120 cm", "20 Ã  30 cm", "30 Ã  40 cm",
"40 Ã  50 cm", "50 Ã  60 cm", "60 Ã  70 cm", "70 Ã  80 cm", "80 Ã  90 cm"
), class = "factor"), Species = structure(c(4L, 1L, 6L, 7L, 9L,
9L, 5L, 8L, 1L, NA, NA, 13L, 7L, 15L, NA, 12L, 11L, 7L, 9L, 1L,
8L, 15L, 8L, 13L, 11L, 9L, 1L, 8L, 4L, 14L, 8L, 1L, 9L, 7L, 9L,
2L, 8L, 9L, 8L, NA, 12L, 3L, 9L, 7L, 12L, 9L, 10L, 9L, 9L, 1L,
11L, 13L, 1L), .Label = c("acerifolia", "betulus", "campestris",
"cordata", "excelsior", "grandiflora", "japonica", "nigra", "Other ",
"platanoides", "pseudoplatanus", "styraciflua", "tomentosa",
"tulipifera", "verrucosa"), class = "factor"), Traffic.frequence = structure(c(2L,
1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 3L, 1L,
1L, 1L, 1L, 1L), .Label = c("passages frÃ©quents et arrÃªts frÃ©quents",
"passages frÃ©quents ou arrÃªts", "quelques passages"), class = "factor"),
    Botanical.category = structure(c(2L, 16L, 11L, 19L, 8L, 14L,
    8L, 17L, 16L, 1L, 20L, 20L, 19L, 3L, 4L, 9L, 1L, 19L, 13L,
    16L, 17L, 3L, 15L, 20L, 1L, 7L, 16L, 15L, 20L, 10L, 15L,
    16L, 13L, 19L, 6L, 4L, 15L, 5L, 15L, 4L, 9L, 1L, 13L, 19L,
    9L, 12L, 1L, 7L, 18L, 16L, 1L, 20L, 16L), .Label = c("Acer",
    "Alnus", "Betula", "Carpinus", "Celtis", "Cercis", "Cupressus",
    "Fraxinus", "Liquidambar", "Liriodendron", "Magnolia", "Malus",
    "Other ", "Picea", "Pinus", "Platanus", "Populus", "Robinia",
    "Sophora", "Tilia"), class = "factor"), PLU.ident.number = c(NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA), PLU.ProtectionCateg = c(NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA), Diagnosis.remarks = structure(c(4L,
    4L, 4L, 4L, 4L, 2L, 4L, 1L, 4L, 3L, 4L, 4L, 3L, 4L, 4L, 4L,
    4L, 2L, 4L, 4L, 3L, 4L, 3L, 4L, 3L, 4L, 4L, 4L, 3L, 4L, 3L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c("Arbre Ã  abattre dans les 10 ans",
    "Arbre Ã  abattre dans les 5 ans", "Arbre d'avenir incertain",
    "Arbre d'avenir normal"), class = "factor"), Diagnosis.renewal.priority = structure(c(3L,
    3L, 3L, 3L, 3L, 1L, 3L, 2L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L,
    2L, 1L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 3L, 3L, 2L, 3L, 2L,
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L,
    3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("de 1 Ã  5 ans",
    "de 11 Ã  20 ans", "plus de 20 ans"), class = "factor"),
    Reasoning.planting = structure(c(1L, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA), .Label = "Remplacement", class = "factor"), Subcategory = structure(c(1L,
    1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L,
    1L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 2L,
    1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L,
    2L, 2L, 2L, 1L, 2L, 2L, 2L), .Label = c("ESP151", "ESP174"
    ), class = "factor"), Development.stage = structure(c(2L,
    2L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
    2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L,
    2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L,
    1L, 1L, 1L, 2L, 1L, 1L, 1L), .Label = c("Arbre d'espaces ouverts",
    "Arbre de voirie"), class = "factor"), STADEDEDEVELOPPEMENT = structure(c(2L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 2L, 1L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Arbre adulte", "Arbre jeune",
    "Arbre vieillissant"), class = "factor"), Development.stage.diagnosis = structure(c(2L,
    1L, 1L, 1L, 1L, 1L, 1L, 3L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 2L,
    1L, 1L, 2L, 1L, 3L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
    1L, 2L, 1L, 1L, 1L, 1L, 1L), .Label = c("Arbre adulte", "Arbre jeune",
    "Arbre vieillissant"), class = "factor"), Caterpillar.treat.priority = structure(c(NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, 1L, NA, NA, NA, NA, 2L, NA, NA, 1L,
    NA, NA, NA, NA, NA, 1L, NA, 1L, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA), .Label = c("Haute", "Moyenne"
    ), class = "factor"), Recommended.treatment = structure(c(2L,
    NA, 2L, 8L, NA, 3L, 6L, 6L, NA, 6L, NA, 9L, 5L, 7L, 7L, NA,
    NA, 1L, NA, 7L, 7L, 4L, 6L, 9L, 6L, NA, 6L, NA, 2L, NA, NA,
    7L, NA, NA, 7L, 6L, 7L, NA, 7L, 7L, 7L, 7L, 7L, NA, 7L, 2L,
    6L, NA, NA, NA, NA, 6L, 5L), .Label = c("Abattage", "Controle",
    "Controle rÃ©sistographe", "Controle tuteur, attache ou protection",
    "Taille d'Ã©claircie", "Taille de bois mort", "Taille formation et mise au gabarit",
    "Taille mise en sÃ©curitÃ©", "Taille rideau"), class = "factor"),
    Sidewalk = structure(c(1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L,
    1L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L,
    1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L), .Label = c("non",
    "oui"), class = "factor"), PLU.spatial.arrangement = c(NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA, NA), Variety = structure(c(NA, NA,
    NA, NA, NA, NA, NA, 3L, NA, NA, NA, NA, NA, NA, 4L, NA, NA,
    NA, NA, NA, NA, NA, 1L, NA, NA, 2L, NA, 1L, NA, NA, 1L, NA,
    NA, NA, NA, NA, 1L, NA, 1L, 4L, NA, NA, NA, NA, NA, NA, NA,
    NA, NA, NA, NA, NA, NA), .Label = c("Austriaca", "Glauca",
    "Italica", "Pyramidalis"), class = "factor"), Vigor = structure(c(2L,
    2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
    3L, 1L, 2L, 2L, 2L, 2L, 3L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, NA,
    2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 2L, 2L, 2L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("vieillissement dÃ©pÃ©rissement",
    "vigoureux", "vigueur intermÃ©diaire"), class = "factor"),
    Class = c(0L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L,
    0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 1L,
    0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L,
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L), Collar = c(0L,
    0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
    0L, 0L, 0L, 0L, 1L, 0L, 0L), Crown = c(0L, 0L, 0L, 1L, 0L,
    0L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
    1L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
    0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
    1L, 0L, 0L), Root = c(0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
    Trunk = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
    0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
    0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L,
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L)), .Names = c("Sector",
"Plantation.year", "Diagnosis.year", "Next.diagnosis.year", "Stump.diameter",
"Species", "Traffic.frequence", "Botanical.category", "PLU.ident.number",
"PLU.ProtectionCateg", "Diagnosis.remarks", "Diagnosis.renewal.priority",
"Reasoning.planting", "Subcategory", "Development.stage", "STADEDEDEVELOPPEMENT",
"Development.stage.diagnosis", "Caterpillar.treat.priority",
"Recommended.treatment", "Sidewalk", "PLU.spatial.arrangement",
"Variety", "Vigor", "Class", "Collar", "Crown", "Root", "Trunk"
), class = "data.frame", row.names = c(NA, -53L))

Body:
Based on your question above, it seems the problem you are having are variables that have labels and are not numerical in some way? The easiest way to deal with this is to add another variable in your matrix for all 5 variables that are labels and have them have corresponding numbers. So Acer = 1, Alnus = 2 and so forth (class becomes class.id)

Now, with the randomforest package, categorical predictor variables must be specified as factors or else they will be wrongly treated as continuous. So to convert these, just add the code:

converts to factor

as.factor(class.id)

checks to see

is.factor(class.id)

Then you can use your random forest code from the randomforest package. I can't really figure out from your matrix of variables you have listed above, which variables determine whether a tree/species is sick or not, but in essence:

predicts sickness based on your variables

sickness<-randomforest(class.id~variable1, variable2, etc., data=matrix, ntree=4000, importance=TRUE, proximity=TRUE

this code allows you to see importance values as well as plot them

print(sickness)
importance(sickness)
varImpPlot(sickness)


来源: stackexchange

问:
Set cache-control for entire S3 bucket automatically (using bucket policies?)
I need to set cache-control headers for an entire s3 bucket, both existing and future files and was hoping to do it in a bucket policy.
I know I can edit the existing ones and I know how to specify them on put if I upload them myself but unfortunately the app that uploads them cannot set the headers as it uses s3fs to copy the files there.</p>

答:
You can always configure a lambda with a trigger on PUTOBJECT on S3, the lambda will simply change the header of this particular object that was just put.

Then you can run the copy command mentioned above one last time, and all the new objects will be fixed by the lambda.

UPDATE:

Here is a good place to start from: https://www.aaronfagan.ca/blog/2017/how-to-configure-aws-lambda-to-automatically-set-cache-control-headers-on-s3-objects/

ContentLicense: CC BY-SA 3.0


问:
Spring Controller mapping error
I'm new in spring development.
I am trying to make an helloworld application works. But the /welcome path result in a 404 page.

Here is my configuration :

web.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
    <display-name>Archetype Created Web Application</display-name>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>Spring</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Spring</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>
</code>```

Spring-servlet.xml

```<code><beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">

    <mvc:annotation-driven/>
    <context:component-scan base-package="controller" />

    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>
</beans>
</code>```

SpringController.java

```<code>package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class SpringController {
    @RequestMapping("/welcome")
    public ModelAndView helloWorld()
    {
        return new ModelAndView("welcome");
    }
}
</code>```

In the console output I can see :

```<code>INFOS: Mapped "{[/welcome],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView controller.SpringController.helloWorld()
</code>```

But when i go to "http://localhost:8080/test/welcome" I still have a 404 error

Could you help me please?

答:
The problem is likely a URL matching problem in your web.xml

Please change the <servlet-mapping>URL patterns. Try this instead:

```<code><?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
    <display-name>Archetype Created Web Application</display-name>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>Spring</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Spring</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/Spring-servlet.xml</param-value>
    </context-param>
</web-app>
</code>```

You will notice that the url-pattern now is only "/". This will forward any incoming request to your application to the dispatcher servlet, which will forward it to the corresponding controllers. The <context-param>loads your Spring-servlet.xml configuration file into your application context. Make sure the Spring-serlvet.xml file is in your WEB-INF folder.

You should also have a view called "welcome.jsp" in your WEB-INF/jsp/ folder -
 because that is what your SpringController is returning in helloWorld()

Title: Spring Controller mapping error

Body:
I'm new in spring development.
I am trying to make an helloworld application works. But the /welcome path result in a 404 page.

Here is my configuration :

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
    <display-name>Archetype Created Web Application</display-name>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>Spring</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Spring</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

Spring-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">

    <mvc:annotation-driven/>
    <context:component-scan base-package="controller" />

    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>
</beans>

SpringController.java

package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class SpringController {
    @RequestMapping("/welcome")
    public ModelAndView helloWorld()
    {
        return new ModelAndView("welcome");
    }
}

In the console output I can see :

INFOS: Mapped "{[/welcome],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView controller.SpringController.helloWorld()

But when i go to "http://localhost:8080/test/welcome" I still have a 404 error

Could you help me please?

Body:
The problem is likely a URL matching problem in your web.xml

Please change the <servlet-mapping>URL patterns. Try this instead:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
    <display-name>Archetype Created Web Application</display-name>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>Spring</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Spring</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/Spring-servlet.xml</param-value>
    </context-param>
</web-app>

You will notice that the url-pattern now is only "/". This will forward any incoming request to your application to the dispatcher servlet, which will forward it to the corresponding controllers. The <context-param>loads your Spring-servlet.xml configuration file into your application context. Make sure the Spring-serlvet.xml file is in your WEB-INF folder.

You should also have a view called "welcome.jsp" in your WEB-INF/jsp/ folder -
 because that is what your SpringController is returning in helloWorld()


问:
automate SSRS access
I have inherited an SSRS environment which is a mess; Folders named only with numbers, hundreds of reports not accessed in the last 2 months (I checked ExecutionLog), etc..

I wanted to achieve two things…

Because every other day someone asks for read access to random reports, is there any way of making it “public”, meaning anyone can read and open ANY report?

I want to revoke “folder/report creation/move” access to everyone; can it be done without going folder by folder?

Related to it, the other day I found another SSRS box, that had this access?! What is that “everyone” is it a group inside my domain, or is it an SSRS feature that you can make it public so anyone can access?

答:
You can export ALL permissions from SSRS using PowerShell.

I've also detailed a script that allows you to revert every folder to "inherit parent security" so you can control every folder by simply setting the home folder security. Sorry for the shameless plug but I blogged about both in April on SQLShack actually Managing SSRS Security using PowerShell

Both scripts are in that post. I hope that helps

Title: automate SSRS access


问:
Use .htaccess to redirect HTTP to HTTPs
I have tried this post, and many others (1, 2, 3, 4), but they all give me TOO_MANY_REDIRECTS or error 500. So, here is my issue:

With my current .htaccess, this is what happens:

https://www.dukescasino.com/ - works perfectly

https://dukescasino.com/ - redirects to the above which is great

The two options below loads fine, but it should be redirecting to the https version:

http://www.dukescasino.com/

http://dukescasino.com/

Here is the current .htaccess:

```<code><IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
</code>```

I don't believe it is relevant, but if so, here is the list of current active plugins:

Advanced Custom Fields

All In One SEO Pack

Bop Search Box Item Type For Nav Menus

Contact Form 7

Disable Comments

Google XML Sitemaps

Jetpack by WordPress.com

Search & Filter

Slider WD

TablePress

UpdraftPlus - Backup/Restore

Wordfence Security

WPide

WP Smush

WP Super Cache

Tests performed:

Test A:

```<code><IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
</code>```

Result: ERR_TOO_MANY_REDIRECTS

Test B:

```<code><IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
</code>```

Result: ERR_TOO_MANY_REDIRECTS

Test C:

```<code><IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{SERVER_PORT} ^80$
 RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
</code>```

Result: ERR_TOO_MANY_REDIRECTS

Test D:

```<code><IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
</code>```

Result: ERR_TOO_MANY_REDIRECTS

Test E:

```<code><IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI}$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}$1

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
</code>```

Result: 302 found. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

答:
Just add this code, And it will work like charm:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST}#%{HTTPS}s ^www\.([^#]+)#(?:off|on(s)) [NC]
    RewriteRule ^ http%2://%1%{REQUEST_URI} [R=301,L]
</IfModule>
```

ContentLicense: CC BY-SA 4.0

Title: Use .htaccess to redirect HTTP to HTTPs

Body:
I have tried this post, and many others (1, 2, 3, 4), but they all give me TOO_MANY_REDIRECTS or error 500. So, here is my issue:

With my current .htaccess, this is what happens:

https://www.dukescasino.com/ - works perfectly

https://dukescasino.com/ - redirects to the above which is great

The two options below loads fine, but it should be redirecting to the https version:

http://www.dukescasino.com/

http://dukescasino.com/

Here is the current .htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

I don't believe it is relevant, but if so, here is the list of current active plugins:

Advanced Custom Fields

All In One SEO Pack

Bop Search Box Item Type For Nav Menus

Contact Form 7

Disable Comments

Google XML Sitemaps

Jetpack by WordPress.com

Search & Filter

Slider WD

TablePress

UpdraftPlus - Backup/Restore

Wordfence Security

WPide

WP Smush

WP Super Cache

Tests performed:

Test A:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Result: ERR_TOO_MANY_REDIRECTS

Test B:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Result: ERR_TOO_MANY_REDIRECTS

Test C:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{SERVER_PORT} ^80$
 RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Result: ERR_TOO_MANY_REDIRECTS

Test D:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Result: ERR_TOO_MANY_REDIRECTS

Test E:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI}$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}$1

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Result: 302 found. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.


问:
SSTable multiple directories
I have recently started working on Cassandra everything was well documented and easy to understand so far.

However I am unable to find any answer to the following question:

Why do Cassandra data directory (/var/lib/cassandra/data/ks) have multiple subdirectories for the same SSTable?
At why what point is the new directory is created?

[centos@cs1 2017-06-03--19-46-14 cassandra $] ls -l /var/lib/cassandra/data/ks
total 8
drwxr-xr-x. 3 root root 4096 Jun  3 19:46 events-4f35e2c0482911e79119511599d22fe7
drwxr-xr-x. 3 root root 4096 Jun  3 19:41 events-7a34c34047f411e7aee3b9dc2549db1c

[centos@cs1 2017-06-03--19-46-10 cassandra $] tree
.
├── events-4f35e2c0482911e79119511599d22fe7
│   ├── ks-events-ka-4-CompressionInfo.db
│   ├── ks-events-ka-4-Data.db
│   ├── ks-events-ka-4-Digest.sha1
│   ├── ks-events-ka-4-Filter.db
│   ├── ks-events-ka-4-Index.db
│   ├── ks-events-ka-4-Statistics.db
│   ├── ks-events-ka-4-Summary.db
│   ├── ks-events-ka-4-TOC.txt
│   └── snapshots
└── events-7a34c34047f411e7aee3b9dc2549db1c
    └── snapshots
        └── 1496472654574-device_log
            └── manifest.json

5 directories, 9 files```

I noticed that flushing or compacting does not create new directory. It Simply adds/compacts the most recent SSTable directory

答: If you drop a keyspace (ks as in my case) it does not deletes the keyspace directory (/var/lib/cassandra/data/ks) from the filesystem (auto_snapshot:true). That was the reason I was still seeing old - directory/s.</p>

Title: SSTable multiple directories

Body:
I have recently started working on Cassandra everything was well documented and easy to understand so far.

However I am unable to find any answer to the following question:

Why do Cassandra data directory (/var/lib/cassandra/data/ks) have multiple subdirectories for the same SSTable?
At why what point is the new directory is created?

[centos@cs1 2017-06-03--19-46-14 cassandra $] ls -l /var/lib/cassandra/data/ks
total 8
drwxr-xr-x. 3 root root 4096 Jun  3 19:46 events-4f35e2c0482911e79119511599d22fe7
drwxr-xr-x. 3 root root 4096 Jun  3 19:41 events-7a34c34047f411e7aee3b9dc2549db1c

[centos@cs1 2017-06-03--19-46-10 cassandra $] tree
.
├── events-4f35e2c0482911e79119511599d22fe7
│   ├── ks-events-ka-4-CompressionInfo.db
│   ├── ks-events-ka-4-Data.db
│   ├── ks-events-ka-4-Digest.sha1
│   ├── ks-events-ka-4-Filter.db
│   ├── ks-events-ka-4-Index.db
│   ├── ks-events-ka-4-Statistics.db
│   ├── ks-events-ka-4-Summary.db
│   ├── ks-events-ka-4-TOC.txt
│   └── snapshots
└── events-7a34c34047f411e7aee3b9dc2549db1c
    └── snapshots
        └── 1496472654574-device_log
            └── manifest.json

5 directories, 9 files

I noticed that flushing or compacting does not create new directory. It Simply adds/compacts the most recent SSTable directory


问:
C - How to make sure that an array contains 8 integers with the value 0 or 1?
That's my code so far:

```<code>int main(void) {
    int byte[8], position = 0, match8 = 0;
    printf("Please enter 1 byte as a binary sequence: ");
    match8 = scanf("%1d%1d%1d%1d%1d%1d%1d%1d", &byte[0], &byte[1], &byte[2], &byte[3], &byte[4], &byte[5], &byte[6],&byte[7]);
    return 0;
}
</code>```

Now I want to make sure that the user made a correct input and if not the program should say "Error! Please enter 1 byte as a binary sequence: " and check the input again.

I tried:

```<code>while(getchar() != '\n' || match8 != 8) {
    ...do something
}
</code>```

But I can't figure out how to check if the array contains only 0 and 1.

I hope you can help me with my problem :)

答:
Suggest to avoid scanf() and use fgets() to read a line of user input

```<code>char buf[100];
if (fgets(buf, sizeof buf, stdin)) {
</code>```

Then use strspn() to test buf[] for only '0' or '1'

size_t strspn(const char *s1, const char *s2);

  The strspn function computes the length of the maximum initial segment of the string pointed to by s1 which consists entirely of characters from the string pointed to by s2.  C11 7.23.5.6

```<code>  size_t offset = strspn(buf, "01");
  if (buf[offset] == '\n') {
    buf[offset--] = '\0'; // eat trailing \n
  }
  if (offset == 8 && buf[offset] == '\0') {
    sscanf(buf, "%1d%1d%1d%1d%1d%1d%1d%1d",
        &byte[0], &byte[1], &byte[2], &byte[3], &byte[4], &byte[5], &byte[6],&byte[7]);
    // Success!
  }
}
</code>```

Body:
That's my code so far:

int main(void) {
    int byte[8], position = 0, match8 = 0;
    printf("Please enter 1 byte as a binary sequence: ");
    match8 = scanf("%1d%1d%1d%1d%1d%1d%1d%1d", &byte[0], &byte[1], &byte[2], &byte[3], &byte[4], &byte[5], &byte[6],&byte[7]);
    return 0;
}

Now I want to make sure that the user made a correct input and if not the program should say "Error! Please enter 1 byte as a binary sequence: " and check the input again.

I tried:

while(getchar() != '\n' || match8 != 8) {
    ...do something
}

But I can't figure out how to check if the array contains only 0 and 1.

I hope you can help me with my problem :)

Body:
Suggest to avoid scanf() and use fgets() to read a line of user input

char buf[100];
if (fgets(buf, sizeof buf, stdin)) {

Then use strspn() to test buf[] for only '0' or '1'

size_t strspn(const char *s1, const char *s2);

  The strspn function computes the length of the maximum initial segment of the string pointed to by s1 which consists entirely of characters from the string pointed to by s2.  C11 7.23.5.6

  size_t offset = strspn(buf, "01");
  if (buf[offset] == '\n') {
    buf[offset--] = '\0'; // eat trailing \n
  }
  if (offset == 8 && buf[offset] == '\0') {
    sscanf(buf, "%1d%1d%1d%1d%1d%1d%1d%1d",
        &byte[0], &byte[1], &byte[2], &byte[3], &byte[4], &byte[5], &byte[6],&byte[7]);
    // Success!
  }
}


问:
Swift 3 Passing ArrayList object variables to String Array
I have a list of objects that have a getName func that returns a string, and am looking to populate another list of Strings by looping through the first list and calling the objects functions to pass it through. Right now my code looks like this.

```<code>    let brT = Skill(name: "brT", difficulty: 0.6)
    let brP = Skill(name: "brP", difficulty: 0.7)
    let brS = Skill(name: "brS", difficulty: 0.7)
    let bkT = Skill(name: "bkT", difficulty: 0.6)
    let bkP = Skill(name: "bkP", difficulty: 0.6)
    let bkS = Skill(name: "bkS", difficulty: 0.6)

    let list1 = [brT, brP, brS, bkT, brP, brS]

    var list: <String>

    for (index, element) in list1.enumerated() {
        list.append(element.getName())
    }
</code>```

I'm trying to do this for an app so the list of Strings display in a table view, and then the double will sum all the doubles and display to a UI label below the table. Finally I need the String list to be able to be looked through for a search bar that can add the object string variable to the table view, and add the double to another list that does the label output I mentioned above, am I on the right track?

答:
You should declare and initialize list like this:

```<code>var list = [String]()
</code>```

which is the same as:

```<code>var list = Array<String>()
</code>```

Also, there's no need for enumerated() here. Just do:

```<code>for element in list1 {
    list.append(element.getName())
}
</code>```

Or, better yet, use map to do everything in a single step, making list a constant:

```<code>let list = list1.map { $0.getName() }
</code>```

Body:
I have a list of objects that have a getName func that returns a string, and am looking to populate another list of Strings by looping through the first list and calling the objects functions to pass it through. Right now my code looks like this.

    let brT = Skill(name: "brT", difficulty: 0.6)
    let brP = Skill(name: "brP", difficulty: 0.7)
    let brS = Skill(name: "brS", difficulty: 0.7)
    let bkT = Skill(name: "bkT", difficulty: 0.6)
    let bkP = Skill(name: "bkP", difficulty: 0.6)
    let bkS = Skill(name: "bkS", difficulty: 0.6)

    let list1 = [brT, brP, brS, bkT, brP, brS]

    var list: <String>

    for (index, element) in list1.enumerated() {
        list.append(element.getName())
    }

I'm trying to do this for an app so the list of Strings display in a table view, and then the double will sum all the doubles and display to a UI label below the table. Finally I need the String list to be able to be looked through for a search bar that can add the object string variable to the table view, and add the double to another list that does the label output I mentioned above, am I on the right track?

Body:
You should declare and initialize list like this:

var list = [String]()

which is the same as:

var list = Array<String>()

Also, there's no need for enumerated() here. Just do:

for element in list1 {
    list.append(element.getName())
}

Or, better yet, use map to do everything in a single step, making list a constant:

let list = list1.map { $0.getName() }


问:
Align the table on the center of the page
I just want to put the table in the middle of the page. Any help would be great.</p>

```<code><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Randy's first html web page !</title>
<style type="text/css">
body
{background-image:url('Koala.gif');}
h1
{
text-align:center;
}
h2
{
text-align:center;
}
p
{
text-align:center;
font-size:200%;
color:#00fff0;
}
div
{
background-color:#efffff;
}
</style>
</head>
<h1> Hello Professor</h1>
<h2> By: Randy White</h2>
<P> I haven't done anything like this before.</P>
<P>Seems to be ok</P>
<P><img src="Hydrangeas.jpg" width="150" height="100" alt="Hydrangeas.jpg"></P>
<table border="1">
<tr>
<th>Month</th>
<th>Day</th>
<th>Year</th>
</tr>
<tr>
<td>December</td>
<td>1</td>
<td>2010</td>
</tr>
</table>
<a href="http://www.google.com">Visit Google!</a>
</body>
</html>
</code>```

答:
Try:

```<code>table {
    width: 50%;
    margin-left: auto;
    margin-right: auto;
}
</code>```

or:

```<code>table {
    width: 200px;
    margin-left: auto;
    margin-right: auto;
}
</code>```

BTW, this sets this for all tables. You might want to have the properties on a more specific selector (like table.someclass).

ContentLicense: CC BY-SA 2.5

Body:
I just want to put the table in the middle of the page. Any help would be great.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">

<title>Randy's first html web page !</title>

 Hello Professor

 By: Randy White

 I haven't done anything like this before.

Seems to be ok

Month
Day
Year

December
1
2010

Visit Google!

Body:
Try:

table {
    width: 50%;
    margin-left: auto;
    margin-right: auto;
}

or:

table {
    width: 200px;
    margin-left: auto;
    margin-right: auto;
}

BTW, this sets this for all tables. You might want to have the properties on a more specific selector (like table.someclass).


问:
ANSI coloring in emacs start-process output buffer
I am running a process from within emacs which uses ANSI color codes in its output.

I'm using start-process to create the process, and provided a custom buffer name for the process's output

```<code>(start-process "foo" "*Foo*" foo-command foo-args)
</code>```

If I open *Foo* buffer, the ANSI color codes are printed in their raw format to the buffer

```<code>^[[36msome output message^[[m
^[[1;35msome output message^[[m
^[[1;34msome output message^[[m
</code>```

I see in this SO answer it is possible to add colorization to a buffer; however I'm unsure as to how to do it with a buffer created using start-process

Is it possible to convert those ANSI color codes to colorised output in my *Foo* buffer?

答:
It doesn't look like the linked answers had any solutions not involving comint-mode.  You can use ansi-color-apply-on-region to colorize the output buffer, eg.

```<code>(set-process-sentinel
 (start-process "foo" "*Foo*" foo-command foo-args)
 (lambda (p _m)
   (when (eq 0 (process-exit-status p))
     (with-current-buffer (process-buffer p)
       (ansi-color-apply-on-region (point-min) (point-max))))))
</code>```

Body:
I am running a process from within emacs which uses ANSI color codes in its output.

I'm using start-process to create the process, and provided a custom buffer name for the process's output

(start-process "foo" "*Foo*" foo-command foo-args)

If I open *Foo* buffer, the ANSI color codes are printed in their raw format to the buffer

^[[36msome output message^[[m
^[[1;35msome output message^[[m
^[[1;34msome output message^[[m

I see in this SO answer it is possible to add colorization to a buffer; however I'm unsure as to how to do it with a buffer created using start-process

Is it possible to convert those ANSI color codes to colorised output in my *Foo* buffer?

Body:
It doesn't look like the linked answers had any solutions not involving comint-mode.  You can use ansi-color-apply-on-region to colorize the output buffer, eg.

(set-process-sentinel
 (start-process "foo" "*Foo*" foo-command foo-args)
 (lambda (p _m)
   (when (eq 0 (process-exit-status p))
     (with-current-buffer (process-buffer p)
       (ansi-color-apply-on-region (point-min) (point-max))))))


问:
Running an SDL program
So I've recently started to learn SDL2, and I am trying run a simple program, but I don't know what I'm doing wrong. My IDE (Code Blocks) says that the line of code SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO); has some kind of error and won't run. What am I missing or doing wrong?</p>

```<code>#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <SDL2/SDL.h>

static const int width = 800;
static const int height = 600;

int main(int argc, char **argv)
{
    SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO); // <-Supposed Error

    SDL_Window *window = SDL_CreateWindow("Hey\n", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_OPENGL);
    SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
    SDL_SetRendererDrawColor(renderer, 255, 0, 0, 255);
    bool running = true;
    SDL_Event event;
    while(running)
    {
        while(SDL_PollEvent(&event))
        {
            if(event.type == SDL_QUIT)
            {
                running = false;
            }
        }
        SDL_RenderClear(renderer);
        SDL_RenderPresent(renderer);
    }
    SDL_DestroyRenderer(renderer);
    SDL_DestroyWindow(window);
    SDL_Quit();
    return 0;
}
</code>```

答:
The linker error that I get is:

```<code>undefined reference to `SDL_SetRendererDrawColor'
</code>```

Because this function doesn't exist in SDL2, you must use SDL_SetRenderDrawColor().

```<code>SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
</code>```

Title: Running an SDL program

Body:
So I've recently started to learn SDL2, and I am trying run a simple program, but I don't know what I'm doing wrong. My IDE (Code Blocks) says that the line of code SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO); has some kind of error and won't run. What am I missing or doing wrong?

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <SDL2/SDL.h>

static const int width = 800;
static const int height = 600;

int main(int argc, char **argv)
{
    SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO); // <-Supposed Error

    SDL_Window *window = SDL_CreateWindow("Hey\n", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_OPENGL);
    SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
    SDL_SetRendererDrawColor(renderer, 255, 0, 0, 255);
    bool running = true;
    SDL_Event event;
    while(running)
    {
        while(SDL_PollEvent(&event))
        {
            if(event.type == SDL_QUIT)
            {
                running = false;
            }
        }
        SDL_RenderClear(renderer);
        SDL_RenderPresent(renderer);
    }
    SDL_DestroyRenderer(renderer);
    SDL_DestroyWindow(window);
    SDL_Quit();
    return 0;
}

Body:
The linker error that I get is:

undefined reference to `SDL_SetRendererDrawColor'

Because this function doesn't exist in SDL2, you must use SDL_SetRenderDrawColor().

SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);


问:
NameError issue with Desktop
I am new to python.
I am trying to run my first script... I think this is what is called.
I have following in a python doc called "intro.py":

```<code>print('hello world')
</code>```

This is saved under my Desktop (running Windows).
When I go to cmd, I type:

```<code>>>> Desktop/intro.py
</code>```

When I do this I get a response that says:

```<code>Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
NameError: name 'Desktop' is not defined
</code>```

Can someone please explain to me my issue? Thanks

答:
Windows shell refers to what you see, when you hit windows-button + r and then type cmd and hit enter.

To start your script: hit windows-button + r and then type cmd and hit enter

After that navigate in the command line to your desktop using cd and then type python init.py to execute your script.

It seems to me like you were already in the python shell, when you tried to start your script.

To see the difference open the command line like before: hit windows-button + r and then type cmd and hit enter, remember how your terminal looks like now, then type in python and note the three >>> at the beginning of the line. This is then called the Python shell.

You tried to execute windows commands in this python shell, which obviously does not work. However you could also theoretically write your script   in this python shell. But this is really awkward.

I suggest you to use an IDE. If I'm not wrong IDLE comes with the python 3 interpreter already or I can recommend my personal favorite PyCharm.

Title: NameError issue with Desktop

Body:
I am new to python.
I am trying to run my first script... I think this is what is called.
I have following in a python doc called "intro.py":

print('hello world')

This is saved under my Desktop (running Windows).
When I go to cmd, I type:

>>> Desktop/intro.py

When I do this I get a response that says:

Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
NameError: name 'Desktop' is not defined

Can someone please explain to me my issue? Thanks


问:
read data file with mixed numbers and texts in r
I have data files that contain the following:
the first 10 columns are numbers, the last column is text. They are separated by space. The problem is that the text in the last column may also contain space. So when I used read.table() I got the following error:

```<code>Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  :
line 21 did not have 11 elements
</code>```

what's the easiest way of reading the first 10 columns into a data matrix, and the last column into a string vector? Should I use readLines() first then process it?

答:
You could reformat your file before reading it in R.
For example, using perl in a terminal:

```<code>perl -pe 's/(?<=[0-9]) /,/g' myfile.txt > myfile.csv
</code>```

This replaces every space preceded by a number by a comma.
Then read it into R using read.csv:

```<code>df = read.csv("myfile.csv")
</code>```

Body:
I have data files that contain the following:
the first 10 columns are numbers, the last column is text. They are separated by space. The problem is that the text in the last column may also contain space. So when I used read.table() I got the following error:

Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  :
line 21 did not have 11 elements

what's the easiest way of reading the first 10 columns into a data matrix, and the last column into a string vector? Should I use readLines() first then process it?

Body:
You could reformat your file before reading it in R.
For example, using perl in a terminal:

perl -pe 's/(?<=[0-9]) /,/g' myfile.txt > myfile.csv

This replaces every space preceded by a number by a comma.
Then read it into R using read.csv:

df = read.csv("myfile.csv")


问:
My css and javascript files not running
I installed Nginx server for my laravel project. But css and javascript file not working. Css and javascript file downloadable on server. For example http://myipaddress/css/bootstrap.css download the bootstrap.css file. I call the css file like <link href="{{ URL::asset('css/bootstrap.css') }}" rel="stylesheet"> like this.

My source code

My public folder permissions

/etc/nginx/sites-available/default looks like the following

```<code># Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

# SSL configuration
#
 listen 443 ssl default_server;
 listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;

root /var/www/english4-u.com/public;

# Add index.php to the list if you are using PHP
index index.php index.html index.htm;

server_name english4-u.com;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;

location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ /index.php?$query_string;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
#   include snippets/fastcgi-php.conf;
#
#   # With php7.0-cgi alone:
#   fastcgi_pass 127.0.0.1:9000;
#   # With php7.0-fpm:
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
    deny all;
}

access_log /var/log/nginx/english4-u.com-access.log;
error_log  /var/log/nginx/english4-u.com-error.log error;

location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt  { access_log off; log_not_found off; }

charset utf-8;

error_page 404 /index.php;}
</code>```

Can you help me with this?

Thank You.

答:
Have you seen the movie Hidden Figures? There's a scene where a main character can see censored information by holding up redacted papers to a lamp. The relevance you may ask? Your censoring in the question wasn't very hard circumvent.

When I visit your server and check the Console I get ...

The stylesheet http://###/css/bootstrap.css was not loaded because its MIME type, "application/octet-stream", is not "text/css".

  The stylesheet http://###/css/font-awesome.min.css was not loaded because its MIME type, "application/octet-stream", is not "text/css".

  The stylesheet http://###/css/style.css was not loaded because its MIME type, "application/octet-stream", is not "text/css".

Fix the mime-types of the stylesheets and they should load properly. I would start looking in /etc/nginx/mime.types and verify that you've mapped the css extension to text/css.

Title: My css and javascript files not running

Body:
I installed Nginx server for my laravel project. But css and javascript file not working. Css and javascript file downloadable on server. For example http://myipaddress/css/bootstrap.css download the bootstrap.css file. I call the css file like <link href="{{ URL::asset('css/bootstrap.css') }}" rel="stylesheet"> like this.

My source code

My public folder permissions

/etc/nginx/sites-available/default looks like the following

# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

# SSL configuration
#
 listen 443 ssl default_server;
 listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;

root /var/www/english4-u.com/public;

# Add index.php to the list if you are using PHP
index index.php index.html index.htm;

server_name english4-u.com;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;

location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ /index.php?$query_string;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
#   include snippets/fastcgi-php.conf;
#
#   # With php7.0-cgi alone:
#   fastcgi_pass 127.0.0.1:9000;
#   # With php7.0-fpm:
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
    deny all;
}

access_log /var/log/nginx/english4-u.com-access.log;
error_log  /var/log/nginx/english4-u.com-error.log error;

location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt  { access_log off; log_not_found off; }

charset utf-8;

error_page 404 /index.php;}

Can you help me with this?

Thank You.


问:
Regular expression with multiline block of text (python)
I have the following file named seq.fasta:

```<code>>AAM15934.1| NtrX [Gluconacetobacter diazotrophicus]| NTRX1 | Response_reg - Sigma54_activat - HTH_8
MGHEILIVDDEPDIRLLVEGILRDEGYETRLAGDSDSAISAFRARRPSLVILDVWLQGSRLDGLGILQAI
QGEEPVVPTIMISGHGTIETAVAALQHGAYDFIEKPFQSDRLLLVVRRALEASRLARENAELRLRAGPEA
MLYGDSPVIAGVRNQIERVAPSGSRVLISGAAGAGKEVAARMIHARSPGPKAFIALNCATLAPGRFEEEL
FGIEGAPDGTGRRTGVLERAHGGTLLLDEVSDMPIETQGKIVRALQDQSFERVGGASRVKVDVRVLAATN
RDLQEAIAAGRFREDLYYRLAVVPLRVPSLRERREDIPGLARLFLRRAAENAGLPLRDLSGDAVAALQSY
DWPGNARELRNLMERLLIMMPGNGSDLIRAEMLPPSVGQGAPALLKFDPAADVMGLPLREARDLFETQYL
QAQLLRFGGNISRTAGFVGMERSALHRKLKQLGVTSEERGAG

>WP_002731145.1| NtrX [Phaeospirillum molischianum]| NTRX1 | Response_reg - Sigma54_activat - HTH_8
MAHDILIVDDEADIRVLIAGILEDEGHSTREAANADEALERIRARRPSLVIQDIWLQGSRLDGLGVLDEI
KREHPDVPVVMISGHGTIETAVQAIKQGAYDFIEKPFKADRLLLVVDRAIESARLKRENQELRVRSGSTG
DLVGISPALVQIRQTIERVAPTNSRVLITGPAGSGKEVAARMIHAHSRRTEGPFVVVNCAAMHPDRMEIE
LFGTEYGADGSTSPRKIGTFEQAHSGTLLLDEVADMPLETQGKIVRVLQDQTFERVGGGKRVEVDVRVIA
TTNRDLQSEMIAGHFREDLFYRLNVVPIRMPALRDGKEDIPLLARQFMQLAAQLAGVPPRPLGEDALAAL
QAYDWPGNVRQLRNAIDWLLIMAPGDWRDPVRADMLPSEIGAITPAVLRWEKSSEIMTLPLREARELFER
EYLLAQVNRFAGNISRTAAFVGMERSALHRKLKLLGINTDEKVR

>WP_002967695.1| NtrX  [Brucella abortus]| NTRX1 | Response_reg - Sigma54_activat - HTH_8
MAADILVVDDEVDIRDLVAGILSDEGHETRTAFDADSALAAINDRAPRLVFLDIWLQGSRLDGLALLDEI
KKQHPELPVVMISGHGNIETAVSAIRRGAYDFIEKPFKADRLILVAERALETSKLKREVSDLRKRTGDQL
ELVGTSLAMNQLRQTIERVAPTNSRIMITGPSGAGKELVARTIHAQSSRANGPFVTVNAATITPERMEIE
LFGTEMDGGERKVGALEEAHGGILYLDEVADMPRETQNKILRVLVDQQFERVGGTKRVKVDVRIISSTAQ
NLEGMIAEGTFREDLFHRLSVVPVQVPALAARREDIPSLVEFFMKQIAEQAGIKPRKIGPDAMAVLQAHS
WPGNLRQLRNNVERLMILTRGDDPDELVTADLLPAEIGDTLPRAPTESDQHIMALPLREARERFEKEYLI
AQINRFGGNISRTAEFVGMERSALHRKLKSLGV
</code>```

I want to put each block of letters in a list.
Example:

List Contents:

```<code>List[0] = MGHEILIVDDEPDIRLLVEGILRDEGYETRLAGDSDSAISAFRARRPSLVILDVWLQGSRLDGLGILQAI
QGEEPVVPTIMISGHGTIETAVAALQHGAYDFIEKPFQSDRLLLVVRRALEASRLARENAELRLRAGPEA
MLYGDSPVIAGVRNQIERVAPSGSRVLISGAAGAGKEVAARMIHARSPGPKAFIALNCATLAPGRFEEEL
FGIEGAPDGTGRRTGVLERAHGGTLLLDEVSDMPIETQGKIVRALQDQSFERVGGASRVKVDVRVLAATN
RDLQEAIAAGRFREDLYYRLAVVPLRVPSLRERREDIPGLARLFLRRAAENAGLPLRDLSGDAVAALQSY
DWPGNARELRNLMERLLIMMPGNGSDLIRAEMLPPSVGQGAPALLKFDPAADVMGLPLREARDLFETQYL
QAQLLRFGGNISRTAGFVGMERSALHRKLKQLGVTSEERGAG

List[1] = MAHDILIVDDEADIRVLIAGILEDEGHSTREAANADEALERIRARRPSLVIQDIWLQGSRLDGLGVLDEI
KREHPDVPVVMISGHGTIETAVQAIKQGAYDFIEKPFKADRLLLVVDRAIESARLKRENQELRVRSGSTG
DLVGISPALVQIRQTIERVAPTNSRVLITGPAGSGKEVAARMIHAHSRRTEGPFVVVNCAAMHPDRMEIE
LFGTEYGADGSTSPRKIGTFEQAHSGTLLLDEVADMPLETQGKIVRVLQDQTFERVGGGKRVEVDVRVIA
TTNRDLQSEMIAGHFREDLFYRLNVVPIRMPALRDGKEDIPLLARQFMQLAAQLAGVPPRPLGEDALAAL
QAYDWPGNVRQLRNAIDWLLIMAPGDWRDPVRADMLPSEIGAITPAVLRWEKSSEIMTLPLREARELFER
EYLLAQVNRFAGNISRTAAFVGMERSALHRKLKLLGINTDEKVR

List[2] = MAADILVVDDEVDIRDLVAGILSDEGHETRTAFDADSALAAINDRAPRLVFLDIWLQGSRLDGLALLDEI
KKQHPELPVVMISGHGNIETAVSAIRRGAYDFIEKPFKADRLILVAERALETSKLKREVSDLRKRTGDQL
ELVGTSLAMNQLRQTIERVAPTNSRIMITGPSGAGKELVARTIHAQSSRANGPFVTVNAATITPERMEIE
LFGTEMDGGERKVGALEEAHGGILYLDEVADMPRETQNKILRVLVDQQFERVGGTKRVKVDVRIISSTAQ
NLEGMIAEGTFREDLFHRLSVVPVQVPALAARREDIPSLVEFFMKQIAEQAGIKPRKIGPDAMAVLQAHS
WPGNLRQLRNNVERLMILTRGDDPDELVTADLLPAEIGDTLPRAPTESDQHIMALPLREARERFEKEYLI
AQINRFGGNISRTAEFVGMERSALHRKLKSLGV
</code>```

But i'm struggling to split and put them in a list, my code is like:

```<code>import re

myfile = open('seq.fasta', 'r').read()

regex = re.compile(r'^>([^\n\r]+)[\n\r]([A-Z\n\r]+)', re.MULTILINE)
matches = [m.groups() for m in regex.finditer(myfile)]

for m in matches:
    onlySequences = (m[1])

print(onlySequences)
</code>```

The variable onlySequences returns just the last one block of letters, how do i keep all of them, each one in a number of a list?

答:
You don't need regex to do that. A better way consists to read the file line by line:</p>

```<code>with open('seq.fasta', 'r') as fh:
    result = []
    for line in fh:
        if line.startswith('>'):
            temp = ''
        elif not line.strip():
            result.append(temp)
        else:
            temp = temp + line

    if temp:
        result.append(temp)

    print("\n".join(result))
</code>```

Body:
I have the following file named seq.fasta:

>AAM15934.1| NtrX [Gluconacetobacter diazotrophicus]| NTRX1 | Response_reg - Sigma54_activat - HTH_8
MGHEILIVDDEPDIRLLVEGILRDEGYETRLAGDSDSAISAFRARRPSLVILDVWLQGSRLDGLGILQAI
QGEEPVVPTIMISGHGTIETAVAALQHGAYDFIEKPFQSDRLLLVVRRALEASRLARENAELRLRAGPEA
MLYGDSPVIAGVRNQIERVAPSGSRVLISGAAGAGKEVAARMIHARSPGPKAFIALNCATLAPGRFEEEL
FGIEGAPDGTGRRTGVLERAHGGTLLLDEVSDMPIETQGKIVRALQDQSFERVGGASRVKVDVRVLAATN
RDLQEAIAAGRFREDLYYRLAVVPLRVPSLRERREDIPGLARLFLRRAAENAGLPLRDLSGDAVAALQSY
DWPGNARELRNLMERLLIMMPGNGSDLIRAEMLPPSVGQGAPALLKFDPAADVMGLPLREARDLFETQYL
QAQLLRFGGNISRTAGFVGMERSALHRKLKQLGVTSEERGAG

>WP_002731145.1| NtrX [Phaeospirillum molischianum]| NTRX1 | Response_reg - Sigma54_activat - HTH_8
MAHDILIVDDEADIRVLIAGILEDEGHSTREAANADEALERIRARRPSLVIQDIWLQGSRLDGLGVLDEI
KREHPDVPVVMISGHGTIETAVQAIKQGAYDFIEKPFKADRLLLVVDRAIESARLKRENQELRVRSGSTG
DLVGISPALVQIRQTIERVAPTNSRVLITGPAGSGKEVAARMIHAHSRRTEGPFVVVNCAAMHPDRMEIE
LFGTEYGADGSTSPRKIGTFEQAHSGTLLLDEVADMPLETQGKIVRVLQDQTFERVGGGKRVEVDVRVIA
TTNRDLQSEMIAGHFREDLFYRLNVVPIRMPALRDGKEDIPLLARQFMQLAAQLAGVPPRPLGEDALAAL
QAYDWPGNVRQLRNAIDWLLIMAPGDWRDPVRADMLPSEIGAITPAVLRWEKSSEIMTLPLREARELFER
EYLLAQVNRFAGNISRTAAFVGMERSALHRKLKLLGINTDEKVR

>WP_002967695.1| NtrX  [Brucella abortus]| NTRX1 | Response_reg - Sigma54_activat - HTH_8
MAADILVVDDEVDIRDLVAGILSDEGHETRTAFDADSALAAINDRAPRLVFLDIWLQGSRLDGLALLDEI
KKQHPELPVVMISGHGNIETAVSAIRRGAYDFIEKPFKADRLILVAERALETSKLKREVSDLRKRTGDQL
ELVGTSLAMNQLRQTIERVAPTNSRIMITGPSGAGKELVARTIHAQSSRANGPFVTVNAATITPERMEIE
LFGTEMDGGERKVGALEEAHGGILYLDEVADMPRETQNKILRVLVDQQFERVGGTKRVKVDVRIISSTAQ
NLEGMIAEGTFREDLFHRLSVVPVQVPALAARREDIPSLVEFFMKQIAEQAGIKPRKIGPDAMAVLQAHS
WPGNLRQLRNNVERLMILTRGDDPDELVTADLLPAEIGDTLPRAPTESDQHIMALPLREARERFEKEYLI
AQINRFGGNISRTAEFVGMERSALHRKLKSLGV

I want to put each block of letters in a list.
Example:

List Contents:

List[0] = MGHEILIVDDEPDIRLLVEGILRDEGYETRLAGDSDSAISAFRARRPSLVILDVWLQGSRLDGLGILQAI
QGEEPVVPTIMISGHGTIETAVAALQHGAYDFIEKPFQSDRLLLVVRRALEASRLARENAELRLRAGPEA
MLYGDSPVIAGVRNQIERVAPSGSRVLISGAAGAGKEVAARMIHARSPGPKAFIALNCATLAPGRFEEEL
FGIEGAPDGTGRRTGVLERAHGGTLLLDEVSDMPIETQGKIVRALQDQSFERVGGASRVKVDVRVLAATN
RDLQEAIAAGRFREDLYYRLAVVPLRVPSLRERREDIPGLARLFLRRAAENAGLPLRDLSGDAVAALQSY
DWPGNARELRNLMERLLIMMPGNGSDLIRAEMLPPSVGQGAPALLKFDPAADVMGLPLREARDLFETQYL
QAQLLRFGGNISRTAGFVGMERSALHRKLKQLGVTSEERGAG

List[1] = MAHDILIVDDEADIRVLIAGILEDEGHSTREAANADEALERIRARRPSLVIQDIWLQGSRLDGLGVLDEI
KREHPDVPVVMISGHGTIETAVQAIKQGAYDFIEKPFKADRLLLVVDRAIESARLKRENQELRVRSGSTG
DLVGISPALVQIRQTIERVAPTNSRVLITGPAGSGKEVAARMIHAHSRRTEGPFVVVNCAAMHPDRMEIE
LFGTEYGADGSTSPRKIGTFEQAHSGTLLLDEVADMPLETQGKIVRVLQDQTFERVGGGKRVEVDVRVIA
TTNRDLQSEMIAGHFREDLFYRLNVVPIRMPALRDGKEDIPLLARQFMQLAAQLAGVPPRPLGEDALAAL
QAYDWPGNVRQLRNAIDWLLIMAPGDWRDPVRADMLPSEIGAITPAVLRWEKSSEIMTLPLREARELFER
EYLLAQVNRFAGNISRTAAFVGMERSALHRKLKLLGINTDEKVR

List[2] = MAADILVVDDEVDIRDLVAGILSDEGHETRTAFDADSALAAINDRAPRLVFLDIWLQGSRLDGLALLDEI
KKQHPELPVVMISGHGNIETAVSAIRRGAYDFIEKPFKADRLILVAERALETSKLKREVSDLRKRTGDQL
ELVGTSLAMNQLRQTIERVAPTNSRIMITGPSGAGKELVARTIHAQSSRANGPFVTVNAATITPERMEIE
LFGTEMDGGERKVGALEEAHGGILYLDEVADMPRETQNKILRVLVDQQFERVGGTKRVKVDVRIISSTAQ
NLEGMIAEGTFREDLFHRLSVVPVQVPALAARREDIPSLVEFFMKQIAEQAGIKPRKIGPDAMAVLQAHS
WPGNLRQLRNNVERLMILTRGDDPDELVTADLLPAEIGDTLPRAPTESDQHIMALPLREARERFEKEYLI
AQINRFGGNISRTAEFVGMERSALHRKLKSLGV

But i'm struggling to split and put them in a list, my code is like:

import re

myfile = open('seq.fasta', 'r').read()

regex = re.compile(r'^>([^\n\r]+)[\n\r]([A-Z\n\r]+)', re.MULTILINE)
matches = [m.groups() for m in regex.finditer(myfile)]

for m in matches:
    onlySequences = (m[1])

print(onlySequences)

The variable onlySequences returns just the last one block of letters, how do i keep all of them, each one in a number of a list?

Body:
You don't need regex to do that. A better way consists to read the file line by line:

with open('seq.fasta', 'r') as fh:
    result = []
    for line in fh:
        if line.startswith('>'):
            temp = ''
        elif not line.strip():
            result.append(temp)
        else:
            temp = temp + line

    if temp:
        result.append(temp)

    print("\n".join(result))


问:
Dealing with small variations in CSS?
Whats the best way of dealing with small variations in CSS?

For instance say if I have two buttons:

.btn-red .btn-blue

And I want each of the buttons next to one another but I want .btn-blue to have margin-left of 10 pixels.

I have a number of options that I could implement:

I could add an inline style to the .btn-blue element (but then you have issues of maintainability and readability if your conforming to a naming convention like BEM).

I could create a utility class that adds 10 pixels of margin (but then I'm falling into the trap of potentially having many one off utility classes, how about if I want an additional 20 pixels of margin on another item?)

I could extend .btn-blue and apply a different class (but that creates near enough the same problems as having a one-off utility class)

I could add 10 pixels directly to the .btn-green class but that conflicts with the Single Responsibility Principle.

I could target a wrapper class and using a descendent selector target .btn-blue but then I negate the usefulness of using something like BEM and fall into the world of specificity.

I realise the questions rather pedantic but this is one of the key issues as my CSS files grow that typically spirals out of control.

Say if I had the following...

SASS:

```<code>.btn {
  padding: 10px  30px;
  font-size: 16px;
  border-radius: 3px;
  border: none;
}

.btn-red,
.btn-blue {
  @extend .btn;
  color: white;
}

.btn-red {
  background: red;
}

.btn-blue {
  background: blue;
}
</code>```

HTML:

```<code><div class="btn-wrap">
  <button class="btn-red">
    Mr Red
  </button>
  <button class="btn-blue">
    Mr Blue
  </button>
</div>
</code>```

答:
I am honestly not quite certain about what you're trying to achieve, but could something like this help?</p>

```<code>.btn-red + .btn-blue { /* Or [class*="btn-"] + [class*="btn-"], maybe */
   margin-left: 10px;
}
</code>```

Title: Dealing with small variations in CSS?

Body:
Whats the best way of dealing with small variations in CSS?

For instance say if I have two buttons:

.btn-red .btn-blue

And I want each of the buttons next to one another but I want .btn-blue to have margin-left of 10 pixels.

I have a number of options that I could implement:

I could add an inline style to the .btn-blue element (but then you have issues of maintainability and readability if your conforming to a naming convention like BEM).

I could create a utility class that adds 10 pixels of margin (but then I'm falling into the trap of potentially having many one off utility classes, how about if I want an additional 20 pixels of margin on another item?)

I could extend .btn-blue and apply a different class (but that creates near enough the same problems as having a one-off utility class)

I could add 10 pixels directly to the .btn-green class but that conflicts with the Single Responsibility Principle.

I could target a wrapper class and using a descendent selector target .btn-blue but then I negate the usefulness of using something like BEM and fall into the world of specificity.

I realise the questions rather pedantic but this is one of the key issues as my CSS files grow that typically spirals out of control.

Say if I had the following...

SASS:

.btn {
  padding: 10px  30px;
  font-size: 16px;
  border-radius: 3px;
  border: none;
}

.btn-red,
.btn-blue {
  @extend .btn;
  color: white;
}

.btn-red {
  background: red;
}

.btn-blue {
  background: blue;
}

HTML:

  <button class="btn-red">
    Mr Red
  </button>
  <button class="btn-blue">
    Mr Blue
  </button>

Body:
I am honestly not quite certain about what you're trying to achieve, but could something like this help?

.btn-red + .btn-blue { /* Or [class*="btn-"] + [class*="btn-"], maybe */
   margin-left: 10px;
}


问:
python - support .send() for a class?
Writing a class, how do I implement

foo.send(item) ?

__iter__ allows iterating over the class like a generator, what if I want it to be a coroutine?

答:
Here is a basic example of a coroutine:

```<code>def coroutine(func):
    def start(*args,**kwargs):
        cr = func(*args,**kwargs)
        cr.next()
        return cr
    return start

@coroutine
def grep(pattern):
    print "Looking for %s" % pattern
    while True:
        line = (yield)
        if pattern in line:
            print(line)

g = grep("python")
# Notice how you don't need a next() call here
g.send("Yeah, but no, but yeah, but no")
g.send("A series of tubes")
g.send("python generators rock!")
# Looking for python
# python generators rock!
</code>```

We can make a class which contains such a coroutine, and delegates calls to its send method to the coroutine:

```<code>class Foo(object):
    def __init__(self,pattern):
        self.count=1
        self.pattern=pattern
        self.grep=self._grep()
    @coroutine
    def _grep(self):
        while True:
            line = (yield)
            if self.pattern in line:
                print(self.count, line)
                self.count+=1
    def send(self,arg):
        self.grep.send(arg)

foo = Foo("python")
foo.send("Yeah, but no, but yeah, but no")
foo.send("A series of tubes")
foo.send("python generators rock!")
foo.pattern='spam'
foo.send("Some cheese?")
foo.send("More spam?")

# (1, 'python generators rock!')
# (2, 'More spam?')
</code>```

Notice that foo acts like a coroutine (insofar as it has a send method), but is a class -- it can have attributes and methods which can interact with the coroutine.

For more information (and wonderful examples), see David Beazley's Curious Course on Coroutines and Concurrency.

Title: python - support .send() for a class?

Body:
Here is a basic example of a coroutine:

def coroutine(func):
    def start(*args,**kwargs):
        cr = func(*args,**kwargs)
        cr.next()
        return cr
    return start

@coroutine
def grep(pattern):
    print "Looking for %s" % pattern
    while True:
        line = (yield)
        if pattern in line:
            print(line)

g = grep("python")
# Notice how you don't need a next() call here
g.send("Yeah, but no, but yeah, but no")
g.send("A series of tubes")
g.send("python generators rock!")
# Looking for python
# python generators rock!

We can make a class which contains such a coroutine, and delegates calls to its send method to the coroutine:

class Foo(object):
    def __init__(self,pattern):
        self.count=1
        self.pattern=pattern
        self.grep=self._grep()
    @coroutine
    def _grep(self):
        while True:
            line = (yield)
            if self.pattern in line:
                print(self.count, line)
                self.count+=1
    def send(self,arg):
        self.grep.send(arg)

foo = Foo("python")
foo.send("Yeah, but no, but yeah, but no")
foo.send("A series of tubes")
foo.send("python generators rock!")
foo.pattern='spam'
foo.send("Some cheese?")
foo.send("More spam?")

# (1, 'python generators rock!')
# (2, 'More spam?')

Notice that foo acts like a coroutine (insofar as it has a send method), but is a class -- it can have attributes and methods which can interact with the coroutine.

For more information (and wonderful examples), see David Beazley's Curious Course on Coroutines and Concurrency.


问:
How do I set AFrame position using variables and javascript?
When I use:

```<code>myObject.setAttribute('position','3 0 35' );
</code>```

everything works fine.

I want to set attributes from variables,
instead of having to manually type in the numbers,
like this:

```<code>myObject.setAttribute('position','myX myY myZ' );
</code>```

What am I doing wrong?

答:
```<code>myObject.setAttribute('position',myX+" "+ myY+" "+myZ);'
</code>```

You need to construct a string...

Body:
When I use:

myObject.setAttribute('position','3 0 35' );

everything works fine.

I want to set attributes from variables,
instead of having to manually type in the numbers,
like this:

myObject.setAttribute('position','myX myY myZ' );

What am I doing wrong?

Body:
myObject.setAttribute('position',myX+" "+ myY+" "+myZ);'

You need to construct a string...


问:
Replace first column on csv file based on their value
I have a csv file structured like this:

```<code>01 - FOO_1,value2,value3,...
01 - FOO_1,value2,value3,...
07 - FOO_7,value2,value3,...
...
</code>```

How do i change the first column so it keeps only the number and looks like this:

```<code>01,value2,value3,...
01,value2,value3,...
07,value2,value3,...
</code>```

Body:
I have a csv file structured like this:

01 - FOO_1,value2,value3,...
01 - FOO_1,value2,value3,...
07 - FOO_7,value2,value3,...
...

How do i change the first column so it keeps only the number and looks like this:

01,value2,value3,...
01,value2,value3,...
07,value2,value3,...

Body:
sed 's/ [^,]*//' file

..........


问:
Complementing bits in a register in Assembly Language
How does one complement an individual bit or bits in a register?</p>

答:
You can use a XOR and NOT instruction respectively, for example.

Your number is 1111, and you need complement of 0 and 3 position like this 0110, so:

```<code>mov al, 1111
xor al, 0110
not al
int 3
</code>```

This should change al register of 1111 to 0110

Body:
You can use a XOR and NOT instruction respectively, for example.

Your number is 1111, and you need complement of 0 and 3 position like this 0110, so:

mov al, 1111
xor al, 0110
not al
int 3

This should change al register of 1111 to 0110


问:
need to clear adapter from listview
i am trying to clear adapter from list view but nothing happen
here it  is my code  </p>

```<code> @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    search_button = (Button) findViewById(R.id.next_button);
    editText = (EditText) findViewById(R.id.edit_text);
    emptyTextView = (TextView) findViewById(R.id.empty_view);

    bookListView = (ListView) findViewById(R.id.list_view);

    // Get a reference to the ConnectivityManager to check state of network connectivity
    ConnectivityManager connMgr = (ConnectivityManager)
            getSystemService(Context.CONNECTIVITY_SERVICE);

    // Get details on the currently active default data network
    final NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

    search_button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (networkInfo != null && networkInfo.isConnected()) {

                new GetBook().execute(BOOK_REQUEST_URL);
            } else {
</code>```

<p>//here need to clear adapter but nothin happen</p>

```<code>                emptyTextView.setText(R.string.NoConnect);
                bookListView.setEmptyView(emptyTextView);
                bookAdapter.clear();

            }
        }
</code>```

答:
@mohammedragabmohammedborik, here is an example for internet logic.

```<code>final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
if (activeNetwork != null && activeNetwork.isConnected()) {
    // you are online and do your stuff
} else {
    // not online, show MessageBox or something else
}
</code>```

Add this permission to your AndroidManifest.xml:

```<code><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</code>```

I cannot help you with adapter.clear(), you have not provided adapter code.

Title: need to clear adapter from listview

Body:
i am trying to clear adapter from list view but nothing happen
here it  is my code

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    search_button = (Button) findViewById(R.id.next_button);
    editText = (EditText) findViewById(R.id.edit_text);
    emptyTextView = (TextView) findViewById(R.id.empty_view);

    bookListView = (ListView) findViewById(R.id.list_view);

    // Get a reference to the ConnectivityManager to check state of network connectivity
    ConnectivityManager connMgr = (ConnectivityManager)
            getSystemService(Context.CONNECTIVITY_SERVICE);

    // Get details on the currently active default data network
    final NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

    search_button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (networkInfo != null && networkInfo.isConnected()) {

                new GetBook().execute(BOOK_REQUEST_URL);
            } else {

//here need to clear adapter but nothin happen

                emptyTextView.setText(R.string.NoConnect);
                bookListView.setEmptyView(emptyTextView);
                bookAdapter.clear();

            }
        }

Body:
@mohammedragabmohammedborik, here is an example for internet logic.

final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
if (activeNetwork != null && activeNetwork.isConnected()) {
    // you are online and do your stuff
} else {
    // not online, show MessageBox or something else
}

Add this permission to your AndroidManifest.xml:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

I cannot help you with adapter.clear(), you have not provided adapter code.


问:
java.nio.file not workin in java 8
I have the following code:

```<code>import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
public class debugImageMain {
    public static void main() throws IOException {
        Path path = Paths.get("path/to/file");
        byte[] data = Files.readAllBytes(path);
    }
}
</code>```

But when I run I get:

Exception in thread "main" java.lang.NoSuchMethodException:
  pdc.conversor.debugImageMain.main([Ljava.lang.String;)    at
  java.lang.Class.getMethod(Class.java:1786)

javac -version gives: javac 1.8.0_60 and I have java VERSION 8 Update 91.

IntelliJ tell me java.nio.file imports are underlined in red and says "Usages of API which isn't available at the configured language level.

Any help please???

答:
Java required the main method to be definded correctly which is the entry point to run the app.

Try:

```<code>import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
public class debugImageMain {
    public static void main(String[] args) throws IOException {
        Path path = Paths.get("path/to/file");
        byte[] data = Files.readAllBytes(path);
    }
}
</code>```

Title: java.nio.file not workin in java 8

Body:
I have the following code:

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
public class debugImageMain {
    public static void main() throws IOException {
        Path path = Paths.get("path/to/file");
        byte[] data = Files.readAllBytes(path);
    }
}

But when I run I get:

Exception in thread "main" java.lang.NoSuchMethodException:
  pdc.conversor.debugImageMain.main([Ljava.lang.String;)    at
  java.lang.Class.getMethod(Class.java:1786)

javac -version gives: javac 1.8.0_60 and I have java VERSION 8 Update 91.

IntelliJ tell me java.nio.file imports are underlined in red and says "Usages of API which isn't available at the configured language level.

Any help please???

Body:
Java required the main method to be definded correctly which is the entry point to run the app.

Try:

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
public class debugImageMain {
    public static void main(String[] args) throws IOException {
        Path path = Paths.get("path/to/file");
        byte[] data = Files.readAllBytes(path);
    }
}


问:
How do I get the current date in GML?
I need to be able to get the current date, it doesn't really matter what format it is. Is there a function, or perhaps an API i can use?</p>

答:
It exists some ways to do it. If you only need to show the current datetime you can use this:

```<code>show_message("Today is " + string(current_day) + "/" + string (current_month) + "/" + string(current_year) + " - "  + string(current_hour) + ":" + string(current_minute) + "." + string(current_second) +".");
</code>```

This will return something like: "Today is 3/6/2017 - 23:40:15."

Title: How do I get the current date in GML?

Body:
It exists some ways to do it. If you only need to show the current datetime you can use this:

show_message("Today is " + string(current_day) + "/" + string (current_month) + "/" + string(current_year) + " - "  + string(current_hour) + ":" + string(current_minute) + "." + string(current_second) +".");

This will return something like: "Today is 3/6/2017 - 23:40:15."


问:
Cloning famous sites using Drupal. What are the limits?
We hear a lot about some "Drupal shops" demonstrating Drupals strengths by cloning some very famous websites using Drupal and only Drupal. I want to know, can Drupal really leverage the same strengths the original web app does? What are the limits of Drupal anyway?

Thanks.

答:
No limit, which is kinda the point.

If you want to build a web application, you can start with Drupal.

A funny video explains:
http://www.youtube.com/watch?v=lZ-s3DRZJKY

Drupal is both a framework and an application. The application can be extended through the framework.

The application, out of the box, handles:

user management and authentication

file uploads

search engine

content creation

and much, much more

The application is also easily extensible via the vast array of modules available.

The framework is a hook based API that lets you can extend the application as much as you want.

The framework includes

a content API

a forms API

a user API

a fields API

and many more APIs

a database abstraction layer

jQuery

You can use the framework to write modules, which add functionality to the application. So, with a Drupal programmer, you can make the application do whatever you want.

The theming rocks. As vanneto noted, the site can be made to look however you want. The presentation is in the theme layer and doesn't affect the functionality at all; users can have separate themes, pages can have separate themes, the theming system supports sub-themes themes can be changed without having to worry about nearly anything.

Some examples:
- theonion.com
- whitehouse.gov
- nasa.gov
- grammy.com

And here is a list of some high profile sites in various industries:

http://drupal.org/cases

Essentially, if people log in and create content (no matter if it the content is a news story, car reservation, music lesson confirmation, blog post, product, or whatever), then Drupal might be a great starting point for your application.

I am a Drupal module developer, and I love the framework. The applications I have recently built in Drupal include online databases for a set of yoga studios, a sports league, a magazine, and a web interface to a FileMaker database. Notice how random that list is? You can build whatever you want.


问:
Powershell IE object finding correct element
I am trying to access an element of a popup window, which seems to be embedded in an iframe.  Below is the html I am dealing with. The line I am interested in below is ...OK.../a> . I have left some html out as it is rather large and I did not think it would be helpful. If needed I can post. I have tried many combinations to access this but so far nothing gets that OK button. Below is my best guess code that does not work.

```<code>$ie.Document.getElementsByTagName("A") | Where {$_.getAttributeNode
('class').Value -eq 'btn btn3d PopupBtn'}
</code>```

```<code><html>
<head>...</head>
  <body>
    <iframe id="12345"src="https://example.com/html/messagepopup.html"
     frameborder="0" style="width:100%; height: 154px;">
     <!-- COMMENT HERE about the software
     -->
     <html>
     <head>
     <link href="https://example.com/path/to/custompage.css"rel=stylesheet">
     </link>
     </head>
     <body class="popupmsg" onload="onload()">
     <div class="PopupMsgFooter" id="PopupMsgFooter">
     <a class="btn bnt3d PopupBtn" href="#" arid="2"arwindowid="0">OK</a>
     </body>
     </html>
     </iframe>
 </body>
</html>
</code>```

答:
Here is the final answer. Very close to the below but my final answer is convoluted. I had two iframes in this HTML DOC and for some reason searching by src would not return the correct result. Instead I had to eliminate the other. Weird but works. Second line is a hodge podge of stuff. I googled and found that trying contentwindow may work. After a number of iterations, I came up with the below line. Instead of contentdocument, I had to use contentwindow. (Anyone know why??) I also needed to change the where clause, due to there being two buttons under the same classname. The unique value for me here was the arid. Once I got a reference to the correct object it was easy to see the needed changes. Serious KUDOS to wOxxOm for this.....</p>

```<code>$iframe =  $ie.Document.getElementsByTagName('iframe')
    | Where { $_.id -notcontains 'pinghtml' }

$ok = $iframe.contentwindow.document.body.getElementsByTagName('a')
    | Where {$_.getAttributeNode('arid').Value -eq '2'}

$ok.click()
</code>```

Body:
I am trying to access an element of a popup window, which seems to be embedded in an iframe.  Below is the html I am dealing with. The line I am interested in below is ...OK.../a> . I have left some html out as it is rather large and I did not think it would be helpful. If needed I can post. I have tried many combinations to access this but so far nothing gets that OK button. Below is my best guess code that does not work.

$ie.Document.getElementsByTagName("A") | Where {$_.getAttributeNode
('class').Value -eq 'btn btn3d PopupBtn'}

...

     <link href="https://example.com/path/to/custompage.css"rel=stylesheet">
     </link>

     OK

Body:
Here is the final answer. Very close to the below but my final answer is convoluted. I had two iframes in this HTML DOC and for some reason searching by src would not return the correct result. Instead I had to eliminate the other. Weird but works. Second line is a hodge podge of stuff. I googled and found that trying contentwindow may work. After a number of iterations, I came up with the below line. Instead of contentdocument, I had to use contentwindow. (Anyone know why??) I also needed to change the where clause, due to there being two buttons under the same classname. The unique value for me here was the arid. Once I got a reference to the correct object it was easy to see the needed changes. Serious KUDOS to wOxxOm for this.....

$iframe =  $ie.Document.getElementsByTagName('iframe')
    | Where { $_.id -notcontains 'pinghtml' }

$ok = $iframe.contentwindow.document.body.getElementsByTagName('a')
    | Where {$_.getAttributeNode('arid').Value -eq '2'}

$ok.click()


问:
Is there any library or algorithm for Persian (Shamsi or Jalali) calendar in Android?
I want to convert Gregorian (western) date to Persian (Shamsi) date and vice versa for all versions of Android.

Is there any complete and reliable library or algorithm?

答:
Create the calculateJalaliDate as function like so;
and then return the Jalali date in String</p>

```<code>public String calculateJalaliDate(){

    Calendar c = Calendar.getInstance();
    String jalaliDate,JalaliMonth;
    int jalaliYear,jalaliMonth,calculateMonth,jalaliDay=0,allDays=0;
    int day=c.get(Calendar.DAY_OF_MONTH);
    int month=c.get(Calendar.MONTH)+1;
    int year=c.get(Calendar.YEAR);

    switch (month){
        case 1: allDays=year*365+31+day;break;
        case 2: allDays=year*365+(31+28)+day;break;
        case 3: allDays=year*365+(31+28+31)+day;break;
        case 4: allDays=year*365+(31+28+31+30)+day;break;
        case 5: allDays=year*365+(31+28+31+30+31)+day;break;
        case 6: allDays=year*365+(31+28+31+30+31+30)+day;break;
        case 7: allDays=year*365+(31+28+31+30+31+30+31)+day;break;
        case 8: allDays=year*365+(31+28+31+30+31+30+31+31)+day;break;
        case 9: allDays=year*365+(31+28+31+30+31+30+31+31+30)+day;break;
        case 10: allDays=year*365+(31+28+31+30+31+30+31+31+30+31)+day;break;
        case 11: allDays=year*365+(31+28+31+30+31+30+31+31+30+31+30)+day;break;
        case 12: allDays=year*365+(31+28+31+30+31+30+31+31+30+31+30+31)+day;break;
    }

    //226899
    jalaliYear=( allDays - 227139 )/365+1;
    calculateMonth=( allDays - 227139 )%365;
    if(calculateMonth<32)jalaliMonth=1;
    else if((calculateMonth-31)<32){jalaliMonth=2;jalaliDay=calculateMonth-31;}
    else if((calculateMonth-62)<32){jalaliMonth=3;jalaliDay=calculateMonth-62;}
    else if((calculateMonth-93)<32){jalaliMonth=4;jalaliDay=calculateMonth-93;}
    else if((calculateMonth-124)<32){jalaliMonth=5;jalaliDay=calculateMonth-124;}
    else if((calculateMonth-155)<32){jalaliMonth=6;jalaliDay=calculateMonth-155;}
    else if((calculateMonth-186)<31){jalaliMonth=7;jalaliDay=calculateMonth-186;}
    else if((calculateMonth-216)<31){jalaliMonth=8;jalaliDay=calculateMonth-216;}
    else if((calculateMonth-246)<31){jalaliMonth=9;jalaliDay=calculateMonth-246;}
    else if((calculateMonth-276)<31){jalaliMonth=10;jalaliDay=calculateMonth-276;}
    else if((calculateMonth-306)<31){jalaliMonth=11;jalaliDay=calculateMonth-306;}
    else {
        jalaliMonth=12;
        if((jalaliYear%4)==0)jalaliDay=calculateMonth-336;
        else jalaliDay=calculateMonth-335;
    }

    /*switch (jalaliMonth){
        case 1:JalaliMonth="فروردین"; break;
        case 2:JalaliMonth="اردیبهشت"; break;
        case 3:JalaliMonth="خرداد"; break;
        case 4:JalaliMonth="تیر"; break;
        case 5:JalaliMonth="مرداد"; break;
        case 6:JalaliMonth="شهریور"; break;
        case 7:JalaliMonth="مهر"; break;
        case 8:JalaliMonth="آبان"; break;
        case 9:JalaliMonth="آذر"; break;
        case 10:JalaliMonth="دی"; break;
        case 11:JalaliMonth="بهمن"; break;
        case 12:JalaliMonth="اسفند"; break;
    }*/

    jalaliDate=String.valueOf(jalaliYear)+"/"+String.valueOf(jalaliMonth)+"/"+String.valueOf(jalaliDay);
    return jalaliDate;
}
</code>```

Body:
Create the calculateJalaliDate as function like so;
and then return the Jalali date in String

public String calculateJalaliDate(){

    Calendar c = Calendar.getInstance();
    String jalaliDate,JalaliMonth;
    int jalaliYear,jalaliMonth,calculateMonth,jalaliDay=0,allDays=0;
    int day=c.get(Calendar.DAY_OF_MONTH);
    int month=c.get(Calendar.MONTH)+1;
    int year=c.get(Calendar.YEAR);

    switch (month){
        case 1: allDays=year*365+31+day;break;
        case 2: allDays=year*365+(31+28)+day;break;
        case 3: allDays=year*365+(31+28+31)+day;break;
        case 4: allDays=year*365+(31+28+31+30)+day;break;
        case 5: allDays=year*365+(31+28+31+30+31)+day;break;
        case 6: allDays=year*365+(31+28+31+30+31+30)+day;break;
        case 7: allDays=year*365+(31+28+31+30+31+30+31)+day;break;
        case 8: allDays=year*365+(31+28+31+30+31+30+31+31)+day;break;
        case 9: allDays=year*365+(31+28+31+30+31+30+31+31+30)+day;break;
        case 10: allDays=year*365+(31+28+31+30+31+30+31+31+30+31)+day;break;
        case 11: allDays=year*365+(31+28+31+30+31+30+31+31+30+31+30)+day;break;
        case 12: allDays=year*365+(31+28+31+30+31+30+31+31+30+31+30+31)+day;break;
    }

    //226899
    jalaliYear=( allDays - 227139 )/365+1;
    calculateMonth=( allDays - 227139 )%365;
    if(calculateMonth<32)jalaliMonth=1;
    else if((calculateMonth-31)<32){jalaliMonth=2;jalaliDay=calculateMonth-31;}
    else if((calculateMonth-62)<32){jalaliMonth=3;jalaliDay=calculateMonth-62;}
    else if((calculateMonth-93)<32){jalaliMonth=4;jalaliDay=calculateMonth-93;}
    else if((calculateMonth-124)<32){jalaliMonth=5;jalaliDay=calculateMonth-124;}
    else if((calculateMonth-155)<32){jalaliMonth=6;jalaliDay=calculateMonth-155;}
    else if((calculateMonth-186)<31){jalaliMonth=7;jalaliDay=calculateMonth-186;}
    else if((calculateMonth-216)<31){jalaliMonth=8;jalaliDay=calculateMonth-216;}
    else if((calculateMonth-246)<31){jalaliMonth=9;jalaliDay=calculateMonth-246;}
    else if((calculateMonth-276)<31){jalaliMonth=10;jalaliDay=calculateMonth-276;}
    else if((calculateMonth-306)<31){jalaliMonth=11;jalaliDay=calculateMonth-306;}
    else {
        jalaliMonth=12;
        if((jalaliYear%4)==0)jalaliDay=calculateMonth-336;
        else jalaliDay=calculateMonth-335;
    }

    /*switch (jalaliMonth){
        case 1:JalaliMonth="فروردین"; break;
        case 2:JalaliMonth="اردیبهشت"; break;
        case 3:JalaliMonth="خرداد"; break;
        case 4:JalaliMonth="تیر"; break;
        case 5:JalaliMonth="مرداد"; break;
        case 6:JalaliMonth="شهریور"; break;
        case 7:JalaliMonth="مهر"; break;
        case 8:JalaliMonth="آبان"; break;
        case 9:JalaliMonth="آذر"; break;
        case 10:JalaliMonth="دی"; break;
        case 11:JalaliMonth="بهمن"; break;
        case 12:JalaliMonth="اسفند"; break;
    }*/

    jalaliDate=String.valueOf(jalaliYear)+"/"+String.valueOf(jalaliMonth)+"/"+String.valueOf(jalaliDay);
    return jalaliDate;
}