问:
Goodness of fit test for logistic model
I want know what g means and why use Lemeshow goodness of fit (GOF) test in Research ??  and what wrong in "confusion matrix for logistic regression ?
this message :

Error in confusionMatrix(cnfmat) :
    could not find function "confusionMatrix"

```<code># ..Binary Logistic Regression :

install.packages("caTools")
library(caTools)
require(caTools)
sample = sample.split(diabetes$Outcome, SplitRatio=0.80)
train = subset(diabetes, sample==TRUE)
test = subset(diabetes, sample==FALSE)
nrow(diabetes) ##calculationg the total number of rows
nrow(train) ## total number of Train data rows >> 0.80 * 768
nrow(test) ## total number of Test data rows   >> 0.20 * 768
str(train) ## Structure of train set

Logis_mod<- glm(Outcome~Pregnancies+Glucose+BloodPressure+SkinThickness+
                  Insulin+BMI+DiabetesPedigreeFunction+Age,family = binomial,data = train)
summary(Logis_mod)
#AIC .. Akaike information criteria ...
#A good model is the one that has minimum AIC among all the other models.

# Testing the Model
glm_probs <- predict(Logis_mod, newdata = test, type = "response")
summary(glm_probs)
glm_pred <- ifelse(glm_probs > 0.5, 1, 0)
summary(glm_pred)

#Avarge prediction for each of the Two outcomes ..
tapply(glm_pred,train$Outcome,mean)

# Confusion Matrix for logistic regression
install.packages("e1071")
library(e1071)
prdval <-predict(Logis_mod,type = "response")
prdbln <-ifelse(prdval > 0.5, 1, 0)
cnfmat <-table(prd=prdbln,act =train$Outcome)
confusionMatrix(cnfmat)

#Odd Ratio :
exp(cbind("OR"=coef(Logis_mod),confint(Logis_mod)))
</code>```

答:
I'm not sure what "g" you are referring to, but I'm going to assume it's your resulting computed statistic from your Lemeshow test.  If this is the case then values of "g" indicate how well a model explains the variability in the data and can be used to compare models based on the same set of data (better models will have larger "g" values).

More generally, any goodness of fit (GOF) test in research is used to determine how well your model fits the variability in your data.

Additionally, you are receiving your error because the confusionMatrix() function is a part of the caret R package.  Install caret by first running the below line of code in R or RStudio.

install.packages("caret")
```

<p>Then in your code change  </p>

```cnfmat <-table(prd=prdbln,act =train$Outcome)
confusionMatrix(cnfmat)
```

<p>to </p>

```cnfmat <-data.frame(prd=prdbln,act =train$Outcome, stringsAsFactors = FALSE)
caret::confusionMatrix(cnfmat)
```

Title: Goodness of fit test for logistic model

Body:
I want know what g means and why use Lemeshow goodness of fit (GOF) test in Research ??  and what wrong in "confusion matrix for logistic regression ?
this message :

Error in confusionMatrix(cnfmat) :
    could not find function "confusionMatrix"

# ..Binary Logistic Regression :

install.packages("caTools")
library(caTools)
require(caTools)
sample = sample.split(diabetes$Outcome, SplitRatio=0.80)
train = subset(diabetes, sample==TRUE)
test = subset(diabetes, sample==FALSE)
nrow(diabetes) ##calculationg the total number of rows
nrow(train) ## total number of Train data rows >> 0.80 * 768
nrow(test) ## total number of Test data rows   >> 0.20 * 768
str(train) ## Structure of train set

Logis_mod<- glm(Outcome~Pregnancies+Glucose+BloodPressure+SkinThickness+
                  Insulin+BMI+DiabetesPedigreeFunction+Age,family = binomial,data = train)
summary(Logis_mod)
#AIC .. Akaike information criteria ...
#A good model is the one that has minimum AIC among all the other models.

# Testing the Model
glm_probs <- predict(Logis_mod, newdata = test, type = "response")
summary(glm_probs)
glm_pred <- ifelse(glm_probs > 0.5, 1, 0)
summary(glm_pred)

#Avarge prediction for each of the Two outcomes ..
tapply(glm_pred,train$Outcome,mean)

# Confusion Matrix for logistic regression
install.packages("e1071")
library(e1071)
prdval <-predict(Logis_mod,type = "response")
prdbln <-ifelse(prdval > 0.5, 1, 0)
cnfmat <-table(prd=prdbln,act =train$Outcome)
confusionMatrix(cnfmat)

#Odd Ratio :
exp(cbind("OR"=coef(Logis_mod),confint(Logis_mod)))

Body:
I'm not sure what "g" you are referring to, but I'm going to assume it's your resulting computed statistic from your Lemeshow test.  If this is the case then values of "g" indicate how well a model explains the variability in the data and can be used to compare models based on the same set of data (better models will have larger "g" values).

More generally, any goodness of fit (GOF) test in research is used to determine how well your model fits the variability in your data.

Additionally, you are receiving your error because the confusionMatrix() function is a part of the caret R package.  Install caret by first running the below line of code in R or RStudio.

install.packages("caret")

Then in your code change

cnfmat <-table(prd=prdbln,act =train$Outcome)
confusionMatrix(cnfmat)

to

cnfmat <-data.frame(prd=prdbln,act =train$Outcome, stringsAsFactors = FALSE)
caret::confusionMatrix(cnfmat)


来源: stackexchange

问:
How do I use a style when putting a textView into code manually in Android?
I'm trying to make my game work in all layouts equally well, and in order to facilitate this, I'm using styles which are size dependent. The problem is, this breaks down with the function that I've coded directly, due to its high repetitiveness. So, what can I do to apply one of my styles to these text views that I'm creating in code?

Sample Style code:

```<code><style name="medText">
    <item name="android:textSize">22sp</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_width">wrap_content</item>
