问:
I downloaded Live Speech to Text by Watson and I got this problem
I have downloaded Live Speech to Text with Watson Speech to Text and Python from :
https://github.com/nicknochnack/RealTimeSpeechToText

I put the apikey and the region in RealTimeSpeechToText-main\watson-streaming-stt\speech.cfg"

I don't know why this problem appears :

```<code>
Traceback (most recent call last):
  File "c:\Users\Ahmad Sadek\Desktop\RealTimeSpeechToText-main\watson-streaming-stt\transcribe.py", line 222, in <module>
    main()
  File "c:\Users\Ahmad Sadek\Desktop\RealTimeSpeechToText-main\watson-streaming-stt\transcribe.py", line 197, in main
    userpass = ":".join(get_auth())
  File "c:\Users\Ahmad Sadek\Desktop\RealTimeSpeechToText-main\watson-streaming-stt\transcribe.py", line 180, in get_auth
    apikey = config.get('auth', 'apikey')
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\configparser.py", line 782, in get
    d = self._unify_values(section, vars)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\configparser.py", line 1153, in _unify_values
    raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'auth'

</code>```

You have downloaded :
pyaudio
websocket-client

I am using Python 3.10.2 win 11 pro

what should I do?

答:
Looking at your error:

```<code>configparser.NoSectionError: No section: 'auth'
</code>```

The configuration file is missing an auth section.

Looking at the sample.

```<code>[auth]
apikey = <YOUR API KEY>
# Modify region based on where you provisioned your stt instance
region = <YOUR REGION>
</code>```

My guess is that you have deleted / edited the line [auth]

Body:
I have downloaded Live Speech to Text with Watson Speech to Text and Python from :
https://github.com/nicknochnack/RealTimeSpeechToText

I put the apikey and the region in RealTimeSpeechToText-main\watson-streaming-stt\speech.cfg"

I don't know why this problem appears :

Traceback (most recent call last):
  File "c:\Users\Ahmad Sadek\Desktop\RealTimeSpeechToText-main\watson-streaming-stt\transcribe.py", line 222, in <module>
    main()
  File "c:\Users\Ahmad Sadek\Desktop\RealTimeSpeechToText-main\watson-streaming-stt\transcribe.py", line 197, in main
    userpass = ":".join(get_auth())
  File "c:\Users\Ahmad Sadek\Desktop\RealTimeSpeechToText-main\watson-streaming-stt\transcribe.py", line 180, in get_auth
    apikey = config.get('auth', 'apikey')
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\configparser.py", line 782, in get
    d = self._unify_values(section, vars)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\configparser.py", line 1153, in _unify_values
    raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'auth'

You have downloaded :
pyaudio
websocket-client

I am using Python 3.10.2 win 11 pro

what should I do?

Body:
Looking at your error:

configparser.NoSectionError: No section: 'auth'

The configuration file is missing an auth section.

Looking at the sample.

[auth]
apikey = <YOUR API KEY>
# Modify region based on where you provisioned your stt instance
region = <YOUR REGION>

My guess is that you have deleted / edited the line [auth]


来源: stackexchange

问:
In flutter with riverpod, how to update state on a page already in the navigation stack
I have some flutter/riverpod/navigator 2.0 pages that follow this flow.

list of items page -> navigate to -> edit item page -> back button -> list of items page.

the issue is when one hits the back button, the list of items is not updated with the new content, since that page is cached in the navigation stack of pages.

Are there any suggestions on how to handle this case?

答:
Wouldn't this example help to solve it? The problem of navigation is there reduced to manipulating an immutable collection.

Strictly typed navigation is used. You can use navigate([Home(), Books(), Book(id: bookId)]); instead of navigate('home/books/$bookId'); in your code.

See riverpod_navigator_example

ContentLicense: CC BY-SA 4.0


问:
How to create a new text file on button click
Here is my problem:

I am developing a windows application

I am converting an image into text format, and saving it into a system location.

This is my code:

```<code>if (!System.IO.Directory.Exists("D:\\SaveImageOutPutFolder"))
{
    System.IO.Directory.CreateDirectory("D:\\SaveImageOutPutFolder");
    doc.Save(ConfigurationSettings.AppSettings["SaveImagefolderPath"] +@"\\MytxtFile.txt", Leadtools.Forms.DocumentWriters.DocumentFormat.Text, null);
    MessageBox.Show("folder created and image output saved");
}
else
{
    doc.Save(ConfigurationSettings.AppSettings["SaveImagefolderPath"] + @"\\MytxtFile.txt", Leadtools.Forms.DocumentWriters.DocumentFormat.Text, null);
    MessageBox.Show("ImageFolder is available  images are  Saved into folder Now");
}
</code>```

The problem is that it is not creating a new text file every time the button is clicked. It is writing to the same file. I want to create to a new txt file for every click.

Can anyboy help in this, and give me some sample code?

答:
You need to create or pass in a name, otherwise it will create the same file name every time - it's doing what you told it to do.  Try this:

```<code>// Assuming you have a string named fileName that holds the name of the file
if (!System.IO.Directory.Exists("D:\\SaveImageOutPutFolder"))
{
    System.IO.Directory.CreateDirectory("D:\\SaveImageOutPutFolder");
    doc.Save(ConfigurationSettings.AppSettings["SaveImagefolderPath"] + "\\" + fileName, Leadtools.Forms.DocumentWriters.DocumentFormat.Text, null);
        MessageBox.Show("folder created and image output saved");
}
else
{
    doc.Save(ConfigurationSettings.AppSettings["SaveImagefolderPath"] + "\\" + fileNAme, Leadtools.Forms.DocumentWriters.DocumentFormat.Text, null);
    MessageBox.Show("ImageFolder is available  images are  Saved into folder Now");
}
</code>```

How and when the variable fileName gets populated is up to you and the requirements of your program.

As zenwalker noted above, images are binary, so saving it to a text file is questionable; but as to your original question, the above should fix it.

EDIT
Another thing to be careful of - in your code you're explicitly checking for D:\SaveImageOutPutFolder, and creating it if it does not exist, but you're building the path based on the value of SaveImagefolderPath in your config file.  That could cause problems if the value in your config file is not D:\SaveImageOutPutFolder.  Suggest you do something like this:

```<code>string outputFolder = ConfigurationSettings.AppSettings["SaveImagefolderPath"];

if (!System.IO.Directory.Exists(outputFolder)
{
    System.IO.Directory.CreateDirectory(outputFolder);
    MessageBox.Show("Folder created");
}

doc.Save(outputFolder + "\\" + fileName, Leadtools.Forms.DocumentWriters.DocumentFormat.Text, null);
MessageBox.Show("ImageFolder is available images are saved into folder now");
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Here is my problem:

I am developing a windows application

I am converting an image into text format, and saving it into a system location.

This is my code:

if (!System.IO.Directory.Exists("D:\\SaveImageOutPutFolder"))
{
    System.IO.Directory.CreateDirectory("D:\\SaveImageOutPutFolder");
    doc.Save(ConfigurationSettings.AppSettings["SaveImagefolderPath"] +@"\\MytxtFile.txt", Leadtools.Forms.DocumentWriters.DocumentFormat.Text, null);
    MessageBox.Show("folder created and image output saved");
}
else
{
    doc.Save(ConfigurationSettings.AppSettings["SaveImagefolderPath"] + @"\\MytxtFile.txt", Leadtools.Forms.DocumentWriters.DocumentFormat.Text, null);
    MessageBox.Show("ImageFolder is available  images are  Saved into folder Now");
}

The problem is that it is not creating a new text file every time the button is clicked. It is writing to the same file. I want to create to a new txt file for every click.

Can anyboy help in this, and give me some sample code?

Body:
You need to create or pass in a name, otherwise it will create the same file name every time - it's doing what you told it to do.  Try this:

// Assuming you have a string named fileName that holds the name of the file
if (!System.IO.Directory.Exists("D:\\SaveImageOutPutFolder"))
{
    System.IO.Directory.CreateDirectory("D:\\SaveImageOutPutFolder");
    doc.Save(ConfigurationSettings.AppSettings["SaveImagefolderPath"] + "\\" + fileName, Leadtools.Forms.DocumentWriters.DocumentFormat.Text, null);
        MessageBox.Show("folder created and image output saved");
}
else
{
    doc.Save(ConfigurationSettings.AppSettings["SaveImagefolderPath"] + "\\" + fileNAme, Leadtools.Forms.DocumentWriters.DocumentFormat.Text, null);
    MessageBox.Show("ImageFolder is available  images are  Saved into folder Now");
}

How and when the variable fileName gets populated is up to you and the requirements of your program.

As zenwalker noted above, images are binary, so saving it to a text file is questionable; but as to your original question, the above should fix it.

EDIT
Another thing to be careful of - in your code you're explicitly checking for D:\SaveImageOutPutFolder, and creating it if it does not exist, but you're building the path based on the value of SaveImagefolderPath in your config file.  That could cause problems if the value in your config file is not D:\SaveImageOutPutFolder.  Suggest you do something like this:

string outputFolder = ConfigurationSettings.AppSettings["SaveImagefolderPath"];

if (!System.IO.Directory.Exists(outputFolder)
{
    System.IO.Directory.CreateDirectory(outputFolder);
    MessageBox.Show("Folder created");
}

doc.Save(outputFolder + "\\" + fileName, Leadtools.Forms.DocumentWriters.DocumentFormat.Text, null);
MessageBox.Show("ImageFolder is available images are saved into folder now");


问:
Should I move my static resources from App Engine to Google Cloud Storage?
We have a web application in App Engine. I was wondering whether it is a good idea to move my static resources (i.e Images, CSS files, and JS files) out from App Engine and serve them from Google Cloud Storage.

My thinking here is two-fold:

1) We can get the advantages of a CDN with Google Cloud Storage. We can even configure metadata for each file to set expiration headers, gzip compression, etc. Also, by serving files from different domains we can have browsers download more content in parallel.

2) By off-loading some of the files from App Engine, the instance consumption is going to decrease (less requests to App Engine), so the costs will go down.

Am I right? Is this a wise move?

Thanks,

答:
Moving static assets to Google cloud storage is recommended and has many advantages, have a look at this:
https://cloud.google.com/storage/docs/static-website
and personally it improves my webapp performance and reduces load on server.</p>


问:
Tensorflow, multi-label confusion matrix
I am trying to figure out how to the generate a confusion matrix for a multi-label classification task using neural networks. I previously managed to calculate the accuracy using the function "intersection", since for that I did not care about any ordering.

```<code>intersection = tf.sets.set_intersection(predictions, labels)
</code>```

However, in order to calculate the confusion matrix, I do care about the indexing order of the predictions/labels. And since the labels have always the same value (1,1 or 0.5,0.5) there is no possible sorting according to higher/lower value.

I wonder:

1) Is it possible to calculate a confusion matrix for the multi-label classification task?

2) How would that be implemented ?

3) How can you handle the case of failure in predicting both labels? Since it is not possible to know which confusion belongs to which prediction.

4) What is the logic behind the sorting of the function tf.nn.top_k()

Below I show an example of the code that I was trying to use.

```<code>import numpy as np
import tensorflow as tf
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix

