问:
formatting text in footer (text under icons)
I need help formatting the footer for my website. I am new to CSS and I cannot figure out how to get the text for the Copyright to sit underneath of the icons. I tried tweaking by altering the height of the footer and the best I can get is the text to the left or right of the icons. Any help would be appreciated.

CSS Style Sheet:

```<code>body {
    margin: 0;
}

.logo {
    display: block;
    margin-left: auto;
    margin-right: auto;
    width: 50px;
    height: 50px;
    margin-top: 11px;
}

.navBar {
    display: flex;
    justify-content: center;
    overflow: hidden;
    background-color: white;
    position: fixed;
    top: 0;
    width: 100%;
    margin-top: 61px;
    text-align: center;
}

.navBar a {
    display: inline-block;
    width: 10%;
    color: black;
    text-align: center;
    padding: 7px 7px;
    text-decoration: none;
    font-size: 17px;
    font-family: "Poppins";
}

body.services a.services,
body.ourstory a.ourstory {
    border-bottom: 1.5px solid black;
}

.header {
    position: fixed;
    background-color: white;
    width: 100%;
    height: 80px;
}

.p3 {
    color: black;
    text-align: center;
    font-family: 'Poppins';
    font-size: 105%;
    font-weight: 300;
    line-height: 1.8em;
}
.p4 {
    color: black;
    text-align: center;
    padding-left: 200px;
    font-family: 'Poppins';
    font-size: 100%;
    font-weight: 300;
    line-height: 1.8em;
}
</code>```

HTML Document:

.content {
  padding: 10.4%;
}

.main {
  height: 800px;
  background-color: #f9f9f9;
}

.copyright {
  color: black;
  text-align: center;
  font-family: 'Poppins';
  font-size: 70%;
  font-weight: 300;
  line-height: 1.8em;
  display: block;
  margin-bottom: 100px;
}

.navbarSocialMedia {
  display: flex;
  justify-content: center;
  overflow: hidden;
  background-color: white;
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
}

.newFooter {
  position: fixed;
  background-color: white;
  width: 100%;
  height: 800px;
}

.navbarSocialMedia a {
  display: inline-block;
  width: 3.5%;
  color: black;
  text-align: center;
  padding: 5px 5px;
  text-decoration: none;
  font-size: 17px;
  font-family: "Poppins";
}