</style>
</code>```

Sample program code:

```<code>TableRow row=new TableRow(this);
TableLayout tlayout=new TableLayout(this);
text1.setText(R.string.name);
row.addView(text1);
text2.setText(R.string.level);
row.addView(text2);
text3.setText(R.string.score);
row.addView(text3);
tlayout.addView(row);
</code>```

I loop through re-creating these TextViews a number of times, with the later ones containing variable input.

答:
Try this:

```<code>TableRow row=new TableRow(this);
TableLayout tlayout=new TableLayout(this);
text1.setText(R.string.name);
text1.setTextAppearance(this, R.style.medText);
row.addView(text1);
text2.setText(R.string.level);
text2.setTextAppearance(this, R.style.medText);
row.addView(text2);
text3.setText(R.string.score);
text3.setTextAppearance(this, R.style.medText);
row.addView(text3);
tlayout.addView(row);
</code>```

Let me know if it works: never used the text appearance functionality.

ContentLicense: CC BY-SA 3.0

Body:
I'm trying to make my game work in all layouts equally well, and in order to facilitate this, I'm using styles which are size dependent. The problem is, this breaks down with the function that I've coded directly, due to its high repetitiveness. So, what can I do to apply one of my styles to these text views that I'm creating in code?

Sample Style code:

Sample program code:

TableRow row=new TableRow(this);
TableLayout tlayout=new TableLayout(this);
text1.setText(R.string.name);
row.addView(text1);
text2.setText(R.string.level);
row.addView(text2);
text3.setText(R.string.score);
row.addView(text3);
tlayout.addView(row);

I loop through re-creating these TextViews a number of times, with the later ones containing variable input.

Body:
Try this:

TableRow row=new TableRow(this);
TableLayout tlayout=new TableLayout(this);
text1.setText(R.string.name);
text1.setTextAppearance(this, R.style.medText);
row.addView(text1);
text2.setText(R.string.level);
text2.setTextAppearance(this, R.style.medText);
row.addView(text2);
text3.setText(R.string.score);
text3.setTextAppearance(this, R.style.medText);
row.addView(text3);
tlayout.addView(row);

Let me know if it works: never used the text appearance functionality.


问:
Decode case class, String or Int in circe
I use some Rest API responding with json containing a sort of "mixed" field. By mixed I mean that it can take values of a different type. In my case Object, String and Int are allowed. The Object itself consists of 1 Int and 1 String.

The object I need to decode looks as:

I

```<code>{
   field1: 32,
   ...
   value: {
      id: 23,
      text: "text"
   }
}
</code>```

II

```<code>{
   field1: 32,
   ...
   value: 21
}
</code>```

III

```<code>{
   field1: 32,
   ...
   value: "value"
}
</code>```

How to deal with such objects in circe?

答:
Before looking at the answer provided by @MateuszKubuszok I ended up in writing a custom decoder. I will put it here for completeness.</p>

```<code>sealed trait SomeValue
final case class SomeObjValue(id: Int, text: String) extends SomeValue
final case class SomeIntValue(int: Int) extends SomeValue
final case class SomeStringValue(str: String) extends SomeValue

implicit def someValueDecode: Decoder[SomeValue] =
  (cursor: HCursor) =>
    if (cursor.value.isObject) Decoder[SomeObjValue].apply(cursor)
    else if (cursor.value.isString) cursor.value.as[String].map(SomeStringValue)
    else if (cursor.value.isNumber) cursor.value.as[Int].map(SomeIntValue)
    else
      Decoder.resultInstance.raiseError(
      DecodingFailure(s"${cursor.value} is not supported for decoding", List())
    )
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I use some Rest API responding with json containing a sort of "mixed" field. By mixed I mean that it can take values of a different type. In my case Object, String and Int are allowed. The Object itself consists of 1 Int and 1 String.

The object I need to decode looks as:

I

{
   field1: 32,
   ...
   value: {
      id: 23,
      text: "text"
   }
}

II

{
   field1: 32,
   ...
   value: 21
}

III

{
   field1: 32,
   ...
   value: "value"
}

How to deal with such objects in circe?

Body:
Before looking at the answer provided by @MateuszKubuszok I ended up in writing a custom decoder. I will put it here for completeness.

sealed trait SomeValue
final case class SomeObjValue(id: Int, text: String) extends SomeValue
final case class SomeIntValue(int: Int) extends SomeValue
final case class SomeStringValue(str: String) extends SomeValue

implicit def someValueDecode: Decoder[SomeValue] =
  (cursor: HCursor) =>
    if (cursor.value.isObject) Decoder[SomeObjValue].apply(cursor)
    else if (cursor.value.isString) cursor.value.as[String].map(SomeStringValue)
    else if (cursor.value.isNumber) cursor.value.as[Int].map(SomeIntValue)
    else
      Decoder.resultInstance.raiseError(
      DecodingFailure(s"${cursor.value} is not supported for decoding", List())
    )


问:
I get an error when trying to establish a $ lookup relationship in Mongodb and nodejs
I'm at the learning stage yet.

I am having trouble establishing a relationship in Mongodb.

error not found 404
I made all the operations in the collections with the data in both tables, and in the training I received. But somehow I couldn't run it successfully.

Models Books

```<code>    const Book = require('../Models/Book');

    router.post('/new', function(req, res, next) {
        const  book = new Book({
            title: 'Hikayelerde ve çocuk',
            userId: '5ed267005e5d568b58cd17f7',
            published: true,
            category: 'Hikaye',
            comment: [
                {
                    author: "Macit",
                    mail: "macit@macit.com",
                    subject:"Kitap fena değil",
                    message: "Bu kitap oldukça güzel ben çok beğendim ",
                },
                {
                    author: "Mutlu",
                    mail: "mutlu@mutlu.com",
                    subject:"Kitap fena değil",
                    message: "Bu kitap oldukça güzel ben çok beğendim ",

                },
            ],
            meta:
                {
                    votes: 3,
                    favs: 3
                },

        });

        book.save((err, data) => {

            if (err)
                console.log(err);

            res.json(data);
        });
    });
// aggregate $lookup
router.get('aggregate-lookup', (req, res) => {
    Book.aggregate([
        {
            $lookup: {
                from: 'users',
                localField: 'userId',
                foreignField: '_id',
                as: 'user'
            }
        }
    ], (err, result) => {
        res.json(result);
    });
});
</code>```

module.exports = router;

Books Collection

```<code>/* 1 */
{
    "_id" : ObjectId("5ed26a1ca997a08c2d6d59bf"),
    "published" : true,
    "title" : "Hikayelerde ve çocuk",
    "userId" : ObjectId("5ed267005e5d568b58cd17f7"),
    "category" : "Hikaye",
    "comment" : [
        {
            "_id" : ObjectId("5ed26a1ca997a08c2d6d59c0"),
            "author" : "Macit",
            "mail" : "macit@macit.com",
            "message" : "Bu kitap oldukça güzel ben çok beğendim "
        },
        {
            "_id" : ObjectId("5ed26a1ca997a08c2d6d59c1"),
            "author" : "Mutlu",
            "mail" : "mutlu@mutlu.com",
            "message" : "Bu kitap oldukça güzel ben çok beğendim "
        }
    ],
    "meta" : {
        "votes" : 3,
        "favs" : 3
    },
    "publishedAt" : ISODate("2020-05-30T14:13:48.440Z"),
    "__v" : 0
}
</code>```

Book

```<code>const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const BookSchema = new Schema({

    title: String,

    comment: [
        {
            author: String,
            mail: String,
            subjet: String,
            message: String,
        },
    ],
    category: String,
    meta: {
        votes: Number,
        favs: Number
    },

    published: {
        type: Boolean,
        default: true
    },

    publishedAt : {
        type: Date,
        // şuanki tarih
        default: Date.now
    },
    userId: {
        type: mongoose.Schema.Types.ObjectID
    },

});
module.exports = mongoose.model('Book', BookSchema);
</code>```

User Collection

```<code>/* 1 */
{
    "_id" : ObjectId("5ed267005e5d568b58cd17f7"),
    "published" : true,
    "name" : "Macit Mutlu Sarı",
    "age" : "34",
    "about" : "Ankara doğumlu ve güzel sanatlar mezunu 18 yıllık deneyimi olan bir profesyonel",
    "publishedAt" : ISODate("2020-05-30T14:00:32.322Z"),
    "__v" : 0
}
</code>```

答:
Replace _Id with _id</p>

```<code>$lookup: {
               from: 'users',
               localField: '_id', //Replace here
               foreignField: 'userId',
               as: 'user'
           }
</code>```