Z = np.array([[7.0, 3.0, 5.0, 1.0, 0.0, 6.0],[2.0, 3.0, 4.0, 1.0, 3.25, 2.2], [2.0 , 5.0, 1.0, 7.0, 0.0, 8.0]])
Y = np.array([[0.5, 0, 0, 0.0, 0, 0.5],[0, 0.0, 0.5, 0, 0.5, 0], [0,0,0,0.5,0,0.5]])

_, predicted_softmax = tf.nn.top_k(tf.nn.softmax(Z), k = 2, sorted = False)
_ , labels = tf.nn.top_k(Y, k = 2, sorted = False)

with tf.Session() as sess:
    # reshape to (6,1) because there is 2 correct values per sample(2*3)
    print(predicted_softmax.eval().reshape(6,1))
    print(labels.eval().reshape(6,1))
    predicted = predicted_softmax.eval().reshape(6,1)
    labels_idx = labels.eval().reshape(6,1)

class_labels = np.arange(6)
cnf_matrix_train = confusion_matrix(labels_idx, predicted, labels = class_labels)

print(cnf_matrix_train)
</code>```

I don't really get why the output of predicted_softmax is:

```<code>[[5] [0] [4] [2] [3] [5]] ,
</code>```

I was expecting [5] [3] for the last two terms. There is no any logic to this output. In the documentation they don't specify anything about the ordering in the case that sorted = False thought, but I was expecting some consistent behavior.

Thanks for any help!

答:
Is it possible to calculate a confusion matrix for the multi-label classification task?

Yes and no. You can only calculate a TN (true negative), TP (true positive), FN (false negative), FP (false positive) matrix for each class and derive some other metrics based on this. It will not show you, how a specific class has been mis-classified as a specific other class, but only that is has been misclassified and how (FN or FP).

Source: Wikipedia

How would that be implemented ?

You could simply use MultiLabelConfusionMatrix from the TensorFlow add-on package. It gives you just that: a 2x2 matrix for each class, containing TN, TP, FN and FP.

Note that the implementation currently seems to assume that y_pred and y_true are binary tensors, i.e. consists of only 0s and 1s (cast to int).

How can you handle the case of failure in predicting both labels? Since it is not possible to know which confusion belongs to which prediction.

Exactly. You can't.

What is the logic behind the sorting of the function tf.nn.top_k()

The docs says:

If true the resulting k elements will be sorted by the values in descending order.

For example, tf.nn.top_k([10, 3, 1, 11], k=3), could return [10, 3, 11] (no order).

When sorting, tf.nn.top_k([10, 3, 1, 11], k=3) returns [11, 10, 3] (descending order).

(for clarity, please ignore for a second, that it would of course return a tensor, not a regular list)

Body:
I am trying to figure out how to the generate a confusion matrix for a multi-label classification task using neural networks. I previously managed to calculate the accuracy using the function "intersection", since for that I did not care about any ordering.

intersection = tf.sets.set_intersection(predictions, labels)

However, in order to calculate the confusion matrix, I do care about the indexing order of the predictions/labels. And since the labels have always the same value (1,1 or 0.5,0.5) there is no possible sorting according to higher/lower value.

I wonder:

1) Is it possible to calculate a confusion matrix for the multi-label classification task?

2) How would that be implemented ?

3) How can you handle the case of failure in predicting both labels? Since it is not possible to know which confusion belongs to which prediction.

4) What is the logic behind the sorting of the function tf.nn.top_k()

Below I show an example of the code that I was trying to use.

import numpy as np
import tensorflow as tf
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix

Z = np.array([[7.0, 3.0, 5.0, 1.0, 0.0, 6.0],[2.0, 3.0, 4.0, 1.0, 3.25, 2.2], [2.0 , 5.0, 1.0, 7.0, 0.0, 8.0]])
Y = np.array([[0.5, 0, 0, 0.0, 0, 0.5],[0, 0.0, 0.5, 0, 0.5, 0], [0,0,0,0.5,0,0.5]])

_, predicted_softmax = tf.nn.top_k(tf.nn.softmax(Z), k = 2, sorted = False)
_ , labels = tf.nn.top_k(Y, k = 2, sorted = False)

with tf.Session() as sess:
    # reshape to (6,1) because there is 2 correct values per sample(2*3)
    print(predicted_softmax.eval().reshape(6,1))
    print(labels.eval().reshape(6,1))
    predicted = predicted_softmax.eval().reshape(6,1)
    labels_idx = labels.eval().reshape(6,1)

class_labels = np.arange(6)
cnf_matrix_train = confusion_matrix(labels_idx, predicted, labels = class_labels)

print(cnf_matrix_train)

I don't really get why the output of predicted_softmax is:

[[5] [0] [4] [2] [3] [5]] ,

I was expecting [5] [3] for the last two terms. There is no any logic to this output. In the documentation they don't specify anything about the ordering in the case that sorted = False thought, but I was expecting some consistent behavior.

Thanks for any help!


问:
Folium popup does not appear python
I have a geodataframe with Multistring Geometry. I wanted to plot an interactive map, on which when I click on each line, the name and id would appear! I can see that mouse form would change but nothing will appear. I also tried to define the names as labels but it did not work!

```<code>Ex_centreLine_map= folium.Map(location = [43.7180, -79.3762], zoom_start=12)

folium.Choropleth(
    centreline_gdf[centreline_gdf.geometry.length> 0.00001],
    line_weight=3,
    line_color='blue',
    popup=centreline_gdf[['lf_name', 'lfn_id']]).add_to(Ex_centreLine_map)
Ex_centreLine_map
</code>```

Title: Folium popup does not appear python

Body:
I have a geodataframe with Multistring Geometry. I wanted to plot an interactive map, on which when I click on each line, the name and id would appear! I can see that mouse form would change but nothing will appear. I also tried to define the names as labels but it did not work!

Ex_centreLine_map= folium.Map(location = [43.7180, -79.3762], zoom_start=12)

folium.Choropleth(
    centreline_gdf[centreline_gdf.geometry.length> 0.00001],
    line_weight=3,
    line_color='blue',
    popup=centreline_gdf[['lf_name', 'lfn_id']]).add_to(Ex_centreLine_map)
Ex_centreLine_map

Body:
you have not provided any sample data, so I have used some road data to make a MWE

you can do native folium however it's simpler to use geopandas explore()

for native folium you can to use folium.GeoJson()

import geopandas as gpd
import pandas as pd
import shapely.wkt
import io

df = pd.read_csv(io.StringIO("""ref;lanes;highway;maxspeed;length;name;geometry
A3015;2;primary;40 mph;40.68;Rydon Lane;MULTILINESTRING ((-3.4851169 50.70864409999999, -3.4849879 50.7090007), (-3.4857269 50.70693379999999, -3.4853034 50.7081574), (-3.488620899999999 50.70365289999999, -3.4857269 50.70693379999999), (-3.4853034 50.7081574, -3.4851434 50.70856839999999), (-3.4851434 50.70856839999999, -3.4851169 50.70864409999999))
A379;3;primary;50 mph;177.963;Rydon Lane;MULTILINESTRING ((-3.4763853 50.70886769999999, -3.4786112 50.70811229999999), (-3.4746017 50.70944449999999, -3.4763853 50.70886769999999), (-3.470350900000001 50.71041779999999, -3.471219399999999 50.71028909999998), (-3.465049699999999 50.712158, -3.470350900000001 50.71041779999999), (-3.481215600000001 50.70762499999999, -3.4813909 50.70760109999999), (-3.4934747 50.70059599999998, -3.4930204 50.7007898), (-3.4930204 50.7007898, -3.4930048 50.7008015), (-3.4930048 50.7008015, -3.4919513 50.70168349999999), (-3.4919513 50.70168349999999, -3.49137 50.70213669999998), (-3.49137 50.70213669999998, -3.4911565 50.7023015), (-3.4911565 50.7023015, -3.4909108 50.70246919999999), (-3.4909108 50.70246919999999, -3.4902349 50.70291189999999), (-3.4902349 50.70291189999999, -3.4897693 50.70314579999999), (-3.4805021 50.7077218, -3.4806265 50.70770150000001), (-3.488620899999999 50.70365289999999, -3.4888806 50.70353719999999), (-3.4897693 50.70314579999999, -3.489176800000001 50.70340539999999), (-3.489176800000001 50.70340539999999, -3.4888806 50.70353719999999), (-3.4865751 50.70487679999999, -3.4882604 50.70375799999999), (-3.479841700000001 50.70784459999999, -3.4805021 50.7077218), (-3.4882604 50.70375799999999, -3.488620899999999 50.70365289999999), (-3.4806265 50.70770150000001, -3.481215600000001 50.70762499999999), (-3.4717096 50.71021009999998, -3.4746017 50.70944449999999), (-3.4786112 50.70811229999999, -3.479841700000001 50.70784459999999), (-3.471219399999999 50.71028909999998, -3.4717096 50.71021009999998))"""),
           sep=";")

gdf = gpd.GeoDataFrame(df, geometry=df["geometry"].apply(shapely.wkt.loads), crs="epsg:4326")

gdf.explore(style_kwds={"weight":10})

native folium

import folium

m = folium.Map(
    location=[sum(gdf.total_bounds[[1, 3]]) / 2, sum(gdf.total_bounds[[0, 2]]) / 2],
    zoom_start=12,
)

def style_fn(x):
    return {"color":"blue", "weight":3}

folium.GeoJson(
    gdf,
    style_function=style_fn,
    popup=folium.GeoJsonPopup(gdf.drop(columns=["geometry"]).columns.tolist()),
    tooltip=folium.GeoJsonTooltip(["ref"]),
).add_to(m)

m


问:
How is this nested loop algorithm analyzed?
So i have this algorithm analysis from my lecturer i need some help why the outer loop is n - 1 , isn't it should be n - 2? and the inner loop should be log3 (n) instead of log3(n) + 1

```<code>for(int a=3; a<=n; a++)                 n+1-2 = n-1

      for(int a=1; a<n; a=a*3)          log3 (n) +1

          System.out.println(a);         log3 (n)