.mediaLogo {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 21px;
  height: 21px;
  margin-top: 10px;
  margin-bottom: 10px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en-US">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<head>

<title>Giving Back</title>

    <link href="simpleCSS.css" rel="stylesheet" type="text/css">
    <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
    <link rel="shortcut icon" type="image/png" href="name.png">

    </head>

    <body class="services">

    <div class="header">

            <img src="name.png" alt="Logo" class="logo">

        <div class="navBar">
            Our Story
            Giving Back
        </div>

    </div>

    <br>
    <br>
    <br>

    <div class="main">
        <div class="content">

            <p class="p3"> content

            </p>
        </div>
    </div>

    <div class="newFooter">
        <div class="navbarSocialMedia">

                <img src="InstagramLogo48.png " alt="email logo" class="mediaLogo">

                <img src="linkedin48.png " alt="linked in logo" class="mediaLogo">

                <img src="emaillogo48.png " alt="email logo" class="mediaLogo">

                <img src="facebooklogo48.png " alt="facebook logo" class="mediaLogo">
        </div>

        <div class="try">
            <p class=" copyright ">Copyright &copy. </p>
    </div>
    </div>
    </body>
    </html></code>```

答:
Code change on .copyright and .navbarSocialMedia CSS. Mainly to change the position on .copyright and align the bottom of .navbarSocialMedia.

.content {
  padding: 10.4%;
}

.main {
  height: 800px;
  background-color: #f9f9f9;
}

.copyright {
  color: black;
  text-align: center;
  font-family: 'Poppins';
  font-size: 70%;
  font-weight: 300;
  line-height: 1.8em;
  /* display: block;*/
  /* Add fixed position */
  position: fixed;
  bottom: 0;
  left: 50%;
  /* margin-bottom: 100px; */
}

.navbarSocialMedia {
  display: flex;
  justify-content: center;
  overflow: hidden;
  background-color: white;
  position: fixed;
  bottom: 2.5em; /* Change to 2.5em for the copyright space */
  width: 100%;
  text-align: center;
}

.newFooter {
  position: fixed;
  background-color: white;
  width: 100%;
  height: 800px;
}

.navbarSocialMedia a {
  display: inline-block;
  width: 3.5%;
  color: black;
  text-align: center;
  padding: 5px 5px;
  text-decoration: none;
  font-size: 17px;
  font-family: "Poppins";
}

.mediaLogo {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 21px;
  height: 21px;
  margin-top: 10px;
  margin-bottom: 10px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en-US">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<head>

  <title>Giving Back</title>

  <link href="simpleCSS.css" rel="stylesheet" type="text/css">
  <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
  <link rel="shortcut icon" type="image/png" href="name.png">

</head>

<body class="services">

  <div class="header">

      <img src="name.png" alt="Logo" class="logo">

    <div class="navBar">
      Our Story
      Giving Back
    </div>

  </div>

  <br>
  <br>
  <br>

  <div class="main">
    <div class="content">

      <p class="p3"> content

      </p>
    </div>
  </div>

  <div class="newFooter">

    <div class="navbarSocialMedia">

        <img src="InstagramLogo48.png " alt="email logo" class="mediaLogo">

        <img src="linkedin48.png " alt="linked in logo" class="mediaLogo">

        <img src="emaillogo48.png " alt="email logo" class="mediaLogo">

        <img src="facebooklogo48.png " alt="facebook logo" class="mediaLogo">
    </div>

    <div class="try">
      <p class=" copyright ">Copyright &copy. </p>
    </div>
  </div>
</body>

</html></code>```

Body:
I need help formatting the footer for my website. I am new to CSS and I cannot figure out how to get the text for the Copyright to sit underneath of the icons. I tried tweaking by altering the height of the footer and the best I can get is the text to the left or right of the icons. Any help would be appreciated.

CSS Style Sheet:

body {
    margin: 0;
}

.logo {
    display: block;
    margin-left: auto;
    margin-right: auto;
    width: 50px;
    height: 50px;
    margin-top: 11px;
}

.navBar {
    display: flex;
    justify-content: center;
    overflow: hidden;
    background-color: white;
    position: fixed;
    top: 0;
    width: 100%;
    margin-top: 61px;
    text-align: center;
}

.navBar a {
    display: inline-block;
    width: 10%;
    color: black;
    text-align: center;
    padding: 7px 7px;
    text-decoration: none;
    font-size: 17px;
    font-family: "Poppins";
}

body.services a.services,
body.ourstory a.ourstory {
    border-bottom: 1.5px solid black;
}

.header {
    position: fixed;
    background-color: white;
    width: 100%;
    height: 80px;
}

.p3 {
    color: black;
    text-align: center;
    font-family: 'Poppins';
    font-size: 105%;
    font-weight: 300;
    line-height: 1.8em;
}
.p4 {
    color: black;
    text-align: center;
    padding-left: 200px;
    font-family: 'Poppins';
    font-size: 100%;
    font-weight: 300;
    line-height: 1.8em;
}

HTML Document:

.content {
  padding: 10.4%;
}

.main {
  height: 800px;
  background-color: #f9f9f9;
}

.copyright {
  color: black;
  text-align: center;
  font-family: 'Poppins';
  font-size: 70%;
  font-weight: 300;
  line-height: 1.8em;
  display: block;
  margin-bottom: 100px;
}

.navbarSocialMedia {
  display: flex;
  justify-content: center;
  overflow: hidden;
  background-color: white;
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
}

.newFooter {
  position: fixed;
  background-color: white;
  width: 100%;
  height: 800px;
}

.navbarSocialMedia a {
  display: inline-block;
  width: 3.5%;
  color: black;
  text-align: center;
  padding: 5px 5px;
  text-decoration: none;
  font-size: 17px;
  font-family: "Poppins";
}

.mediaLogo {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 21px;
  height: 21px;
  margin-top: 10px;
  margin-bottom: 10px;
}

<!DOCTYPE html>

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Giving Back</title>

    <link href="simpleCSS.css" rel="stylesheet" type="text/css">
    <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
    <link rel="shortcut icon" type="image/png" href="name.png">

            Our Story
            Giving Back

 content

Copyright &copy.

Body:
Code change on .copyright and .navbarSocialMedia CSS. Mainly to change the position on .copyright and align the bottom of .navbarSocialMedia.

.content {
  padding: 10.4%;
}

.main {
  height: 800px;
  background-color: #f9f9f9;
}

.copyright {
  color: black;
  text-align: center;
  font-family: 'Poppins';
  font-size: 70%;
  font-weight: 300;
  line-height: 1.8em;
  /* display: block;*/
  /* Add fixed position */
  position: fixed;
  bottom: 0;
  left: 50%;
  /* margin-bottom: 100px; */
}

.navbarSocialMedia {
  display: flex;
  justify-content: center;
  overflow: hidden;
  background-color: white;
  position: fixed;
  bottom: 2.5em; /* Change to 2.5em for the copyright space */
  width: 100%;
  text-align: center;
}

.newFooter {
  position: fixed;
  background-color: white;
  width: 100%;
  height: 800px;
}

.navbarSocialMedia a {
  display: inline-block;
  width: 3.5%;
  color: black;
  text-align: center;
  padding: 5px 5px;
  text-decoration: none;
  font-size: 17px;
  font-family: "Poppins";
}

.mediaLogo {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 21px;
  height: 21px;
  margin-top: 10px;
  margin-bottom: 10px;
}

<!DOCTYPE html>
<html lang="en-US">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<head>

  <title>Giving Back</title>

  <link href="simpleCSS.css" rel="stylesheet" type="text/css">
  <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
  <link rel="shortcut icon" type="image/png" href="name.png">

</head>

<body class="services">

  <div class="header">

    <a href="simple.html">
      <img src="name.png" alt="Logo" class="logo"> </a>

    <div class="navBar">
      <a href="ourstory.html" class="ourstory">Our Story</a>
      <a href="services.html" class="services">Giving Back</a>
    </div>

  </div>

  <br>
  <br>
  <br>

  <div class="main">
    <div class="content">

      <p class="p3"> content

      </p>
    </div>
  </div>

  <div class="newFooter">

    <div class="navbarSocialMedia">
      <a href="https://www.instagram.com/" target="_blank">
        <img src="InstagramLogo48.png " alt="email logo" class="mediaLogo"> </a>
      <a href="https://www.linkedin.com" target="_blank">
        <img src="linkedin48.png " alt="linked in logo" class="mediaLogo"> </a>
      <a href="//www.google.com" target="_blank">
        <img src="emaillogo48.png " alt="email logo" class="mediaLogo"> </a>
      <a href="https://www.facebook.com " target="_blank">
        <img src="facebooklogo48.png " alt="facebook logo" class="mediaLogo"> </a>
    </div>

    <div class="try">
      <p class=" copyright ">Copyright &copy. </p>
    </div>
  </div>
</body>

</html>


来源: stackexchange

问:
logging the windows shutdown sequence operations
we're working on a hardware platform that freezes during windows shutdown.

I'd like to be able to log what's happening (e.g. to identify if there's a problem with ACPI, or a windows driver etc).

What tools can I use to log the windows shutdown sequence?

答:
You might get some mileage out of VerboseStatus and DisableStatusMessages registry values:

http://support.microsoft.com/kb/325376

Which version of Windows are you testing?

ContentLicense: CC BY-SA 3.0


问:
Flutter : How to align TextField with other widgets in row
I have a row with a Text () and a TextField ()
But they don't seem to align
I'm an Android Developer and my past experience seems to have no effect.
Do you have any suggestions for Android developers in terms of alignment skills?

```<code>  SizedBox(
                          height:44,
                          child:
                          Row(crossAxisAlignment: CrossAxisAlignment.center,
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: <Widget>[
                            Text("+60",
                              textAlign: TextAlign.start,
                              style: TextStyle(fontSize: 15,
                            color: Colors.white
                            ),),
                            Container(margin:EdgeInsets.fromLTRB(15,0,15,0)
                            ,width: 1,height: 12,color: Color(0x33FFFFFF),),
                              Expanded(//TextField
                                child: TextField(
                                  textAlign: TextAlign.start,
                                  keyboardType: TextInputType.number,
                                  cursorColor: Color(0x66FFFFFF),
                                  style: TextStyle(
                                      color: Colors.white,
                                      fontSize:15
                                  ),
                                  inputFormatters: [
                                    WhitelistingTextInputFormatter
                                        .digitsOnly,
                                    LengthLimitingTextInputFormatter(10)
                                  ],
                                  decoration: InputDecoration(
                                      hintText: 'Phone number',
                                      hintStyle: TextStyle(
                                          color: Color(0x66FFFFFF),
                                          fontSize: 15
                                      ),
                                      border: InputBorder.none
                                  ),
                                ),
                              )
                                ,
                          ],)
                        )
</code>```

答: the SizedBox height property is controlling the Row constraint thus it's not allowing it to align it's childern freely, just remove the SizedBox widget and everything will work fine.

ContentLicense: CC BY-SA 4.0

Body:
I have a row with a Text () and a TextField ()
But they don't seem to align
I'm an Android Developer and my past experience seems to have no effect.
Do you have any suggestions for Android developers in terms of alignment skills?

  SizedBox(
                          height:44,
                          child:
                          Row(crossAxisAlignment: CrossAxisAlignment.center,
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: <Widget>[
                            Text("+60",
                              textAlign: TextAlign.start,
                              style: TextStyle(fontSize: 15,
                            color: Colors.white
                            ),),
                            Container(margin:EdgeInsets.fromLTRB(15,0,15,0)
                            ,width: 1,height: 12,color: Color(0x33FFFFFF),),
                              Expanded(//TextField
                                child: TextField(
                                  textAlign: TextAlign.start,
                                  keyboardType: TextInputType.number,
                                  cursorColor: Color(0x66FFFFFF),
                                  style: TextStyle(
                                      color: Colors.white,
                                      fontSize:15
                                  ),
                                  inputFormatters: [
                                    WhitelistingTextInputFormatter
                                        .digitsOnly,
                                    LengthLimitingTextInputFormatter(10)
                                  ],
                                  decoration: InputDecoration(
                                      hintText: 'Phone number',
                                      hintStyle: TextStyle(
                                          color: Color(0x66FFFFFF),
                                          fontSize: 15
                                      ),
                                      border: InputBorder.none
                                  ),
                                ),
                              )
                                ,
                          ],)
                        )


问:
How can I get my Android device country code without using GPS?
An Android mobile actually does know quite well where it is - but is there a way of retrieving the country by something, like a country code or country name?

There isn't any need to know the exact GPS position - the country code or name is sufficient, and I am using this code:

```<code> String locale = context.getResources().getConfiguration().locale.getCountry(Locale.getDefault());
 System.out.println("country = "+locale);
</code>```

It gives me the code "US", but my device kept in India. Is there a way to find the device's current country code without using GPS or a network provider?

Because I am using a tablet.

答:
If you wish to get the country code without asking for any permission, you can choose a tricky way.

The method simply uses an API to get the country code, and there aren't any third-party libraries to depend on. We can create one for us.

Here I have used Google Cloud Functions to write an API and it is so effortless.

Step 1: Create a Google Cloud Account, and set up billing (the free tier is enough)

Step 2: Create a cloud function to get the geo location

Copy this basic function to the code editor of index.js:

```<code>const cors = require('cors')

function _geolocation(req, res) {
  const data = {
    country_code: req.headers["x-appengine-country"],
    region: req.headers["x-appengine-region"],
    city: req.headers["x-appengine-city"],
    cityLatLong: req.headers["x-appengine-citylatlong"],
    userIP: req.headers["x-appengine-user-ip"]
  }

  res.json(data)
};

exports.geolocation = (req, res) => {
  const corsHandler = cors({ origin: true })

  return corsHandler(req, res, function() {
    return _geolocation(req, res);
  });
};
</code>```

Also we need to copy the package.json definition:

```<code>{
  "name": "gfc-geolocation",
  "version": "0.0.1",
  "dependencies": {
    "cors": "^2.8.4"
  }
}
</code>```

Step 3: finish, and get the URL similar to: "https://us-central1-geolocation-mods-sdde.cloudfunctions.net/geolocation"

Step 4: parse the JSON response and get the country code

The response will look like:

```<code>{
   "country": "IN",
   "region": "kl",
   "city": "kochi",
   "cityLatLong": "9.9312,76.2673",
   "userIP": "xx.xx.xx.xx"
}
</code>```

Thanks and credits go to the Medium article: Free IP-based Geolocation with Google Cloud Functions

Body:
An Android mobile actually does know quite well where it is - but is there a way of retrieving the country by something, like a country code or country name?

There isn't any need to know the exact GPS position - the country code or name is sufficient, and I am using this code:

 String locale = context.getResources().getConfiguration().locale.getCountry(Locale.getDefault());
 System.out.println("country = "+locale);

It gives me the code "US", but my device kept in India. Is there a way to find the device's current country code without using GPS or a network provider?

Because I am using a tablet.

Body:
If you wish to get the country code without asking for any permission, you can choose a tricky way.

The method simply uses an API to get the country code, and there aren't any third-party libraries to depend on. We can create one for us.

Here I have used Google Cloud Functions to write an API and it is so effortless.

Step 1: Create a Google Cloud Account, and set up billing (the free tier is enough)

Step 2: Create a cloud function to get the geo location

Copy this basic function to the code editor of index.js:

const cors = require('cors')

function _geolocation(req, res) {
  const data = {
    country_code: req.headers["x-appengine-country"],
    region: req.headers["x-appengine-region"],
    city: req.headers["x-appengine-city"],
    cityLatLong: req.headers["x-appengine-citylatlong"],
    userIP: req.headers["x-appengine-user-ip"]
  }

  res.json(data)
};

exports.geolocation = (req, res) => {
  const corsHandler = cors({ origin: true })

  return corsHandler(req, res, function() {
    return _geolocation(req, res);
  });
};

Also we need to copy the package.json definition:

{
  "name": "gfc-geolocation",
  "version": "0.0.1",
  "dependencies": {
    "cors": "^2.8.4"
  }
}

Step 3: finish, and get the URL similar to: "https://us-central1-geolocation-mods-sdde.cloudfunctions.net/geolocation"

Step 4: parse the JSON response and get the country code

The response will look like:

{
   "country": "IN",
   "region": "kl",
   "city": "kochi",
   "cityLatLong": "9.9312,76.2673",
   "userIP": "xx.xx.xx.xx"
}

Thanks and credits go to the Medium article: Free IP-based Geolocation with Google Cloud Functions


问:
Random non overlapping circles(with circle number controlled) in python and pygame
I was writing the code for non overlapping random circles with different radii.I kind of got the deserved, but my 'if' statement that checks overlap or non overlap excludes a number of circles. So, I get lesser number of circles. Here's the code: </p>

```<code>import pygame
import numpy as np

pygame.init()
display_width = 800
display_height = 500

black = [0, 0, 0]
white = [255, 255, 255]
red = [255, 0, 0]

display_surface = pygame.display.set_mode((display_width, display_height))
clock = pygame.time.Clock()
pygame.display.set_caption("Random Circle")

def circle(x, y, r):
    pygame.draw.circle(display_surface, red, (int(x), int(y)), int(r), 2)

def distance(x1, y1, x2, y2):
    dsq = (x1 - x2) ** 2 + (y1 - y2) ** 2
    d = np.sqrt(dsq)
    return d

n = 100

r = np.random.randint(10, 20, size=n)
x = np.random.randint(r, display_width - r, size=n)
y = np.random.randint(r, display_height - r, size=n)

display_surface.fill(black)

for i in range(len(r)):
    valid = True
    for j in range(len(r)):
        if i != j:
            d = distance(x[i], y[i], x[j], y[j])
            if d < r[i] + r[j]:
                valid = False

    if valid:

        circle(x[i], y[i], r[i])

    pygame.display.update()
    clock.tick(100)

exit = False
while not exit:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            quit()
</code>```

<p>I saw an answer to a  question here which does exactly what this code does( except it uses a class of circles which I didn't use).
I sense that I have to use some kind of while loop which doesn't end until I get my desired number o circles. But I find difficulty in actually writing the code. Can anyone help? </p>

答:
Create a list of circles Each circle is a tuple with 3 components, the x and y coordinate and the radius. Append new circles as long the length of the list is less than n:

circle_list = []
while len(circle_list) < n:
    # [...]
```
<p>Create a random position and radius:</p>
<pre class="lang-py prettyprint-override"><code>r = random.randint(10, 20)
x = random.randint(r, display_width - r)
y = random.randint(r, display_height - r)
</code>```

Evaluate if the circle intersects with a other circle wich is in the list:

collide = False
for x2, y2, r2 in circle_list:
    d = distance(x, y, x2, y2)
    if d < r + r2:
        collide = True
        break
```
<p>Append the circle if it does not collide:</p>
<pre class="lang-py prettyprint-override"><code>if not collide:
    circle_list.append((x, y, r))
</code>```

Minimal example:

import random
import math
import pygame

def euclidean_distance(x1, y1, x2, y2):
    #return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
    return math.hypot((x1 - x2), (y1 - y2))

pygame.init()
window = pygame.display.set_mode((400, 400))
font50 = pygame.font.SysFont(None, 50)
clock = pygame.time.Clock()

pygame.time.delay(10000)

run = True
circle_list = []
while run:
    clock.tick(100)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False

    r = random.randint(10, 20)
    x = random.randint(10+r, window.get_width()- r-10)
    y = random.randint(10+r, window.get_height()-r-10)
    if not any((x2, y2, r2) for x2, y2, r2 in circle_list if euclidean_distance(x, y, x2, y2) < r + r2):
        circle_list.append((x, y, r))

    window.fill((255, 255, 255))
    for x, y, r in circle_list:
        pygame.draw.circle(window, (0, 0, 0), (round(x), round(y)), int(r), 3)
    window.blit(font50.render(str(len(circle_list)), True, (255, 0, 0)), (10, 10))
    pygame.display.flip()

pygame.quit()
exit()
```

Body:
I was writing the code for non overlapping random circles with different radii.I kind of got the deserved, but my 'if' statement that checks overlap or non overlap excludes a number of circles. So, I get lesser number of circles. Here's the code:

import pygame
import numpy as np

pygame.init()
display_width = 800
display_height = 500

black = [0, 0, 0]
white = [255, 255, 255]
red = [255, 0, 0]

display_surface = pygame.display.set_mode((display_width, display_height))
clock = pygame.time.Clock()
pygame.display.set_caption("Random Circle")

def circle(x, y, r):
    pygame.draw.circle(display_surface, red, (int(x), int(y)), int(r), 2)

def distance(x1, y1, x2, y2):
    dsq = (x1 - x2) ** 2 + (y1 - y2) ** 2
    d = np.sqrt(dsq)
    return d

n = 100

r = np.random.randint(10, 20, size=n)
x = np.random.randint(r, display_width - r, size=n)
y = np.random.randint(r, display_height - r, size=n)

display_surface.fill(black)

for i in range(len(r)):
    valid = True
    for j in range(len(r)):
        if i != j:
            d = distance(x[i], y[i], x[j], y[j])
            if d < r[i] + r[j]:
                valid = False

    if valid:

        circle(x[i], y[i], r[i])

    pygame.display.update()
    clock.tick(100)

exit = False
while not exit:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            quit()

I saw an answer to a  question here which does exactly what this code does( except it uses a class of circles which I didn't use).
I sense that I have to use some kind of while loop which doesn't end until I get my desired number o circles. But I find difficulty in actually writing the code. Can anyone help?

Body:
Create a list of circles Each circle is a tuple with 3 components, the x and y coordinate and the radius. Append new circles as long the length of the list is less than n:

circle_list = []
while len(circle_list) < n:
    # [...]

Create a random position and radius:

r = random.randint(10, 20)
x = random.randint(r, display_width - r)
y = random.randint(r, display_height - r)

Evaluate if the circle intersects with a other circle wich is in the list:

collide = False
for x2, y2, r2 in circle_list:
    d = distance(x, y, x2, y2)
    if d < r + r2:
        collide = True
        break

Append the circle if it does not collide:

if not collide:
    circle_list.append((x, y, r))

Minimal example:

import random
import math
import pygame

def euclidean_distance(x1, y1, x2, y2):
    #return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
    return math.hypot((x1 - x2), (y1 - y2))

pygame.init()
window = pygame.display.set_mode((400, 400))
font50 = pygame.font.SysFont(None, 50)
clock = pygame.time.Clock()

pygame.time.delay(10000)

run = True
circle_list = []
while run:
    clock.tick(100)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False

    r = random.randint(10, 20)
    x = random.randint(10+r, window.get_width()- r-10)
    y = random.randint(10+r, window.get_height()-r-10)
    if not any((x2, y2, r2) for x2, y2, r2 in circle_list if euclidean_distance(x, y, x2, y2) < r + r2):
        circle_list.append((x, y, r))

    window.fill((255, 255, 255))
    for x, y, r in circle_list:
        pygame.draw.circle(window, (0, 0, 0), (round(x), round(y)), int(r), 3)
    window.blit(font50.render(str(len(circle_list)), True, (255, 0, 0)), (10, 10))
    pygame.display.flip()

pygame.quit()
exit()


问:
Memory barriers on entry and exit of Java synchronized block
I came across answers, here on SO, about Java flushing the work copy of variables within a synchronized block during exit. Similarly it syncs all the variable from main memory once during the entry into the synchronized section.

However, I have some fundamental questions around this:

What if I access mostly non-volatile instance variables inside my synchronized section? Will the JVM automatically cache those variables into the CPU registers at the time of entering into the block and then carry all the necessary computations before finally flushing them back?

I have a synchronized block as below:
The underscored variables _ e.g. _callStartsInLastSecondTracker are all instance variables which I heavily access in this critical section.

```<code>public CallCompletion startCall()
{
  long currentTime;
  Pending pending;
  synchronized (_lock)
  {
    currentTime = _clock.currentTimeMillis();
    _tracker.getStatsWithCurrentTime(currentTime);
    _callStartCountTotal++;
    _tracker._callStartCount++;
    if (_callStartsInLastSecondTracker != null)
      _callStartsInLastSecondTracker.addCall();
    _concurrency++;
    if (_concurrency > _tracker._concurrentMax)
    {
      _tracker._concurrentMax = _concurrency;
    }
    _lastStartTime = currentTime;
    _sumOfOutstandingStartTimes += currentTime;
    pending = checkForPending();
  }
  if (pending != null)
  {
    pending.deliver();
  }
  return new CallCompletionImpl(currentTime);
}
</code>```

Does this mean that all these operations e.g. +=, ++, > etc. requires the JVM to interact with main memory repeatedly? If so, can I use local variables to cache them (preferably stack allocation for primitives) and perform operations and in the end assign them back to the instance variables? Will that help to optimise performance of this block?

I have such blocks in other places as well. On running a JProfiler, it has been observed that most of the time threads are in WAITING state and throughput is also very low. Hence the optimisation necessity.

Appreciate any help here.

答:
You are accessing members on a single object. So when the CPU reads the _lock member, it needs to load the cache line containing _lock member first. So probably quite a few of the member variables will be on the same cache line which is already in your cache.

I would be more worried about the synchronized block itself IF you have determined it is actually a problem; it might not be a problem at all. For example Java uses quite a few lock optimization techniques like biased locking, adaptive spin lock to reduce the costs of locks.

But if it is a contended lock, you might want to make the duration of the lock shorter by moving as much out of the lock as possible and perhaps even get rid of the whole lock and switch to a lock free approach.

I would not trust JPofiler for a second.
http://psy-lob-saw.blogspot.com/2016/02/why-most-sampling-java-profilers-are.html
So it might be that JProfiler is putting you in the wrong direction.

Body:
I came across answers, here on SO, about Java flushing the work copy of variables within a synchronized block during exit. Similarly it syncs all the variable from main memory once during the entry into the synchronized section.

However, I have some fundamental questions around this:

What if I access mostly non-volatile instance variables inside my synchronized section? Will the JVM automatically cache those variables into the CPU registers at the time of entering into the block and then carry all the necessary computations before finally flushing them back?

I have a synchronized block as below:
The underscored variables _ e.g. _callStartsInLastSecondTracker are all instance variables which I heavily access in this critical section.

public CallCompletion startCall()
{
  long currentTime;
  Pending pending;
  synchronized (_lock)
  {
    currentTime = _clock.currentTimeMillis();
    _tracker.getStatsWithCurrentTime(currentTime);
    _callStartCountTotal++;
    _tracker._callStartCount++;
    if (_callStartsInLastSecondTracker != null)
      _callStartsInLastSecondTracker.addCall();
    _concurrency++;
    if (_concurrency > _tracker._concurrentMax)
    {
      _tracker._concurrentMax = _concurrency;
    }
    _lastStartTime = currentTime;
    _sumOfOutstandingStartTimes += currentTime;
    pending = checkForPending();
  }
  if (pending != null)
  {
    pending.deliver();
  }
  return new CallCompletionImpl(currentTime);
}

Does this mean that all these operations e.g. +=, ++, > etc. requires the JVM to interact with main memory repeatedly? If so, can I use local variables to cache them (preferably stack allocation for primitives) and perform operations and in the end assign them back to the instance variables? Will that help to optimise performance of this block?

I have such blocks in other places as well. On running a JProfiler, it has been observed that most of the time threads are in WAITING state and throughput is also very low. Hence the optimisation necessity.

Appreciate any help here.


问:
SQL query to display data in gridview
I have a grid view that displays data from a SQL Server database during page load. My gridview contains these columns:

```<code>AssetType, IssuedOn, ReturnedOn
</code>```

I have used a query:

```<code>SqlCommand cmd = new SqlCommand(
    "SELECT * FROM AssetRequest WHERE ReturnedOn IS NULL OR ReturnedOn ='' ORDER BY id DESC",
    conn);
</code>```

which will display data from SQL Server in the gridview when ReturnedOn column doesn't have any data.

The new query has to satisfy these conditions,

It Should not displays a record when Assetype="Laptop" or "Desktop" and IssuedOn is not empty.

But if the Assetype="Laptop" or "Desktop" and IssuedOn is empty it should display the record.

If the Assetype=anything and Returnedon is not empty it should not display that record in gridview.

答:
I hope this query resolves your issue.</p>

```<code>SELECT *
FROM AssetRequest
WHERE (AssetType IN ('Laptop', 'Desktop') AND (IssuedOn IS NULL OR IssuedOn = '') AND (ReturnedOn IS NULL OR ReturnedOn = ''))
OR (AssetType NOT IN ('Laptop', 'Desktop') AND (ReturnedOn IS NULL OR ReturnedOn = ''))
</code>```

Title: SQL query to display data in gridview

Body:
I have a grid view that displays data from a SQL Server database during page load. My gridview contains these columns:

AssetType, IssuedOn, ReturnedOn

I have used a query:

SqlCommand cmd = new SqlCommand(
    "SELECT * FROM AssetRequest WHERE ReturnedOn IS NULL OR ReturnedOn ='' ORDER BY id DESC",
    conn);

which will display data from SQL Server in the gridview when ReturnedOn column doesn't have any data.

The new query has to satisfy these conditions,

It Should not displays a record when Assetype="Laptop" or "Desktop" and IssuedOn is not empty.

But if the Assetype="Laptop" or "Desktop" and IssuedOn is empty it should display the record.

If the Assetype=anything and Returnedon is not empty it should not display that record in gridview.

Body:
I hope this query resolves your issue.

SELECT *
FROM AssetRequest
WHERE (AssetType IN ('Laptop', 'Desktop') AND (IssuedOn IS NULL OR IssuedOn = '') AND (ReturnedOn IS NULL OR ReturnedOn = ''))
OR (AssetType NOT IN ('Laptop', 'Desktop') AND (ReturnedOn IS NULL OR ReturnedOn = ''))


问:
How to install requests module with pip?
I'm trying to install the requests module with pip, but I'm not sure if I'm doing it right. I open up the command prompt on windows(windows key+r,type in 'cmd' and hit enter). I have pip already installed, but when I type in 'pip install requests' to the command prompt it says

```<code>    C:\Users\khern>pip install requests
    'pip' is not recognized as an internal or external command,
    operable program or batch file.
</code>```

When I go check if pip is installed, this comes up

```<code>    C:\Users\khern>python -m pip --version
    'python' is not recognized as an internal or external command,
    operable program or batch file.
</code>```

So, then I go to add python's path to the environment variables changing the top part and the bottom part so hopefully the command prompt can run python programs. But when I go to the command prompt and type python, it still says

```<code>    C:\Users\khern>python
    'python' is not recognized as an internal or external command,
    operable program or batch file.
</code>```

Can someone tell me what I'm doing wrong? I'm new to programming, and just want to install the 'requests' module to finish the class I'm taking on python. Thanks!

答:
The python path I think is not selected. Try reinstalling python and do this:
solve python path

or this:
solve python path

Check out this link:
'python' is not recognized as an internal or external command

Body:
I'm trying to install the requests module with pip, but I'm not sure if I'm doing it right. I open up the command prompt on windows(windows key+r,type in 'cmd' and hit enter). I have pip already installed, but when I type in 'pip install requests' to the command prompt it says

    C:\Users\khern>pip install requests
    'pip' is not recognized as an internal or external command,
    operable program or batch file.

When I go check if pip is installed, this comes up

    C:\Users\khern>python -m pip --version
    'python' is not recognized as an internal or external command,
    operable program or batch file.

So, then I go to add python's path to the environment variables changing the top part and the bottom part so hopefully the command prompt can run python programs. But when I go to the command prompt and type python, it still says

    C:\Users\khern>python
    'python' is not recognized as an internal or external command,
    operable program or batch file.

Can someone tell me what I'm doing wrong? I'm new to programming, and just want to install the 'requests' module to finish the class I'm taking on python. Thanks!


问:
flutter / dart How can check if a document exists in firestore?
I try to query using a bool if a document exists on the cloudfirestore or not. Unfortunately, my code does not work

I tried the following, but the bool does not change.

```<code>getok() {
  bool ok;
  Firestore.instance.document('collection/$name').get().then((onexist){
      onexist.exists ? ok = true : ok = false;
    }
  );
  if (ok = true) {
    print('exist');
  } else {
    print('Error');
  }
}
</code>```

答:
You could try this it works for me</p>

```<code>Future getDoc() async{
   var a = await Firestore.instance.collection('collection').document($name).get();
   if(a.exists){
     print('Exists');
     return a;
   }
   if(!a.exists){
     print('Not exists');
     return null;
   }

  }
</code>```

Body:
I try to query using a bool if a document exists on the cloudfirestore or not. Unfortunately, my code does not work

I tried the following, but the bool does not change.

getok() {
  bool ok;
  Firestore.instance.document('collection/$name').get().then((onexist){
      onexist.exists ? ok = true : ok = false;
    }
  );
  if (ok = true) {
    print('exist');
  } else {
    print('Error');
  }
}

Body:
You could try this it works for me

Future getDoc() async{
   var a = await Firestore.instance.collection('collection').document($name).get();
   if(a.exists){
     print('Exists');
     return a;
   }
   if(!a.exists){
     print('Not exists');
     return null;
   }

  }


问:
How to create a mailitem?
I'm trying to send the active Excel workbook as an attachment via Outlook.

Whenever I run the code it says

Invalid use of New key word

at New Outlook.MailItem`.

```<code>Sub SendOutlook()
    'Declaring Variables
    Dim OutlookApp  As Outlook.Application
    Dim OutlookEmail  As Outlook.MailItem

    'Assigning variables to create outlook application and mailitem
    Set OutlookApp = New Outlook.Application
    Set OutlookEmail = New Outlook.MailItem

    With OutlookEmail
        'Format of the mail
        .BodyFormat = olFormatPlain
        'Body of the mail
        .Body = "Dear Someone" & vbNewLine & "How are you?"
        'To whom you want to send mail
        .To = "Someone@somewhere.com"
        'Subject of mail
        .Subject = "Write Subject Here"
        'TO add an attachment
        .Attachments.Add ActiveWorkbook.FullName
        'sends the mail
        .Send
    End With

End Sub
</code>```

答: As far as I got to know from the research is that Programmatic access to sending emails is a security risk, so it's not allowed via VBA. </p>

Title: How to create a mailitem?

Body:
I'm trying to send the active Excel workbook as an attachment via Outlook.

Whenever I run the code it says

Invalid use of New key word

at New Outlook.MailItem`.

Sub SendOutlook()
    'Declaring Variables
    Dim OutlookApp  As Outlook.Application
    Dim OutlookEmail  As Outlook.MailItem

    'Assigning variables to create outlook application and mailitem
    Set OutlookApp = New Outlook.Application
    Set OutlookEmail = New Outlook.MailItem

    With OutlookEmail
        'Format of the mail
        .BodyFormat = olFormatPlain
        'Body of the mail
        .Body = "Dear Someone" & vbNewLine & "How are you?"
        'To whom you want to send mail
        .To = "Someone@somewhere.com"
        'Subject of mail
        .Subject = "Write Subject Here"
        'TO add an attachment
        .Attachments.Add ActiveWorkbook.FullName
        'sends the mail
        .Send
    End With

End Sub


问:
Can't access URL of created Pop Up window
I'm creating a new window and opening it on a new pop up window

```<code> var win = window.open(varforURl,"Login to Spot",'width=800, height=600');
</code>```

On my next line I'm trying to get the URL of the window I just created and the pop up window is still opened.

```<code>console.log(win.document.URL);
</code>```

What I expect to see is:

```<code>https://accounts.spotify.com/en/authorize?....
</code>```

(This is the Url I passed with a variable, and it is in fact displayed on the page)

However, on my console I get about:blank

Any ideas why this is happening and how I can get the url for the window I created?

答:
win.location.href
Should do the trick

Body:
I'm creating a new window and opening it on a new pop up window

 var win = window.open(varforURl,"Login to Spot",'width=800, height=600');

On my next line I'm trying to get the URL of the window I just created and the pop up window is still opened.

console.log(win.document.URL);

What I expect to see is:

https://accounts.spotify.com/en/authorize?....

(This is the Url I passed with a variable, and it is in fact displayed on the page)

However, on my console I get about:blank

Any ideas why this is happening and how I can get the url for the window I created?

Body:
win.location.href
Should do the trick


问:
Spring Context Hierarchy: How to initialize child contexts concurrently
I use the Spring Boot Fluent Builder API to build a Spring context Hierarchy like described here.

Is it possible to initialize the child contexts concurrently?

答: It's not supported. I raised a Spring Boot issue which has been declined: SpringApplicationBuilder: Initialize siblings concurrently</p>


问:
How do you do NAT traversal for RTP media using Kamailio for signalling?
There are three devices in question.

A VoIP phone behind NAT

My own Kamailio Server on an EC2 instance.

The Linphone application for android on my phone.

My phone is on mobile data, and since I have an MVNO, it appears to be NATed as well (private IP like 192.0.0.X).

My problem, is that Although SIP signalling is working just fine, I can't get either device to receive the other's RTP media streams.

I've defined WITH_NAT in the kamailio.cfg, but it doesn't seem to be helping with gathering candidates.  Here's the invite before and after passing through Kamailio.

Before:

```<code>Via: SIP/2.0/UDP 192.0.0.4:46244;branch=z9hG4bK.bLB4chm4B;rport.
From: "the app" <sip:105@<SERVERDOMAIN>>;tag=EHCGj~8d5.
To: sip:104@<SERVERDOMAIN>.
CSeq: 20 INVITE.
Call-ID: SyOH-iCt1A.
Max-Forwards: 70.
Supported: replaces, outbound, gruu.
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, UPDATE.
Content-Type: application/sdp.
Content-Length: 721.
Contact: <sip:105@172.56.20.144:43565;transport=udp>;expires=3600;received="sip:172.56.20.144:43565";+sip.instance="<urn:uuid:f102067f-da3a-00f6-9530-ee66544ec6b4>".
User-Agent: <USERAGENT>/0.2.1-debug (Mobile Dev Environment 1) LinphoneSDK/4.1-366-g1b22291 (master) (belle-sip/1.6.3).
.
v=0.
o=105 911 2837 IN IP4 192.0.0.4.
s=Talk.
c=IN IP4 192.0.0.4.
t=0 0.
a=ice-pwd:42da1553a4faaaf4b57c93f2.
a=ice-ufrag:894dda61.
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics.
m=audio 7078 RTP/AVP 0 8 101.
a=rtpmap:101 telephone-event/8000.
a=candidate:1 1 UDP 2130706303 192.0.0.4 7078 typ host.
a=candidate:1 2 UDP 2130706302 192.0.0.4 7079 typ host.
a=rtcp-fb:* trr-int 1000.
a=rtcp-fb:* ccm tmmbr.
m=video 9078 RTP/AVP 96.
a=rtpmap:96 H264/90000.
a=fmtp:96 profile-level-id=42801F.
a=candidate:1 1 UDP 2130706303 192.0.0.4 9078 typ host.
a=candidate:1 2 UDP 2130706302 192.0.0.4 9079 typ host.
a=rtcp-fb:* trr-int 1000.
a=rtcp-fb:* ccm tmmbr.
a=rtcp-fb:96 nack pli.
a=rtcp-fb:96 ccm fir.
</code>```

After:

```<code>Record-Route: <sip:<SERVERDOMAIN>:<PORT>;lr;nat=yes>.
Via: SIP/2.0/UDP <SERVERDOMAIN>:<PORT>;branch=z9hG4bKdd88.20b5965a3ea168d68a6b0603ebaa6c80.0.
Via: SIP/2.0/UDP 192.0.0.4:46244;received=172.56.20.144;branch=z9hG4bK.bLB4chm4B;rport=43565.
From: "the app" <sip:105@<SERVERDOMAIN>>;tag=EHCGj~8d5.
To: sip:104@<SERVERDOMAIN>.
CSeq: 20 INVITE.
Call-ID: SyOH-iCt1A.
Max-Forwards: 69.
Supported: replaces, outbound, gruu.
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, UPDATE.
Content-Type: application/sdp.
Content-Length: 721.
Contact: <sip:105@172.56.20.144:43565;transport=udp;alias=172.56.20.144~43565~1>;expires=3600;received="sip:172.56.20.144:43565";+sip.instance="<urn:uuid:f102067f-da3a-00f6-9530-ee66544ec6b4>".
User-Agent: <USERAGENT>/0.2.1-debug (Mobile Dev Environment 1) LinphoneSDK/4.1-366-g1b22291 (master) (belle-sip/1.6.3).
.
v=0.
o=105 911 2837 IN IP4 192.0.0.4.
s=Talk.
c=IN IP4 192.0.0.4.
t=0 0.
a=ice-pwd:42da1553a4faaaf4b57c93f2.
a=ice-ufrag:894dda61.
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics.
m=audio 7078 RTP/AVP 0 8 101.
a=rtpmap:101 telephone-event/8000.
a=candidate:1 1 UDP 2130706303 192.0.0.4 7078 typ host.
a=candidate:1 2 UDP 2130706302 192.0.0.4 7079 typ host.
a=rtcp-fb:* trr-int 1000.
a=rtcp-fb:* ccm tmmbr.
m=video 9078 RTP/AVP 96.
a=rtpmap:96 H264/90000.
a=fmtp:96 profile-level-id=42801F.
a=candidate:1 1 UDP 2130706303 192.0.0.4 9078 typ host.
a=candidate:1 2 UDP 2130706302 192.0.0.4 9079 typ host.
a=rtcp-fb:* trr-int 1000.
a=rtcp-fb:* ccm tmmbr.
a=rtcp-fb:96 nack pli.
a=rtcp-fb:96 ccm fir.
</code>```

It's the same story for inbound calls.

I was expecting the nathelper module to add something like

```<code>a=candidate:2 1 UDP 1694498815 <SOME_PUBLIC_IP> <SOME_PUBLIC_PORT> typ srflx raddr
192.0.0.4 rport 7078
</code>```

but clearly it is not.  I can modify o= and c= in the headers to use the IP that the server received the invite from, but how is the server suppose to know which ports the RTP media should be sent to?  The only ports the server could know are

The port that the invite was sent from (private and public side)

The ports provided in the sdp.  But these are on the private-side.  Surely they would be different on the public-side?

Any help on this would be appreciated.

答:
You will need to setup rtpproxy or rtpengine.

Here is the simplest procedure for installing and configuring rtpproxy with Kamailio:

1- install rtpproxy

```<code>apt install rtpproxy
</code>```

2- Enter these 2 lines in rtpproxy configuration file (/etc/default/rtpproxy):

```<code>CONTROL_SOCK=udp:127.0.0.1:7722
EXTRA_OPTS="-l IP-address"
</code>```

IP-address is the external IP address of your host.

3- Enter this define near the top of Kamailio configuration file (/etc/kamailio/kamailio.cfg):

```<code>#!define WITH_NAT
</code>```

4- Restart rtpproxy

```<code>systemctl restart rtpproxy
</code>```

5- Restart Kamailio

```<code>systemctl restart kamailio
</code>```

INVITE and 200 OK relayed by Kamailio should then have their SDP Contact IPs and Ports replaced with the ones for rtpproxy

Note: I noticed at least one of the UAC should use TCP Transport for the above to work.

Body:
There are three devices in question.

A VoIP phone behind NAT

My own Kamailio Server on an EC2 instance.

The Linphone application for android on my phone.

My phone is on mobile data, and since I have an MVNO, it appears to be NATed as well (private IP like 192.0.0.X).

My problem, is that Although SIP signalling is working just fine, I can't get either device to receive the other's RTP media streams.

I've defined WITH_NAT in the kamailio.cfg, but it doesn't seem to be helping with gathering candidates.  Here's the invite before and after passing through Kamailio.

Before:

Via: SIP/2.0/UDP 192.0.0.4:46244;branch=z9hG4bK.bLB4chm4B;rport.
From: "the app" <sip:105@<SERVERDOMAIN>>;tag=EHCGj~8d5.
To: sip:104@<SERVERDOMAIN>.
CSeq: 20 INVITE.
Call-ID: SyOH-iCt1A.
Max-Forwards: 70.
Supported: replaces, outbound, gruu.
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, UPDATE.
Content-Type: application/sdp.
Content-Length: 721.
Contact: <sip:105@172.56.20.144:43565;transport=udp>;expires=3600;received="sip:172.56.20.144:43565";+sip.instance="<urn:uuid:f102067f-da3a-00f6-9530-ee66544ec6b4>".
User-Agent: <USERAGENT>/0.2.1-debug (Mobile Dev Environment 1) LinphoneSDK/4.1-366-g1b22291 (master) (belle-sip/1.6.3).
.
v=0.
o=105 911 2837 IN IP4 192.0.0.4.
s=Talk.
c=IN IP4 192.0.0.4.
t=0 0.
a=ice-pwd:42da1553a4faaaf4b57c93f2.
a=ice-ufrag:894dda61.
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics.
m=audio 7078 RTP/AVP 0 8 101.
a=rtpmap:101 telephone-event/8000.
a=candidate:1 1 UDP 2130706303 192.0.0.4 7078 typ host.
a=candidate:1 2 UDP 2130706302 192.0.0.4 7079 typ host.
a=rtcp-fb:* trr-int 1000.
a=rtcp-fb:* ccm tmmbr.
m=video 9078 RTP/AVP 96.
a=rtpmap:96 H264/90000.
a=fmtp:96 profile-level-id=42801F.
a=candidate:1 1 UDP 2130706303 192.0.0.4 9078 typ host.
a=candidate:1 2 UDP 2130706302 192.0.0.4 9079 typ host.
a=rtcp-fb:* trr-int 1000.
a=rtcp-fb:* ccm tmmbr.
a=rtcp-fb:96 nack pli.
a=rtcp-fb:96 ccm fir.

After:

Record-Route: <sip:<SERVERDOMAIN>:<PORT>;lr;nat=yes>.
Via: SIP/2.0/UDP <SERVERDOMAIN>:<PORT>;branch=z9hG4bKdd88.20b5965a3ea168d68a6b0603ebaa6c80.0.
Via: SIP/2.0/UDP 192.0.0.4:46244;received=172.56.20.144;branch=z9hG4bK.bLB4chm4B;rport=43565.
From: "the app" <sip:105@<SERVERDOMAIN>>;tag=EHCGj~8d5.
To: sip:104@<SERVERDOMAIN>.
CSeq: 20 INVITE.
Call-ID: SyOH-iCt1A.
Max-Forwards: 69.
Supported: replaces, outbound, gruu.
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, UPDATE.
Content-Type: application/sdp.
Content-Length: 721.
Contact: <sip:105@172.56.20.144:43565;transport=udp;alias=172.56.20.144~43565~1>;expires=3600;received="sip:172.56.20.144:43565";+sip.instance="<urn:uuid:f102067f-da3a-00f6-9530-ee66544ec6b4>".
User-Agent: <USERAGENT>/0.2.1-debug (Mobile Dev Environment 1) LinphoneSDK/4.1-366-g1b22291 (master) (belle-sip/1.6.3).
.
v=0.
o=105 911 2837 IN IP4 192.0.0.4.
s=Talk.
c=IN IP4 192.0.0.4.
t=0 0.
a=ice-pwd:42da1553a4faaaf4b57c93f2.
a=ice-ufrag:894dda61.
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics.
m=audio 7078 RTP/AVP 0 8 101.
a=rtpmap:101 telephone-event/8000.
a=candidate:1 1 UDP 2130706303 192.0.0.4 7078 typ host.
a=candidate:1 2 UDP 2130706302 192.0.0.4 7079 typ host.
a=rtcp-fb:* trr-int 1000.
a=rtcp-fb:* ccm tmmbr.
m=video 9078 RTP/AVP 96.
a=rtpmap:96 H264/90000.
a=fmtp:96 profile-level-id=42801F.
a=candidate:1 1 UDP 2130706303 192.0.0.4 9078 typ host.
a=candidate:1 2 UDP 2130706302 192.0.0.4 9079 typ host.
a=rtcp-fb:* trr-int 1000.
a=rtcp-fb:* ccm tmmbr.
a=rtcp-fb:96 nack pli.
a=rtcp-fb:96 ccm fir.

It's the same story for inbound calls.

I was expecting the nathelper module to add something like

a=candidate:2 1 UDP 1694498815 <SOME_PUBLIC_IP> <SOME_PUBLIC_PORT> typ srflx raddr
192.0.0.4 rport 7078

but clearly it is not.  I can modify o= and c= in the headers to use the IP that the server received the invite from, but how is the server suppose to know which ports the RTP media should be sent to?  The only ports the server could know are

The port that the invite was sent from (private and public side)

The ports provided in the sdp.  But these are on the private-side.  Surely they would be different on the public-side?

Any help on this would be appreciated.

Body:
You will need to setup rtpproxy or rtpengine.

Here is the simplest procedure for installing and configuring rtpproxy with Kamailio:

1- install rtpproxy

apt install rtpproxy

2- Enter these 2 lines in rtpproxy configuration file (/etc/default/rtpproxy):

CONTROL_SOCK=udp:127.0.0.1:7722
EXTRA_OPTS="-l IP-address"

IP-address is the external IP address of your host.

3- Enter this define near the top of Kamailio configuration file (/etc/kamailio/kamailio.cfg):

#!define WITH_NAT

4- Restart rtpproxy

systemctl restart rtpproxy

5- Restart Kamailio

systemctl restart kamailio

INVITE and 200 OK relayed by Kamailio should then have their SDP Contact IPs and Ports replaced with the ones for rtpproxy

Note: I noticed at least one of the UAC should use TCP Transport for the above to work.


问:
A subquery returning multple rows
I am getting an error in the below query.. can anyone help fixing this query

```<code>select c.CHANGE_NUMBER,
(select le.ENTRYVALUE from listentry  le
where le.ENTRYID = c.CATEGORY)as CATEGORY ,
(
            SELECT  last_name || ',' || first_name || '(' || loginid || ')'
            FROM agileuser
            WHERE id = c.ORIGINATOR
        ) initiator,(
            SELECT  last_name || ',' || first_name || '(' || loginid || ')'
            FROM agileuser
            WHERE id = c.owner
        ) coordinator, w.state,

(SELECT description
            FROM nodetable
            WHERE id = w.state
        ) workflow_status , TO_CHAR(w.LOCAL_DATE,'DD-MON-YY HH24:MI:SS')local_date,
      (select
        (trunc(to_date(B.local_date, 'DD-MON-YY HH24:MI:SS') - to_date(w.local_date, 'DD-MON-YY HH24:MI:SS')))as timediff
        FROM WORKFLOW_PROCESS w INNER JOIN WORKFLOW_PROCESS B ON B.order_by = (w.order_by + 1)
        where w.change_id=B.Change_id and w.change_id=9946301 )--ORDER BY w.order_by ASC

       from change c, WORKFLOW_PROCESS w
        where w.change_id = c.id-- order by w.ORDER_BY)
       and c.CHANGE_NUMBER='NPI001084'
      order by w.ORDER_BY,local_date ASC
</code>```

The trunc() query gives multiple records

```<code> select
     (trunc(to_date(B.local_date, 'DD-MON-YY HH24:MI:SS') - to_date(w.local_date, 'DD-MON-YY HH24:MI:SS')))as timediff
      FROM WORKFLOW_PROCESS w INNER JOIN WORKFLOW_PROCESS B ON B.order_by = (w.order_by + 1)
      where w.change_id=B.Change_id and w.change_id=9946301 ORDER BY w.order_by ASC
</code>```

hence not able to run along with this main query.

答:
Completely untested, and probably with some typos, also possibly joins that should be left joins, and maybe incorrect oracle syntax, but... </p>

```<code>select c.CHANGE_NUMBER,
    le.ENTRYVALUE as CATEGORY
    orig.last_name || ',' || orig.first_name || '(' || orig.loginid || ')' as initiator,
    own.last_name || ',' || own.first_name || '(' || own.loginid || ')' as coordinator,
    w.state,
    n.description as workflow_status,
    TO_CHAR(w.LOCAL_DATE,'DD-MON-YY HH24:MI:SS')local_date,
    trunc(to_date(B.local_date, 'DD-MON-YY HH24:MI:SS') - to_date(w.local_date, 'DD-MON-YY HH24:MI:SS')) as timediff
from change c
join WORKFLOW_PROCESS w on w.change_id = c.id
join listentry le on le.ENTRYID = c.CATEGORY
join agileuser as orig on orig.id = c.ORIGINATOR
join agileuser as own on own.id = c.owner
join nodetable as n on n.id = w.state
JOIN WORKFLOW_PROCESS B ON B.order_by = (w.order_by + 1)
where c.CHANGE_NUMBER='NPI001084'
order by w.ORDER_BY,local_date ASC
</code>```

Title: A subquery returning multple rows

Body:
I am getting an error in the below query.. can anyone help fixing this query

select c.CHANGE_NUMBER,
(select le.ENTRYVALUE from listentry  le
where le.ENTRYID = c.CATEGORY)as CATEGORY ,
(
            SELECT  last_name || ',' || first_name || '(' || loginid || ')'
            FROM agileuser
            WHERE id = c.ORIGINATOR
        ) initiator,(
            SELECT  last_name || ',' || first_name || '(' || loginid || ')'
            FROM agileuser
            WHERE id = c.owner
        ) coordinator, w.state,

(SELECT description
            FROM nodetable
            WHERE id = w.state
        ) workflow_status , TO_CHAR(w.LOCAL_DATE,'DD-MON-YY HH24:MI:SS')local_date,
      (select
        (trunc(to_date(B.local_date, 'DD-MON-YY HH24:MI:SS') - to_date(w.local_date, 'DD-MON-YY HH24:MI:SS')))as timediff
        FROM WORKFLOW_PROCESS w INNER JOIN WORKFLOW_PROCESS B ON B.order_by = (w.order_by + 1)
        where w.change_id=B.Change_id and w.change_id=9946301 )--ORDER BY w.order_by ASC

       from change c, WORKFLOW_PROCESS w
        where w.change_id = c.id-- order by w.ORDER_BY)
       and c.CHANGE_NUMBER='NPI001084'
      order by w.ORDER_BY,local_date ASC

The trunc() query gives multiple records

 select
     (trunc(to_date(B.local_date, 'DD-MON-YY HH24:MI:SS') - to_date(w.local_date, 'DD-MON-YY HH24:MI:SS')))as timediff
      FROM WORKFLOW_PROCESS w INNER JOIN WORKFLOW_PROCESS B ON B.order_by = (w.order_by + 1)
      where w.change_id=B.Change_id and w.change_id=9946301 ORDER BY w.order_by ASC

hence not able to run along with this main query.

Body:
Completely untested, and probably with some typos, also possibly joins that should be left joins, and maybe incorrect oracle syntax, but...

select c.CHANGE_NUMBER,
    le.ENTRYVALUE as CATEGORY
    orig.last_name || ',' || orig.first_name || '(' || orig.loginid || ')' as initiator,
    own.last_name || ',' || own.first_name || '(' || own.loginid || ')' as coordinator,
    w.state,
    n.description as workflow_status,
    TO_CHAR(w.LOCAL_DATE,'DD-MON-YY HH24:MI:SS')local_date,
    trunc(to_date(B.local_date, 'DD-MON-YY HH24:MI:SS') - to_date(w.local_date, 'DD-MON-YY HH24:MI:SS')) as timediff
from change c
join WORKFLOW_PROCESS w on w.change_id = c.id
join listentry le on le.ENTRYID = c.CATEGORY
join agileuser as orig on orig.id = c.ORIGINATOR
join agileuser as own on own.id = c.owner
join nodetable as n on n.id = w.state
JOIN WORKFLOW_PROCESS B ON B.order_by = (w.order_by + 1)
where c.CHANGE_NUMBER='NPI001084'
order by w.ORDER_BY,local_date ASC


问:
React Native - use useDimensions hook in stylesheet
How do you use dimensions returned from a hook in RN in the Stylesheet?

for example

```<code>import { useDimensions } from '@react-native-community/hooks';

const ProfileEditScreen = () => {
  const { width, height } = useDimensions().window;
  ...

const styles = StyleSheet.create({
  profileEditContainer__form: {
    borderRadius: 15,
    height: 40,
    width: width - width / 4,
    borderColor: Colors.defaultColor,
    borderWidth: 1,
    textAlign: 'center',
  },
  ...
</code>```

In the example above, width is not defined.

In the past (class components), I used to have a top-level

```<code>const { width: WIDTH } = Dimensions.get('window');
</code>```

Can't really do that anymore with functional components.. any suggestions?

答:
You only can use hooks in functional components.

For your example I would still suggest to use Dimensions.get('window').

Body:
How do you use dimensions returned from a hook in RN in the Stylesheet?

for example

import { useDimensions } from '@react-native-community/hooks';

const ProfileEditScreen = () => {
  const { width, height } = useDimensions().window;
  ...

const styles = StyleSheet.create({
  profileEditContainer__form: {
    borderRadius: 15,
    height: 40,
    width: width - width / 4,
    borderColor: Colors.defaultColor,
    borderWidth: 1,
    textAlign: 'center',
  },
  ...

In the example above, width is not defined.

In the past (class components), I used to have a top-level

const { width: WIDTH } = Dimensions.get('window');

Can't really do that anymore with functional components.. any suggestions?


问:
In python regex r'\W' vs r'\W+' vs r'\W*', can someone explain this?
```<code>txt = "The rain in Spain '69'"
x = re.split(r'\W*', txt)
print(x)
</code>```

['', 'T', 'h', 'e', '', 'r', 'a', 'i', 'n', '', 'i', 'n', '', 'S', 'p', 'a', 'i', 'n', '', '6', '9', '', '']

```<code>txt = "The rain in Spain '69'"
x = re.split(r'\W+', txt)
print(x)
</code>```

['The', 'rain', 'in', 'Spain', '69', '']

The documentation (python.org):

Another repeating metacharacter is +, which matches one or more times. Pay careful attention to the difference between * and +; * matches zero or more times, so whatever’s being repeated may not be present at all, while + requires at least one occurrence. To use a similar example, ca+t will match 'cat' (1 'a'), 'caaat' (3 'a's), but won’t match 'ct'.

Please explain this difference.

答:
the split function goes through the string looking for the pattern, when found, it makes a new element in the result array.

asterisk split

it starts the string, it sees nothing, this matches the pattern (0 or more). The array is now [''].

then it sees the first character, which is also zero or more. the array is now ['', 'T']. This continues until all characters match, and each one gets own element.

plus regex split

With this mode, the space before the first character does not match. only at the end of the word is the first non word character found (it needs at least one). If it were "a     b" splitting on one or more non-word ("\W+") would result in ['a', 'b'] i think.

So it finds a space at the end of every word and splits there.

If there were no characters which fit the pattern, it does not split, ie, if the pattern is one or more 'a' and the input is 'ct' it should not split.

definition of 'word' in regex

Word and nonword: word is [a-zA-Z0-9_], so what you expect in a word, non word is everything typically between: [^a-zA-Z0-9_]

Body:
txt = "The rain in Spain '69'"
x = re.split(r'\W*', txt)
print(x)

['', 'T', 'h', 'e', '', 'r', 'a', 'i', 'n', '', 'i', 'n', '', 'S', 'p', 'a', 'i', 'n', '', '6', '9', '', '']

txt = "The rain in Spain '69'"
x = re.split(r'\W+', txt)
print(x)

['The', 'rain', 'in', 'Spain', '69', '']

The documentation (python.org):

Another repeating metacharacter is +, which matches one or more times. Pay careful attention to the difference between * and +; * matches zero or more times, so whatever’s being repeated may not be present at all, while + requires at least one occurrence. To use a similar example, ca+t will match 'cat' (1 'a'), 'caaat' (3 'a's), but won’t match 'ct'.

Please explain this difference.


问:
How can I compile this program?
I have a problem with compilation of this program  I don't know how can I  solve this problem</p>

```<code>class ArrayTester{

    public void arrayTester(ArrayDeque arrayDeque) {

        List evenlist = new ArrayList();
        List oddlist = new ArrayList();

        for (int n = 0; n < arrayDeque.size(); n++) {

            if (arrayDeque.Length() % 2 == 0) {
                arrayDeque.addAll(evenlist);
            } else {
                arrayDeque.addAll(oddlist);
            }

            System.out.println(evenlist);
            System.out.println(oddlist);
        }
    }
}

class Kodilla {
    public static void main(String[] args) {

        ArrayDeque<String> arrayDeque = new ArrayDeque<>();
        Random random = new Random();
        String text = "";
        int howLong = random.nextInt(50) + 1;
        while (text.length() < howLong) {
            text = text + "a";
            for (int i = 0; i < 50; i++) {
                arrayDeque.add(text);
                System.out.println(arrayDeque);
                System.out.println(arrayDeque.size());

                arrayTester tester = new ArrayTester();
                tester.arrayTester(arrayDeque);
                System.out.println(arrayTester);
            }
        }
    }
}
</code>```

答:
what I see is that in this line

arrayTester tester = new ArrayTester();

there is typo in the variable definition.  (lowercase a)

Title: How can I compile this program?

Body:
I have a problem with compilation of this program  I don't know how can I  solve this problem

class ArrayTester{

    public void arrayTester(ArrayDeque arrayDeque) {

        List evenlist = new ArrayList();
        List oddlist = new ArrayList();

        for (int n = 0; n < arrayDeque.size(); n++) {

            if (arrayDeque.Length() % 2 == 0) {
                arrayDeque.addAll(evenlist);
            } else {
                arrayDeque.addAll(oddlist);
            }

            System.out.println(evenlist);
            System.out.println(oddlist);
        }
    }
}

class Kodilla {
    public static void main(String[] args) {

        ArrayDeque<String> arrayDeque = new ArrayDeque<>();
        Random random = new Random();
        String text = "";
        int howLong = random.nextInt(50) + 1;
        while (text.length() < howLong) {
            text = text + "a";
            for (int i = 0; i < 50; i++) {
                arrayDeque.add(text);
                System.out.println(arrayDeque);
                System.out.println(arrayDeque.size());

                arrayTester tester = new ArrayTester();
                tester.arrayTester(arrayDeque);
                System.out.println(arrayTester);
            }
        }
    }
}


问:
formatting text in footer (text under icons)
I need help formatting the footer for my website. I am new to CSS and I cannot figure out how to get the text for the Copyright to sit underneath of the icons. I tried tweaking by altering the height of the footer and the best I can get is the text to the left or right of the icons. Any help would be appreciated.

CSS Style Sheet:

```<code>body {
    margin: 0;
}

.logo {
    display: block;
    margin-left: auto;
    margin-right: auto;
    width: 50px;
    height: 50px;
    margin-top: 11px;
}

.navBar {
    display: flex;
    justify-content: center;
    overflow: hidden;
    background-color: white;
    position: fixed;
    top: 0;
    width: 100%;
    margin-top: 61px;
    text-align: center;
}

.navBar a {
    display: inline-block;
    width: 10%;
    color: black;
    text-align: center;
    padding: 7px 7px;
    text-decoration: none;
    font-size: 17px;
    font-family: "Poppins";
}

body.services a.services,
body.ourstory a.ourstory {
    border-bottom: 1.5px solid black;
}

.header {
    position: fixed;
    background-color: white;
    width: 100%;
    height: 80px;
}

.p3 {
    color: black;
    text-align: center;
    font-family: 'Poppins';
    font-size: 105%;
    font-weight: 300;
    line-height: 1.8em;
}
.p4 {
    color: black;
    text-align: center;
    padding-left: 200px;
    font-family: 'Poppins';
    font-size: 100%;
    font-weight: 300;
    line-height: 1.8em;
}
</code>```

HTML Document:

.content {
  padding: 10.4%;
}

.main {
  height: 800px;
  background-color: #f9f9f9;
}

.copyright {
  color: black;
  text-align: center;
  font-family: 'Poppins';
  font-size: 70%;
  font-weight: 300;
  line-height: 1.8em;
  display: block;
  margin-bottom: 100px;
}

.navbarSocialMedia {
  display: flex;
  justify-content: center;
  overflow: hidden;
  background-color: white;
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
}

.newFooter {
  position: fixed;
  background-color: white;
  width: 100%;
  height: 800px;
}

.navbarSocialMedia a {
  display: inline-block;
  width: 3.5%;
  color: black;
  text-align: center;
  padding: 5px 5px;
  text-decoration: none;
  font-size: 17px;
  font-family: "Poppins";
}

.mediaLogo {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 21px;
  height: 21px;
  margin-top: 10px;
  margin-bottom: 10px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en-US">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<head>

<title>Giving Back</title>

    <link href="simpleCSS.css" rel="stylesheet" type="text/css">
    <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
    <link rel="shortcut icon" type="image/png" href="name.png">

    </head>

    <body class="services">

    <div class="header">

            <img src="name.png" alt="Logo" class="logo">

        <div class="navBar">
            Our Story
            Giving Back
        </div>

    </div>

    <br>
    <br>
    <br>

    <div class="main">
        <div class="content">

            <p class="p3"> content

            </p>
        </div>
    </div>

    <div class="newFooter">
        <div class="navbarSocialMedia">

                <img src="InstagramLogo48.png " alt="email logo" class="mediaLogo">

                <img src="linkedin48.png " alt="linked in logo" class="mediaLogo">

                <img src="emaillogo48.png " alt="email logo" class="mediaLogo">

                <img src="facebooklogo48.png " alt="facebook logo" class="mediaLogo">
        </div>

        <div class="try">
            <p class=" copyright ">Copyright &copy. </p>
    </div>
    </div>
    </body>
    </html></code>```

答:
The reason the copyright div is not visible is because your
 has a position fixed, so it is displayed on top of the footer (that also has a fixed position).

An element with position: fixed; is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled.
  w3

I set bottom: 0; left: 0; right: 0; footer's attributes so it's displayed on the bottom of the window and with full width.

Also I would suggest to remove the margin-bottom: 100px from the
 as it takes too much space from the window.

And last but not least, I noticed that for the
 you had set text-align: center (so I'm assuming you want the icons to be centered) but as it has the property display: flex. It's better to use align-items: center instead.

Hope this helps you out.

.content {
  padding: 10.4%;
}

.main {
  height: 800px;
  background-color: #f9f9f9;
}

.copyright {
  color: black;
  text-align: center;
  font-family: 'Poppins';
  font-size: 70%;
  font-weight: 300;
  line-height: 1.8em;
  display: block;
}

.navbarSocialMedia {
  display: flex;
  justify-content: center;
  overflow: hidden;
  background-color: white;
  width: 100%;
  align-items: center;
}

.newFooter {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: white;
  width: 100%;
}

.navbarSocialMedia a {
  display: inline-block;
  width: 3.5%;
  color: black;
  text-align: center;
  padding: 5px 5px;
  text-decoration: none;
  font-size: 17px;
  font-family: "Poppins";
}

.mediaLogo {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 21px;
  height: 21px;
  margin-top: 10px;
  margin-bottom: 10px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en-US">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<head>

<title>Giving Back</title>

    <link href="simpleCSS.css" rel="stylesheet" type="text/css">
    <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
    <link rel="shortcut icon" type="image/png" href="name.png">

    </head>

    <body class="services">

    <div class="header">

            <img src="name.png" alt="Logo" class="logo">

        <div class="navBar">
            Our Story
            Giving Back
        </div>

    </div>

    <br>
    <br>
    <br>

    <div class="main">
        <div class="content">

            <p class="p3"> content

            </p>
        </div>
    </div>

    <div class="newFooter">
        <div class="navbarSocialMedia">

                <img src="InstagramLogo48.png " alt="email logo" class="mediaLogo">

                <img src="linkedin48.png " alt="linked in logo" class="mediaLogo">

                <img src="emaillogo48.png " alt="email logo" class="mediaLogo">

                <img src="facebooklogo48.png " alt="facebook logo" class="mediaLogo">
        </div>

        <div class="try">
            <p class=" copyright ">Copyright &copy. </p>
    </div>
    </div>
    </body>
    </html></code>```

Body:
I need help formatting the footer for my website. I am new to CSS and I cannot figure out how to get the text for the Copyright to sit underneath of the icons. I tried tweaking by altering the height of the footer and the best I can get is the text to the left or right of the icons. Any help would be appreciated.

CSS Style Sheet:

body {
    margin: 0;
}

.logo {
    display: block;
    margin-left: auto;
    margin-right: auto;
    width: 50px;
    height: 50px;
    margin-top: 11px;
}

.navBar {
    display: flex;
    justify-content: center;
    overflow: hidden;
    background-color: white;
    position: fixed;
    top: 0;
    width: 100%;
    margin-top: 61px;
    text-align: center;
}

.navBar a {
    display: inline-block;
    width: 10%;
    color: black;
    text-align: center;
    padding: 7px 7px;
    text-decoration: none;
    font-size: 17px;
    font-family: "Poppins";
}

body.services a.services,
body.ourstory a.ourstory {
    border-bottom: 1.5px solid black;
}

.header {
    position: fixed;
    background-color: white;
    width: 100%;
    height: 80px;
}

.p3 {
    color: black;
    text-align: center;
    font-family: 'Poppins';
    font-size: 105%;
    font-weight: 300;
    line-height: 1.8em;
}
.p4 {
    color: black;
    text-align: center;
    padding-left: 200px;
    font-family: 'Poppins';
    font-size: 100%;
    font-weight: 300;
    line-height: 1.8em;
}

HTML Document:

.content {
  padding: 10.4%;
}

.main {
  height: 800px;
  background-color: #f9f9f9;
}

.copyright {
  color: black;
  text-align: center;
  font-family: 'Poppins';
  font-size: 70%;
  font-weight: 300;
  line-height: 1.8em;
  display: block;
  margin-bottom: 100px;
}

.navbarSocialMedia {
  display: flex;
  justify-content: center;
  overflow: hidden;
  background-color: white;
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
}

.newFooter {
  position: fixed;
  background-color: white;
  width: 100%;
  height: 800px;
}

.navbarSocialMedia a {
  display: inline-block;
  width: 3.5%;
  color: black;
  text-align: center;
  padding: 5px 5px;
  text-decoration: none;
  font-size: 17px;
  font-family: "Poppins";
}

.mediaLogo {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 21px;
  height: 21px;
  margin-top: 10px;
  margin-bottom: 10px;
}

<!DOCTYPE html>

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Giving Back</title>

    <link href="simpleCSS.css" rel="stylesheet" type="text/css">
    <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
    <link rel="shortcut icon" type="image/png" href="name.png">

            Our Story
            Giving Back

 content

Copyright &copy.

Body:
The reason the copyright div is not visible is because your <div class="navbarSocialMedia"> has a position fixed, so it is displayed on top of the footer (that also has a fixed position).

An element with position: fixed; is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled.
  w3

I set bottom: 0; left: 0; right: 0; footer's attributes so it's displayed on the bottom of the window and with full width.

Also I would suggest to remove the margin-bottom: 100px from the <p class="copyright"> as it takes too much space from the window.

And last but not least, I noticed that for the <div class="navbarSocialMedia"> you had set text-align: center (so I'm assuming you want the icons to be centered) but as it has the property display: flex. It's better to use align-items: center instead.

Hope this helps you out.

.content {
  padding: 10.4%;
}

.main {
  height: 800px;
  background-color: #f9f9f9;
}

.copyright {
  color: black;
  text-align: center;
  font-family: 'Poppins';
  font-size: 70%;
  font-weight: 300;
  line-height: 1.8em;
  display: block;
}

.navbarSocialMedia {
  display: flex;
  justify-content: center;
  overflow: hidden;
  background-color: white;
  width: 100%;
  align-items: center;
}

.newFooter {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: white;
  width: 100%;
}

.navbarSocialMedia a {
  display: inline-block;
  width: 3.5%;
  color: black;
  text-align: center;
  padding: 5px 5px;
  text-decoration: none;
  font-size: 17px;
  font-family: "Poppins";
}

.mediaLogo {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 21px;
  height: 21px;
  margin-top: 10px;
  margin-bottom: 10px;
}

<!DOCTYPE html>
<html lang="en-US">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<head>

<title>Giving Back</title>

    <link href="simpleCSS.css" rel="stylesheet" type="text/css">
    <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
    <link rel="shortcut icon" type="image/png" href="name.png">

    </head>

    <body class="services">

    <div class="header">

        <a href="simple.html">
            <img src="name.png" alt="Logo" class="logo"> </a>

        <div class="navBar">
            <a href="ourstory.html" class="ourstory">Our Story</a>
            <a href="services.html" class="services">Giving Back</a>
        </div>

    </div>

    <br>
    <br>
    <br>

    <div class="main">
        <div class="content">

            <p class="p3"> content

            </p>
        </div>
    </div>

    <div class="newFooter">
        <div class="navbarSocialMedia">
            <a href="https://www.instagram.com/" target="_blank">
                <img src="InstagramLogo48.png " alt="email logo" class="mediaLogo"> </a>
            <a href="https://www.linkedin.com" target="_blank">
                <img src="linkedin48.png " alt="linked in logo" class="mediaLogo"> </a>
            <a href="//www.google.com" target="_blank">
                <img src="emaillogo48.png " alt="email logo" class="mediaLogo"> </a>
            <a href="https://www.facebook.com " target="_blank">
                <img src="facebooklogo48.png " alt="facebook logo" class="mediaLogo"> </a>
        </div>

        <div class="try">
            <p class=" copyright ">Copyright &copy. </p>
    </div>
    </div>
    </body>
    </html>


问:
How to insert data from html form into database without using HTML POST method?
Hi I would like to know if there is any other way using javascript or something to enter the user input directly to database without using POST method.</p>

答: Yes using the GET method. Over HTTP those are your choices.</p>

OwnerDisplayName: johnnaples

ContentLicense: CC BY-SA 2.5

OwnerDisplayName: zodeus


答:
added red background to footer just to identify footer element. You can change later.

.content {
  padding: 10.4%;
}

.main {
  height: 800px;
  background-color: #f9f9f9;
}

.copyright {
  color: black;
  text-align: center;
  font-family: 'Poppins';
  font-size: 70%;
  font-weight: 300;
  line-height: 1.8em;
  display: block;
}

.navbarSocialMedia {
  display: flex;
  justify-content: center;
  overflow: hidden;
  background-color: red;
  bottom: 0;
  width: 100%;
  text-align: center;
}

.newFooter {
  position: fixed;
  background-color: white;
  width: 100%;
  height: 800px;
}

.navbarSocialMedia a {
  display: inline-block;
  width: 3.5%;
  color: black;
  text-align: center;
  padding: 5px 5px;
  text-decoration: none;
  font-size: 17px;
  font-family: "Poppins";
}

.mediaLogo {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 21px;
  height: 21px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.try {
  position: absolute;
  width: 100%;
  color: #fff;
  line-height: 40px;
  font-size: 0.7em;
  text-align: center;
  bottom: 0;
}

.footer {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  background-color: red;
  color: white;
  text-align: center;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en-US">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<head>

  <title>Giving Back</title>

  <link href="simpleCSS.css" rel="stylesheet" type="text/css">
  <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
  <link rel="shortcut icon" type="image/png" href="name.png">
  <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
</head>

<body class="services">

  <div class="header">

      <img src="name.png" alt="Logo" class="logo">

    <div class="navBar">
      Our Story
      Giving Back
    </div>

  </div>

  <br>
  <br>
  <br>

  <div class="main">
    <div class="content">

      <p class="p3"> content

      </p>
    </div>
  </div>

  <div class="footer">
    <div class="navbarSocialMedia">

        <i class="fa fa-instagram"></i>

        <i class="fa fa-linkedin"></i>

        <i class="fa fa-google"></i>

        <i class="fa fa-facebook"></i>
    </div>
    <p class=" copyright ">Copyright ©. </p>
  </div>
</body>

</html></code>```

Title: formatting text in footer (text under icons)

Body:
added red background to footer just to identify footer element. You can change later.

.content {
  padding: 10.4%;
}

.main {
  height: 800px;
  background-color: #f9f9f9;
}

.copyright {
  color: black;
  text-align: center;
  font-family: 'Poppins';
  font-size: 70%;
  font-weight: 300;
  line-height: 1.8em;
  display: block;
}

.navbarSocialMedia {
  display: flex;
  justify-content: center;
  overflow: hidden;
  background-color: red;
  bottom: 0;
  width: 100%;
  text-align: center;
}

.newFooter {
  position: fixed;
  background-color: white;
  width: 100%;
  height: 800px;
}

.navbarSocialMedia a {
  display: inline-block;
  width: 3.5%;
  color: black;
  text-align: center;
  padding: 5px 5px;
  text-decoration: none;
  font-size: 17px;
  font-family: "Poppins";
}

.mediaLogo {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 21px;
  height: 21px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.try {
  position: absolute;
  width: 100%;
  color: #fff;
  line-height: 40px;
  font-size: 0.7em;
  text-align: center;
  bottom: 0;
}

.footer {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  background-color: red;
  color: white;
  text-align: center;
}

<!DOCTYPE html>
<html lang="en-US">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<head>

  <title>Giving Back</title>

  <link href="simpleCSS.css" rel="stylesheet" type="text/css">
  <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
  <link rel="shortcut icon" type="image/png" href="name.png">
  <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
</head>

<body class="services">

  <div class="header">

    <a href="simple.html">
      <img src="name.png" alt="Logo" class="logo"> </a>

    <div class="navBar">
      <a href="ourstory.html" class="ourstory">Our Story</a>
      <a href="services.html" class="services">Giving Back</a>
    </div>

  </div>

  <br>
  <br>
  <br>

  <div class="main">
    <div class="content">

      <p class="p3"> content

      </p>
    </div>
  </div>

  <div class="footer">
    <div class="navbarSocialMedia">
      <a href="https://www.instagram.com/" target="_blank">
        <i class="fa fa-instagram"></i></a>
      <a href="https://www.linkedin.com" target="_blank">
        <i class="fa fa-linkedin"></i> </a>
      <a href="//www.google.com" target="_blank">
        <i class="fa fa-google"></i></a>
      <a href="https://www.facebook.com " target="_blank">
        <i class="fa fa-facebook"></i> </a>
    </div>
    <p class=" copyright ">Copyright &copy;. </p>
  </div>
</body>

</html>


问:
Entity Framework Core retrieving related entities
I'm new to EFC and was hoping to get some help with a problem I ran into.
Suppose I have two tables:

Tool table:

```<code>Version  FeatureId

1         1

1         2

1         4

2         1
</code>```

Feature Table:

```<code>FeatureId Name

1         feature1

2         feature2

3         feature3

4         feature4
</code>```

and based on these two tables I have the following:

```<code>public class Tool
{

public int Id {get; set;}

public int Version { get; set; }

public List<Feature> Features { get; set; }

}

public class Feature
{

public string FeatureId { get; set; }

public string Name { get; set; }
}
</code>```

so a tool version may include more than one features and a feature may be included in more than one version. When I tried to retrieve a tool based on the version number like this:

```<code>_context.Tool.Where(x => x.Version == versionID)
           .Include(i => i.Features)
           .ToList()
</code>```

I ran into an error asking for a ToolId. Why is that?

答:
a tool version may include more than one features and a feature may be included in more than one version.

So you have many-to-many relashionship, and your tables must look like below:

public class Tool
{
    public int Id {get; set;}
    public int Version { get; set; }
    public ICollection<Feature> Features { get; set; }
}

public class Feature
{
    public string FeatureId { get; set; }
    public string Name { get; set; }
    public ICollection<Tool> Tools { get; set; }
}
```

<p>And the missed one:</p>

<pre class="lang-cs prettyprint-override"><code>public class ToolsFeatures
{
    public int ToolId { get; set; }
    public Tool Tool { get; set; }

    public int FeatureId { get; set; }
    public Feature Feature { get; set; }
}
</code>```

Then configure the relashions the dbcontext:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<ToolsFeatures>()
        .HasKey(t => new { t.ToolId, t.FeatureId});

        modelBuilder.Entity<ToolsFeatures>()
            .HasOne(t => t.Tool)
            .WithMany(f => f.Features)
            .HasForeignKey(t => t.ToolId);

        modelBuilder.Entity<ToolsFeatures>()
            .HasOne(f => f.Feature)
            .WithMany(t => t.Tools)
            .HasForeignKey(f => f.FeatureId);
    }
```

See Many-to-Many relashions

Notice: You have FeatureId defined as string but it has int values! is there any mistake here?

Body:
I'm new to EFC and was hoping to get some help with a problem I ran into.
Suppose I have two tables:

Tool table:

Version  FeatureId

1         1

1         2

1         4

2         1

Feature Table:

FeatureId Name

1         feature1

2         feature2

3         feature3

4         feature4

and based on these two tables I have the following:

public class Tool
{

public int Id {get; set;}

public int Version { get; set; }

public List<Feature> Features { get; set; }

}

public class Feature
{

public string FeatureId { get; set; }

public string Name { get; set; }
}

so a tool version may include more than one features and a feature may be included in more than one version. When I tried to retrieve a tool based on the version number like this:

_context.Tool.Where(x => x.Version == versionID)
           .Include(i => i.Features)
           .ToList()

I ran into an error asking for a ToolId. Why is that?

Body:
a tool version may include more than one features and a feature may be included in more than one version.

So you have many-to-many relashionship, and your tables must look like below:

public class Tool
{
    public int Id {get; set;}
    public int Version { get; set; }
    public ICollection<Feature> Features { get; set; }
}

public class Feature
{
    public string FeatureId { get; set; }
    public string Name { get; set; }
    public ICollection<Tool> Tools { get; set; }
}

And the missed one:

public class ToolsFeatures
{
    public int ToolId { get; set; }
    public Tool Tool { get; set; }

    public int FeatureId { get; set; }
    public Feature Feature { get; set; }
}

Then configure the relashions the dbcontext:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<ToolsFeatures>()
        .HasKey(t => new { t.ToolId, t.FeatureId});

        modelBuilder.Entity<ToolsFeatures>()
            .HasOne(t => t.Tool)
            .WithMany(f => f.Features)
            .HasForeignKey(t => t.ToolId);

        modelBuilder.Entity<ToolsFeatures>()
            .HasOne(f => f.Feature)
            .WithMany(t => t.Tools)
            .HasForeignKey(f => f.FeatureId);
    }

See Many-to-Many relashions

Notice: You have FeatureId defined as string but it has int values! is there any mistake here?


问:
Optionnal parameter for a Javascript Function
I want to write an overload of a function in javascript. I tried optional parameter but it don't work.
What I tried:

```<code>let myFunction = (foo, bar) => {
 foo = (foo || 'FOO');
 console.log(foo + " " + bar);
}
</code>```

Here I expect: foo bar

```<code>myFunction("foo","bar");
</code>```

Here I expect: FOO bar

```<code>myFunction("bar");
</code>```

Anyone knows how to pass optional parameters to a function ?

答:
It's important to call a function with every parameters. Even with undefined values.

To obtain FOO bar

```<code> myFunction( undefined, "bar")
</code>```

Working js fiddle here

p.s: it's working with null as well

Body:
I want to write an overload of a function in javascript. I tried optional parameter but it don't work.
What I tried:

let myFunction = (foo, bar) => {
 foo = (foo || 'FOO');
 console.log(foo + " " + bar);
}

Here I expect: foo bar

myFunction("foo","bar");

Here I expect: FOO bar

myFunction("bar");

Anyone knows how to pass optional parameters to a function ?

Body:
It's important to call a function with every parameters. Even with undefined values.

To obtain FOO bar

 myFunction( undefined, "bar")

Working js fiddle here

p.s: it's working with null as well


问:
Dynamic row selection
I want to execute a series of code based on row number but want to keep the selection of row number flexible, so that i can execute code for row 15:15, 20:20 etc
here is the code i tried...</p>

```<code> Dim i As Integer
  i = 15

Rows("i:i").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Rows("i-1:i-1").Select
Selection.Copy
Rows("i:i").Select
ActiveSheet.Paste
Rows("i:i").Select
Application.CutCopyMode = False
With Selection.Interior
    .PatternColorIndex = xlAutomatic
    .Color = 65535
    .TintAndShade = 0
    .PatternTintAndShade = 0
End With
Range("Ei-1").Select
Selection.ClearContents
Range("Ei-1").Select
ActiveCell.FormulaR1C1 = "=RC[-1]+(R[1]C-RC[-1])/2"
Range("Ei").Select
</code>```

答:
Something like this:</p>

```<code>Dim i As Long
i = 15
Rows(i).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Rows(i - 1).Copy Rows(i)

With Rows(i).Interior
    .PatternColorIndex = xlAutomatic
    .Color = 65535
    .TintAndShade = 0
    .PatternTintAndShade = 0
End With
Range("E" & i - 1).FormulaR1C1 = "=RC[-1]+(R[1]C-RC[-1])/2"
</code>```

Title: Dynamic row selection

Body:
I want to execute a series of code based on row number but want to keep the selection of row number flexible, so that i can execute code for row 15:15, 20:20 etc
here is the code i tried...

 Dim i As Integer
  i = 15

Rows("i:i").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Rows("i-1:i-1").Select
Selection.Copy
Rows("i:i").Select
ActiveSheet.Paste
Rows("i:i").Select
Application.CutCopyMode = False
With Selection.Interior
    .PatternColorIndex = xlAutomatic
    .Color = 65535
    .TintAndShade = 0
    .PatternTintAndShade = 0
End With
Range("Ei-1").Select
Selection.ClearContents
Range("Ei-1").Select
ActiveCell.FormulaR1C1 = "=RC[-1]+(R[1]C-RC[-1])/2"
Range("Ei").Select

Body:
Something like this:

Dim i As Long
i = 15
Rows(i).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Rows(i - 1).Copy Rows(i)

With Rows(i).Interior
    .PatternColorIndex = xlAutomatic
    .Color = 65535
    .TintAndShade = 0
    .PatternTintAndShade = 0
End With
Range("E" & i - 1).FormulaR1C1 = "=RC[-1]+(R[1]C-RC[-1])/2"


问:
need direct3d model import example
Can someone point me to an example for loading a 3d model into a direct3d(9) scene?
I just want to be able to see the 3d model in my window.
Also, is there a 3d format that I can use that will already contain the surface coloring for me?

thanks

答: Theres a samples directory that comes with your direct x SDK install. Look there.</p>

Title: need direct3d model import example


问:
Powemock unable to mock class whose dependent class is not present
I am using the third party jar file which contains a class A. Class A is depends on the class B but this B class is not present in the jar file.
I am trying to mock the Class A but getting "NoClassDefFoundError" for the class B.
Is it possible to mock class A here? If yes could you please suggest a way to do it?</p>

答: Since you wont be using A or B (you will be mocking them) try to feed him a fake class B. Obviously you need to use the same package name as the original B. </p>


问:
Error: httpd24-tools conflicts with httpd-tools-2.2.34-1.16.amzn1.x86_64
Got these errors while installing and didn't find a specific answer for it.  So, I'm offering the solutions as I found them in case anyone else encounters this:

Error: httpd24 conflicts with httpd-2.2.31-1.8.amzn1.x86_64
Error: httpd24-tools conflicts with httpd-tools-2.2.34-1.16.amzn1.x86_64

The problem was encountered while trying to install https (mod24_ssl) over apache version 2.2.

答:
If you install Apache using "yum install httpd" then you're going to get version 2.2.  If you are getting this error then that's what you have.  You'll have to upgrade to Apache 2.4.  Hopefully you aren't so far in that you'll lose any work if you just delete version 2.2:</p>

```<code>sudo yum remove httpd
sudo yum remove httpd-tools
sudo yum install httpd24
</code>```

Body:
If you install Apache using "yum install httpd" then you're going to get version 2.2.  If you are getting this error then that's what you have.  You'll have to upgrade to Apache 2.4.  Hopefully you aren't so far in that you'll lose any work if you just delete version 2.2:

sudo yum remove httpd
sudo yum remove httpd-tools
sudo yum install httpd24