Body:
I'm at the learning stage yet.

I am having trouble establishing a relationship in Mongodb.

error not found 404
I made all the operations in the collections with the data in both tables, and in the training I received. But somehow I couldn't run it successfully.

Models Books

    const Book = require('../Models/Book');

    router.post('/new', function(req, res, next) {
        const  book = new Book({
            title: 'Hikayelerde ve çocuk',
            userId: '5ed267005e5d568b58cd17f7',
            published: true,
            category: 'Hikaye',
            comment: [
                {
                    author: "Macit",
                    mail: "macit@macit.com",
                    subject:"Kitap fena değil",
                    message: "Bu kitap oldukça güzel ben çok beğendim ",
                },
                {
                    author: "Mutlu",
                    mail: "mutlu@mutlu.com",
                    subject:"Kitap fena değil",
                    message: "Bu kitap oldukça güzel ben çok beğendim ",

                },
            ],
            meta:
                {
                    votes: 3,
                    favs: 3
                },

        });

        book.save((err, data) => {

            if (err)
                console.log(err);

            res.json(data);
        });
    });
// aggregate $lookup
router.get('aggregate-lookup', (req, res) => {
    Book.aggregate([
        {
            $lookup: {
                from: 'users',
                localField: 'userId',
                foreignField: '_id',
                as: 'user'
            }
        }
    ], (err, result) => {
        res.json(result);
    });
});

module.exports = router;

Books Collection

/* 1 */
{
    "_id" : ObjectId("5ed26a1ca997a08c2d6d59bf"),
    "published" : true,
    "title" : "Hikayelerde ve çocuk",
    "userId" : ObjectId("5ed267005e5d568b58cd17f7"),
    "category" : "Hikaye",
    "comment" : [
        {
            "_id" : ObjectId("5ed26a1ca997a08c2d6d59c0"),
            "author" : "Macit",
            "mail" : "macit@macit.com",
            "message" : "Bu kitap oldukça güzel ben çok beğendim "
        },
        {
            "_id" : ObjectId("5ed26a1ca997a08c2d6d59c1"),
            "author" : "Mutlu",
            "mail" : "mutlu@mutlu.com",
            "message" : "Bu kitap oldukça güzel ben çok beğendim "
        }
    ],
    "meta" : {
        "votes" : 3,
        "favs" : 3
    },
    "publishedAt" : ISODate("2020-05-30T14:13:48.440Z"),
    "__v" : 0
}

Book

const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const BookSchema = new Schema({

    title: String,

    comment: [
        {
            author: String,
            mail: String,
            subjet: String,
            message: String,
        },
    ],
    category: String,
    meta: {
        votes: Number,
        favs: Number
    },

    published: {
        type: Boolean,
        default: true
    },

    publishedAt : {
        type: Date,
        // şuanki tarih
        default: Date.now
    },
    userId: {
        type: mongoose.Schema.Types.ObjectID
    },

});
module.exports = mongoose.model('Book', BookSchema);

User Collection

/* 1 */
{
    "_id" : ObjectId("5ed267005e5d568b58cd17f7"),
    "published" : true,
    "name" : "Macit Mutlu Sarı",
    "age" : "34",
    "about" : "Ankara doğumlu ve güzel sanatlar mezunu 18 yıllık deneyimi olan bir profesyonel",
    "publishedAt" : ISODate("2020-05-30T14:00:32.322Z"),
    "__v" : 0
}

Body:
Replace _Id with _id

$lookup: {
               from: 'users',
               localField: '_id', //Replace here
               foreignField: 'userId',
               as: 'user'
           }


问:
URL Connect to XAMPP Server using Android Emulator
I am writing a program in which i am trying to store data into XAMPP Server via Android Emulator, but i am getting error while inserting data into XAMPP.

Error: Unknown Status!

and i dam sure that i am getting this error because i am not using correct url to connect

Please check my below url to connect to XAMPP Server via Android Emulator:

```<code>   String url = "http://ipaddress/test.php"
</code>```

I have tried this by using my IP address also, but whenever i browse it on browser getting  Object Not Found:

The requested URL '/test.php' was not found on the RomPager server

```<code>  String url = "http://127.0.0.1/test.php"

  String url = "http://10.0.2.2/test.php"
</code>```

Note : I have tested my php code before and it works fine, so something wrong in my URL

I am using below lines in PHP Script:

```<code>$objConnect = mysql_connect("localhost","root","") or die("Cannnot Connect to Database");
    $objDB = mysql_select_db("registration");
</code>```

答: Xampp was working with Port: 80 as shown in below image. So writing below ip address as http://10.0.2.2:80/ worked for me. Hope this helps someone.

Body:
I am writing a program in which i am trying to store data into XAMPP Server via Android Emulator, but i am getting error while inserting data into XAMPP.

Error: Unknown Status!

and i dam sure that i am getting this error because i am not using correct url to connect

Please check my below url to connect to XAMPP Server via Android Emulator:

   String url = "http://ipaddress/test.php"

I have tried this by using my IP address also, but whenever i browse it on browser getting  Object Not Found:

The requested URL '/test.php' was not found on the RomPager server

  String url = "http://127.0.0.1/test.php"

  String url = "http://10.0.2.2/test.php"

Note : I have tested my php code before and it works fine, so something wrong in my URL

I am using below lines in PHP Script:

$objConnect = mysql_connect("localhost","root","") or die("Cannnot Connect to Database");
    $objDB = mysql_select_db("registration");


问:
Taking a certain part of the page with selenium
```<code> from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver import ActionChains
import selenium.webdriver.common.keys
from bs4 import BeautifulSoup
import requests
import time

driver = webdriver.Chrome(executable_path="../drivers/chromedriver.exe")
driver.get("https://www.Here the address of the relevant website ends with aspx.com.aspx")

element=driver.find_element_by_id("ctl00_ContentPlaceHolder1_LB_SEKTOR")
drp=Select(element)

drp.select_by_index(0)

element1=driver.find_element_by_id("ctl00_ContentPlaceHolder1_Lb_Oran")
drp=Select(element1)

drp.select_by_index(41)

element2=driver.find_element_by_id("ctl00_ContentPlaceHolder1_LB_DONEM")
drp=Select(element2)

drp.select_by_index(1)

driver.find_element_by_id("ctl00_ContentPlaceHolder1_ImageButton1").click()
time.sleep(1)
print(driver.page_source)

</code>```

The last part of these codes, I can print the source codes of the page as a result. So I can get the source codes of the page as a print.
But in source codes of the page  I just need the following table part written in java. How can I extract this section. and I can output csv as a table. (How can I get the table in the Java section.)

Not:In the Selenium test, I thought of pressing the CTRL U keys while in Chrome, but I was not successful in this.The web page is a user interactive page. Some interactions are required to get the data I want. That's why I used Selenium.