</code>```

Total    =(n - 1)* (log3 (n)+1+log3 (n))

```<code>     =(n-1)*(2 log3(n) + 1)

     =2(n log3(n))+n -1 – 2 log3(n)

     =n log3(n) + n – log3(n)
</code>```

Is this correct answer for algorithmn analysis? thats what my lecturer showed me. Anyone can explain to me?

答:
If you want a very precise count of the operations, it's important to specify: what operations are you counting? Number of increments a++? Number of comparisons a<=n? Number of executions of the loop body?

If you don't specify which operation you're counting, then there is not much sense in worrying about an extra +1 or -1.

Note that the variable used as counter for the outer loop is called a and the variable used as counter for the inner loop is also called a. While this is possible to do in C++, I strongly recommend not doing it. It's confusing and a good source of errors.

The outer loop is going to run for n-2 iterations. The inner loop is going to run for ceil(log3(n)) iterations (where ceil is the ceiling function). The line System.out.println(a) is not a loop, it's just one line of code, so you could write "1" on that line if you wanted; there is not much sense in writing "log3(n)" here.

The total number of times the line System.out.println(a) is executed is thus:

(n - 2) ceil(log3(n)).

It is possible that you might want to count the exact number of characters written. Again, we're coming back to the fact that you didn't specify what it is that you were counting. The number of characters depends on the exact value of a, so it changes at each iteration of the loop. But all in all, each call to System.out.println(a) prints about log10(n) characters, since we're writing in decimal.

Body:
So i have this algorithm analysis from my lecturer i need some help why the outer loop is n - 1 , isn't it should be n - 2? and the inner loop should be log3 (n) instead of log3(n) + 1

for(int a=3; a<=n; a++)                 n+1-2 = n-1

      for(int a=1; a<n; a=a*3)          log3 (n) +1

          System.out.println(a);         log3 (n)

Total    =(n - 1)* (log3 (n)+1+log3 (n))

     =(n-1)*(2 log3(n) + 1)

     =2(n log3(n))+n -1 – 2 log3(n)

     =n log3(n) + n – log3(n)

Is this correct answer for algorithmn analysis? thats what my lecturer showed me. Anyone can explain to me?


问:
"page-break-before: always" not working as intended after updating chrome from v97 to v98
https://cbbanalytics.com/stats/27694/games/1864019/overview - page-break-before is not working as intended on this page following chrome update from v97 to v98. In the screenshot below:

The highlighted
 element has the class print-break, which simply adds the CSS style page-break-before: always. However, when we pull up the print window (CMD+P on mac) and set Margins: None, the print break is not correct on chrome v98. On a colleague's laptop that still has Chrome v97 and the page-break-before works just fine.

We're not sure if this an issue with Chrome v98 or with our site's CSS and html. I created a simple html file with just a few
 tags and a page-break-before and the page break worked fine for me locally in chrome. Quite frankly, it seems like chrome is miscalculating the page size for print, it is just so strange that the page break starts at the bottom of the previous page... Changing Margins: from None to either Default or Minimum does resolve the issue on this page, however there are many pages on our site where the page-break-before is buggy regardless of print margins.

答:
(1) Meh Option - Changing Margins: from None to either Default or Minimum seems to resolve our issue... We prefer None for saving pages on our site to PDF without a white border around the page, however Default looks just fine otherwise and we can use this.

(2) Better Option - Adding width: 100.25% to the div with class controller-navbar-container  fixes this issue on this page and on every other page on the site as well. I am not sure why this is the case.


问:
Selenium (Python) - NoSuchElementException: Message: no such element: Unable to locate element
I'm trying to make a simple script that goes to the homepage of The Whiskey Exchange, clicks on the following menu item, navigates to the new page and finally grabs a screenshot.

```<code>from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By

chrome_options = Options()

driver = webdriver.Chrome(options=chrome_options)
driver.get("https://www.thewhiskyexchange.com/")
driver.implicitly_wait(3)

search_bar = driver.find_element(
    By.XPATH, "/html/body/div[3]/nav/div/div[3]/div/div/div[2]/a[2]")
search_bar.click()
driver.implicitly_wait(3)

driver.save_screenshot('./image.png')
driver.quit()
</code>```

I've tried multiple approaches to get this to work, mainly by changing the type of finder, but with no luck. I've tried copying both XPATH and Full XPATH (directly from chrome), but that hasn't worked either. Maybe it's something to do with how the site is built, but no idea.

I'm getting the following error message:

```<code>NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[3]/nav/div/div[3]/div/div/div[2]/a[2]"}
</code>```

First time using selenium, so the struggle is a bit real. Please help.

答:
To expand the Scotch Whisky menu you don't need to click on the item, instead you can simply Mouse Hover and grab a screenshot of the webpage using either of the following Locator Strategies:

Using CSS_SELECTOR:

```<code>driver.get('https://www.thewhiskyexchange.com/')
ActionChains(driver).move_to_element(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "a[title='Scotch Whisky']")))).perform()
driver.save_screenshot('./Scotch_Whisky.png')
driver.quit()
</code>```

Using XPATH:

```<code>driver.get('https://www.thewhiskyexchange.com/')
ActionChains(driver).move_to_element(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//a[@title='Scotch Whisky']")))).perform()
driver.save_screenshot('./Scotch_Whisky.png')
driver.quit()
</code>```

Note : You have to add the following imports :

```<code>from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
</code>```

Screenshot:

Body:
I'm trying to make a simple script that goes to the homepage of The Whiskey Exchange, clicks on the following menu item, navigates to the new page and finally grabs a screenshot.

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By

chrome_options = Options()

driver = webdriver.Chrome(options=chrome_options)
driver.get("https://www.thewhiskyexchange.com/")
driver.implicitly_wait(3)

search_bar = driver.find_element(
    By.XPATH, "/html/body/div[3]/nav/div/div[3]/div/div/div[2]/a[2]")
search_bar.click()
driver.implicitly_wait(3)

driver.save_screenshot('./image.png')
driver.quit()

I've tried multiple approaches to get this to work, mainly by changing the type of finder, but with no luck. I've tried copying both XPATH and Full XPATH (directly from chrome), but that hasn't worked either. Maybe it's something to do with how the site is built, but no idea.

I'm getting the following error message:

NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[3]/nav/div/div[3]/div/div/div[2]/a[2]"}

First time using selenium, so the struggle is a bit real. Please help.

Body:
To expand the Scotch Whisky menu you don't need to click on the item, instead you can simply Mouse Hover and grab a screenshot of the webpage using either of the following Locator Strategies:

Using CSS_SELECTOR:

driver.get('https://www.thewhiskyexchange.com/')
ActionChains(driver).move_to_element(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "a[title='Scotch Whisky']")))).perform()
driver.save_screenshot('./Scotch_Whisky.png')
driver.quit()

Using XPATH:

driver.get('https://www.thewhiskyexchange.com/')
ActionChains(driver).move_to_element(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//a[@title='Scotch Whisky']")))).perform()
driver.save_screenshot('./Scotch_Whisky.png')
driver.quit()

Note : You have to add the following imports :

from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

Screenshot:


问:
NSMutableArray Init troubles
I have this method dealing with a couple array that I can't seem to get right.  Something related to the alloc and init.  </p>

```<code>- (void)addBookmark
{
    // Get the user defaults object
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];

    // Load your bookmarks (editable array)
    NSMutableArray *bookmarks = [[NSMutableArray alloc]init];
    NSArray *bookmarksLoaded = [userDefaults arrayForKey:@"bookmarks"];
    if (bookmarksLoaded != nil) {
        [bookmarks initWithArray:bookmarksLoaded];
    } else {
        [bookmarks init];
    }

    // Add a bookmark
    NSMutableDictionary *bookmark = [NSMutableDictionary new];
    [bookmark setValue:@"value" forKey:@"name"];
    [bookmark setValue:@"value" forKey:@"description"];
    [bookmark setValue:@"value" forKey:@"code"];
    [bookmarks addObject:bookmark];

    // Save your (updated) bookmarks
    [userDefaults setObject:bookmarks forKey:@"bookmarks"];
    [userDefaults synchronize];

    // Memory cleanup
    [bookmarks release];
}
</code>```

答:
```<code>NSMutableArray *bookmarks = [[NSMutableArray alloc]init];
NSArray *bookmarksLoaded = [userDefaults arrayForKey:@"bookmarks"];
if (bookmarksLoaded != nil) {
    [bookmarks initWithArray:bookmarksLoaded];
} else {
    [bookmarks init];
}
</code>```

The problem with above code is you are initing bookmarks everywhere..Any object in objective C must be inited once..I will rewrite your code as

```<code>NSMutableArray *bookmarks = nil;
NSArray *bookmarksLoaded = [userDefaults arrayForKey:@"bookmarks"];
if (bookmarksLoaded != nil) {
    bookmarks            = [[NSMutableArray alloc] initWithArray:bookmarksLoaded];
} else {
    bookmarks     =  [[NSMutableArray alloc] init];
}
</code>```

Also you must release NSMutableDictionary bookmark since you are creating it via new..

```<code>NSMutableDictionary *bookmark = [NSMutableDictionary new];
[bookmark setValue:@"value" forKey:@"name"];
[bookmark setValue:@"value" forKey:@"description"];
[bookmark setValue:@"value" forKey:@"code"];
[bookmarks addObject:bookmark];
 [bookmark release];
