问:
browser = webdriver.Chrome() not working
I am getting started with Selenium for python and have this:

```<code>from selenium import webdriver
browser = webdriver.Chrome()
</code>```

However it gives this error:

```<code>Traceback (most recent call last):
File "C:\Users\Bradley Jo\AppData\Local\Programs\Python\Python36\lib\site-
packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
 File "C:\Users\Bradley
Jo\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 709, in
__init__
restore_signals, start_new_session)
File "C:\Users\Bradley
Jo\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 997, in
_execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
  File "C:\Users\Bradley Jo\Desktop\Project\app.py", line 3, in
 <module>
 browser = webdriver.Chrome()
  File "C:\Users\Bradley Jo\AppData\Local\Programs\Python\Python36\lib\site-
  packages\selenium\webdriver\chrome\webdriver.py", line 68, in __init__
 self.service.start()
 File "C:\Users\Bradley Jo\AppData\Local\Programs\Python\Python36\lib\site-
 packages\selenium\webdriver\common\service.py", line 81, in start
 os.path.basename(self.path), self.start_error_message)
 selenium.common.exceptions.WebDriverException: Message: 'chromedriver'
 executable needs to be in PATH. Please see
 https://sites.google.com/a/chromium.org/chromedriver/home

[Finished in 1.0s]
</code>```

Anyone have any idea how to fix this? Thanks

答:
The error says it all as follows :

```<code>selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
</code>```

You need to override any other existing paths and pass the absolute path of the chromedriver binary as an argument while initializing the webdriver instance as follows :

```<code>from selenium import webdriver

driver = webdriver.Chrome(executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
</code>```

Body:
I am getting started with Selenium for python and have this:

from selenium import webdriver
browser = webdriver.Chrome()

However it gives this error:

Traceback (most recent call last):
File "C:\Users\Bradley Jo\AppData\Local\Programs\Python\Python36\lib\site-
packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
 File "C:\Users\Bradley
Jo\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 709, in
__init__
restore_signals, start_new_session)
File "C:\Users\Bradley
Jo\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 997, in
_execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
  File "C:\Users\Bradley Jo\Desktop\Project\app.py", line 3, in
 <module>
 browser = webdriver.Chrome()
  File "C:\Users\Bradley Jo\AppData\Local\Programs\Python\Python36\lib\site-
  packages\selenium\webdriver\chrome\webdriver.py", line 68, in __init__
 self.service.start()
 File "C:\Users\Bradley Jo\AppData\Local\Programs\Python\Python36\lib\site-
 packages\selenium\webdriver\common\service.py", line 81, in start
 os.path.basename(self.path), self.start_error_message)
 selenium.common.exceptions.WebDriverException: Message: 'chromedriver'
 executable needs to be in PATH. Please see
 https://sites.google.com/a/chromium.org/chromedriver/home

[Finished in 1.0s]

Anyone have any idea how to fix this? Thanks

Body:
The error says it all as follows :

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

You need to override any other existing paths and pass the absolute path of the chromedriver binary as an argument while initializing the webdriver instance as follows :

from selenium import webdriver