```<code>
<span id="ctl00_ContentPlaceHolder1_Label2" class="Georgia_10pt_Red"></span>
    <div id="ctl00_ContentPlaceHolder1_Divtable">
        <div id="table">
            <layer name="table" top="0"><IMG height="2" src="../images/spacer.gif" width="2"><br>
                        <font face="arial" color="#000000" size="2"><b>Tablo Yükleniyor. Lütfen Bekleyiniz...</b></font><br>
                    </layer>
        </div>
    </div>

<script language=JavaScript> var theHlp='/yardim/matris.asp';var theTitle = 'Piya Deg';var theCaption='OtomoT (TL)';var lastmod = '';var h='<a class=hislink href=../Hisse/Hisealiz.aspx?HNO=';var e='<a class=hislink href=../endeks/endeksAnaliz.aspx?HNO=';var d='<center><font face=symbol size=1 color=#FF0000><b>ß</b></font></center>';var u='<center><font face=symbol size=1 color=#008000><b>İ</b></font></center>';var n='<center><font face=symbol size=1 color=#00A000><b>=</b></font></center>';var fr='<font color=#FF0000>';var fg='<font color=#008000>';var theFooter=new Array();var theCols = new Array();theCols[0] = new Array('cksart',4,50);theCols[1] = new Array('2018.12',1,60);theCols[2] = new Array('2019.03',1,60);theCols[3] = new Array('2019.06',1,60);theCols[4] = new Array('2019.09',1,60);theCols[5] = new Array('2019.12',1,60);theCols[6] = new Array('2020.03',1,60);var theRows = new Array();theRows[0] = new Array ('<b>'+h+'42>AHRT</B></a>','519,120,000.00','590,520,000.00','597,240,000.00','789,600,000.00','1,022,280,000.00','710,640,000.00');
theRows[1] = new Array ('<b>'+h+'427>SEEL</B></a>','954,800,000.00','983,400,000.00','1,201,200,000.00','1,716,000,000.00','2,094,400,000.00','-');
theRows[2] = new Array ('<b>'+h+'140>TOFO</B></a>','17,545,500,000.00','17,117,389,800.00','21,931,875,000.00','20,844,054,000.00','24,861,973,500.00','17,292,844,800.00');
theRows[3] = new Array ('<b>'+h+'183>MSO</B></a>','768,000,000.00','900,000,000.00','732,000,000.00','696,000,000.00','1,422,000,000.00','1,134,000,000.00');
theRows[4] = new Array ('<b>'+h+'237>KURT</B></a>','2,118,000,000.00','2,517,600,000.00','2,736,000,000.00','3,240,000,000.00','3,816,000,000.00','2,488,800,000.00');
theRows[5] = new Array ('<b>'+h+'668>GRTY</B></a>','517,500,000.00','500,250,000.00','445,050,000.00','552,000,000.00','737,150,000.00','-');
theRows[6] = new Array ('<b>'+h+'291>MEME</B></a>','8,450,000,000.00','8,555,000,000.00','9,650,000,000.00','10,140,000,000.00','13,430,000,000.00','8,225,000,000.00');
theRows[7] = new Array ('<b>'+h+'292>AMMI</B></a>','-','-','-','-','-','-');
theRows[8] = new Array ('<b>'+h+'426>GOTE</B></a>','1,862,578,100.00','1,638,428,300.00','1,689,662,540.00','2,307,675,560.00','2,956,642,600.00','2,121,951,440.00');
var thetable=new mytable();thetable.tableWidth=650;thetable.shownum=false;thetable.controlaccess=true;thetable.visCols=new Array(true,true,true,true,true);thetable.initsort=new Array(0,-1);thetable.inittable();thetable.refreshTable();</script></form>
                                    <div style="clear: both; margin-top: 10px;">

<div style="background-color: Red; border: 2px solid Green; display: none">
    TABLO-ALT</div>
<div id="Bannerctl00_SiteBannerControl2">
    <div id="_bannerctl00_SiteBannerControl2">
        <div id="Sayfabannerctl00_SiteBannerControl2" class="banner_Codex">
        </div>

</code>```

答:
Please, note that I've only used Selenium in Java, so I'll give you the most generic and languaje-agnostic answer I can. Keep in mind that Python Selenium MAY provide a method to do this directly.

Steps:

Make all Selenium interactions so the WebDriver actually has a VALID page version with all your contents loaded

Extract from selenium the current contents of the whole page

Load it with a HTML parsing library. I use JSoup in Java, I don't now if there's a Python version. From now on, Selenium does not matter.

Use CSS selectors on your parser Object to get the section you want

Convert that section to String to print.

If performance is a requeriment this approach may be a bit too expensive, as the contents are parsed twice: Selenium does it first, and your HTML parser will do it again later with the extracted String from Selenium.

ALTERNATIVE: If your "target page" uses AJAX, you may directly interact with the REST API that javascript is accesing to get the data to fill for you. I tend to follow this approach when doing serious web scraping, but sometimes this is not an option, so I use the above approach.

EDIT

Some more details base on questions in comments:

You can use BeautifullSoup as a html parsing library.

To load a page in BeautifullSoup use:

```<code>html = "<html><head></head><body><div id=\"events-horizontal\">Hello world</div></body></html>"
soup = BeautifulSoup(html, "html.parser")
</code>```

Then look at this answer to see how to extract the specific contents from your soup:

```<code>your_div = soup.select_one('div#events-horizontal')
</code>```

That would give you the first div with events-horizontal id:

```<code><div id="events-horizontal">Hello world</div>
</code>```

BeautifullSoup code based on:

How to use CSS selectors to retrieve specific links lying in some class using BeautifulSoup?

Body:
 from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver import ActionChains
import selenium.webdriver.common.keys
from bs4 import BeautifulSoup
import requests
import time

driver = webdriver.Chrome(executable_path="../drivers/chromedriver.exe")
driver.get("https://www.Here the address of the relevant website ends with aspx.com.aspx")

element=driver.find_element_by_id("ctl00_ContentPlaceHolder1_LB_SEKTOR")
drp=Select(element)

drp.select_by_index(0)

element1=driver.find_element_by_id("ctl00_ContentPlaceHolder1_Lb_Oran")
drp=Select(element1)

drp.select_by_index(41)

element2=driver.find_element_by_id("ctl00_ContentPlaceHolder1_LB_DONEM")
drp=Select(element2)

drp.select_by_index(1)

driver.find_element_by_id("ctl00_ContentPlaceHolder1_ImageButton1").click()
time.sleep(1)
print(driver.page_source)

The last part of these codes, I can print the source codes of the page as a result. So I can get the source codes of the page as a print.
But in source codes of the page  I just need the following table part written in java. How can I extract this section. and I can output csv as a table. (How can I get the table in the Java section.)

Not:In the Selenium test, I thought of pressing the CTRL U keys while in Chrome, but I was not successful in this.The web page is a user interactive page. Some interactions are required to get the data I want. That's why I used Selenium.

            <layer name="table" top="0">

                        Tablo Yükleniyor. Lütfen Bekleyiniz...

                    </layer>

</form>

    TABLO-ALT

Body:
Please, note that I've only used Selenium in Java, so I'll give you the most generic and languaje-agnostic answer I can. Keep in mind that Python Selenium MAY provide a method to do this directly.

Steps:

Make all Selenium interactions so the WebDriver actually has a VALID page version with all your contents loaded

Extract from selenium the current contents of the whole page

Load it with a HTML parsing library. I use JSoup in Java, I don't now if there's a Python version. From now on, Selenium does not matter.