</code>```

Additionally, from the code it is understood that you haven't grasped memory management in iphone yet..To be a successful iOS developer, you must study that first..

Title: NSMutableArray Init troubles

Body:
I have this method dealing with a couple array that I can't seem to get right.  Something related to the alloc and init.

- (void)addBookmark
{
    // Get the user defaults object
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];

    // Load your bookmarks (editable array)
    NSMutableArray *bookmarks = [[NSMutableArray alloc]init];
    NSArray *bookmarksLoaded = [userDefaults arrayForKey:@"bookmarks"];
    if (bookmarksLoaded != nil) {
        [bookmarks initWithArray:bookmarksLoaded];
    } else {
        [bookmarks init];
    }

    // Add a bookmark
    NSMutableDictionary *bookmark = [NSMutableDictionary new];
    [bookmark setValue:@"value" forKey:@"name"];
    [bookmark setValue:@"value" forKey:@"description"];
    [bookmark setValue:@"value" forKey:@"code"];
    [bookmarks addObject:bookmark];

    // Save your (updated) bookmarks
    [userDefaults setObject:bookmarks forKey:@"bookmarks"];
    [userDefaults synchronize];

    // Memory cleanup
    [bookmarks release];
}

Body:
NSMutableArray *bookmarks = [[NSMutableArray alloc]init];
NSArray *bookmarksLoaded = [userDefaults arrayForKey:@"bookmarks"];
if (bookmarksLoaded != nil) {
    [bookmarks initWithArray:bookmarksLoaded];
} else {
    [bookmarks init];
}

The problem with above code is you are initing bookmarks everywhere..Any object in objective C must be inited once..I will rewrite your code as

NSMutableArray *bookmarks = nil;
NSArray *bookmarksLoaded = [userDefaults arrayForKey:@"bookmarks"];
if (bookmarksLoaded != nil) {
    bookmarks            = [[NSMutableArray alloc] initWithArray:bookmarksLoaded];
} else {
    bookmarks     =  [[NSMutableArray alloc] init];
}

Also you must release NSMutableDictionary bookmark since you are creating it via new..

NSMutableDictionary *bookmark = [NSMutableDictionary new];
[bookmark setValue:@"value" forKey:@"name"];
[bookmark setValue:@"value" forKey:@"description"];
[bookmark setValue:@"value" forKey:@"code"];
[bookmarks addObject:bookmark];
 [bookmark release];

Additionally, from the code it is understood that you haven't grasped memory management in iphone yet..To be a successful iOS developer, you must study that first..


问:
How to make CupertinoActivityIndicator fully white

I want to change the barBackgroundColor  and primary Color fully white of CupertinoActivityIndicator but it show grey here is two colors one is white and the second one is grey i want to make both fully white.

```<code> Container(
        height: 80,
        width: 80,
        decoration: BoxDecoration(
            color: Colors.black,
          borderRadius: BorderRadius.circular(8)
        ),
        child: Theme(
            data: ThemeData(
                cupertinoOverrideTheme:
                    CupertinoThemeData(     brightness: Brightness.dark,
                      primaryColor: CupertinoColors.extraLightBackgroundGray,
                      barBackgroundColor: CupertinoColors.extraLightBackgroundGray,
                      scaffoldBackgroundColor: CupertinoColors.black,)),
            child: CupertinoActivityIndicator(animating: true, radius: 20,)),
      ),
</code>```

i also change the color but it Still Not Wroking Please tell me how can i get fully white indicator

```<code>Container(
    height: 80,
    width: 80,
    decoration: BoxDecoration(
        color: Colors.black,
      borderRadius: BorderRadius.circular(8)
    ),
    child: Theme(
        data: ThemeData(
            cupertinoOverrideTheme:
                CupertinoThemeData(
                  brightness: Brightness.dark,
                  primaryColor:   CupertinoDynamicColor.withBrightness(
                color: CupertinoColors.white,
                  darkColor: CupertinoColors.white,
                ),
                  barBackgroundColor:   CupertinoDynamicColor.withBrightness(
                    color: CupertinoColors.white,
                    darkColor: CupertinoColors.white,
                  ),
                  scaffoldBackgroundColor:   CupertinoDynamicColor.withBrightness(
                    color: CupertinoColors.white,
                    darkColor: CupertinoColors.white,
                  ),
                )),
        child: CupertinoActivityIndicator(animating: true, radius: 20,)),
  ),
</code>```

答:
I found alot of folks onlile asking the same question, while the native platform allow modification it got me wondering why did the remove they parameter ?

Anyhow, a quick work around this would be using color filters like:

Widget withColor(Color color) => ColorFiltered(
      colorFilter: ColorFilter.mode(
        color,
        BlendMode.srcATop,
      ),
      child: const CupertinoActivityIndicator(),
    );
```

Body:
I want to change the barBackgroundColor  and primary Color fully white of CupertinoActivityIndicator but it show grey here is two colors one is white and the second one is grey i want to make both fully white.

 Container(
        height: 80,
        width: 80,
        decoration: BoxDecoration(
            color: Colors.black,
          borderRadius: BorderRadius.circular(8)
        ),
        child: Theme(
            data: ThemeData(
                cupertinoOverrideTheme:
                    CupertinoThemeData(     brightness: Brightness.dark,
                      primaryColor: CupertinoColors.extraLightBackgroundGray,
                      barBackgroundColor: CupertinoColors.extraLightBackgroundGray,
                      scaffoldBackgroundColor: CupertinoColors.black,)),
            child: CupertinoActivityIndicator(animating: true, radius: 20,)),
      ),

i also change the color but it Still Not Wroking Please tell me how can i get fully white indicator

Container(
    height: 80,
    width: 80,
    decoration: BoxDecoration(
        color: Colors.black,
      borderRadius: BorderRadius.circular(8)
    ),
    child: Theme(
        data: ThemeData(
            cupertinoOverrideTheme:
                CupertinoThemeData(
                  brightness: Brightness.dark,
                  primaryColor:   CupertinoDynamicColor.withBrightness(
                color: CupertinoColors.white,
                  darkColor: CupertinoColors.white,
                ),
                  barBackgroundColor:   CupertinoDynamicColor.withBrightness(
                    color: CupertinoColors.white,
                    darkColor: CupertinoColors.white,
                  ),
                  scaffoldBackgroundColor:   CupertinoDynamicColor.withBrightness(
                    color: CupertinoColors.white,
                    darkColor: CupertinoColors.white,
                  ),
                )),
        child: CupertinoActivityIndicator(animating: true, radius: 20,)),
  ),


问:
Can I disable the emacs wanderlust splash screen?
I have searched the wanderlust docs for all the keywords I could think of, to no avail.

When I start wanderlust, there is a very ugly splash screen while the program initializes. Can I disable that somehow? Emacs hangs for about a second after that splash screen has gone anyway, so I would prefer it to hang for two seconds instead and not show the splash.

答:
I don't know much about this library, but IIUC you're looking for this:

M-x customize-option RET wl-demo RET


问:
AIR - StageWebView on iPhone
I am using Flash Builder 4.5 to build an iPhone app.

In order to display ads I plan to use StageWebView and load a webpage containing the ad code.

Lets say the ad will be 320x50 pixels. So the Actionscript code would look similar to this:

```<code>adView = new StageWebView();
adView.loadURL("http://www.myadishere.com/ad.html");
var top:Number = navigator.actionBar.measuredHeight + 1
adView.viewPort = new Rectangle(0, top, 320, 50);
adView.stage = stage;
</code>```

In the application I have set the applicationDPI="160" so the application is displayed properly when run on iPhone3 and iPhone4.
However the content of the StageWebView looks tiny on iPhone4.
If I do adView.drawViewPortToBitmapData() the bitmap's size is OK.

So the question is how to make the StageWebView content to scale accordingly, so it looks OK regardless of the screen DPI?

答:
```<code> You need to scale by yourself. Here is sample code.

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
         xmlns:s="library://ns.adobe.com/flex/spark" width="100%" height="100%" top="0">
    <fx:Declarations>
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            import mx.core.FlexGlobals;
            import mx.core.IVisualElement;
            import mx.events.FlexEvent;

            import spark.components.View;
            import spark.events.ViewNavigatorEvent;

            [Bindable]
            public var htmlText:String;
            public var url:String;
            private var swv:StageWebView;
            private function resizeSWV():void{
                var currentFlexScalingFactor:Number=FlexGlobals.topLevelApplication.runtimeDPI/FlexGlobals.topLevelApplication.applicationDPI;
                if(swv!=null){

    //swv.viewPort=new Rectangle(0, stage.stageHeight-height*currentFlexScalingFactor-FlexGlobals.topLevelApplication.tabbedNavigator.tabBar.height*currentFlexScalingFactor,width*currentFlexScalingFactor,height*currentFlexScalingFactor);

    swv.viewPort=new Rectangle(0, systemManager.screen.height*currentFlexScalingFactor-height*currentFlexScalingFactor-FlexGlobals.topLevelApplication.tabbedNavigator.tabBar.height*currentFlexScalingFactor,width*currentFlexScalingFactor,height*currentFlexScalingFactor);

                }
            }

        ]]>
    </fx:Script>
    <s:creationComplete>
        <![CDATA[
        swv=new StageWebView();
        resizeSWV();
        swv.stage=stage;

        var htmlString:String=htmlText;
        var urlL:String=url;

        swv.loadURL(url);
        (owner as View).addEventListener(ViewNavigatorEvent.REMOVING,
        function(event:ViewNavigatorEvent):void{
            swv.viewPort=null;
            swv.dispose();
            swv=null;
        }
        );
        ]]>
    </s:creationComplete>
    <s:resize>
        resizeSWV();
    </s:resize>
</s:Group>

 This is for TabbedViewNavigatorApplication.
</code>```

Title: AIR - StageWebView on iPhone

Body:
I am using Flash Builder 4.5 to build an iPhone app.

In order to display ads I plan to use StageWebView and load a webpage containing the ad code.

Lets say the ad will be 320x50 pixels. So the Actionscript code would look similar to this:

adView = new StageWebView();
adView.loadURL("http://www.myadishere.com/ad.html");
var top:Number = navigator.actionBar.measuredHeight + 1
adView.viewPort = new Rectangle(0, top, 320, 50);
adView.stage = stage;

In the application I have set the applicationDPI="160" so the application is displayed properly when run on iPhone3 and iPhone4.
However the content of the StageWebView looks tiny on iPhone4.
If I do adView.drawViewPortToBitmapData() the bitmap's size is OK.

So the question is how to make the StageWebView content to scale accordingly, so it looks OK regardless of the screen DPI?


问:
How to get the name of a type as a string
I wish to get the name of a type as shown in the example below.

Can it be achieved ?

type Type = 1

type TypeName <T> = `Type name is ${T & string}`