driver = webdriver.Chrome(executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')


来源: stackexchange

问:
How to generate files in a docker container for having the same owner as the host's user
I use docker containers to get some development tasks done in my git repositories.

The containers I use are built specifically for each project, that way each contributor only need docker CLI to get things done.

The bad side is the container run as root, thus generated files are owned by root once the container stops, and that's bad..

I can't change the owner in the container before exiting because there isn't the required user in the container /etc/passwd file.

I would create a user in the container before compiling the docker image but then the container won't be universal (for all my dev team).

What is the best practice(s) about that ?

答: I would recommend you to read this link to have the complete understanding of docker privileges - and for you, the solution would be to run docker using --user command.</p>

ContentLicense: CC BY-SA 3.0


问:
Sort by descending using underscore JS
I have below code where I need to do sorting by underscore JS based on value of (y).

Please find my code below. I am trying to do ascending first and then reverse. Unfortunately, it is not doing the sorting at all for me and shows data without sorting.

```<code>        function getMessageNames(){
        var rowIter = 1;
        //document.getElementById("demo2").innerHTML += "from getMessageNames="+calltypes;
        for (var i in calltypes){
            keyId = calltypes[i].label;
            for (var index in keyMsgNames){
                if(keyMsgNames[index].Id == keyId){
                    var row = {"label":keyMsgNames[index].Name,"y":calltypes[i].y};
                    messageNames.push(row);
                    break;
                }
            }

// Result:
//document.getElementById("demo2").innerHTML += "descending="+descending;
        }

            var ascending = _.sortBy(messageNames, ['y']);
// Then get DESC
var descending = ascending.reverse();
        for (var index in descending){
            addRow("CallTable", [ descending[index].label, descending[index].y], rowIter++);
        }
        createChart(descending,"Distribution on Key Messages",chartContainer);
    }

function createChart(data,title,container){
    var chart = new CanvasJS.Chart(container, {
                animationEnabled: true,
                title: {
                    text: title
                },
                data: [{
                    type: "pie",
                    startAngle: 240,
                    yValueFormatString: "",
                    indexLabel: "{label} '('{y}')'",
                    dataPoints: data
                }]
            });
            chart.render();
}

 function addRow(tblName, colData, rowNum){
    var table = document.getElementById(tblName);
    var tableRow = table.insertRow(rowNum);

    for (var index in colData){
        var cell = tableRow.insertCell(index);
        cell.innerHTML = colData[index];
    }
}
</code>```

答:
the sortBy expects an array of properties

Replace

```<code>var ascending = _.sortBy(messageNames, 'y');
</code>```

with

```<code>var ascending = _.sortBy(messageNames, ['y']);
</code>```

Title: Sort by descending using underscore JS

Body:
I have below code where I need to do sorting by underscore JS based on value of (y).

Please find my code below. I am trying to do ascending first and then reverse. Unfortunately, it is not doing the sorting at all for me and shows data without sorting.

        function getMessageNames(){
        var rowIter = 1;
        //document.getElementById("demo2").innerHTML += "from getMessageNames="+calltypes;
        for (var i in calltypes){
            keyId = calltypes[i].label;
            for (var index in keyMsgNames){
                if(keyMsgNames[index].Id == keyId){
                    var row = {"label":keyMsgNames[index].Name,"y":calltypes[i].y};
                    messageNames.push(row);
                    break;
                }
            }

// Result:
//document.getElementById("demo2").innerHTML += "descending="+descending;
        }

            var ascending = _.sortBy(messageNames, ['y']);
// Then get DESC
var descending = ascending.reverse();
        for (var index in descending){
            addRow("CallTable", [ descending[index].label, descending[index].y], rowIter++);
        }
        createChart(descending,"Distribution on Key Messages",chartContainer);
    }

function createChart(data,title,container){
    var chart = new CanvasJS.Chart(container, {
                animationEnabled: true,
                title: {
                    text: title
                },
                data: [{
                    type: "pie",
                    startAngle: 240,
                    yValueFormatString: "",
                    indexLabel: "{label} '('{y}')'",
                    dataPoints: data
                }]
            });
            chart.render();
}

 function addRow(tblName, colData, rowNum){
    var table = document.getElementById(tblName);
    var tableRow = table.insertRow(rowNum);

    for (var index in colData){
        var cell = tableRow.insertCell(index);
        cell.innerHTML = colData[index];
    }
}

Body:
the sortBy expects an array of properties

Replace

var ascending = _.sortBy(messageNames, 'y');

with

var ascending = _.sortBy(messageNames, ['y']);


问:
'Spawning.SpawnCube' is a 'field' but a 'method group' was expected
I am trying to spawn a prefab on a set of coordinates in Unity but this keeps coming up.</p>

```<code>using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Spawning : MonoBehaviour {

    public GameObject TestCube;
    public GameObject SpawnCube;
    public float CubeFallTime = 7.0f;
    public Vector3 Pos;

    void Start()
    {
        StartCoroutine(SpawnCube());
    }

    IEnumerator Spawn()
    {
        yield return new WaitForSeconds(CubeFallTime);
        Instantiate(TestCube, new Vector3(0, 6, 0), Quaternion.identity);
    }
}
</code>```

答:
SpawnCube is a variable and you are trying to accesses it as a method that why error keeps coming

You should do something like this

```<code>using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Spawning : MonoBehaviour {

    public GameObject TestCube;
    public GameObject SpawnCube;
    public float CubeFallTime = 7.0f;
    public Vector3 Pos;

    void Start()
    {
        StartCoroutine(Spawn());
    }

    IEnumerator Spawn()
    {
        yield return new WaitForSeconds(CubeFallTime);
        Instantiate(TestCube, new Vector3(0, 6, 0), Quaternion.identity);
    }
}`
</code>```

It should work fine and please search the internet for this kind of error before posting it as a question on Stack
Thanks

Body:
I am trying to spawn a prefab on a set of coordinates in Unity but this keeps coming up.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Spawning : MonoBehaviour {

    public GameObject TestCube;
    public GameObject SpawnCube;
    public float CubeFallTime = 7.0f;
    public Vector3 Pos;

    void Start()
    {
        StartCoroutine(SpawnCube());
    }

    IEnumerator Spawn()
    {
        yield return new WaitForSeconds(CubeFallTime);
        Instantiate(TestCube, new Vector3(0, 6, 0), Quaternion.identity);
    }
}

Body:
SpawnCube is a variable and you are trying to accesses it as a method that why error keeps coming

You should do something like this

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Spawning : MonoBehaviour {

    public GameObject TestCube;
    public GameObject SpawnCube;
    public float CubeFallTime = 7.0f;
    public Vector3 Pos;

    void Start()
    {
        StartCoroutine(Spawn());
    }

    IEnumerator Spawn()
    {
        yield return new WaitForSeconds(CubeFallTime);
        Instantiate(TestCube, new Vector3(0, 6, 0), Quaternion.identity);
    }
}`

It should work fine and please search the internet for this kind of error before posting it as a question on Stack
Thanks


问:
Loop synchronization deadlock
I've got the following classes in Java

```<code>public class Counter {
    private int value;

    public Counter(int value) {
        this.value = value;
    }
    public void setValue(int value) {
        this.value = value;
    }
    public void decrement() {
        this.value--;
    }
    public int getValue() {
        return this.value;
    }
}

public class Cell extends Thread {

    private Object sync;
    private Counter counter;

    public Cell(Object sync, Counter counter) {
        this.sync = sync;
        this.counter = counter;
    }

    public void run() {
        for (int r=0; r<Simulation.ROUND_NUM; r++) {

            // do something

            synchronized(counter) {
                counter.decrement();
                counter.notifyAll();
            }
            synchronized(sync) {
                try {
                    sync.wait();
                }
                catch (Exception ex) {}
            }

        }
    }
}

public class Simulation extends Thread {

    public static final int THREAD_NUM = 5;
    public static final int ROUND_NUM = 5;

    public Object sync = new Object();
    private Counter counter = new Counter(THREAD_NUM);

    public void run() {

        for (int i=0; i<THREAD_NUM; i++) {
            Cell c = new Cell(sync,counter);
            c.start();
        }

        for (int i=0; i<ROUND_NUM; i++) {
            synchronized(counter) {
                while(counter.getValue() != 0) {
                    try {
                        counter.wait();
                    }
                    catch (Exception ex) {}
                }
                counter.setValue(THREAD_NUM);
            }

            synchronized(sync) {
                sync.notifyAll();
            }
        }
    }
}
</code>```

The aim is to prevent from executing the next iteration of loop in each Cell Thread, until every Cell Thread will be done on each iteration. My solution sometimes leads to deadlock. I can't understand why. Please help

答:
First of all you could make use of the AtomicInteger class instead of the Counter class you made. The AtomicInteger class is thread-safe so that you can use atomic action such as decrementAndGet and incrementAndGet.

To achieve the functionality of waiting till each of the Cell threads is done you can use a CountDownLatch like mentioned in a previous comment, or even concurrent objects like CyclicBarriers to halt execution till all Cell threads join on the barrier. Through some of these concurrent objects it should be easier to control multiple threads. Using plain synchronization does work as well, you just are typically required to do more coding and thinking to ensure everything works well.

ContentLicense: CC BY-SA 2.5

Title: Loop synchronization deadlock

Body:
I've got the following classes in Java

public class Counter {
    private int value;

    public Counter(int value) {
        this.value = value;
    }
    public void setValue(int value) {
        this.value = value;
    }
    public void decrement() {
        this.value--;
    }
    public int getValue() {
        return this.value;
    }
}

public class Cell extends Thread {

    private Object sync;
    private Counter counter;

    public Cell(Object sync, Counter counter) {
        this.sync = sync;
        this.counter = counter;
    }

    public void run() {
        for (int r=0; r<Simulation.ROUND_NUM; r++) {

            // do something

            synchronized(counter) {
                counter.decrement();
                counter.notifyAll();
            }
            synchronized(sync) {
                try {
                    sync.wait();
                }
                catch (Exception ex) {}
            }

        }
    }
}

public class Simulation extends Thread {

    public static final int THREAD_NUM = 5;
    public static final int ROUND_NUM = 5;

    public Object sync = new Object();
    private Counter counter = new Counter(THREAD_NUM);

    public void run() {

        for (int i=0; i<THREAD_NUM; i++) {
            Cell c = new Cell(sync,counter);
            c.start();
        }

        for (int i=0; i<ROUND_NUM; i++) {
            synchronized(counter) {
                while(counter.getValue() != 0) {
                    try {
                        counter.wait();
                    }
                    catch (Exception ex) {}
                }
                counter.setValue(THREAD_NUM);
            }

            synchronized(sync) {
                sync.notifyAll();
            }
        }
    }
}

The aim is to prevent from executing the next iteration of loop in each Cell Thread, until every Cell Thread will be done on each iteration. My solution sometimes leads to deadlock. I can't understand why. Please help


问:
how to get text outside in HTML JS
```<code><ul class="select2-selection__rendered">
  <li class="select2-selection__choice" title="List"><span class="select2-selection__choice__remove" role="presentation">×</span>**List**</li>
  <li class="select2-search select2-search--inline">
    <input class="select2-search__field" type="search" tabindex="0" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" aria-autocomplete="list" placeholder="" style="width: 0.75em;">
  </li>
</ul>
</code>```

Thats the code ..

I want to get text "List" which I bold .

```<code>alert( $("ul > li > .select2-selection__choice").text() );
</code>```

still can't get the text .
Thanks

答:
You can use the following code,

```<code>alert(e.params.data.text);
</code>```

This will gives you the answer as your requirement. This will display the last unselected value.

Title: how to get text outside in HTML JS

Body:
×**List**

    <input class="select2-search__field" type="search" tabindex="0" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" aria-autocomplete="list" placeholder="" style="width: 0.75em;">

Thats the code ..

I want to get text "List" which I bold .

alert( $("ul > li > .select2-selection__choice").text() );

still can't get the text .
Thanks

Body:
You can use the following code,

alert(e.params.data.text);

This will gives you the answer as your requirement. This will display the last unselected value.


问:
Node/Angularjs app not receiving JSON Web Token when using angularjs ui
I am making a MEAN stack application with authentication by JWT. This is the script which handles token authentication:

authenticationService.js

```<code>examApp.factory('authenticationService', ['$window', function ($window) {
var authToken = {};
var store = $window.localStorage;
var key = 'auth-token';
authToken.getToken = function () {
    return store.getItem(key);
}

authToken.setToken = function (token) {
    if (token) {
        store.setItem = (key, token);
    } else {
        store.removeItem(key);
    }
}

return authToken;}]);
</code>```

Now, whenever i am logging into my application, the user/admin can log in successfully but in console, i am not receiving any tokens with token=null being displayed.

When i log in the application through POSTMAN tool and manually copy-pasting token after token= part in routes, i can perform any task, but logging in through angularjs ui, i get

Token authentication failed

Any help will be appreciated.

答:
There is a problem in your code at

```<code>authToken.setToken = function (token) {
    if (token) {
        store.setItem = (key, token); // Here is the problem
    } else {
        store.removeItem(key);
    }
}
</code>```

You are assigning the store.setItem, instead you need to execute store.setItem like below

```<code>authToken.setToken = function (token) {
    if (token) {
        store.setItem(key, token);
    } else {
        store.removeItem(key);
    }
}
</code>```

Body:
I am making a MEAN stack application with authentication by JWT. This is the script which handles token authentication:

authenticationService.js

examApp.factory('authenticationService', ['$window', function ($window) {
var authToken = {};
var store = $window.localStorage;
var key = 'auth-token';
authToken.getToken = function () {
    return store.getItem(key);
}

authToken.setToken = function (token) {
    if (token) {
        store.setItem = (key, token);
    } else {
        store.removeItem(key);
    }
}

return authToken;}]);

Now, whenever i am logging into my application, the user/admin can log in successfully but in console, i am not receiving any tokens with token=null being displayed.

When i log in the application through POSTMAN tool and manually copy-pasting token after token= part in routes, i can perform any task, but logging in through angularjs ui, i get

Token authentication failed

Any help will be appreciated.

Body:
There is a problem in your code at

authToken.setToken = function (token) {
    if (token) {
        store.setItem = (key, token); // Here is the problem
    } else {
        store.removeItem(key);
    }
}

You are assigning the store.setItem, instead you need to execute store.setItem like below

authToken.setToken = function (token) {
    if (token) {
        store.setItem(key, token);
    } else {
        store.removeItem(key);
    }
}


问:
How to loop each thread with unique data from CSV Data Config file
I have CSV data config file with 25 users. When I create a Thread group of 25 users I want each  thread to pick one line from CSV Data config and loop around.

So

```<code>User1 picks userA
Users2 pick userB.......userN pick user(SomeX)
</code>```

As I set keep alive so I want to reuse the connection and same set of data on the same socket.

```<code>My CSV file Recycle on EOF False
Stop Thread on EOF True
Sharing Mode : Current Thread.
</code>```

But what I observed is Thread 1-1 User1 picks UserA ( iteration 1)
Thread 1-1 User 1 picks User B  iteration 2

What I expect is

```<code>Thread 1-1 User1 picks UserA ( iteration 1)
Thread 1-1 User 1 picks User A ( iteration 2 )
</code>```

答:
According to your description each JMeter thread will read CSV file independently and separately, i.e.:

Thread 1-1 will process all 25 CSV entries defined number of iterations

Thread 1-2 will process all 25 CSV entries defined number of iterations

etc.

Given you have equal number of lines in CSV file and virtual users it might be better idea setting "Sharing mode" to All threads so each virtual user could pick its own line from the CSV file.

More information:

CSV Data Set Config

CSV Data Set Config in Sharing Mode - Made Easy

Body:
I have CSV data config file with 25 users. When I create a Thread group of 25 users I want each  thread to pick one line from CSV Data config and loop around.

So

User1 picks userA
Users2 pick userB.......userN pick user(SomeX)

As I set keep alive so I want to reuse the connection and same set of data on the same socket.

My CSV file Recycle on EOF False
Stop Thread on EOF True
Sharing Mode : Current Thread.

But what I observed is Thread 1-1 User1 picks UserA ( iteration 1)
Thread 1-1 User 1 picks User B  iteration 2

What I expect is

Thread 1-1 User1 picks UserA ( iteration 1)
Thread 1-1 User 1 picks User A ( iteration 2 )


问:
How do I use google maps async callback with knockout and webpack?

Hi all. I'm trying to integrate google maps api with knockout and webpack. I've set my request for the google maps api directly in my html. The script includes a callback function that I want to execute once its finished loading. But when I run the server I get the error "initMap is not a function." I think this is happening because the function is located in a bundle but I'm not sure. Does anybody know why this is happening?

Heres the js that I'm bundling:

```<code>import ko from 'knockout';

function initMap() {
  console.log('hey')
}

var MyApp = () => {
}

ko.applyBindings(new MyApp())
</code>```

Heres the html:

```<code><!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Neighborhood Map</title>
    <link rel="stylesheet" type="text/css" href="./css/main.css"
  </head>
  <body>
    <div id="map">
    </div>

    <script type="text/javascript" src="build/bundle.js"></script>
    <script defer
      src="http://maps.google.com/maps/api/js?key=[KEY]&v=3&callback=initMap">
    </script>

  </body>
</html>
</code>```

Here's my webpack config file:

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

module.exports = {
    devtool: 'sourcemap',
      entry: './app.js',
      output: {
        path: path.resolve('build', ''),
        filename: 'bundle.js'
      },
      module: {
      noParse: /node_modules\/knockout\/build\/output\/*.js/,
      loaders: [
        {
          test: /\.html$/, loader: 'html-loader'
        },
          {
            test: /\.js?$/,
            exclude: /(node_modules)/,
            loader: 'babel-loader',
            query: {
                presets: ['es2015']
            }
          },
        ]
    }
};
</code>```

FYI I've tried putting the initMap funtion in MyApp variable as well as leaving as seen as a global function. Neither option works. Do you think I should request the script within the js file instead as a script in the html? If so, what would be the best way to do this?

答:
After days of scouring the internet I finally found the answer here: Calling webpacked code from outside (HTML script tag)

The answer I used is actually the 3rd accepted answer. It involves setting the function as a property of the window and exporting the function

```<code>window.initMap = initMap
export function initMap() { function stuff }
</code>```

Please, if this answer helps you, go to that site and upvote that answer so it becomes the accepted answer.

Body:
Hi all. I'm trying to integrate google maps api with knockout and webpack. I've set my request for the google maps api directly in my html. The script includes a callback function that I want to execute once its finished loading. But when I run the server I get the error "initMap is not a function." I think this is happening because the function is located in a bundle but I'm not sure. Does anybody know why this is happening?

Heres the js that I'm bundling:

import ko from 'knockout';

function initMap() {
  console.log('hey')
}

var MyApp = () => {
}

ko.applyBindings(new MyApp())

Heres the html:

<!DOCTYPE html>

    <meta charset="utf-8">
    <title>Neighborhood Map</title>
    <link rel="stylesheet" type="text/css" href="./css/main.css"

Here's my webpack config file:

const path = require('path');

module.exports = {
    devtool: 'sourcemap',
      entry: './app.js',
      output: {
        path: path.resolve('build', ''),
        filename: 'bundle.js'
      },
      module: {
      noParse: /node_modules\/knockout\/build\/output\/*.js/,
      loaders: [
        {
          test: /\.html$/, loader: 'html-loader'
        },
          {
            test: /\.js?$/,
            exclude: /(node_modules)/,
            loader: 'babel-loader',
            query: {
                presets: ['es2015']
            }
          },
        ]
    }
};

FYI I've tried putting the initMap funtion in MyApp variable as well as leaving as seen as a global function. Neither option works. Do you think I should request the script within the js file instead as a script in the html? If so, what would be the best way to do this?

Body:
After days of scouring the internet I finally found the answer here: Calling webpacked code from outside (HTML script tag)

The answer I used is actually the 3rd accepted answer. It involves setting the function as a property of the window and exporting the function

window.initMap = initMap
export function initMap() { function stuff }

Please, if this answer helps you, go to that site and upvote that answer so it becomes the accepted answer.


问:
The type or namespace name 'DbContext' could not be found
I am VERY new to ASP.NET MVC (3) and am having a hard time resolving a build error in Visual Studio:

The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)

```<code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;

namespace MyProjectName.Models
{
    public class MachineModel
    {
        // name
        [Required]
        [Display(Name = "Nom de la machine")]
        public string Name { get; set; }

        // IP
        [Required]
        [RegularExpression(@"(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",
           ErrorMessage = "Donnez une adresse IPv4 valide.")]
        [Display(Name = "Adresse IP de la machine")]
        public string IP { get; set; }
    }

    public class MachineDbContext : DbContext
    {
        public DbSet<MachineModel> Machines{ get; set; }
    }
}
</code>```

The two errors I am getting are:

The type or namespace name
'DbContext' could not be found (are
you missing a using directive or an
assembly reference?)

The type or namespace name 'DbSet'
could not be found (are you
missing a using directive or an
assembly reference?)

What am I missing?

答:
Like the others have suggested:

Add the correct references and directives. But it still doesn't work? Maybe you have the same problem I did:

Have a look below and see if you can tell me what is wrong:

public class PanelLengthContext : DBContext {     } ??!

Make sure the class name is not misspelt - (case sensitivity)!

DbContext is the correct spelling.

this is how it should look:

check the spelling. don't waste 20 min of your life like i did. public class PanelLengthContext : DbContext {}

HTH

Body:
I am VERY new to ASP.NET MVC (3) and am having a hard time resolving a build error in Visual Studio:

The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;

namespace MyProjectName.Models
{
    public class MachineModel
    {
        // name
        [Required]
        [Display(Name = "Nom de la machine")]
        public string Name { get; set; }

        // IP
        [Required]
        [RegularExpression(@"(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",
           ErrorMessage = "Donnez une adresse IPv4 valide.")]
        [Display(Name = "Adresse IP de la machine")]
        public string IP { get; set; }
    }

    public class MachineDbContext : DbContext
    {
        public DbSet<MachineModel> Machines{ get; set; }
    }
}

The two errors I am getting are:

The type or namespace name
'DbContext' could not be found (are
you missing a using directive or an
assembly reference?)

The type or namespace name 'DbSet'
could not be found (are you
missing a using directive or an
assembly reference?)

What am I missing?


问:
If an object is passed as an argument in a function, does it create a new instance?
In this code:

```<code>function myFunction(obj) {
  console.log(obj);
}

var obj = {
  key : 'value',
  funct :  function(){},
  elem  :  document.getElementById('navigation').getElementsByTagName('a')
}

myFunction(obj);
</code>```

Is the object "obj" printed in the console inside myFunction the same object i defined or is a new instance?

Also, what if i pass it from myFunction to another function?

答:
All non-primitives are passed by reference in JavaScript -- that is, they are the same object. However, primitives are passed by value instead:</p>

```<code>function change(a) {
    a = 2;
}
var a = 1;
change(a);
alert(a); // should alert 1

function change2(a) {
    a.test = 2;
}
var obj = {test:1};
change2(obj);
alert(obj.test); // should alert 2
</code>```

Body:
In this code:

function myFunction(obj) {
  console.log(obj);
}

var obj = {
  key : 'value',
  funct :  function(){},
  elem  :  document.getElementById('navigation').getElementsByTagName('a')
}

myFunction(obj);

Is the object "obj" printed in the console inside myFunction the same object i defined or is a new instance?

Also, what if i pass it from myFunction to another function?

Body:
All non-primitives are passed by reference in JavaScript -- that is, they are the same object. However, primitives are passed by value instead:

function change(a) {
    a = 2;
}
var a = 1;
change(a);
alert(a); // should alert 1

function change2(a) {
    a.test = 2;
}
var obj = {test:1};
change2(obj);
alert(obj.test); // should alert 2


问:
Unable to get Latitude and Longitude android
I am trying to get Latitude and Longitude using given below code but every time i am getting 0.00 and 0.00 lat and long as result.

```<code>locationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 3000L, 1, listener);
Log.d("Network", "Network");
if (locationManager != null) {
    location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    if (location != null) {
        Log.e("Google latitude 111", location.getLatitude() + "");
        Log.e("Google longitude 111", location.getLongitude() + "");
        if (ServiceManager.lat.equals("") || ServiceManager.lng.equals("")) {
            ServiceManager.lat = String.valueOf(location.getLatitude());
            ServiceManager.lng = String.valueOf(location.getLongitude());
            MainActivity.handler.sendEmptyMessage(Response.GOT_LOCATION);
        }
    }
}
</code>```

I want to get actual latitude and longitude. I have taken and allowed all require permissions in device (FINE_LOCATION, COARSE_LOCATION and INTERNET).My target SDK version is 25. Is that any update in Androids Location Manager Policy for latest SDKs?

答:
If you are working with android version 23 or greater i.e marshmallow or greater you need to add runtime permissions i.e access fine location and access coarse location then only you will get result else if you are working with version less than 23 you will get latitude and longtitude and dont forget to add permissions in manifest.

Link-How to request Location Permission on Android 6

Body:
I am trying to get Latitude and Longitude using given below code but every time i am getting 0.00 and 0.00 lat and long as result.

locationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 3000L, 1, listener);
Log.d("Network", "Network");
if (locationManager != null) {
    location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    if (location != null) {
        Log.e("Google latitude 111", location.getLatitude() + "");
        Log.e("Google longitude 111", location.getLongitude() + "");
        if (ServiceManager.lat.equals("") || ServiceManager.lng.equals("")) {
            ServiceManager.lat = String.valueOf(location.getLatitude());
            ServiceManager.lng = String.valueOf(location.getLongitude());
            MainActivity.handler.sendEmptyMessage(Response.GOT_LOCATION);
        }
    }
}

I want to get actual latitude and longitude. I have taken and allowed all require permissions in device (FINE_LOCATION, COARSE_LOCATION and INTERNET).My target SDK version is 25. Is that any update in Androids Location Manager Policy for latest SDKs?


问:
Switch Statement inside condition refactoring
I have a piece of code that works but I do not like the way it looks. It looks clunky and messy. Is basically an if statement that has a switch statement inside.

Is there a way to refactor this? Maybe a well know to deal with them?

```<code>private Direction update(Coordinates coordinate) {
    if (coordinate.isLeft()) {
        switch (coordinate.getDirection()) {
        case NORTH: return Direction.WEST;
        case SOUTH: return Direction.EASTH;
        case EASTH: return Direction.NORTH;
        case WEST: return Direction.SOUTH;
        }
    }
    if (coordinate.isRight()) {
        switch (coordinate.getDirection()) {
        case NORTH: return Direction.EASTH;
        case SOUTH: return Direction.WEST;
        case EASTH: return Direction.SOUTH;
        case WEST: return Direction.NORTH;
        }
    }
    return null;
}
</code>```

答:
If you order your enum clockwise, you can walk from one to the next with a simple index:</p>

```<code>enum Direction {
    NORTH, EAST, SOUTH, WEST;

    public Direction rotate(boolean clockwise) {
        int nextIndex = ordinal() + (clockwise ? 1 : 3);
        return values()[nextIndex % 4];
    }
}
</code>```

Body:
I have a piece of code that works but I do not like the way it looks. It looks clunky and messy. Is basically an if statement that has a switch statement inside.

Is there a way to refactor this? Maybe a well know to deal with them?

private Direction update(Coordinates coordinate) {
    if (coordinate.isLeft()) {
        switch (coordinate.getDirection()) {
        case NORTH: return Direction.WEST;
        case SOUTH: return Direction.EASTH;
        case EASTH: return Direction.NORTH;
        case WEST: return Direction.SOUTH;
        }
    }
    if (coordinate.isRight()) {
        switch (coordinate.getDirection()) {
        case NORTH: return Direction.EASTH;
        case SOUTH: return Direction.WEST;
        case EASTH: return Direction.SOUTH;
        case WEST: return Direction.NORTH;
        }
    }
    return null;
}

Body:
If you order your enum clockwise, you can walk from one to the next with a simple index:

enum Direction {
    NORTH, EAST, SOUTH, WEST;

    public Direction rotate(boolean clockwise) {
        int nextIndex = ordinal() + (clockwise ? 1 : 3);
        return values()[nextIndex % 4];
    }
}


问:
How does a UInt128, relate to the 2 UInt64s it's comprised of?
If I have the following struct:

```<code>public struct UInt128 {
    internal var value: (upperBits: UInt64, lowerBits: UInt64)
}
</code>```

Imagine an initializer that creates a random number that fits into UInt128 and that number is sufficiently large such that it exceeds the value of one of the UInt64

Do the upper bits and the lower bits sum to be the total of the UInt128 or the memory managed in another way?

For the sake of working with small numbers, if the capacity of each UInt64 is 20, If the value of the UInt128 was 24, would the upper bits value be 20 and the lower bits value be 4?

答:
Imagine you are asked to make a struct that represents 4-digit numbers, but you can only store 2-digit numbers.  So, you have an upperHalf that represents the first 2 digits and a lowerHalf that represents the second 2 digits.

```<code>let upperHalf = 12
let lowerHalf = 34
</code>```

Now, you want to combine them to make the full 4-digit number 1234.

How do you do that?  Do you add them?

```<code>12 + 34 = 46
</code>```

No, because the 12 doesn't just represent 12.  It is really 1200.

```<code>1200 + 34 = 1234
</code>```

So in order to combine them, you multiply the upperHalf by 100 to make space for the lower digits and then add the lowerHalf.

```<code>let upperHalf = 12
let lowerHalf = 34
let value = upperHalf * 100 + lowerHalf
print(value)  // 1234
</code>```

So, what is 100?  It represents shifting a base-10 number left 2 places.  For each shift, you multiply by 10.  So 2 shifts is 10 * 10 or 100.

Now you are given the task of using two UInt8 numbers to represent a UInt16 number.

```<code>let upperBits = 2
let lowerBits = 1
</code>```

Now you want to combine them to make the UInt16 value.  Like in the previous case, you can't just add them.  You need to shift the upperBits over to the left by 8 places to make room for the lowerBits.  But now you are using binary (base 2), so every shift is accomplished by multiplying by 2.

So combining the upperBits and lowerBits of two UInt8 values becomes

```<code>let value = (upperBits * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2) + lowerBits
</code>```

which is the same as:

```<code>let value = (upperBits * 256) + lowerBits
</code>```

which can also be written as:

```<code>let value = (upperBits << 8) + lowerBits
</code>```

<< 8 means shift the bits left 8 times.

So if upperBits is 2 and lowerBits is 1 then

```<code>let value = (2 * 256) + 1  // value = 513
</code>```

Extending this analogy to using two UInt64 numbers to represent a UInt128, you need to shift the upperBits 64 places to the left before adding the lowerBits.  Each shift is the same as multiplying by 2, so you have to multiply upperBits by 2 ^ 64 (or 18446744073709551616) to make room before adding lowerBits:

Conceptually:

```<code>let value: UInt128 = (upperBits << 64) + lowerBits
</code>```

Which is the same as:

```<code>let value: UInt128 = (upperBits * 18446744073709551616) + lowerBits
</code>```

Body:
If I have the following struct:

public struct UInt128 {
    internal var value: (upperBits: UInt64, lowerBits: UInt64)
}

Imagine an initializer that creates a random number that fits into UInt128 and that number is sufficiently large such that it exceeds the value of one of the UInt64

Do the upper bits and the lower bits sum to be the total of the UInt128 or the memory managed in another way?

For the sake of working with small numbers, if the capacity of each UInt64 is 20, If the value of the UInt128 was 24, would the upper bits value be 20 and the lower bits value be 4?

Body:
Imagine you are asked to make a struct that represents 4-digit numbers, but you can only store 2-digit numbers.  So, you have an upperHalf that represents the first 2 digits and a lowerHalf that represents the second 2 digits.

let upperHalf = 12
let lowerHalf = 34

Now, you want to combine them to make the full 4-digit number 1234.

How do you do that?  Do you add them?

12 + 34 = 46

No, because the 12 doesn't just represent 12.  It is really 1200.

1200 + 34 = 1234

So in order to combine them, you multiply the upperHalf by 100 to make space for the lower digits and then add the lowerHalf.

let upperHalf = 12
let lowerHalf = 34
let value = upperHalf * 100 + lowerHalf
print(value)  // 1234

So, what is 100?  It represents shifting a base-10 number left 2 places.  For each shift, you multiply by 10.  So 2 shifts is 10 * 10 or 100.

Now you are given the task of using two UInt8 numbers to represent a UInt16 number.

let upperBits = 2
let lowerBits = 1

Now you want to combine them to make the UInt16 value.  Like in the previous case, you can't just add them.  You need to shift the upperBits over to the left by 8 places to make room for the lowerBits.  But now you are using binary (base 2), so every shift is accomplished by multiplying by 2.

So combining the upperBits and lowerBits of two UInt8 values becomes

let value = (upperBits * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2) + lowerBits

which is the same as:

let value = (upperBits * 256) + lowerBits

which can also be written as:

let value = (upperBits << 8) + lowerBits

<< 8 means shift the bits left 8 times.

So if upperBits is 2 and lowerBits is 1 then

let value = (2 * 256) + 1  // value = 513

Extending this analogy to using two UInt64 numbers to represent a UInt128, you need to shift the upperBits 64 places to the left before adding the lowerBits.  Each shift is the same as multiplying by 2, so you have to multiply upperBits by 2 ^ 64 (or 18446744073709551616) to make room before adding lowerBits:

Conceptually:

let value: UInt128 = (upperBits << 64) + lowerBits

Which is the same as:

let value: UInt128 = (upperBits * 18446744073709551616) + lowerBits


问:
Is it possible to use emoji on A-Frame a-text?
I find it useful to use an emoji instead of an image in an a-text
But I tried this:

```<code><a-text value="&#1F601"></a-text>
</code>```

And this:

```<code><a-text value=""></a-text>
</code>```

And it doesn't seem to work (text is omitted).

And yes, it's included in head:

```<code><head>
  <meta charset="utf-8" />
</head>
</code>```

Is it possible or is there a limitation with WebGL/ThreeJS/A-Frame?

答:
Yes, if you have a font that comes with those glyphs. There are a bunch of fonts ready to use here: https://github.com/etiennepinchon/aframe-fonts
I have not seen though anyone that includes emojis.</p>

Body:
I find it useful to use an emoji instead of an image in an a-text
But I tried this:

And this:

And it doesn't seem to work (text is omitted).

And yes, it's included in head:

  <meta charset="utf-8" />

Is it possible or is there a limitation with WebGL/ThreeJS/A-Frame?


问:
Replacing images in the bundle at run time
Can I replace images in bundle at run time? Basically, I have some images part of my bundle and also I will have them from the server if there is any change in the image. Can I place them in the bundle at run time so that I need not to change my code to pick the image?</p>

答:
You cannot change the contents of an Application bundle.

It is however possible to store the images in the Application's documents folder. Then you'll be able to overwrite those images in case they need to be changed.

There are two ways to achieve this:

At launch, check whether the image files exist in the documents directory. If not, copy the bundle images to the document folder.

Every time you load an image, check if it exists in the documents directory. If it does, load it, otherwise load the one from the bundle. This avoids copying the data thus leading to less disk usage, however it's more work to implement.


问:
Advanced numpy indexing
Here is what I want to do with numpy arrays:

```<code>import numpy as np

x = np.random.random((10,321,321))
y = np.random.rand((10,21,321,321))
z = np.random.randint(0,21,size=(10,321,321))

for i in range(10):
    for j in range(321):
        for k in range(321):
            if x[i][j][k] <= 0.5:
               for l in range(21):
                   if l == z[i][j][k]:
                       y[i][l][j][k] = 1
                   else:
                       y[i][l][j][k] = 0
</code>```

What would be the better way of doing this?

答:
Here's one possibility:</p>

```<code>tmp_y = np.zeros_like(y)

for l in range(21):
    tmp_y[:, l, :, :] = (z == l).astype(dtype=np.int32)

y = np.where(x <= 0.5, tmp_y, y)
</code>```

Title: Advanced numpy indexing

Body:
Here is what I want to do with numpy arrays:

import numpy as np

x = np.random.random((10,321,321))
y = np.random.rand((10,21,321,321))
z = np.random.randint(0,21,size=(10,321,321))

for i in range(10):
    for j in range(321):
        for k in range(321):
            if x[i][j][k] <= 0.5:
               for l in range(21):
                   if l == z[i][j][k]:
                       y[i][l][j][k] = 1
                   else:
                       y[i][l][j][k] = 0

What would be the better way of doing this?

Body:
Here's one possibility:

tmp_y = np.zeros_like(y)

for l in range(21):
    tmp_y[:, l, :, :] = (z == l).astype(dtype=np.int32)

y = np.where(x <= 0.5, tmp_y, y)


问:
change the content of a page without changing url in angular2
I changed my route without changing the url by using the skipLocationChange attribute like below.

```<code><a [routerLink]="['/articledetail']" skipLocationChange><h4>{{article.HeadLine}}</h4></a>
</code>```

But it goes to previous route while I am refreshing the page.

Then I used ngIf to check a variable value by setting value of it in a method which is called  while clicking on anchor tag,.But here also,my contents are previous contents after refreshing the page

How can I change the content of a page without changing the url while clicking an anchor tag in angular 2.

Thanks

答:
I  used ngIf to check a variable value by setting value of it in a method which is called while clicking on anchor tag,.But here also,my contents are previous contents after refreshing the page

In app.component.html

```<code>            <div class="row b-r" *ngIf="region==='INDIA'">
             INDIA Region
            .........
            .........
            </div>
           <div class="row b-r" *ngIf="region==='US'">

            US Region
            ................
             ..............
             .....
           </div>
       <a role="menuitem" tabindex="-1" [routerLink]="'/'"
       (click)="ChangeRegion('US')">US</a>
       <a role="menuitem" tabindex="-1" [routerLink]="'/'"
        (click)="ChangeRegion('INDIA')">INDIA</a>
</code>```

In app.compoenent.ts

```<code>     ngOnInit() {

          //Using localstorage for retaining region value after refreshing the page
       if (localStorage.getItem("region") === null) {
          this.region = "INDIA";
         }
      else {
       this.region = localStorage.getItem("region");
        }
      }
         region: string;

    ChangeRegion(region) {
       this.region = region;

     localStorage.setItem("region", this.region);

        }
</code>```

So,that I used localstorage to retain my variable value after refreshing the page.Its working fine

Body:
I changed my route without changing the url by using the skipLocationChange attribute like below.

{{article.HeadLine}}

But it goes to previous route while I am refreshing the page.

Then I used ngIf to check a variable value by setting value of it in a method which is called  while clicking on anchor tag,.But here also,my contents are previous contents after refreshing the page

How can I change the content of a page without changing the url while clicking an anchor tag in angular 2.

Thanks

Body:
I  used ngIf to check a variable value by setting value of it in a method which is called while clicking on anchor tag,.But here also,my contents are previous contents after refreshing the page

In app.component.html

            <div class="row b-r" *ngIf="region==='INDIA'">
             INDIA Region
            .........
            .........
            </div>
           <div class="row b-r" *ngIf="region==='US'">

            US Region
            ................
             ..............
             .....
           </div>
       <a role="menuitem" tabindex="-1" [routerLink]="'/'"
       (click)="ChangeRegion('US')">US</a>
       <a role="menuitem" tabindex="-1" [routerLink]="'/'"
        (click)="ChangeRegion('INDIA')">INDIA</a>

In app.compoenent.ts

     ngOnInit() {

          //Using localstorage for retaining region value after refreshing the page
       if (localStorage.getItem("region") === null) {
          this.region = "INDIA";
         }
      else {
       this.region = localStorage.getItem("region");
        }
      }
         region: string;

    ChangeRegion(region) {
       this.region = region;

     localStorage.setItem("region", this.region);

        }

So,that I used localstorage to retain my variable value after refreshing the page.Its working fine


问:
Azure database randomly stopped working after publishing UWP app
Ive made an app that uses Azure easy tables and connects using the following:

```<code> try
        {
            await ctv.combatDrillsTable.Initialization;
            await ctv.combatDrillsTable.InitLocalStoreAsync();
            await AddItemsAsync();
        }
        catch
        {
            var addError = new MessageDialog("Connection to your drills could not be established at this time, returning to " +
                "main menu");
            await addError.ShowAsync();
            if (MainPage.MyFrame.CanGoBack)
            {
                MainPage.MyFrame.GoBack();
            }
        }
</code>```

This was doing a GET request fine the last few weeks but now the connection error throws, I checked my Azure portal and the drills are there, the server overview shows the following:

HTTP Error stats
Im not really sure whats wrong and why Azure has just decided to stop working. I get the same results on bith my local machince is Visual Studio 2017 and the app installed on windows from the store.

答:
Im not really sure whats wrong and why Azure has just decided to stop working.

Firstly, you need to enable logs in Azure, in that case you could access the information logged by Azure and check the logs to find the detail reason. Details for how to do please reference this article.

Since  you're using easy table, the azure backend should be node.js. After enabled logs, you could access logs by address like: https://{your app name}.scm.azurewebsites.net/api/vfs/LogFiles/Application/index.html.

If you still cannot resolve your issues by checking the log details, you could upload the log for further looking.

Body:
Ive made an app that uses Azure easy tables and connects using the following:

 try
        {
            await ctv.combatDrillsTable.Initialization;
            await ctv.combatDrillsTable.InitLocalStoreAsync();
            await AddItemsAsync();
        }
        catch
        {
            var addError = new MessageDialog("Connection to your drills could not be established at this time, returning to " +
                "main menu");
            await addError.ShowAsync();
            if (MainPage.MyFrame.CanGoBack)
            {
                MainPage.MyFrame.GoBack();
            }
        }

This was doing a GET request fine the last few weeks but now the connection error throws, I checked my Azure portal and the drills are there, the server overview shows the following:

HTTP Error stats
Im not really sure whats wrong and why Azure has just decided to stop working. I get the same results on bith my local machince is Visual Studio 2017 and the app installed on windows from the store.


问:
How to build ascidoc PDF in IntelliJ with Maven on Ubuntu Linux
My system setup is the following:

IntelliJ 2017.2

Maven 3.5.2

Java 7

Ubuntu 17.10

I have a project in IntelliJ where I want to use asciidoctor variant of asciidocs. I have created a adoc file, and now I want to create the PDF from that file.

I have tried:

```<code>mvn clean install -Pbuild-release-notes
</code>```

But I cant find any PDF file.

答:
Have a look at the POM File (pom.xml) in this asciidoctor-pdf-example project.

When you run:

```<code>mvn clean process-resources
</code>```

(the maven command depends from the asciidoctor-maven-plugin configuration in the POM File)

You can run maven from the command line or from an IDE, you will get your PDF in target/generated-docs.

Body:
My system setup is the following:

IntelliJ 2017.2

Maven 3.5.2

Java 7

Ubuntu 17.10

I have a project in IntelliJ where I want to use asciidoctor variant of asciidocs. I have created a adoc file, and now I want to create the PDF from that file.

I have tried:

mvn clean install -Pbuild-release-notes

But I cant find any PDF file.

Body:
Have a look at the POM File (pom.xml) in this asciidoctor-pdf-example project.

When you run:

mvn clean process-resources

(the maven command depends from the asciidoctor-maven-plugin configuration in the POM File)

You can run maven from the command line or from an IDE, you will get your PDF in target/generated-docs.


问:
PHP create drop down menu, insert into database
I am trying to create a drop down menu for users to insert their orders into my database system.

I am having trouble creating the drop down menu, but I get the general idea of what I am supposed to do. I am new to this, so bear with me please.
Here is my uml if it helps:

```<code><?php

$databaseName = 'pizza_db';
$databaseUser = 'root';
$databasePassword = 'root';
$databaseHost = '127.0.0.1';
$conn = new mysqli($databaseHost, $databaseUser, $databasePassword, $databaseName);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected sucessfully";
if(isset($_POST['submit'})){

$sql = "SELECT size FROM size";
$result = mysqli_query($sql);
$opt = "<select name='size'>";
while($row = mysqli_fetch_assoc($result)) {
    $opt .= "option value='{$row['size']}' >{$row['size']}></option>";
}

$opt .="</select>";

if ($conn->query($sql)){
    $msg = "Data inserted successfully";
} else{
    $msg = "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Pizza</title>
</head>
<body>
<form action="size.php" method="POST">
    <select name="size">

    </select>
    <button type ="submit" name="submit"> Submit</button
</form>
</body>
</html>
</code>```

I know my html code is wrong or incomplete. How do I make it so that multiple drop down menus are created and how do I use multiple $sql insert statements in one script in order to submit my data into my database? Any help would be appreciated.

答:
You have few typos. In line 13,  if(isset($_POST['submit'})){ should be if(isset($_POST['submit'])){.
At options while loop, you should have had $opt .= "<option value='{$row['size']}' >{$row['size']}></option>"; (missing "<")

Also, there is some redundant code. mysqli_query() and $conn->query() does the same (see this SO tread). Simply OOP vs Procedural syntax.

You can remove

```<code>if ($conn->query($sql)){
    $msg = "Data inserted successfully";
}
else{
     $msg = "Error: " . $sql . "<br>" . $conn->error;
}
</code>```

Afterwards, something like this should be enough

```<code><?php

$databaseName = 'pizza_db';
$databaseUser = 'root';
$databasePassword = 'root';
$databaseHost = '127.0.0.1';
$conn = new mysqli($databaseHost, $databaseUser, $databasePassword, $databaseName);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected sucessfully";
if(isset($_POST['submit'])){

    $sql = "SELECT size FROM size";
    $result = mysqli_query($sql);
    $opt = "<select name='size'>";
    while($row = mysqli_fetch_assoc($result)) {
        $opt .= "<option value='{$row['size']}' >{$row['size']}></option>";
    }

    $opt .="</select>";
    $conn->close();
}
?>
</code>```

However, as I understand here, you have an empty form, which on submit gets all the sizes. If you wanted to have it like php get sizes > generate form > submit form and redirect to next step you should do it like or similar to this (and remove the if $_POST['submit'] condition from the php part)

```<code><!DOCTYPE html>
<html>
<head>
    <title>Pizza</title>
</head>
<body>
<form action="submit-chosen-size.php" method="POST">
    <label for="size">Select your size:</label>
    <?php echo($obj); ?>
    <button type ="submit" name="submit"> Submit</button
</form>
</body>
</html>
</code>```

EDIT: Please, try with this code. It's very similar to code above but will help with finding the problem

```<code><?php
$databaseName = 'pizza_db';
$databaseUser = 'root';
$databasePassword = 'root';
$databaseHost = '127.0.0.1';
$conn = new mysqli($databaseHost, $databaseUser, $databasePassword, $databaseName);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected sucessfully";

$sql = "SELECT size FROM size";
$result = mysqli_query($sql);
$opt = "<select name='size'>";
while($row = mysqli_fetch_assoc($result)) {
    $opt .= "<option value='{$row['size']}' >{$row['size']}></option>";
    echo $row['size']; // you can remove this later
}
$opt .="</select>";
echo $obj; //you can remove this later
$conn->close();
?>

<!DOCTYPE html>
<html>
    <head>
        <title>Pizza</title>
    </head>
    <body>
        <form action="submit-chosen-size.php" method="POST">
            <label for="size">Select your size:</label>
            <?php echo(isset($obj) ? $obj : "Empty"); ?>
            <button type ="submit" name="submit"> Submit</button
        </form>
    </body>
</html>
</code>```

Body:
I am trying to create a drop down menu for users to insert their orders into my database system.

I am having trouble creating the drop down menu, but I get the general idea of what I am supposed to do. I am new to this, so bear with me please.
Here is my uml if it helps:

<?php

$databaseName = 'pizza_db';
$databaseUser = 'root';
$databasePassword = 'root';
$databaseHost = '127.0.0.1';
$conn = new mysqli($databaseHost, $databaseUser, $databasePassword, $databaseName);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected sucessfully";
if(isset($_POST['submit'})){

$sql = "SELECT size FROM size";
$result = mysqli_query($sql);
$opt = "<select name='size'>";
while($row = mysqli_fetch_assoc($result)) {
    $opt .= "option value='{$row['size']}' >{$row['size']}></option>";
}

$opt .="</select>";

if ($conn->query($sql)){
    $msg = "Data inserted successfully";
} else{
    $msg = "Error: " . $sql . "
" . $conn->error;
}
$conn->close();
}
?>

<!DOCTYPE html>

    <title>Pizza</title>

<form action="size.php" method="POST">
    <select name="size">

    </select>
    <button type ="submit" name="submit"> Submit</button
</form>

I know my html code is wrong or incomplete. How do I make it so that multiple drop down menus are created and how do I use multiple $sql insert statements in one script in order to submit my data into my database? Any help would be appreciated.

Body:
You have few typos. In line 13,  if(isset($_POST['submit'})){ should be if(isset($_POST['submit'])){.
At options while loop, you should have had $opt .= "<option value='{$row['size']}' >{$row['size']}></option>"; (missing "<")

Also, there is some redundant code. mysqli_query() and $conn->query() does the same (see this SO tread). Simply OOP vs Procedural syntax.

You can remove

if ($conn->query($sql)){
    $msg = "Data inserted successfully";
}
else{
     $msg = "Error: " . $sql . "<br>" . $conn->error;
}

Afterwards, something like this should be enough

<?php

$databaseName = 'pizza_db';
$databaseUser = 'root';
$databasePassword = 'root';
$databaseHost = '127.0.0.1';
$conn = new mysqli($databaseHost, $databaseUser, $databasePassword, $databaseName);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected sucessfully";
if(isset($_POST['submit'])){

    $sql = "SELECT size FROM size";
    $result = mysqli_query($sql);
    $opt = "<select name='size'>";
    while($row = mysqli_fetch_assoc($result)) {
        $opt .= "<option value='{$row['size']}' >{$row['size']}></option>";
    }

    $opt .="</select>";
    $conn->close();
}
?>

However, as I understand here, you have an empty form, which on submit gets all the sizes. If you wanted to have it like php get sizes > generate form > submit form and redirect to next step you should do it like or similar to this (and remove the if $_POST['submit'] condition from the php part)

<!DOCTYPE html>
<html>
<head>
    <title>Pizza</title>
</head>
<body>
<form action="submit-chosen-size.php" method="POST">
    <label for="size">Select your size:</label>
    <?php echo($obj); ?>
    <button type ="submit" name="submit"> Submit</button
</form>
</body>
</html>

EDIT: Please, try with this code. It's very similar to code above but will help with finding the problem

<?php
$databaseName = 'pizza_db';
$databaseUser = 'root';
$databasePassword = 'root';
$databaseHost = '127.0.0.1';
$conn = new mysqli($databaseHost, $databaseUser, $databasePassword, $databaseName);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected sucessfully";

$sql = "SELECT size FROM size";
$result = mysqli_query($sql);
$opt = "<select name='size'>";
while($row = mysqli_fetch_assoc($result)) {
    $opt .= "<option value='{$row['size']}' >{$row['size']}></option>";
    echo $row['size']; // you can remove this later
}
$opt .="</select>";
echo $obj; //you can remove this later
$conn->close();
?>

<!DOCTYPE html>
<html>
    <head>
        <title>Pizza</title>
    </head>
    <body>
        <form action="submit-chosen-size.php" method="POST">
            <label for="size">Select your size:</label>
            <?php echo(isset($obj) ? $obj : "Empty"); ?>
            <button type ="submit" name="submit"> Submit</button
        </form>
    </body>
</html>


问:
Solving nonnegative linear system in R
Is it possible to find a solution to the undetermined system Ax = b, x >= 0 using some native R function? I can certainly write a linear program and use lpsolve, but am hoping for something native.</p>

答: Actually, I found what I was looking for. The package nnls addresses exactly my problem.

Title: Solving nonnegative linear system in R


问:
Order of items in set has been changed, Set, Swift
Im creating 2 sets which are containing String like following

```<code> let set1 : Set<String>   =   (["07:00", "QShift", "PRN"])
 let set2 : Set<String>   =   (["07:15", "QShift", "PRN"])
</code>```

At first, I am thinking the order of strings in each set will be exactly as same as their orders when being added. However I was wrong about the one of set1, the console gives me this

```<code>Printing description of set1:
▿ 3 elements
  - [0] : "QShift"
  - [1] : "PRN"
  - [2] : "07:00" { ... }

Printing description of set2:
▿ 3 elements
  - [0] : "07:15"
  - [1] : "QShift"
  - [2] : "PRN" { ... }
</code>```

Does anyone know why the order of strings in set1 has been changed to QShift, PRN, 07:00?

答:
OrderedSet On Github.

that should work for your need.

Body:
Im creating 2 sets which are containing String like following

 let set1 : Set<String>   =   (["07:00", "QShift", "PRN"])
 let set2 : Set<String>   =   (["07:15", "QShift", "PRN"])

At first, I am thinking the order of strings in each set will be exactly as same as their orders when being added. However I was wrong about the one of set1, the console gives me this

Printing description of set1:
▿ 3 elements
  - [0] : "QShift"
  - [1] : "PRN"
  - [2] : "07:00" { ... }

Printing description of set2:
▿ 3 elements
  - [0] : "07:15"
  - [1] : "QShift"
  - [2] : "PRN" { ... }

Does anyone know why the order of strings in set1 has been changed to QShift, PRN, 07:00?


问:
Adding support:preference-v7 or -v14 library causes Gradle build to fail
My project builds fine, until I attempt to include the Support Preference library.

When I do, build fails with this error:

```<code>C:\Users\user\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.0.aar\e8afe3ff4b4dc10495266439a3695e57\res\values\values.xml:252:5-69: AAPT: error: duplicate value for resource 'attr/min' with config ''.

C:\Users\user\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.0.aar\e8afe3ff4b4dc10495266439a3695e57\res\values\values.xml:252:5-69: AAPT: error: resource previously defined here.

C:\Users\user\StudioProjects\project\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:627: error: duplicate value for resource 'attr/min' with config ''.

C:\Users\user\StudioProjects\project\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:483: error: resource previously defined here.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
</code>```

I really don't know why this error is occuring...

EDIT: Full build.gradle:

```<code>apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 27

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.myapp"
        minSdkVersion 16
        targetSdkVersion 27
        multiDexEnabled true
        versionCode 1
        versionName "myVersion"
        resConfigs "en"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        debug {
            ext.enableCrashlytics = false
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')

    def firebaseVersion = '11.4.2'
    def supportVersion = '27.0.0'

    //Firebase Crashlytics
    compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
        transitive = true
    }

    //Firebase
    implementation 'com.google.firebase:firebase-auth:' + firebaseVersion
    implementation 'com.google.firebase:firebase-core:' + firebaseVersion
    implementation 'com.google.firebase:firebase-firestore:' + firebaseVersion

    //FirebaseUI
    implementation 'com.firebaseui:firebase-ui-auth:3.1.0'

    //Android Support
    implementation 'com.android.support:support-v4:' + supportVersion

    implementation 'com.android.support:appcompat-v7:' + supportVersion
    implementation 'com.android.support:cardview-v7:' + supportVersion
    implementation 'com.android.support:gridlayout-v7:' + supportVersion
    implementation 'com.android.support:recyclerview-v7:' + supportVersion
    implementation 'com.android.support:preference-v7:' + supportVersion

    implementation 'com.android.support:preference-v14:' + supportVersion

    implementation 'com.android.support:support-vector-drawable:' + supportVersion

    implementation 'com.android.support:design:' + supportVersion

    implementation 'com.android.support.constraint:constraint-layout:1.0.2'

    implementation 'com.android.support:multidex:1.0.2'

    //Material About
    implementation 'com.github.daniel-stoneuk:material-about-library:2.2.3-support26.1.0' //Weird version system

    //OpenCSV
    implementation('com.opencsv:opencsv:4.0') {
        //Transitively requires Apache Commons, which necessitates multidex...
        exclude group: 'commons-beanutils'
    }

    //Gson
    implementation 'com.google.code.gson:gson:2.8.2'
}

apply plugin: 'com.google.gms.google-services'
</code>```

It wants some more details, so I'll elaborate on the problem.
I want to use the AppCompat Preference library, but the error at the beginning pops up whenever I try to add it to my build.gradle.

答:
Apparently the problem was caused by an id in my attrs.xml:

```<code><resources>
    <declare-styleable name="MyView">
        <attr name="min" format="float" />
    </declare-styleable>
</resources>
</code>```

I fixed this error by changing min to minValue.

Body:
My project builds fine, until I attempt to include the Support Preference library.

When I do, build fails with this error:

C:\Users\user\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.0.aar\e8afe3ff4b4dc10495266439a3695e57\res\values\values.xml:252:5-69: AAPT: error: duplicate value for resource 'attr/min' with config ''.

C:\Users\user\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.0.aar\e8afe3ff4b4dc10495266439a3695e57\res\values\values.xml:252:5-69: AAPT: error: resource previously defined here.

C:\Users\user\StudioProjects\project\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:627: error: duplicate value for resource 'attr/min' with config ''.

C:\Users\user\StudioProjects\project\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:483: error: resource previously defined here.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

I really don't know why this error is occuring...

EDIT: Full build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 27

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.myapp"
        minSdkVersion 16
        targetSdkVersion 27
        multiDexEnabled true
        versionCode 1
        versionName "myVersion"
        resConfigs "en"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        debug {
            ext.enableCrashlytics = false
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')

    def firebaseVersion = '11.4.2'
    def supportVersion = '27.0.0'

    //Firebase Crashlytics
    compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
        transitive = true
    }

    //Firebase
    implementation 'com.google.firebase:firebase-auth:' + firebaseVersion
    implementation 'com.google.firebase:firebase-core:' + firebaseVersion
    implementation 'com.google.firebase:firebase-firestore:' + firebaseVersion

    //FirebaseUI
    implementation 'com.firebaseui:firebase-ui-auth:3.1.0'

    //Android Support
    implementation 'com.android.support:support-v4:' + supportVersion

    implementation 'com.android.support:appcompat-v7:' + supportVersion
    implementation 'com.android.support:cardview-v7:' + supportVersion
    implementation 'com.android.support:gridlayout-v7:' + supportVersion
    implementation 'com.android.support:recyclerview-v7:' + supportVersion
    implementation 'com.android.support:preference-v7:' + supportVersion

    implementation 'com.android.support:preference-v14:' + supportVersion

    implementation 'com.android.support:support-vector-drawable:' + supportVersion

    implementation 'com.android.support:design:' + supportVersion

    implementation 'com.android.support.constraint:constraint-layout:1.0.2'

    implementation 'com.android.support:multidex:1.0.2'

    //Material About
    implementation 'com.github.daniel-stoneuk:material-about-library:2.2.3-support26.1.0' //Weird version system

    //OpenCSV
    implementation('com.opencsv:opencsv:4.0') {
        //Transitively requires Apache Commons, which necessitates multidex...
        exclude group: 'commons-beanutils'
    }

    //Gson
    implementation 'com.google.code.gson:gson:2.8.2'
}

apply plugin: 'com.google.gms.google-services'

It wants some more details, so I'll elaborate on the problem.
I want to use the AppCompat Preference library, but the error at the beginning pops up whenever I try to add it to my build.gradle.

Body:
Apparently the problem was caused by an id in my attrs.xml:

<resources>
    <declare-styleable name="MyView">
        <attr name="min" format="float" />
    </declare-styleable>
</resources>

I fixed this error by changing min to minValue.


问:
python getattr from class method, why is it not finding the other class method?
```<code>class Dog(object):
    def __init__(self):
        self.type = 'corgi'
        self.barked = False
    def __bark(self):
        print('__woof')
        self.barked = True
    def _bark(self):
        print('_woof')
        self.barked = True
    def call_method(self, method_name):
        method = getattr(self, method_name)()
d = Dog()
d.call_method('_bark')  # this works
d.call_method('__bark')  # this raise an AttributeError
</code>```

I have a dog class where I want to use getattr to dynamically find a method under self
When I try to find the method name of a class with two underscores is fails but if I use one underscore it works.
Why is the double underscore method not seen by getattr?

答:
Double underscore methods are name mangled per here:
What is the meaning of a single- and a double-underscore before an object name?

If you need to access your methods with getattr make them have no leading underscores, or one underscore.

Body:
class Dog(object):
    def __init__(self):
        self.type = 'corgi'
        self.barked = False
    def __bark(self):
        print('__woof')
        self.barked = True
    def _bark(self):
        print('_woof')
        self.barked = True
    def call_method(self, method_name):
        method = getattr(self, method_name)()
d = Dog()
d.call_method('_bark')  # this works
d.call_method('__bark')  # this raise an AttributeError

I have a dog class where I want to use getattr to dynamically find a method under self
When I try to find the method name of a class with two underscores is fails but if I use one underscore it works.
Why is the double underscore method not seen by getattr?


问:
Usage of SUMIF in Excel
I have list of customers and their corresponding revenues in 3 services. These list of customer belongs to various regions- North, East, South, West.

In above excel, I wish to find sum total region wise. Kindly help to use SUMIF or any other useful function.

答:
In C13 and copied down and across:

```<code>=SUMIF($A$3:$A$11,$B13,C$3:C$11)
</code>```

provided in A3 and copied down:

```<code>=VLOOKUP(B3,G$3:H$11,2,0)
</code>```

Well done for showing row and column headings but I am surprised (after your 179 As) you don't seem to have realised yet how much less likely an OP is to see a good A quickly when their data sample is presented as an image only.

Title: Usage of SUMIF in Excel

Body:
In C13 and copied down and across:

=SUMIF($A$3:$A$11,$B13,C$3:C$11)

provided in A3 and copied down:

=VLOOKUP(B3,G$3:H$11,2,0)

Well done for showing row and column headings but I am surprised (after your 179 As) you don't seem to have realised yet how much less likely an OP is to see a good A quickly when their data sample is presented as an image only.


问:
CSS Style sheet is applying to all pages, but is showing different results
I am trying to get all pages to look the same and the DIVs connected.

Here is my code

```<code>footer{
height:auto;
padding:10px;
background-color:lightgray;
margin-right:auto;
margin-left:auto;
text-align:center;

}

article{
height:auto;
background-color:darkgray;
margin-right:auto;
margin-left:auto;
text-align:center;
}

h1,h2,h3,h4,h5,h6{
margin:0;
}

#wrapper{
width:80%;
margin-left:10%;
margin-right:10%;
border:2px solid black;
background-color:lightgray;
box-shadow: 10px 10px 5px #888888;
border-top-left-radius:18px;
border-top-right-radius:18px;
border-bottom-left-radius:18px;
border-bottom-right-radius:18px;
}

header{
height:140px;
background-color:lightgray;
background-image:url(logo1.png);
background-repeat:no-repeat;
background-position:20px center;
text-align:center;
border-bottom-left-radius:18px;
border-bottom-right-radius:18px;
}

nav{
height:40px;
background-color:lightgray;
margin-left:auto;
margin-right:auto;
text-align:center;
width:auto;
}
</code>```

I expect all the corners to be rounded and all margins to be the same.

The result I receive is a top corner rounded but bottom not, the margins on one page are great, but there are none on another, border not showing up on certain. I am positive the page is linked. The background colors are not following.

Here's the link to my assignment:
https://iceconescafe.000webhostapp.com/index.html

I just want to let you know I fixed a majority of the issues, but the nav table is aligning different on most pages. Some pages don't have the div styling done yet so please focus on Kids Menu and Menu, as well as Index.

The issues are the margins on kids menu, and the nav table alignments, as well as the article not changing on testimonials (background).

Here is the html code:

```<code><html>
<head>
<link rel="stylesheet" type="text/css" href="index.css">
<link rel="icon" href="logo.png" type=" image/png">
<title> IceCones</title>
</head>

<body>
<div id="wrapper">
<header>
<h1 id="t" class="l"> Ice Cones Cafe </h1>

</header>

<nav>
<table  id=navtable class="tr">
<tr>
<td class="td"><a href="index.html" class="b3">Home</a></td>
<td class="td"><a href="menu.html" class="b3">Menu</a></td>
<td class="td"><a href="kids.html" class="b3">Kids Menu</a></td>
<td class="td"><a href="nutrition.html" class="b3">Nutrition</a></td>
<td class="td"><a href="testimonials.html" class="b3">Testimonials</a></td>
<td class="td"><a href="orderonline.html" class="b3">Order Online</a></h5></td>
</tr>
</table>

</nav>
<article class="setmin">
<br>
<img src="IceConesLog.jpg" border="3">

<br>
<blockquote>
<p >

Ice Cones Cafe, established in 1880, is the best ice cream joint in town!  With desserts ranging from waffles to ice cream, Ice Cones only uses the purest  ice from Antarctica. With our wide selection of foods, and our expertise  chefs,
you will never leave unhappy.  Only when you walk through our doors  will you taste the best ice cream the world has to offer! </p>
</blockquote>
</article>

<footer>

<h4><b> Contact Information </h4>

<ul>
<li> Abdu Hijazi </li>
<li>contact_support@icecones.com</li>
<li>(313)962-7906</li> </b>

<audio autoplay loop>
  <source src="ice.mp3" type="audio/mpeg">
</footer>
</div>
</body>
</html>

Ignore this (Next page Menu)

<html>
<head>
<link rel="icon" href="IceConesfavicon.ico" type=" image/png">
<link rel="stylesheet" type="text/css" href="index.css">
<title> Menu</title>
</head>
<body>
<div id="wrapper">
<header>

<h1 id="t"> Ice Cones Cafe </h1>
</header>
<nav>
<table class="tr">
<tr>
<td class="td"><a href="index.html" class="b3">Home</a></td>
<td class="td"><a href="menu.html" class="b3">Menu</a></td>
<td class="td"><a href="kids.html" class="b3">Kids Menu</a></td>
<td class="td"><a href="nutrition.html" class="b3">Nutrition</a></td>
<td class="td"><a href="testimonials.html" class="b3">Testimonials</a></td>
<td class="td"><a href="orderonline.html" class="b3">Order Online</a></h5></td>
</tr>
</table>
</nav>

</tr>

<article>
<h2> Menu</h2>

<table>
<th colspan="3"> Menu </th>

<tr>
<th>Picture</th>
<th>Description</th>
<th>Price</th>
</tr>

<tr>
<td><img src="SnowConeMenu1.jpg"></td>
<td>The classic ice in a cup. Our Ice Cones come in flavors of lemon lime, blue berry, and cotton candy. This product is our cafe's specialty.</td>
<td>Small/$0.99 Large/$1.99</td>
</tr>

<tr>
<td><img src="IceCream.jpg"></td>

<td>Another famous classic using ice imported directly from the freshest and purest ice.
With our different flavors of chocolate, vanilla, buttermilk, and pistachio, there are various flavors to try. We also come up with new flavors weekly. </td>
<td>1 scoop/$1.50    2 scoop/$2</td>
</tr>

<tr>
<td><img src="BananaSplit.jpg"></td>
<td> The banana split features a combination of banana, whipped cream, sprinkles, and even a cherry on top. The best part however, is that
warm, melting chocolate syrup.</td>
<td>$2.99</td>

<tr>
<td><img src="OreoShake.jpg"></td>
<td> The classic American favorite of Oreo cookies mixed with milk. A tasty, chunky, cold recipe that your taste buds won't soon forget.</td>
<td>$2.50</td>
</tr>

</table>
</article>
<footer>
<h4> Contact Information </h4>

<ul>
<li> Abdu Hijazi </li>
<li>contact_support@icecones.com</li>
<li>(313)962-7906</li> </b>
</footer>
</div>
</body>
</html>

Kids Menu

<html>
<head>
<title> KidsMenu</title>
<link rel="icon" href="IceConesfavicon.ico" type=" image/png">
<link rel="stylesheet" type="text/css" href="index.css">
</head>

<body>
<header>
<h1 id="t"> Ice Cones Cafe </h1>
</header>

<nav>
<table class="tr">
<tr>
<td class="td"><a href="index.html" class="b3">Home</a></td>
<td class="td"><a href="menu.html" class="b3">Menu</a></td>
<td class="td"><a href="kids.html" class="b3">Kids Menu</a></td>
<td class="td"><a href="nutrition.html" class="b3">Nutrition</a></td>
<td class="td"><a href="testimonials.html" class="b3">Testimonials</a></td>
<td class="td"><a href="orderonline.html" class="b3">Order Online</a></h5></td>
</tr>
</table>

</nav>
<article>

<h2>Kids Menu</h2>

<table>
<th colspan="3"> Kid's Menu </th>

<tr >
<th>Picture</th>
<th>Description</th>
<th>Price</th>
</tr>

<tr>
<td><img src="MiniWaffle.png"></td>
<td> Our chef specially makes these in sizes of 1/3 regular waffles. A great meal for you kid in the morning, or anytime.</td>
<td>$4.59</td>
</tr>

<tr>
<td><img src="SmoresKids.jpg"></td>

<td> These smores are a small, but tasty item for your kids. Includes chocolate syrup, marshmallows, graham crackers, and whipped cream. </td>
<td>$3.99 <br> with whip/$4.50</td>
</tr>

<tr>
<td><img src="FrozenHotChoco.jpg"></td>
<td> Although you're probably thinking warm at a ice cream place is crazy, we have added a frozen aspect to hot chocolate for your kids. They will love
the whipped cream and added syrup.</td>
<td>$3.50</td>

<tr>
<td><img src="KidsCrepe.jpg"></td>
<td> A small, warm crepe filled with whatever your child desires. Banana, Nutella, and strawberry are all viable options, along with
syrups and creams on top.</td>
<td>$4.99</td>
</tr>
<br>
</table>

<h1>Kiddie Activity</h1>
<br>
<img src="Danykmem84.png">
</article>
<footer>
<br>
<br>
<h4> Contact Information </h4>

<ul>
<li> Abdu Hijazi </li>
<li>contact_support@icecones.com</li>
<li>(313)962-7906</li> </b>
</ul>
</footer>
</div>

</body>
</html>

lastly, testimonials
<html>
<head>
<link rel="icon" href="IceConesfavicon.ico" type=" image/png">
<link rel="stylesheet" type="text/css" href="index.css">
<title> IceCones</title>
</head>
<body>
<div id="wrapper">

<div id="header">
<h1 id="t"> Ice Cones Cafe </h1>
</div>
<div id="nav">
<table class="tr">
<tr>
<td class="td"><a href="index.html" class="b3">Home</a></td>
<td class="td"><a href="menu.html" class="b3">Menu</a></td>
<td class="td"><a href="kids.html" class="b3">Kids Menu</a></td>
<td class="td"><a href="nutrition.html" class="b3">Nutrition</a></td>
<td class="td"><a href="testimonials.html" class="b3">Testimonials</a></td>
<td class="td"><a href="orderonline.html" class="b3">Order Online</a></h5></td>
</tr>
</table>
</div>
<div id="article">
<h2>Testimonials</h2>

<p> Below are some testimonials from our CEO and a trusted customer:</p>

<p> Testimonial~CEO Abdu Hijazi</p>

<video controls>
<source src="Test1.mp4" type="video/mp4">
</video>

<p> Testimonial~Satisfied Customer Sara Hijazi</p>

<video controls>
<source src="Test2.mp4" type="video/mp4">
</video>
</div>
<div id="footer">
<h4>Contact Information </h4>

<ul>
<li> Abdu Hijazi </li>
<li>contact_support@icecones.com</li>
<li>(313)962-7906</li>
</div>
</div>
</body>
</html>
</code>```

答:
Clear your Internet Browser history and Cache from beginning of time, then test your web pages. If it doesn't work, check the 'class' and 'id' of CSS is given in proper way. Here you are not using class. To use class:

Example:

In CSS:

```<code>.nav{ }
</code>```

In html:

```<code><div class="nav"></div>
</code>```

Body:
I am trying to get all pages to look the same and the DIVs connected.

Here is my code

footer{
height:auto;
padding:10px;
background-color:lightgray;
margin-right:auto;
margin-left:auto;
text-align:center;

}

article{
height:auto;
background-color:darkgray;
margin-right:auto;
margin-left:auto;
text-align:center;
}

h1,h2,h3,h4,h5,h6{
margin:0;
}

#wrapper{
width:80%;
margin-left:10%;
margin-right:10%;
border:2px solid black;
background-color:lightgray;
box-shadow: 10px 10px 5px #888888;
border-top-left-radius:18px;
border-top-right-radius:18px;
border-bottom-left-radius:18px;
border-bottom-right-radius:18px;
}

header{
height:140px;
background-color:lightgray;
background-image:url(logo1.png);
background-repeat:no-repeat;
background-position:20px center;
text-align:center;
border-bottom-left-radius:18px;
border-bottom-right-radius:18px;
}

nav{
height:40px;
background-color:lightgray;
margin-left:auto;
margin-right:auto;
text-align:center;
width:auto;
}

I expect all the corners to be rounded and all margins to be the same.

The result I receive is a top corner rounded but bottom not, the margins on one page are great, but there are none on another, border not showing up on certain. I am positive the page is linked. The background colors are not following.

Here's the link to my assignment:
https://iceconescafe.000webhostapp.com/index.html

I just want to let you know I fixed a majority of the issues, but the nav table is aligning different on most pages. Some pages don't have the div styling done yet so please focus on Kids Menu and Menu, as well as Index.

The issues are the margins on kids menu, and the nav table alignments, as well as the article not changing on testimonials (background).

Here is the html code:

<link rel="stylesheet" type="text/css" href="index.css">
<link rel="icon" href="logo.png" type=" image/png">
<title> IceCones</title>

 Ice Cones Cafe

Home
Menu
Kids Menu
Nutrition
Testimonials
Order Online

Ice Cones Cafe, established in 1880, is the best ice cream joint in town!  With desserts ranging from waffles to ice cream, Ice Cones only uses the purest  ice from Antarctica. With our wide selection of foods, and our expertise  chefs,
you will never leave unhappy.  Only when you walk through our doors  will you taste the best ice cream the world has to offer!

 Contact Information

 Abdu Hijazi

contact_support@icecones.com

(313)962-7906

<audio autoplay loop>
  <source src="ice.mp3" type="audio/mpeg">

Ignore this (Next page Menu)

<link rel="icon" href="IceConesfavicon.ico" type=" image/png">
<link rel="stylesheet" type="text/css" href="index.css">
<title> Menu</title>

 Ice Cones Cafe

Home
Menu
Kids Menu
Nutrition
Testimonials
Order Online

 Menu

 Menu

Picture
Description
Price

The classic ice in a cup. Our Ice Cones come in flavors of lemon lime, blue berry, and cotton candy. This product is our cafe's specialty.
Small/$0.99 Large/$1.99

Another famous classic using ice imported directly from the freshest and purest ice.
With our different flavors of chocolate, vanilla, buttermilk, and pistachio, there are various flavors to try. We also come up with new flavors weekly.
1 scoop/$1.50    2 scoop/$2

 The banana split features a combination of banana, whipped cream, sprinkles, and even a cherry on top. The best part however, is that
warm, melting chocolate syrup.
$2.99

 The classic American favorite of Oreo cookies mixed with milk. A tasty, chunky, cold recipe that your taste buds won't soon forget.
$2.50

 Contact Information

 Abdu Hijazi

contact_support@icecones.com

(313)962-7906

Kids Menu

<title> KidsMenu</title>
<link rel="icon" href="IceConesfavicon.ico" type=" image/png">
<link rel="stylesheet" type="text/css" href="index.css">

 Ice Cones Cafe

Home
Menu
Kids Menu
Nutrition
Testimonials
Order Online

Kids Menu

 Kid's Menu

Picture
Description
Price

 Our chef specially makes these in sizes of 1/3 regular waffles. A great meal for you kid in the morning, or anytime.
$4.59

 These smores are a small, but tasty item for your kids. Includes chocolate syrup, marshmallows, graham crackers, and whipped cream.
$3.99
 with whip/$4.50

 Although you're probably thinking warm at a ice cream place is crazy, we have added a frozen aspect to hot chocolate for your kids. They will love
the whipped cream and added syrup.
$3.50

 A small, warm crepe filled with whatever your child desires. Banana, Nutella, and strawberry are all viable options, along with
syrups and creams on top.
$4.99

Kiddie Activity

 Contact Information

 Abdu Hijazi

contact_support@icecones.com

(313)962-7906

lastly, testimonials

<link rel="icon" href="IceConesfavicon.ico" type=" image/png">
<link rel="stylesheet" type="text/css" href="index.css">
<title> IceCones</title>

 Ice Cones Cafe

Home
Menu
Kids Menu
Nutrition
Testimonials
Order Online

Testimonials

 Below are some testimonials from our CEO and a trusted customer:

 Testimonial~CEO Abdu Hijazi

<video controls>
<source src="Test1.mp4" type="video/mp4">
</video>

 Testimonial~Satisfied Customer Sara Hijazi

<video controls>
<source src="Test2.mp4" type="video/mp4">
</video>

Contact Information

 Abdu Hijazi

contact_support@icecones.com

(313)962-7906

Body:
Clear your Internet Browser history and Cache from beginning of time, then test your web pages. If it doesn't work, check the 'class' and 'id' of CSS is given in proper way. Here you are not using class. To use class:

Example:

In CSS:

.nav{ }

In html:

<div class="nav"></div>


问:
XmlSerializer - same element with different attribute
I have xml containing:

```<code><day p="d">
<day p="n">
</code>```

What attributes do I need to add to Day class in order to deserialize the xml with XmlSerializer?

答:
The following decorations -

```<code>[XmlType(TypeName="day")]
public class Day
{
    [XmlAttribute("p")]
    public string P { get; set; }
}

[XmlRoot("someObject")]
public class SomeObject
{
    [XmlArray("days")]
    public List<Day> Days { get; set; }
}
</code>```

Would serialise to:

```<code><someObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <days>
    <day p="n" />
    <day p="p" />
  </days>
</someObject>
</code>```

Hope that gets you somewhere.

Kev

OwnerDisplayName: James

LastEditorDisplayName: Kev

ContentLicense: CC BY-SA 4.0

Body:
I have xml containing:

<day p="d">
<day p="n">

What attributes do I need to add to Day class in order to deserialize the xml with XmlSerializer?

Body:
The following decorations -

[XmlType(TypeName="day")]
public class Day
{
    [XmlAttribute("p")]
    public string P { get; set; }
}

[XmlRoot("someObject")]
public class SomeObject
{
    [XmlArray("days")]
    public List<Day> Days { get; set; }
}

Would serialise to:

<someObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <days>
    <day p="n" />
    <day p="p" />
  </days>
</someObject>

Hope that gets you somewhere.

Kev

OwnerDisplayName: Kev


问:
gnuplot: Plotting X,Y coordinates and their label
I have the following file (test.dat):

```<code>A   149 127
B   19  157
C   49  127
D   149 147
E   9   127
F   49  12
G   129 127
</code>```

I would like gnuplot to plot these points with their label (a dot a position (149, 127), another dot at (19, 157), etc.). How can I do this?

Thanks!

答:
Something along the lines of this should help

gnuplot> plot "data.txt" using ($2+3):($3+3):1 with labels, "data.txt" using 2:3

Body:
I have the following file (test.dat):

A   149 127
B   19  157
C   49  127
D   149 147
E   9   127
F   49  12
G   129 127

I would like gnuplot to plot these points with their label (a dot a position (149, 127), another dot at (19, 157), etc.). How can I do this?

Thanks!