Use CSS selectors on your parser Object to get the section you want

Convert that section to String to print.

If performance is a requeriment this approach may be a bit too expensive, as the contents are parsed twice: Selenium does it first, and your HTML parser will do it again later with the extracted String from Selenium.

ALTERNATIVE: If your "target page" uses AJAX, you may directly interact with the REST API that javascript is accesing to get the data to fill for you. I tend to follow this approach when doing serious web scraping, but sometimes this is not an option, so I use the above approach.

EDIT

Some more details base on questions in comments:

You can use BeautifullSoup as a html parsing library.

To load a page in BeautifullSoup use:

html = "<html><head></head><body><div id=\"events-horizontal\">Hello world</div></body></html>"
soup = BeautifulSoup(html, "html.parser")

Then look at this answer to see how to extract the specific contents from your soup:

your_div = soup.select_one('div#events-horizontal')

That would give you the first div with events-horizontal id:

<div id="events-horizontal">Hello world</div>

BeautifullSoup code based on:

How to use CSS selectors to retrieve specific links lying in some class using BeautifulSoup?


问:
Change order of multiple optional substrings
That's a bit like this question, but I have multiple substrings that may or may not occur.

The substrings code for two different dimensions, in my example "test" and "eye". They can occur in any imaginable order.
The variables can be coded in different ways - in my example, "method|test" would be two ways to code for "test", as well as "r|re|l|le" different ways to code for eyes.

I found a convoluted solution, which is using a chain of seven (!) gsub calls, and I wondered if there is a more concise way.

x <- c("id", "r_test", "l_method", "test_re", "method_le", "test_r_old",
       "test_l_old", "re_test_new","new_le_method", "new_r_test")
x
#>  [1] "id"            "r_test"        "l_method"      "test_re"
#>  [5] "method_le"     "test_r_old"    "test_l_old"    "re_test_new"
#>  [9] "new_le_method" "new_r_test"
```

<p>Desired output</p>

```#>  [1] "id"         "r_test"     "l_test"     "r_test"     "l_test"
#>  [6] "r_test_old" "l_test_old" "r_test_new" "l_test_new" "r_test_new"
```

<p>How I got there (convoluted)</p>

```## Unify codes for variables, I use the underscores to make it more unique for future regex
clean_test<- gsub("(?<![a-z])(test|method)(?![a-z])", "_test_", tolower(x), perl = TRUE)
clean_r <- gsub("(?<![a-z])(r|re)(?![a-z])", "_r_", tolower(clean_test), perl = TRUE)
clean_l <- gsub("(?<![a-z])(l|le)(?![a-z])", "_l_", tolower(clean_r), perl = TRUE)

## Now sort, one after the other
sort_eye <- gsub("(.*)(_r_|_l_)(.*)", "\\2\\1\\3", clean_l, perl = TRUE)
sort_test <- gsub("(_r_|_l_)(.*)(_test_)(.*)", "\\1\\3\\2\\4", sort_eye, perl = TRUE)

## Remove underscores
clean_underscore_mult <- gsub("_{2,}", "_", sort_test)
clean_underscore_ends <- gsub("^_|_$", "", clean_underscore_mult)