type NameOfType = TypeName <Type> // never, expected 'Type name is Type'
```

playground link

答:
You can't do that. TypeScrip is just an extortion of JavaScript. Where are no types and generics in runtime. Types exist only in context of TypeScript.

Your question is similar to this one.
How to get Generic class<T> name of typescript?

Body:
I wish to get the name of a type as shown in the example below.

Can it be achieved ?

type Type = 1

type TypeName <T> = `Type name is ${T & string}`

type NameOfType = TypeName <Type> // never, expected 'Type name is Type'

playground link


问:
How can I add an array name in the json data
I am getting the data like this

```<code>[
  { "id":1,
    "name":"john"
  },
  { "id":2,
    "name":"ram"
  }
]
</code>```

I want to change the above data to below

```<code> "array":
[
  { "id":1,
    "name":"john"
  },
  { "id":2,
    "name":"ram"
  }
]
</code>```

答:
The way to format your object in JavaScript would be something like this:</p>
```<code>{
  "array": [
    { "id":1, "name":"john" },
    { "id":2, "name":"ram" }
  ]
{
</code>```

Body:
I am getting the data like this

[
  { "id":1,
    "name":"john"
  },
  { "id":2,
    "name":"ram"
  }
]

I want to change the above data to below

 "array":
[
  { "id":1,
    "name":"john"
  },
  { "id":2,
    "name":"ram"
  }
]

Body:
The way to format your object in JavaScript would be something like this:

{
  "array": [
    { "id":1, "name":"john" },
    { "id":2, "name":"ram" }
  ]
{


问:
Xamarin iOS code signing key not found in keychain
I'm trying to debug my Xamarin.Forms application on a physical iPhone, from my windows machine.

I have a Mac connected, and an iPhone connected to that Mac

I have an Apple developer certificate

I have the device linked to my developer account

I set up automatic provisioning using Visual Studio (17.0.5)

I downloaded the generated certificate, and installed it:

On the Mac in the System keychain and Login keychain

On my windows machine running Visual Studio

When I try to deploy my application in Debug|iPhone, I get the following error:

iOS code signing key 'Apple Development: John Doe (5L4565FZ2L)' not found in keychain.

More details from the build output in Visual Studio:

```<code>2>Using "DetectSigningIdentity" task from assembly "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\iOS\..\iOS\Xamarin.iOS.Tasks.dll".
2>Task "DetectSigningIdentity"
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9039262+01:00 - Started
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9039262+01:00 - Initializing
2>  [xma]: Trying to get a Build Connection for Session '6b535ab5f3c9b550fa521b36f236660807d516f929527c4e1cb2a3ecca9ec40d': Xamarin.Messaging.Build.Client.BuildConnection.6b535ab5f3c9b550fa521b36f236660807d516f929527c4e1cb2a3ecca9ec40d, Lifetime: AppDomain
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9039262+01:00 - Initialized
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9039262+01:00 - There's no available inputs to copy to the Mac
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9039262+01:00 - Serializing intputs
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9079268+01:00 - Executing
2>  [xma]: Starting remote task execution for 'Writeful.Mobile.iOS': Xamarin.iOS.Tasks.DetectSigningIdentity
2>  [xma]: Sending Request Xamarin.Messaging.Build.Contracts.ExecuteTaskMessage to topic xvs/build/execute-task/Writeful.Mobile.iOS/6b535ab002fDetectSigningIdentity
2>  [xma]: Received Response of Xamarin.Messaging.Build.Contracts.ExecuteTaskMessage to topic build6b535ab5f3c9b550fa521b36f236660807d516f929527c4e1cb2a3ecca9ec40d47080johndoe/+/xvs/build/execute-task/Writeful.Mobile.iOS/6b535ab002fDetectSigningIdentity
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9499278+01:00 - Logging messages
2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\iOS\Xamarin.Shared.targets(1566,3): error : iOS code signing key 'Apple Development: John Doe (5L4565FZ2L)' not found in keychain.
2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\iOS\Xamarin.Shared.targets(1566,3): error :
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9499278+01:00 - Finished
2>Done executing task "DetectSigningIdentity" -- FAILED.
2>Done building target "_DetectSigningIdentity" in project "Writeful.Mobile.iOS.csproj" -- FAILED.
2>
2>Build FAILED.
2>
2>"C:\Users\johndoe\source\repos\johndoe\writeful-app\Writeful.Mobile.iOS\Writeful.Mobile.iOS.csproj" (Build;BuiltProjectOutputGroup;BuiltProjectOutputGroupDependencies;DebugSymbolsProjectOutputGroup;DebugSymbolsProjectOutputGroupDependencies;DocumentationProjectOutputGroup;DocumentationProjectOutputGroupDependencies;SatelliteDllsProjectOutputGroup;SatelliteDllsProjectOutputGroupDependencies;SGenFilesOutputGroup;SGenFilesOutputGroupDependencies target) (1) ->
2>(_DetectSigningIdentity target) ->
2>  C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\iOS\Xamarin.Shared.targets(1566,3): error : iOS code signing key 'Apple Development: John Doe (5L4565FZ2L)' not found in keychain.
2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\iOS\Xamarin.Shared.targets(1566,3): error :
2>
2>    0 Warning(s)
2>    1 Error(s)
2>
2>Time Elapsed 00:00:01.23
========== Build: 1 succeeded, 1 failed, 21 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========

</code>```

I'm not sure which device is missing the signing key, but I assume it is the iPhone, since I installed the certificate on the Mac.

If this is the issue, how can I transfer the certificate to the iPhone? I already tried by deploying an empty app from Xcode on the Mac to the iPhone, but that didn't work.

答:
You would have to install both the development certificate AND the development provisioning profile on your Mac.

The easiest way to do this is by following the following steps:

Download and install Xcode, you have probably already done this.

Login into Xcode with your apple developer account: Xcode -> Preferences -> Account, use the + sign the add a new account.

Once logged in Xcode will give you the option to Download Manual Profiles in the same view, click this and Xcode will do as promised. This can be done for each account and development team.

Happy debugging!

Note:
In Xcode projects (*.xcworkspace, Native iOS, Flutter, etc.) The easiest option is to click your top level app project (in xcode) and under Signing & Capabilities check the [ ] Automatically Manage Signing option.

You can also manually download the certificate and provisioning profile(s) from AppStoreConnect. Once downloaded, double click the files to install the certificate and profile. This should work, however, in my experience this can result in duplicate profiles and other weird issues. When using Visual Studio for Mac these are sometimes resolved by restarting VS for Mac or your machine. If issues persist, look in the following folder:
~/Library/MobileDevice/Provisioning Profiles here your installed profiles are listed. Finder will show you a preview with details if you select a provisioning profile. Delete duplicate profiles usually helps, these have different file names but the same profile details.

Body:
I'm trying to debug my Xamarin.Forms application on a physical iPhone, from my windows machine.

I have a Mac connected, and an iPhone connected to that Mac

I have an Apple developer certificate

I have the device linked to my developer account

I set up automatic provisioning using Visual Studio (17.0.5)

I downloaded the generated certificate, and installed it:

On the Mac in the System keychain and Login keychain

On my windows machine running Visual Studio

When I try to deploy my application in Debug|iPhone, I get the following error:

iOS code signing key 'Apple Development: John Doe (5L4565FZ2L)' not found in keychain.

More details from the build output in Visual Studio:

2>Using "DetectSigningIdentity" task from assembly "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\iOS\..\iOS\Xamarin.iOS.Tasks.dll".
2>Task "DetectSigningIdentity"
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9039262+01:00 - Started
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9039262+01:00 - Initializing
2>  [xma]: Trying to get a Build Connection for Session '6b535ab5f3c9b550fa521b36f236660807d516f929527c4e1cb2a3ecca9ec40d': Xamarin.Messaging.Build.Client.BuildConnection.6b535ab5f3c9b550fa521b36f236660807d516f929527c4e1cb2a3ecca9ec40d, Lifetime: AppDomain
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9039262+01:00 - Initialized
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9039262+01:00 - There's no available inputs to copy to the Mac
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9039262+01:00 - Serializing intputs
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9079268+01:00 - Executing
2>  [xma]: Starting remote task execution for 'Writeful.Mobile.iOS': Xamarin.iOS.Tasks.DetectSigningIdentity
2>  [xma]: Sending Request Xamarin.Messaging.Build.Contracts.ExecuteTaskMessage to topic xvs/build/execute-task/Writeful.Mobile.iOS/6b535ab002fDetectSigningIdentity
2>  [xma]: Received Response of Xamarin.Messaging.Build.Contracts.ExecuteTaskMessage to topic build6b535ab5f3c9b550fa521b36f236660807d516f929527c4e1cb2a3ecca9ec40d47080johndoe/+/xvs/build/execute-task/Writeful.Mobile.iOS/6b535ab002fDetectSigningIdentity
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9499278+01:00 - Logging messages
2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\iOS\Xamarin.Shared.targets(1566,3): error : iOS code signing key 'Apple Development: John Doe (5L4565FZ2L)' not found in keychain.
2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\iOS\Xamarin.Shared.targets(1566,3): error :
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9499278+01:00 - Finished
2>Done executing task "DetectSigningIdentity" -- FAILED.
2>Done building target "_DetectSigningIdentity" in project "Writeful.Mobile.iOS.csproj" -- FAILED.
2>
2>Build FAILED.
2>
2>"C:\Users\johndoe\source\repos\johndoe\writeful-app\Writeful.Mobile.iOS\Writeful.Mobile.iOS.csproj" (Build;BuiltProjectOutputGroup;BuiltProjectOutputGroupDependencies;DebugSymbolsProjectOutputGroup;DebugSymbolsProjectOutputGroupDependencies;DocumentationProjectOutputGroup;DocumentationProjectOutputGroupDependencies;SatelliteDllsProjectOutputGroup;SatelliteDllsProjectOutputGroupDependencies;SGenFilesOutputGroup;SGenFilesOutputGroupDependencies target) (1) ->
2>(_DetectSigningIdentity target) ->
2>  C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\iOS\Xamarin.Shared.targets(1566,3): error : iOS code signing key 'Apple Development: John Doe (5L4565FZ2L)' not found in keychain.
2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\iOS\Xamarin.Shared.targets(1566,3): error :
2>
2>    0 Warning(s)
2>    1 Error(s)
2>
2>Time Elapsed 00:00:01.23
========== Build: 1 succeeded, 1 failed, 21 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========

I'm not sure which device is missing the signing key, but I assume it is the iPhone, since I installed the certificate on the Mac.

If this is the issue, how can I transfer the certificate to the iPhone? I already tried by deploying an empty app from Xcode on the Mac to the iPhone, but that didn't work.


问:
How to convert PASCAL VOC to YOLO
I was trying to develop some way to convert annotations between formats, and it's quit hard to find information but here I have :

This one is PASCAL VOC

<width>800</width>
<height>450</height>
<depth>3</depth>
<bndbox>
    <xmin>474</xmin>
    <ymin>2</ymin>
    <xmax>726</xmax>
    <ymax>449</ymax>
</bndbox>
```
<p>convert to <strong>YOLO darknet</strong></p>
```2 0.750000 0.501111 0.315000 0.993333
```

note initial 2 it's a category

答:
I use the following snippet to convert Pascal_VOC to YOLO. Yolo uses normalized coordinates so it is important to have the height and width of your image. Otherwise you can't calculate it.

Here is my snippet:

```<code># Convert Pascal_Voc bb to Yolo
def pascal_voc_to_yolo(x1, y1, x2, y2, image_w, image_h):
    return [((x2 + x1)/(2*image_w)), ((y2 + y1)/(2*image_h)), (x2 - x1)/image_w, (y2 - y1)/image_h]
</code>```

I wrote an article about object detection format and how to convert them. You can check my blog post on Medium: https://christianbernecker.medium.com/convert-bounding-boxes-from-coco-to-pascal-voc-to-yolo-and-back-660dc6178742

Have fun!

Title: How to convert PASCAL VOC to YOLO

Body:
I was trying to develop some way to convert annotations between formats, and it's quit hard to find information but here I have :

This one is PASCAL VOC

<width>800</width>
<height>450</height>
<depth>3</depth>
<bndbox>
    <xmin>474</xmin>
    <ymin>2</ymin>
    <xmax>726</xmax>
    <ymax>449</ymax>
</bndbox>

convert to YOLO darknet

2 0.750000 0.501111 0.315000 0.993333

note initial 2 it's a category

Body:
I use the following snippet to convert Pascal_VOC to YOLO. Yolo uses normalized coordinates so it is important to have the height and width of your image. Otherwise you can't calculate it.

Here is my snippet:

# Convert Pascal_Voc bb to Yolo
def pascal_voc_to_yolo(x1, y1, x2, y2, image_w, image_h):
    return [((x2 + x1)/(2*image_w)), ((y2 + y1)/(2*image_h)), (x2 - x1)/image_w, (y2 - y1)/image_h]

I wrote an article about object detection format and how to convert them. You can check my blog post on Medium: https://christianbernecker.medium.com/convert-bounding-boxes-from-coco-to-pascal-voc-to-yolo-and-back-660dc6178742

Have fun!


问:
Code Question - Encrypt the elements in a list by using lambda and map functions in Python
Encrypt the Elements in a List
Description
A company stores the names of its employees in a list. It wants to encrypt the names so that no one can read them and the data remains safe. One of the steps in this encryption is to reverse each name on the list and convert it to uppercase. Your task is to write Python code to do this job.

Note: Use lambda and map functions. Refer to this link if you need help figuring out how to reverse a string using string indexing. Hint - You can use the same syntax you would use to reverse a list.

Input: A list of names

Output: A list of encrypted names

Sample input:

Ronaldo Cristiano Rakesh Ronak

Sample output:

['ODLANOR', 'ONAITSIRC', 'HSEKAR', 'KANOR']

答:
```<code>names = ['Ronaldo', 'Cristiano', 'Rakesh', 'Ronak']
output = list(map(lambda x: x[::-1].upper(), names))
</code>```


问:
Filtering for email address with a dot
I am trying to filter only the email with dot (Sam.Smith@forfun.com). But all email would be displayed to me. Is this somehow possible to get only "Sam.Smith@forfun.com" this?

```<code>PS C:\Users\Rayman>  Get-AzureADUser -SearchString "Sam".AlternateEmailAddresses
PS C:\Users\Rayman>  (Get-AzureADUser -SearchString "Sam Smith").UserPrincipalName
PS C:\Users\Rayman> Get-AzureADUser -SearchString "Sam Smith" | Select Mail
Sam.Smith@forfun.com
samsmith@forfun.com
</code>```

I have tried many variants without success.

答:
Use Select-Object -First 1 to discard everything but the first output item:

```<code>$samSmith = Get-AzureADUser -SearchString "Sam Smith" |Select-Object -First 1
</code>```

Title: Filtering for email address with a dot

Body:
I am trying to filter only the email with dot (Sam.Smith@forfun.com). But all email would be displayed to me. Is this somehow possible to get only "Sam.Smith@forfun.com" this?

PS C:\Users\Rayman>  Get-AzureADUser -SearchString "Sam".AlternateEmailAddresses
PS C:\Users\Rayman>  (Get-AzureADUser -SearchString "Sam Smith").UserPrincipalName
PS C:\Users\Rayman> Get-AzureADUser -SearchString "Sam Smith" | Select Mail
Sam.Smith@forfun.com
samsmith@forfun.com

I have tried many variants without success.

Body:
Use Select-Object -First 1 to discard everything but the first output item:

$samSmith = Get-AzureADUser -SearchString "Sam Smith" |Select-Object -First 1


问:
Using Case Statement with String
Say i have a string

```<code>'SomeName'
</code>```

and wanted the values return in a case statement. Can this bedone? Can strings be used in a case statement like so

```<code>Case 'SomeName' of

   'bobby' : 2;
   'tommy' :19;
   'somename' :4000;
else
   showmessage('Error');
end;
</code>```

答:
try this it uses System.StrUtils</p>
```<code>procedure TForm3.Button1Click(Sender: TObject);
const
  cCaseStrings : array [0..4] of String = ('zero', 'one', 'two', 'three', 'four');
var
  LCaseKey : String;
begin
  LCaseKey := 'one';
  case IndexStr(LCaseKey, cCaseStrings) of
    0: ShowMessage('0');
    1: ShowMessage('1');
    2: ShowMessage('2');
    else ShowMessage('-1');
  end;
end;
</code>```

Title: Using Case Statement with String

Body:
Say i have a string

'SomeName'

and wanted the values return in a case statement. Can this bedone? Can strings be used in a case statement like so

Case 'SomeName' of

   'bobby' : 2;
   'tommy' :19;
   'somename' :4000;
else
   showmessage('Error');
end;

Body:
try this it uses System.StrUtils

procedure TForm3.Button1Click(Sender: TObject);
const
  cCaseStrings : array [0..4] of String = ('zero', 'one', 'two', 'three', 'four');
var
  LCaseKey : String;
begin
  LCaseKey := 'one';
  case IndexStr(LCaseKey, cCaseStrings) of
    0: ShowMessage('0');
    1: ShowMessage('1');
    2: ShowMessage('2');
    else ShowMessage('-1');
  end;
end;


问:
SwiftUI modal view
What is the best way to modally show a SwiftUI view from any class or structure? I use a UIHostingController from UIKit. Is there any better way to do this using only SwiftUI?

ContentView with buttons to present the SwiftUI view

```<code>struct ContentView: View {
    var body: some View {
        Button {
            //  Present the view
            presentView(controller: UIHostingController(rootView: view))
        } label: {
            Text("Present view")
        }
    }

    var view: some View {
        Button {
            //  Dismiss the view
            dismissView()
        } label: {
            Rectangle()
                .overlay(
                    Text("Dismiss view")
                )
        }
    }
}
</code>```

The functions used to present the SwiftUI view

```<code>extension ContentView {
    //  Returns the top view controller
    func topViewController() -> UIViewController? {
        let keyWindow = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
        if var topController = keyWindow?.rootViewController {
            while let presentedViewController = topController.presentedViewController { topController = presentedViewController }
            return topController
        } else { return nil }
    }

    //  Presents the SwiftUI view in a UIHostingController
    func presentView(controller: UIViewController) {
        controller.view.backgroundColor = .none
        controller.modalPresentationStyle = .overCurrentContext
        topViewController()?.present(controller, animated: false, completion: nil)
    }

    //  Removes the UIHostingViewController from root view
    func dismissView() {
        topViewController()?.dismiss(animated: false, completion: nil)
    }
}
</code>```

答:
You can present modal sheet like this:

```<code>struct ContentView: View {
   @State private var showSheet = false

   var body: some View {
       Button("Present") {
           showSheet.toggle()
       }.font(.largeTitle)
       .sheet(isPresented: $showSheet) {
           SheetView()
       }
    }
}

struct SheetView: View {
   @Environment(\.dismiss) var dismiss

    var body: some View {
        ZStack {
           Button {
              dismiss()
           } label: {
               Image(systemName: "xmark.circle")
                 .font(.largeTitle)
                 .foregroundColor(.gray)
           }
         }
         .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topTrailing)
         .padding()
    }
}
</code>```

Or present modal on full screen like this:

```<code>struct ContentView: View {
   @State private var showSheet = false

   var body: some View {
       Button("Present") {
          showSheet.toggle()
       }.font(.largeTitle)
        .fullScreenCover(isPresented: $showSheet) {
              SheetView()
       }
   }
}

struct SheetView: View {
    @Environment(\.presentationMode) var presentationMode

     var body: some View {

         ZStack {
            Button {
               presentationMode.wrappedValue.dismiss()
             } label: {
                Image(systemName: "xmark.circle")
                .font(.largeTitle)
                .foregroundColor(.gray)
             }
       }
        .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topTrailing)
        .padding()
   }
}
</code>```

For your comment it's no problem, you can just do this:

```<code>struct ContentView: View {
    @State private var showSheet = false

    var body: some View {
        ZStack {
            Button("Present") {
                showSheet.toggle()
            }
            .font(.largeTitle)

            if showSheet {
                ZStack {
                    Button {
                        showSheet.toggle()
                    } label: {
                        Image(systemName: "xmark.circle")
                            .font(.largeTitle)
                            .foregroundColor(.gray)
                    }
                    .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topTrailing)
                    .padding()
                }
                .background(.ultraThickMaterial)
            }
        }
    }
}
</code>```

Title: SwiftUI modal view

Body:
What is the best way to modally show a SwiftUI view from any class or structure? I use a UIHostingController from UIKit. Is there any better way to do this using only SwiftUI?

ContentView with buttons to present the SwiftUI view

struct ContentView: View {
    var body: some View {
        Button {
            //  Present the view
            presentView(controller: UIHostingController(rootView: view))
        } label: {
            Text("Present view")
        }
    }

    var view: some View {
        Button {
            //  Dismiss the view
            dismissView()
        } label: {
            Rectangle()
                .overlay(
                    Text("Dismiss view")
                )
        }
    }
}

The functions used to present the SwiftUI view

extension ContentView {
    //  Returns the top view controller
    func topViewController() -> UIViewController? {
        let keyWindow = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
        if var topController = keyWindow?.rootViewController {
            while let presentedViewController = topController.presentedViewController { topController = presentedViewController }
            return topController
        } else { return nil }
    }

    //  Presents the SwiftUI view in a UIHostingController
    func presentView(controller: UIViewController) {
        controller.view.backgroundColor = .none
        controller.modalPresentationStyle = .overCurrentContext
        topViewController()?.present(controller, animated: false, completion: nil)
    }

    //  Removes the UIHostingViewController from root view
    func dismissView() {
        topViewController()?.dismiss(animated: false, completion: nil)
    }
}

Body:
You can present modal sheet like this:

struct ContentView: View {
   @State private var showSheet = false

   var body: some View {
       Button("Present") {
           showSheet.toggle()
       }.font(.largeTitle)
       .sheet(isPresented: $showSheet) {
           SheetView()
       }
    }
}

struct SheetView: View {
   @Environment(\.dismiss) var dismiss

    var body: some View {
        ZStack {
           Button {
              dismiss()
           } label: {
               Image(systemName: "xmark.circle")
                 .font(.largeTitle)
                 .foregroundColor(.gray)
           }
         }
         .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topTrailing)
         .padding()
    }
}

Or present modal on full screen like this:

struct ContentView: View {
   @State private var showSheet = false

   var body: some View {
       Button("Present") {
          showSheet.toggle()
       }.font(.largeTitle)
        .fullScreenCover(isPresented: $showSheet) {
              SheetView()
       }
   }
}

struct SheetView: View {
    @Environment(\.presentationMode) var presentationMode

     var body: some View {

         ZStack {
            Button {
               presentationMode.wrappedValue.dismiss()
             } label: {
                Image(systemName: "xmark.circle")
                .font(.largeTitle)
                .foregroundColor(.gray)
             }
       }
        .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topTrailing)
        .padding()
   }
}

For your comment it's no problem, you can just do this:

struct ContentView: View {
    @State private var showSheet = false

    var body: some View {
        ZStack {
            Button("Present") {
                showSheet.toggle()
            }
            .font(.largeTitle)

            if showSheet {
                ZStack {
                    Button {
                        showSheet.toggle()
                    } label: {
                        Image(systemName: "xmark.circle")
                            .font(.largeTitle)
                            .foregroundColor(.gray)
                    }
                    .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topTrailing)
                    .padding()
                }
                .background(.ultraThickMaterial)
            }
        }
    }
}


问:
how to change the default positioning of modal in bootstrap?
```<code><div class="modal">
  <div class="modal-dialog">
    <div class="modal-content">

      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h4 class="modal-title">Modal title</h4>
      </div>

      <div class="modal-body">
        <p>One fine body…</p>
      </div>

      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>

    </div>
  </div>
</div>
</code>```

how can I change the default modal position in bootstrap, where should I edit to change the default position.

答:
For Bootstrap 5, just add this to your css.

```<code>  .modal-dialog { top: 7rem !important; }
</code>```

Do not add to .modal otherwise the modal will not be dismissed when tapping on the top of the modal because backdrop is shifted down too.

Body:
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>

Modal title

One fine body…

        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>

how can I change the default modal position in bootstrap, where should I edit to change the default position.