clean_underscore_ends
#>  [1] "id"         "r_test"     "l_test"     "r_test"     "l_test"
#>  [6] "r_test_old" "l_test_old" "r_test_new" "l_test_new" "r_test_new"
```

I'd be already very very grateful for a suggestion how to better proceed from ## Now sort, one after the other downwards...

答:
How about tokenizing the string and using lookup tables instead? I'll use data.table to assist but the idea fits naturally with other data grammars as well

```<code>library(data.table)
# build into a table, keeping track of an ID
#   to say which element it came from originally
l = strsplit(x, '_', fixed=TRUE)
DT = data.table(id = rep(seq_along(l), lengths(l)), token = unlist(l))
</code>```

Now build a lookup table:

```<code># defined using fread to make it easier to see
#   token & match side-by-side; only define tokens
#   that actually need to be changed here
lookups = fread('
token,match
le,l
re,r
method,test
')
</code>```

Now combine:

```<code># default value is the token itself
DT[ , match := token]
# replace anything matched
DT[lookups, match := i.match, on = 'token']
</code>```

Next use factor ordering to get the tokens in the right order:

```<code># the more general [where you don't have an exact list of all the possible
#   tokens ready at hand] is a bit messier -- you might do something
#   similar to setdiff(unique(match), lookups$match)
DT[ , match := factor(match, levels = c('id', 'r', 'l', 'test', 'old', 'new'))]
# sort to this new order
setorder(DT, id, match)
</code>```

Finally combine again (an aggregation) to get the output:

```<code>DT[ , paste(match, collapse='_'), by = id]$V1
#  [1] "id"         "r_test"     "l_test"     "r_test"     "l_test"
#  [6] "r_test_old" "l_test_old" "r_test_new" "l_test_new" "r_test_new"
</code>```

Body:
That's a bit like this question, but I have multiple substrings that may or may not occur.

The substrings code for two different dimensions, in my example "test" and "eye". They can occur in any imaginable order.
The variables can be coded in different ways - in my example, "method|test" would be two ways to code for "test", as well as "r|re|l|le" different ways to code for eyes.

I found a convoluted solution, which is using a chain of seven (!) gsub calls, and I wondered if there is a more concise way.

x <- c("id", "r_test", "l_method", "test_re", "method_le", "test_r_old",
       "test_l_old", "re_test_new","new_le_method", "new_r_test")
x
#>  [1] "id"            "r_test"        "l_method"      "test_re"
#>  [5] "method_le"     "test_r_old"    "test_l_old"    "re_test_new"
#>  [9] "new_le_method" "new_r_test"

Desired output

#>  [1] "id"         "r_test"     "l_test"     "r_test"     "l_test"
#>  [6] "r_test_old" "l_test_old" "r_test_new" "l_test_new" "r_test_new"

How I got there (convoluted)

## Unify codes for variables, I use the underscores to make it more unique for future regex
clean_test<- gsub("(?<![a-z])(test|method)(?![a-z])", "_test_", tolower(x), perl = TRUE)
clean_r <- gsub("(?<![a-z])(r|re)(?![a-z])", "_r_", tolower(clean_test), perl = TRUE)
clean_l <- gsub("(?<![a-z])(l|le)(?![a-z])", "_l_", tolower(clean_r), perl = TRUE)

## Now sort, one after the other
sort_eye <- gsub("(.*)(_r_|_l_)(.*)", "\\2\\1\\3", clean_l, perl = TRUE)
sort_test <- gsub("(_r_|_l_)(.*)(_test_)(.*)", "\\1\\3\\2\\4", sort_eye, perl = TRUE)

## Remove underscores
clean_underscore_mult <- gsub("_{2,}", "_", sort_test)
clean_underscore_ends <- gsub("^_|_$", "", clean_underscore_mult)

clean_underscore_ends
#>  [1] "id"         "r_test"     "l_test"     "r_test"     "l_test"
#>  [6] "r_test_old" "l_test_old" "r_test_new" "l_test_new" "r_test_new"

I'd be already very very grateful for a suggestion how to better proceed from ## Now sort, one after the other downwards...

Body:
How about tokenizing the string and using lookup tables instead? I'll use data.table to assist but the idea fits naturally with other data grammars as well

library(data.table)
# build into a table, keeping track of an ID
#   to say which element it came from originally
l = strsplit(x, '_', fixed=TRUE)
DT = data.table(id = rep(seq_along(l), lengths(l)), token = unlist(l))

Now build a lookup table:

# defined using fread to make it easier to see
#   token & match side-by-side; only define tokens
#   that actually need to be changed here
lookups = fread('
token,match
le,l
re,r
method,test
')

Now combine:

# default value is the token itself
DT[ , match := token]
# replace anything matched
DT[lookups, match := i.match, on = 'token']

Next use factor ordering to get the tokens in the right order:

# the more general [where you don't have an exact list of all the possible
#   tokens ready at hand] is a bit messier -- you might do something
#   similar to setdiff(unique(match), lookups$match)
DT[ , match := factor(match, levels = c('id', 'r', 'l', 'test', 'old', 'new'))]
# sort to this new order
setorder(DT, id, match)

Finally combine again (an aggregation) to get the output:

DT[ , paste(match, collapse='_'), by = id]$V1
#  [1] "id"         "r_test"     "l_test"     "r_test"     "l_test"
#  [6] "r_test_old" "l_test_old" "r_test_new" "l_test_new" "r_test_new"


问:
Gremlin: How to obtain outgoing edges and their target vertices in a single query
Given a set of vertices (say, for simplicity, that I start with one: G.V().hasId("something")), I want to obtain all outgoing edges and their target vertices. I know that .out() will give me all target vertices, but without the information about the edges (which have properties on them, too). On the other hand, .outE() will give me the edges but not the target vertices. Can I obtain both in a single Gremlin query?

答:
Never mind. Figured this out.

G.V().hasId("something").outE().as("E").otherV().as("V").select("E", "V")


问:
How to determine previous page URL in Angular?
Suppose I am currently on the page which has the URL /user/:id . Now from this page I navigate to next page :id/posts.

Now Is there a way, so that i can check what is the previous URL, i.e. /user/:id.

Below are my routes

```<code>export const routes: Routes = [
  {
    path: 'user/:id', component: UserProfileComponent
  },
  {
    path: ':id/posts', component: UserPostsComponet
  }
];
</code>```

答:
FOR ANGULAR 7+

Actually since Angular 7.2 there is not need to use a service for saving the previous url. You could just use the state object to set the last url before linking to the login page. Here is an example for a login scenario.

@Component({ ... })
class SomePageComponent {
  constructor(private router: Router) {}

  checkLogin() {
    if (!this.auth.loggedIn()) {
      this.router.navigate(['login'], { state: { redirect: this.router.url } });
    }
  }
}
```
<pre class="lang-js prettyprint-override"><code>@Component({...})
class LoginComponent {
  constructor(private router: Router) {}

  backToPreviousPage() {
    const { redirect } = window.history.state;

    this.router.navigateByUrl(redirect || '/homepage');
  }
}
</code>```

----------------

Additionally you could also pass the data in the template:

@Component({
  template: 'Go to some route'
})
class SomePageComponent {
  constructor(public router: Router) {}
}
```

Body:
Suppose I am currently on the page which has the URL /user/:id . Now from this page I navigate to next page :id/posts.

Now Is there a way, so that i can check what is the previous URL, i.e. /user/:id.

Below are my routes

export const routes: Routes = [
  {
    path: 'user/:id', component: UserProfileComponent
  },
  {
    path: ':id/posts', component: UserPostsComponet
  }
];

Body:
FOR ANGULAR 7+

Actually since Angular 7.2 there is not need to use a service for saving the previous url. You could just use the state object to set the last url before linking to the login page. Here is an example for a login scenario.

@Component({ ... })
class SomePageComponent {
  constructor(private router: Router) {}

  checkLogin() {
    if (!this.auth.loggedIn()) {
      this.router.navigate(['login'], { state: { redirect: this.router.url } });
    }
  }
}

@Component({...})
class LoginComponent {
  constructor(private router: Router) {}

  backToPreviousPage() {
    const { redirect } = window.history.state;

    this.router.navigateByUrl(redirect || '/homepage');
  }
}

----------------

Additionally you could also pass the data in the template:

@Component({
  template: '<a routerLink="/some-route" [state]="{ redirect: router.url}">Go to some route</a>'
})
class SomePageComponent {
  constructor(public router: Router) {}
}


问:
Horizontally Distribute Inner-Divs of 3-Column Container Without Using Percentages? - Flex
I'm wondering if there's a better way to evenly space the three divs within a parent div (horizontally) using flex. Here's what I have:

.container {
    display: flex;
}
.left-div, .middle-div, .right-div {
    display: flex;
    justify-content: center;
    width: 33.3%;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Demo</title>
</head>
<body>
    <div class="container">
        <div class="left-div">
            Left
        </div>
        <div class="middle-div">
            Middle
        </div>
        <div class="right-div">
            Right
        </div>
    </div>
</body>
</html></code>```

As you can see, I set each child-div / column to width: 33.3% - is there a CSS property that will automatically force them to span 100% width of their parent, collectively, without using percentages?

If I get rid of width: 33%, I get this:

.container {
        display: flex;
}
.left-div, .middle-div, .right-div {
        display: flex;
        justify-content: center;
        /*width: 33.3%;*/
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Demo</title>
</head>
<body>
    <div class="container">
        <div class="left-div">
            Left
        </div>
        <div class="middle-div">
            Middle
        </div>
        <div class="right-div">
            Right
        </div>
    </div>
</body>
</html></code>```

I also tried setting the parent div to justify-content: space-between;, but this is now forcing the content of the inner divs to get aligned to the left (for the left div) or to the right (for the right div):

.container {
        display: flex;
        justify-content: space-between;
}
.left-div, .middle-div, .right-div {
        display: flex;
        justify-content: center;
        /*width: 33.3%;*/
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Demo</title>
</head>
<body>
    <div class="container">
        <div class="left-div">
            Left
        </div>
        <div class="middle-div">
            Middle
        </div>
        <div class="right-div">
            Right
        </div>
    </div>
</body>
</html></code>```

I know that setting each child div to width: 33% works, but is there a better way? Without having to calculate percentages if I wanted 7 columns, for example?

答:
flex-grow might be what you need here .

The flex-grow CSS property sets the flex grow factor of a flex item main size. It specifies how much of the remaining space in the flex container should be assigned to the item (the flex grow factor).

.container {
    display: flex;
}
.left-div, .middle-div, .right-div {
    display: flex;
    justify-content: center;
    flex-grow:1;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Demo</title>
</head>
<body>
    <div class="container">
        <div class="left-div">
            Left
        </div>
        <div class="middle-div">
            Middle
        </div>
        <div class="right-div">
            Right
        </div>
    </div>
</body>
</html></code>```

Body:
I'm wondering if there's a better way to evenly space the three divs within a parent div (horizontally) using flex. Here's what I have:

.container {
    display: flex;
}
.left-div, .middle-div, .right-div {
    display: flex;
    justify-content: center;
    width: 33.3%;
}

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Demo</title>

            Left

            Middle

            Right

As you can see, I set each child-div / column to width: 33.3% - is there a CSS property that will automatically force them to span 100% width of their parent, collectively, without using percentages?

If I get rid of width: 33%, I get this:

.container {
        display: flex;
}
.left-div, .middle-div, .right-div {
        display: flex;
        justify-content: center;
        /*width: 33.3%;*/
}

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Demo</title>

            Left

            Middle

            Right

I also tried setting the parent div to justify-content: space-between;, but this is now forcing the content of the inner divs to get aligned to the left (for the left div) or to the right (for the right div):

.container {
        display: flex;
        justify-content: space-between;
}
.left-div, .middle-div, .right-div {
        display: flex;
        justify-content: center;
        /*width: 33.3%;*/
}

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Demo</title>

            Left

            Middle

            Right

I know that setting each child div to width: 33% works, but is there a better way? Without having to calculate percentages if I wanted 7 columns, for example?

Body:
flex-grow might be what you need here .

The flex-grow CSS property sets the flex grow factor of a flex item main size. It specifies how much of the remaining space in the flex container should be assigned to the item (the flex grow factor).

.container {
    display: flex;
}
.left-div, .middle-div, .right-div {
    display: flex;
    justify-content: center;
    flex-grow:1;
}

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Demo</title>
</head>
<body>
    <div class="container">
        <div class="left-div">
            Left
        </div>
        <div class="middle-div">
            Middle
        </div>
        <div class="right-div">
            Right
        </div>
    </div>
</body>
</html>


问:
pandas-like rolling on a Datetime column in DolphinDB
pandas DataFrame provides rolling window calculations on a DatetimeIndex or a Datetime-typed column like this:

```<code>>>> df = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]},
...                   index = [pd.Timestamp('20130101 09:00:00'),
...                            pd.Timestamp('20130101 09:00:02'),
...                            pd.Timestamp('20130101 09:00:03'),
...                            pd.Timestamp('20130101 09:00:05'),
...                            pd.Timestamp('20130101 09:00:06')])
</code>```

```<code>>>> df.rolling('3s').sum()
                       B
2013-01-01 09:00:00  0.0
2013-01-01 09:00:02  1.0
2013-01-01 09:00:03  3.0
2013-01-01 09:00:05  2.0
2013-01-01 09:00:06  4.0
</code>```

DolphinDB's moving function, as well as functions of the moving-family like msum, mavg, etc., is calculated based on a window with a fixed number of elements inside. But they are unable to handle temporal types.

```<code>df = table(0 1 2 NULL 4 as B,
           [2013.01.01 09:00:00,2013.01.01 09:00:02,2013.01.01 09:00:03,2013.01.01 09:00:05,2013.01.01 09:00:06] as index)
select index, msum(B, 3) as B from df
</code>```

```<code>index               B
------------------- -
2013.01.01T09:00:00
2013.01.01T09:00:02
2013.01.01T09:00:03 3
2013.01.01T09:00:05 3
2013.01.01T09:00:06 6
</code>```

I'd like to do a rolling calculation with the window being a time period that could include variable-sized elements.

答:
DolphinDB Orca API has the same function, in your case:</p>

```<code>odf = orca.DataFrame(df)
odf.rolling('3s').sum()
</code>```

Body:
pandas DataFrame provides rolling window calculations on a DatetimeIndex or a Datetime-typed column like this:

>>> df = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]},
...                   index = [pd.Timestamp('20130101 09:00:00'),
...                            pd.Timestamp('20130101 09:00:02'),
...                            pd.Timestamp('20130101 09:00:03'),
...                            pd.Timestamp('20130101 09:00:05'),
...                            pd.Timestamp('20130101 09:00:06')])