Body:
For Bootstrap 5, just add this to your css.

  .modal-dialog { top: 7rem !important; }

Do not add to .modal otherwise the modal will not be dismissed when tapping on the top of the modal because backdrop is shifted down too.


问:
Can you tell me why my CSS doesn't format in IE 7/8?
I have a web site ( http://www.wapc.org ) that formats perfectly in Firefox, Safari, and Chrome but looks different in IE 7/8.

The main navigation (menubar) doesn't retain the correct size/positioning and the drop-down (cascading menu) is also non-functional in IE.

Here's a screenshot of the problem:

Here's a screenshot of what it should look like (Firefox):

Any ideas on what might be causing this? Thanks :)

HTML:

```<code><div class="menu-main-menu-container"><ul id="menu-main-menu" class="menu"><li id="menu-item-157" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-157"><a href="http://www.wapc.org/">Home</a></li>
<li id="menu-item-167" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-167"><a href="http://www.wapc.org/information/">Information</a>
<ul class="sub-menu">
    <li id="menu-item-172" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-172"><a href="http://www.wapc.org/information/for-you-your-family/">For You & Your Family</a></li>

    <li id="menu-item-168" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-168"><a href="http://www.wapc.org/information/for-animals/">For Animals</a></li>
    <li id="menu-item-171" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-171"><a href="http://www.wapc.org/information/for-medical-professionals/">For Medical Professionals</a></li>
    <li id="menu-item-169" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-169"><a href="http://www.wapc.org/information/for-educators/">For Educators</a></li>
    <li id="menu-item-170" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-170"><a href="http://www.wapc.org/information/for-media/">For Media</a></li>
</ul>
</li>
<li id="menu-item-152" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-152"><a href="http://www.wapc.org/resources/">Resources</a>
<ul class="sub-menu">

    <li id="menu-item-153" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-153"><a href="http://www.wapc.org/resources/brochures-fact-sheets/">Brochures & Fact Sheets</a></li>
    <li id="menu-item-154" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-154"><a href="http://www.wapc.org/resources/order-materials/">Order Materials</a></li>
    <li id="menu-item-155" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-155"><a href="http://www.wapc.org/resources/links/">Links</a></li>
    <li id="menu-item-156" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-156"><a href="http://www.wapc.org/resources/yuk-report/">Yuk Report</a></li>
</ul>
</li>
<li id="menu-item-158" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-158"><a href="http://www.wapc.org/about/">About</a>

<ul class="sub-menu">
    <li id="menu-item-159" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-159"><a href="http://www.wapc.org/about/board-of-directors/">Board of Directors</a></li>
    <li id="menu-item-160" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-160"><a href="http://www.wapc.org/about/calendar/">Calendar</a></li>
    <li id="menu-item-161" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-161"><a href="http://www.wapc.org/about/donations/">Donations</a></li>
    <li id="menu-item-162" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-162"><a href="http://www.wapc.org/about/employment/">Employment</a></li>
    <li id="menu-item-163" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-163"><a href="http://www.wapc.org/about/funding/">Funding</a></li>
    <li id="menu-item-164" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-164"><a href="http://www.wapc.org/about/hipaa/">HIPAA</a></li>

    <li id="menu-item-165" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-165"><a href="http://www.wapc.org/about/history/">History</a></li>
</ul>
</li>
<li id="menu-item-166" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-166"><a href="http://www.wapc.org/contact/">Contact Us</a></li>
</ul></div>
</code>```

CSS:

```<code>.custom .menu {
float: right;
position: relative;
margin: -90px 15px 0 0;
background: -moz-linear-gradient(top, #595959 12%, #161616 57%, #131313 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(12%,#595959), color-stop(57%,#161616), color-stop(100%,#131313)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #595959 12%,#161616 57%,#131313 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #595959 12%,#161616 57%,#131313 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #595959 12%,#161616 57%,#131313 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#595959', endColorstr='#131313',GradientType=0 ); /* IE6-9 */
background: linear-gradient(top, #595959 12%,#161616 57%,#131313 100%); /* W3C */
border-radius: 4px 4px 4px 4px;
}

.custom .menu .current a, a:hover {
border-radius: 4px;
}

.custom .menu a {
background: transparent;
}

.custom .sub-menu .menu-item {
border: none;
background: #333333;
}
</code>```

答:
I guess the main problem is that you have your menu as float without define it a width, try adding one.

How does your dropdown work?

Body:
I have a web site ( http://www.wapc.org ) that formats perfectly in Firefox, Safari, and Chrome but looks different in IE 7/8.

The main navigation (menubar) doesn't retain the correct size/positioning and the drop-down (cascading menu) is also non-functional in IE.

Here's a screenshot of the problem:

Here's a screenshot of what it should look like (Firefox):

Any ideas on what might be causing this? Thanks :)

HTML:

Home

Information

For You & Your Family

For Animals

For Medical Professionals

For Educators

For Media

Resources

Brochures & Fact Sheets

Order Materials

Links

Yuk Report

About

Board of Directors

Calendar

Donations

Employment

Funding

HIPAA

History

Contact Us

CSS:

.custom .menu {
float: right;
position: relative;
margin: -90px 15px 0 0;
background: -moz-linear-gradient(top, #595959 12%, #161616 57%, #131313 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(12%,#595959), color-stop(57%,#161616), color-stop(100%,#131313)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #595959 12%,#161616 57%,#131313 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #595959 12%,#161616 57%,#131313 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #595959 12%,#161616 57%,#131313 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#595959', endColorstr='#131313',GradientType=0 ); /* IE6-9 */
background: linear-gradient(top, #595959 12%,#161616 57%,#131313 100%); /* W3C */
border-radius: 4px 4px 4px 4px;
}

.custom .menu .current a, a:hover {
border-radius: 4px;
}

.custom .menu a {
background: transparent;
}

.custom .sub-menu .menu-item {
border: none;
background: #333333;
}


问:
Getting a warning when adding the new google one tap login in internally used web app and its dynamically created subdomains
I am trying to add the google one tap login to our internal website but I am getting the following warning. Although I have already added the main domain and sub domain(just to test) in Authorized redirect URIs and Authorized JavaScript origins but still getting this error.

I read in the document where it says no verification is required when the app is used internally.

Thanks in advance for any guidance

答:
In order to add the new "Sign in with Google" option on the websites which are hosted on the dynamically created subdomains, one can use the solution provided by google is its integration via iframe.

The annoying part is that the documentation didn't mentioned this solution as another possible solution in its subdomain section.


问:
Soldity: Iterate through address mapping
I am looking for a way to iterate through a mapping in Solidity. For example I have this mapping:

mapping (address => uint) private shares;

And I want to iterate in a function through all addresses and send them ether according to their shares.

Something like:

```<code>function giveOutEth() onlyOwner returns (bool success){
for(uint i=0; i < shares.length ; i++){
//get the address and send a value
}
</code>```

}

How can I achieve this?

Thanks

答:
A similar template recently:</p>
```<code>//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

struct IndexValue {
    uint256 keyIndex;
    uint256 value;
}

struct KeyFlag {
    address key;
    bool deleted;
}

struct ItMap {
    mapping(address => IndexValue) data;
    KeyFlag[] keys;
    uint256 size;
}

library IterableMapping {
    function insert(
        ItMap storage self,
        address key,
        uint256 value
    ) internal returns (bool replaced) {
        uint256 keyIndex = self.data[key].keyIndex;
        self.data[key].value = value;
        if (keyIndex > 0) return true;
        else {
            keyIndex = self.keys.length;
            self.keys.push();
            self.data[key].keyIndex = keyIndex + 1;
            self.keys[keyIndex].key = key;
            self.size++;
            return false;
        }
    }

    function remove(ItMap storage self, address key)
        internal
        returns (bool success)
    {
        uint256 keyIndex = self.data[key].keyIndex;
        if (keyIndex == 0) return false;
        delete self.data[key];
        self.keys[keyIndex - 1].deleted = true;
        self.size--;
    }

    function contains(ItMap storage self, address key)
        internal
        view
        returns (bool)
    {
        return self.data[key].keyIndex > 0;
    }

    function start(ItMap storage self)
        internal
        view
        returns (uint256 keyIndex)
    {
        uint256 index = next(self, type(uint256).min);
        return index - 1;
    }

    function valid(ItMap storage self, uint256 keyIndex)
        internal
        view
        returns (bool)
    {
        return keyIndex < self.keys.length;
    }

    function next(ItMap storage self, uint256 keyIndex)
        internal
        view
        returns (uint256)
    {
        keyIndex++;
        while (keyIndex < self.keys.length && self.keys[keyIndex].deleted)
            keyIndex++;
        return keyIndex;
    }

    function get(ItMap storage self, uint256 keyIndex)
        internal
        view
        returns (address key, uint256 value)
    {
        key = self.keys[keyIndex].key;
        value = self.data[key].value;
    }
}

contract Demo {
    using IterableMapping for ItMap;
    ItMap shares;

    function test() public payable {
        for (uint256 i = shares.start(); shares.valid(i); i = shares.next(i)) {
            (address k, uint256 v) = shares.get(i);
            // get the address and send a value
        }
    }
}
</code>```

Body:
I am looking for a way to iterate through a mapping in Solidity. For example I have this mapping:

mapping (address => uint) private shares;

And I want to iterate in a function through all addresses and send them ether according to their shares.

Something like:

function giveOutEth() onlyOwner returns (bool success){
for(uint i=0; i < shares.length ; i++){
//get the address and send a value
}

}

How can I achieve this?

Thanks

Body:
A similar template recently:

//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

struct IndexValue {
    uint256 keyIndex;
    uint256 value;
}

struct KeyFlag {
    address key;
    bool deleted;
}

struct ItMap {
    mapping(address => IndexValue) data;
    KeyFlag[] keys;
    uint256 size;
}

library IterableMapping {
    function insert(
        ItMap storage self,
        address key,
        uint256 value
    ) internal returns (bool replaced) {
        uint256 keyIndex = self.data[key].keyIndex;
        self.data[key].value = value;
        if (keyIndex > 0) return true;
        else {
            keyIndex = self.keys.length;
            self.keys.push();
            self.data[key].keyIndex = keyIndex + 1;
            self.keys[keyIndex].key = key;
            self.size++;
            return false;
        }
    }

    function remove(ItMap storage self, address key)
        internal
        returns (bool success)
    {
        uint256 keyIndex = self.data[key].keyIndex;
        if (keyIndex == 0) return false;
        delete self.data[key];
        self.keys[keyIndex - 1].deleted = true;
        self.size--;
    }

    function contains(ItMap storage self, address key)
        internal
        view
        returns (bool)
    {
        return self.data[key].keyIndex > 0;
    }

    function start(ItMap storage self)
        internal
        view
        returns (uint256 keyIndex)
    {
        uint256 index = next(self, type(uint256).min);
        return index - 1;
    }

    function valid(ItMap storage self, uint256 keyIndex)
        internal
        view
        returns (bool)
    {
        return keyIndex < self.keys.length;
    }

    function next(ItMap storage self, uint256 keyIndex)
        internal
        view
        returns (uint256)
    {
        keyIndex++;
        while (keyIndex < self.keys.length && self.keys[keyIndex].deleted)
            keyIndex++;
        return keyIndex;
    }

    function get(ItMap storage self, uint256 keyIndex)
        internal
        view
        returns (address key, uint256 value)
    {
        key = self.keys[keyIndex].key;
        value = self.data[key].value;
    }
}

contract Demo {
    using IterableMapping for ItMap;
    ItMap shares;

    function test() public payable {
        for (uint256 i = shares.start(); shares.valid(i); i = shares.next(i)) {
            (address k, uint256 v) = shares.get(i);
            // get the address and send a value
        }
    }
}


问:
Pentaho ETL from mySQL
I am trying to understand if Pentaho can help me with this scenario:

We want to do a data migration from database A (mySQL) to GCP cloud storage as raw data and then to database B (mySQL as cloud sql) with transformation. Does Pentaho can integrate with cloud storage?

答:
Pentaho Data Integration could do that, but it's out of date with regards to cloud storage, I'm not sure if it would work communicating with GCP, I think it works, but I haven't tried, and Hitachi Vantara (the company that bought the Pentaho suite some years ago) is closing all the support to the open source community.

Some old Pentaho DI developers have forked the project and are actively modernizing and applying some new ideas to the tool: I suggest you try apache-hop (https://hop.apache.org/download/) instead of Pentaho, the project is quite mature, they have clean up old PDI bugs (including the log4j library still present in PDI), and are open to new ideas and reporting bugs, if you are beginning with PDI right now, it would be better to start with an actively supported tool.

Title: Pentaho ETL from mySQL


问:
Algorithm Analysis Dependant quadratic
I want to ask for this question, what is the algorithm analysis for this?
outer loop will execute for n + 2 times
how we determine the inner loop? is it (n+1)/2</p>
```<code>for(int i = 0;i <= n;i++)
    for(int j = n;j>i;j--)
</code>```

答:
The outer loop has n + 1 iterations.

The inner loop has n - i iterations.

To find the overall time complexity, you have to sum the iterations of the inner loop for all the values of i:

```<code>n + (n - 1) + (n - 2) + ... + 1 = (n+1)*n/2 = O(n^2)
</code>```

Title: Algorithm Analysis Dependant quadratic

Body:
I want to ask for this question, what is the algorithm analysis for this?
outer loop will execute for n + 2 times
how we determine the inner loop? is it (n+1)/2

for(int i = 0;i <= n;i++)
    for(int j = n;j>i;j--)

Body:
The outer loop has n + 1 iterations.

The inner loop has n - i iterations.

To find the overall time complexity, you have to sum the iterations of the inner loop for all the values of i:

n + (n - 1) + (n - 2) + ... + 1 = (n+1)*n/2 = O(n^2)


问:
Logging errors in axis2 webservice
In my axis2 webservice, I want to log all possible errors to a log file. I am confused with where to store the log4j.properties file in the .aar file. Please help.</p>

答: Java || .Net prgmng? IDE ? If you are looking for, how to use log 4j with eclipse, then --> This helps !!</p>

Title: Logging errors in axis2 webservice


问:
What the following code prints / with arrays, pointers etc
I have problem solving this problem, so if anyne had a similar problem it would help me a lot.

```<code>short y[2][3]={{0123},{0x12345}},*p=y[1];
printf("01:%x\n", y);
printf("02:%x\n", p);
printf("03:%x\n", sizeof(y));
printf("04:%x\n", sizeof(y[0]));
printf("05:%x\n", sizeof(&y[0]));
printf("06:%x\n", sizeof(*p));
printf("07:%x\n", sizeof(p++));
printf("08:%x\n", *p++);
printf("09:%x\n", *p);
return 0;
</code>```

Can anyone explain to me why the printout is like this?

```<code>01:61ff10
02:61ff16
03:c
04:6
05:4
06:2
07:4
08:2345
09:0
</code>```

My opinion:

```<code>01:Prints the address where the array y begins.
02:Prints the address of the pointer, which points to the second element of the array. Since we have 2 * 3 elements that are of type short, each subsequent element of the zero element will increase by 6.
03:Since we have 2 * 3 elements, which is equal to 6, but the elements of the type are short, so it will print hexadecimal c
04:the number of elements in the zero position is 3, but they are of the short type, so it prints 6
05:prints the sizeof addresses of the first element of the array which is 4
06:I don't know why it prints 2 here
07:Prints the sizeof of the pointer address which is 4, it will increase after printing
08:I do not understand
09:I do not understand
</code>```

Can anyone explain why it prints like this?

答:
N6) Sizeof(*p) is size of datatype pointed by p. p is pointer to short: so 2 bytes.

N8) p is pointer to short, it`s pointing to array element y[1][0].
y[1] and y[1][0] have the same memory address.

All array elements are short, 0x12345 truncates to 0x2345 upon array initialisation. So output is 2345.
Also, p++ increases pointer value to point to next short y[1][1].

N9) Because of p++ in step N8, pointer now points to y[1][1], which was initialised to 0 (by default, because init value not provided) - output is 0.

Body:
I have problem solving this problem, so if anyne had a similar problem it would help me a lot.

short y[2][3]={{0123},{0x12345}},*p=y[1];
printf("01:%x\n", y);
printf("02:%x\n", p);
printf("03:%x\n", sizeof(y));
printf("04:%x\n", sizeof(y[0]));
printf("05:%x\n", sizeof(&y[0]));
printf("06:%x\n", sizeof(*p));
printf("07:%x\n", sizeof(p++));
printf("08:%x\n", *p++);
printf("09:%x\n", *p);
return 0;

Can anyone explain to me why the printout is like this?

01:61ff10
02:61ff16
03:c
04:6
05:4
06:2
07:4
08:2345
09:0

My opinion:

01:Prints the address where the array y begins.
02:Prints the address of the pointer, which points to the second element of the array. Since we have 2 * 3 elements that are of type short, each subsequent element of the zero element will increase by 6.
03:Since we have 2 * 3 elements, which is equal to 6, but the elements of the type are short, so it will print hexadecimal c
04:the number of elements in the zero position is 3, but they are of the short type, so it prints 6
05:prints the sizeof addresses of the first element of the array which is 4
06:I don't know why it prints 2 here
07:Prints the sizeof of the pointer address which is 4, it will increase after printing
08:I do not understand
09:I do not understand

Can anyone explain why it prints like this?