>>> df.rolling('3s').sum()
                       B
2013-01-01 09:00:00  0.0
2013-01-01 09:00:02  1.0
2013-01-01 09:00:03  3.0
2013-01-01 09:00:05  2.0
2013-01-01 09:00:06  4.0

DolphinDB's moving function, as well as functions of the moving-family like msum, mavg, etc., is calculated based on a window with a fixed number of elements inside. But they are unable to handle temporal types.

df = table(0 1 2 NULL 4 as B,
           [2013.01.01 09:00:00,2013.01.01 09:00:02,2013.01.01 09:00:03,2013.01.01 09:00:05,2013.01.01 09:00:06] as index)
select index, msum(B, 3) as B from df

index               B
------------------- -
2013.01.01T09:00:00
2013.01.01T09:00:02
2013.01.01T09:00:03 3
2013.01.01T09:00:05 3
2013.01.01T09:00:06 6

I'd like to do a rolling calculation with the window being a time period that could include variable-sized elements.

Body:
DolphinDB Orca API has the same function, in your case:

odf = orca.DataFrame(df)
odf.rolling('3s').sum()


问:
Using Sqlite JDBC Driver in a Gradle Java Project
In this tutorial, http://www.sqlitetutorial.net/sqlite-java/sqlite-jdbc-driver/, about using sqlite with java, it starts by downloading the JDBC driver from the following website, https://bitbucket.org/xerial/sqlite-jdbc/downloads/. After that it then adds the driver to the project using a Maven build system.

I have had a look around and I cannot see what you should if you are using Gradle? What steps should you take before you the code?

I am using the Intellij IDE if this makes any difference.

答:
The Gradle syntax has changed as of version 3.4. So according to new syntax add the following to your build.gradle file:</p>

```<code>repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.xerial:sqlite-jdbc:3.30.1'
}
</code>```

Body:
The Gradle syntax has changed as of version 3.4. So according to new syntax add the following to your build.gradle file:

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.xerial:sqlite-jdbc:3.30.1'
}


问:
Error is Trying to get property 'id' of non-object, but seems object has
I am using PHP for 1st time.
I am just trying to fetch data from database. Here is my code -

```<code>        try{
            ///try to connect with database
            $conn=new PDO("mysql:host=localhost:3306;dbname=try", "root", "abcdef12");
            $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        }
        catch(PDOException $ex){
            echo "error";
        }
        $mysqlcode="SELECT * FROM users";
        $ret=$conn->query($mysqlcode);
        foreach($ret as $ret1)
        print $ret1->id;
</code>```

in the browser,
showing this error:

Notice: Trying to get property 'id' of non-object in /opt/lampp/htdocs/secAsite/verifylogin.php on line 44

In the users table, I have 4 data.
In here, why $ret seems non object. I can't find anything wrong. How to fetch data. Or debug the object.

答:
Before trying to use Object Oriented PHP, is much easier to understand Procedural. Take a look at the code below.

First, connect to database:

```<code><?php
//Store log in info into variables
    $servername = 'localhost';
    $serveruser = 'youruser';
    $serverpassword = 'yourpassword';
    $serverdatabase = 'yourdatabase';

    // Create connection
    $conn = mysqli_connect( $servername, $serveruser, $serverpassword, $serverdatabase );

    if ( !$conn ) {echo "Connection Fail" . mysqli_connect_error();}
    //else {echo "Connected to database $serverdatabase";}
?>
</code>```

Then, call the information from your database and your table and store it into an associative array $data

```<code>$sql = "SELECT * FROM `table`";
$result = mysqli_query($conn, $sql);
$data = mysqli_fetch_all($result, MYSQLI_ASOCC);
mysqli_free_result($result);
</code>```

Now you can use the array to print the results with print_r

```<code>echo '```'; print_r($data); echo '```';}
</code>```

Now you are ready to use foreach depending on your table columns,for example if you have ID column then

```<code><?php foreach ($data as $value){
echo $value['id]."<br>";
} ?>
</code>```

It will print out all the IDs. Hope this helps.

Body:
I am using PHP for 1st time.
I am just trying to fetch data from database. Here is my code -

        try{
            ///try to connect with database
            $conn=new PDO("mysql:host=localhost:3306;dbname=try", "root", "abcdef12");
            $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        }
        catch(PDOException $ex){
            echo "error";
        }
        $mysqlcode="SELECT * FROM users";
        $ret=$conn->query($mysqlcode);
        foreach($ret as $ret1)
        print $ret1->id;

in the browser,
showing this error:

Notice: Trying to get property 'id' of non-object in /opt/lampp/htdocs/secAsite/verifylogin.php on line 44

In the users table, I have 4 data.
In here, why $ret seems non object. I can't find anything wrong. How to fetch data. Or debug the object.

Body:
Before trying to use Object Oriented PHP, is much easier to understand Procedural. Take a look at the code below.

First, connect to database:

<?php
//Store log in info into variables
    $servername = 'localhost';
    $serveruser = 'youruser';
    $serverpassword = 'yourpassword';
    $serverdatabase = 'yourdatabase';

    // Create connection
    $conn = mysqli_connect( $servername, $serveruser, $serverpassword, $serverdatabase );

    if ( !$conn ) {echo "Connection Fail" . mysqli_connect_error();}
    //else {echo "Connected to database $serverdatabase";}
?>

Then, call the information from your database and your table and store it into an associative array $data

$sql = "SELECT * FROM `table`";
$result = mysqli_query($conn, $sql);
$data = mysqli_fetch_all($result, MYSQLI_ASOCC);
mysqli_free_result($result);

Now you can use the array to print the results with print_r

echo '<pre>'; print_r($data); echo '</pre>';}

Now you are ready to use foreach depending on your table columns,for example if you have ID column then

<?php foreach ($data as $value){
echo $value['id]."<br>";
} ?>

It will print out all the IDs. Hope this helps.


问:
Can I move my Mercurial working directory to another location?
I am new to Mercurial and version control in general, so I'm sure this is a pretty basic question but I have, as yet, been unable to find the answer.

I am working on a small project which is under Mercurial version control.  The project and the .hg repository are currently on my local drive (C:\MyProject.hg), however I would like to move the whole lot to another location (in this case a network drive) which is backed up every night.  I would want this new location to become my working directory.

My question is, can I simply copy the MyProject directory (and hence the .hg repository) to the new location and have everything work as it did on my local drive?  Or does this via Mercurial commands (eg clone) so that Mercurial knows about the change of location?

答:
Easiest option is to just move that folder to your network drive.  On your cloned working directory just update the paths found in the .hg/hgrc file (located in the .hg/ folder if that wasn't clear.  In your cloned repo you will see a default path like this...

```
[paths]
default = c:\MyProject
```

That path should be changed to your new location.  Also if there is another path you can add another like this...

```
[paths]
default = c:\MyProject
Bitbucket = https://user@bitbucket.org/MyProject
```

Body:
Easiest option is to just move that folder to your network drive.  On your cloned working directory just update the paths found in the .hg/hgrc file (located in the .hg/ folder if that wasn't clear.  In your cloned repo you will see a default path like this...

[paths]
default = c:\MyProject

That path should be changed to your new location.  Also if there is another path you can add another like this...

[paths]
default = c:\MyProject
Bitbucket = https://user@bitbucket.org/MyProject


问:
HTML Hamburger - how to form proper X
I'm trying to build an animated hamburger using css. To do so I use three different span and animate on click - nothing special.

But somehow the transform-origin whatsoever is messed up, hence I can't form a proper X. How can I do so?

let active = false;

const handleNav = () => {
  const hamburger = document.querySelector(".hamburger");
  if (!active) {
    hamburger.classList.add("is-active");
  } else {
    hamburger.classList.remove("is-active");
  }

  active = !active;
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.hamburger {
  width: 25px;
  cursor: pointer;
}

span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: black;
    margin-bottom: 4px;
    transform-origin: 0 50%;
    transition: all 0.3s;
}

span:last-child {
  margin-bottom: 0;
}

.is-active span:first-child {
  transform: rotate(45deg);
}

.is-active span:nth-child(2) {
  width: 0;
}

.is-active span:last-child {
  transform: rotate(-45deg);
}</code>```

```

答:
As mentioned in the comment, you have to change transform-origin for the s to the right value, here is a snippet:

let active = false;

const handleNav = () => {
  const hamburger = document.querySelector(".hamburger");
  if (!active) {
    hamburger.classList.add("is-active");
  } else {
    hamburger.classList.remove("is-active");
  }

  active = !active;
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.hamburger {
  width: 25px;
  cursor: pointer;
}

span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: black;
    margin-bottom: 4px;
    transform-origin: 17%;
    transition: all 0.3s;
}

span:last-child {
  margin-bottom: 0;
}

.is-active span:first-child {
  transform: rotate(45deg);
}

.is-active span:nth-child(2) {
  width: 0;
}

.is-active span:last-child {
  transform: rotate(-45deg);
}</code>```

```

Title: HTML Hamburger - how to form proper X

Body:
I'm trying to build an animated hamburger using css. To do so I use three different span and animate on click - nothing special.

But somehow the transform-origin whatsoever is messed up, hence I can't form a proper X. How can I do so?

let active = false;

const handleNav = () => {
  const hamburger = document.querySelector(".hamburger");
  if (!active) {
    hamburger.classList.add("is-active");
  } else {
    hamburger.classList.remove("is-active");
  }

  active = !active;
}

.hamburger {
  width: 25px;
  cursor: pointer;
}

span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: black;
    margin-bottom: 4px;
    transform-origin: 0 50%;
    transition: all 0.3s;
}

span:last-child {
  margin-bottom: 0;
}

.is-active span:first-child {
  transform: rotate(45deg);
}

.is-active span:nth-child(2) {
  width: 0;
}

.is-active span:last-child {
  transform: rotate(-45deg);
}

Body:
As mentioned in the comment, you have to change transform-origin for the <span>s to the right value, here is a snippet:

let active = false;

const handleNav = () => {
  const hamburger = document.querySelector(".hamburger");
  if (!active) {
    hamburger.classList.add("is-active");
  } else {
    hamburger.classList.remove("is-active");
  }

  active = !active;
}

.hamburger {
  width: 25px;
  cursor: pointer;
}

span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: black;
    margin-bottom: 4px;
    transform-origin: 17%;
    transition: all 0.3s;
}

span:last-child {
  margin-bottom: 0;
}

.is-active span:first-child {
  transform: rotate(45deg);
}

.is-active span:nth-child(2) {
  width: 0;
}

.is-active span:last-child {
  transform: rotate(-45deg);
}

<div class="hamburger" onclick="handleNav()">
    <span></span>
    <span></span>
    <span></span>
</div>