问:
Openssl Configuration on Windows
I am trying to configure openssl on my windows machine using the following perl command:

perl Configure VC-WIN64A --prefix=C:/Program Files/OpenSSL --openssldir=C:/Program Files/Common Files/SSL
However I get the following error:
Failure!  build file wasn't produced.
Please read INSTALL and associated NOTES files.  You may also have to look over
your available compiler tool chain or change your configuration.

target already defined - VC-WIN64A (offending arg: Files/OpenSSL)

Can anyone help me?

Title: Openssl Configuration on Windows


来源: stackexchange

问:
Show another static content as part of Django page
Collaborator is giving me static content that I'd like to display as a component of a page in a Django app. I'd like to do this without styling interruptions.

Specifically:

I have a Django template templates/page.html that extends templates/base.html. The base.html includes header/footer/navbar/etc.

In the middle of page.html, I'd like to insert external HTML (with its own CSS) exactly as being imported, so that external CSS styling in templates/base.html doesn't get applied. (But I also don't want the CSS I am importing to affect stuff in base.html either.)

Is there a Django-native, or HTML/CSS-native way to accomplish this?

ContentLicense: CC BY-SA 4.0


问:
What are parameters for SharePoint 2013 Save Original Email, Save to folder by subject/sender, overwrite, and Email Security setting in powershell?
I am trying to pull the settings for Email Enabled libraries in powershell for SharePoint 2013 in preparation for a move to SharePoint Online. I can pull the email enabled lists, urls, and email address but want to get a more detailed report to review which have "save original email", "save to subfolders" etc, and "Accept messages from any sender"

In 2013 you can enable sharepoint libraries to be email enabled and further set the two settings below, which i cannot figure out how to pull.

i can get lists and get $list.EmailAlias and $list.CanReceiveEmail but cannot find a parameter that corresponds to the two settings below

E-mail Message
Specify whether to save the original .eml file for an incoming e-mail message.

Save original e-mail?
option: Yes
option: No

E-Mail Attachments
Specify whether to group attachments in folders, and whether to overwrite existing files with the same name as incoming files.

Group attachments in folders?

Save all attachments in root folder

Save all attachments in folders grouped by e-mail subject

Save all attachments in folders grouped by e-mail sender

Overwrite files with the same name?

Yes   No

E-Mail Meeting Invitations
Specify whether to save e-mailed meeting invitations in this document library.

Save meeting invitations?

Yes   No

E-mail Security
E-mail security policy:

Accept e-mail messages based on document library permissions
Accept e-mail messages from any sender

I reviewed the autopopulate values in powershell ISE but none of them seem to correspond. I expected this would be a simple selection of the parameter as with $list.EmailAlias and am hoping we do not have to check each of the 150 libraries manually.


问:
How to change newline to enter in commands run by Popen?
I want to change password through python script.

```<code>import subprocess

cmd = 'echo -e "newpass1\nnewpass1" | passwd root'
with subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p:
    print(p.stderr.read(4096))
</code>```

Result of this command is error: "Passwords do not match".
Why this command is working in my shell and not working in python script?

Body:
I want to change password through python script.

import subprocess

cmd = 'echo -e "newpass1\nnewpass1" | passwd root'
with subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p:
    print(p.stderr.read(4096))

Result of this command is error: "Passwords do not match".
Why this command is working in my shell and not working in python script?


问:
How to get the bitwise symetric of a binary number?
I explain my problem.

For example considering a 8 bit integer, to obtain symmetric number around "middle bits",  bits 0 and 7 are swapped, bits 1 and 6 are swapped, bit 2 and 5 are swapped and bits 3 and 4 are swapped. (ex. 10100110 => 01100101)

The sample principal applies whatever the integer length.

Following this answer(https://stackoverflow.com/a/982139/7462275), I wrote this code that gives the expected result.

```<code>int bit_lg=8; // 8 bits (from 0 to 7)
unsigned int my_int=0b10100110, my_res=my_int;
unsigned short xbit;

for (int i=0; i<bit_lg/2;i++) {
    xbit = ((my_res >> i) ^ (my_res >> (bit_lg-1-i))) & 0b1;
    my_res = my_res ^ ((xbit << i) | (xbit << (bit_lg-1-i)));
}
printf("%B : %.8B\n",my_int,my_res);
</code>```

I wonder if it possible to avoid the for loop. And obtained the result in one step ?
Perhaps does it exist some __builtin_ (gcc is used) ?

Body:
I explain my problem.

For example considering a 8 bit integer, to obtain symmetric number around "middle bits",  bits 0 and 7 are swapped, bits 1 and 6 are swapped, bit 2 and 5 are swapped and bits 3 and 4 are swapped. (ex. 10100110 => 01100101)

The sample principal applies whatever the integer length.

Following this answer(https://stackoverflow.com/a/982139/7462275), I wrote this code that gives the expected result.

int bit_lg=8; // 8 bits (from 0 to 7)
unsigned int my_int=0b10100110, my_res=my_int;
unsigned short xbit;

for (int i=0; i<bit_lg/2;i++) {
    xbit = ((my_res >> i) ^ (my_res >> (bit_lg-1-i))) & 0b1;
    my_res = my_res ^ ((xbit << i) | (xbit << (bit_lg-1-i)));
}
printf("%B : %.8B\n",my_int,my_res);

I wonder if it possible to avoid the for loop. And obtained the result in one step ?
Perhaps does it exist some __builtin_ (gcc is used) ?


问:
Vue.js - displaying images rendered in API
I have a Get method in an API that renders an image:

```<code>[HttpGet("GetImage/{userId}/{imageURL}")]
public IActionResult GetImage(string userId, string imageURL)
{
    byte[] b = System.IO.File.ReadAllBytes("../WebServices/ImgLibrary/" + userId + "/" + imageURL);
    return File(b, "image/png");
}
</code>```

Now I need to call that method and display images in my Vue.js project, but I've been unable to get anything to render. This is my method for calling the API:

```<code>var imgURL = this.baseUrl + "/GetImage/" + user.Id.toString() + "/";
    var i;
    for (i = 0; i < this.imageList.length; i++) {
      imgURL += this.imageList[i].Name;
      const imgResponse = await fetch(imgURL,{
        method: "GET",
      });
      const thisImg = await imgResponse.blob();
      this.imgRawDataList[i] = thisImg
      imgURL = this.baseUrl + "/GetImage/" + user.Id.toString() + "/"; //reset
    }
</code>```

This adds Blobs to the imgRawDataList array, which is a parallel array to the imageList array that stores the image paths. ImageK is a counter.

```<code><div v-for="(ImageD, ImageK) in imageList">
  <div v-bind:data-src="ImageD.ImageUrl">
    <img v-bind:src="getRawURL(ImageD.ImageUrl, ImageK)" />
  </div>
</div>
</code>```

And this is the getRawURL method to get the image src:

```<code>getRawURL(path, i) {
  if (this.imgRawDataList.length > 0) {
    if (this.imgRawDataList[i] !== undefined) {
      return 'data:image/png;base64,' + btoa(
        new Uint8Array(this.imgRawDataList[i])
        .reduce((data, byte) => data + String.fromCharCode(byte), '')
      );
    }
    else { return ''; }
  } else { return ''; }
},
</code>```

What comes back from the btoa method is nothing, so the images look like this:

```<code><img src="data:image/png;base64," data-v-30ae62="">
</code>```

Are Blobs the best way to do this? In Swagger when testing my API the GetImage method will actually render the image, so I feel like I'm doing too much here.

Body:
I have a Get method in an API that renders an image:

[HttpGet("GetImage/{userId}/{imageURL}")]
public IActionResult GetImage(string userId, string imageURL)
{
    byte[] b = System.IO.File.ReadAllBytes("../WebServices/ImgLibrary/" + userId + "/" + imageURL);
    return File(b, "image/png");
}

Now I need to call that method and display images in my Vue.js project, but I've been unable to get anything to render. This is my method for calling the API:

var imgURL = this.baseUrl + "/GetImage/" + user.Id.toString() + "/";
    var i;
    for (i = 0; i < this.imageList.length; i++) {
      imgURL += this.imageList[i].Name;
      const imgResponse = await fetch(imgURL,{
        method: "GET",
      });
      const thisImg = await imgResponse.blob();
      this.imgRawDataList[i] = thisImg
      imgURL = this.baseUrl + "/GetImage/" + user.Id.toString() + "/"; //reset
    }

This adds Blobs to the imgRawDataList array, which is a parallel array to the imageList array that stores the image paths. ImageK is a counter.

And this is the getRawURL method to get the image src:

getRawURL(path, i) {
  if (this.imgRawDataList.length > 0) {
    if (this.imgRawDataList[i] !== undefined) {
      return 'data:image/png;base64,' + btoa(
        new Uint8Array(this.imgRawDataList[i])
        .reduce((data, byte) => data + String.fromCharCode(byte), '')
      );
    }
    else { return ''; }
  } else { return ''; }
},

What comes back from the btoa method is nothing, so the images look like this:

Are Blobs the best way to do this? In Swagger when testing my API the GetImage method will actually render the image, so I feel like I'm doing too much here.


问:
WPF ContentPresenter Recreating Template
I have strange behavior with the ContentPresenter in WPF. I use the ContentPresenter control in my user control to change some child controls based on a property change in my view model. The ContentPresenter definition looks like this:

```<code>        <ContentPresenter Grid.Row="2" Content="{Binding}">
            <ContentPresenter.Resources>
                <DataTemplate x:Key="Gray" d:DataType="{x:Type vm:ResultViewModel}">
                    <util:RestrictDesiredSize KeepHeight="True">
                        <Border Padding="5,5">
                            <controls:GrayAnalysis/>
                        </Border>
                    </util:RestrictDesiredSize>
                </DataTemplate>
                <DataTemplate x:Key="Color" d:DataType="{x:Type vm:ResultViewModel}">
                    <util:RestrictDesiredSize KeepHeight="True">
                        <Border Padding="5,5">
                            <controls:ColorAnalysis/>
                        </Border>
                    </util:RestrictDesiredSize>
                </DataTemplate>
            </ContentPresenter.Resources>
            <ContentPresenter.Style>
                <Style TargetType="{x:Type ContentPresenter}">
                    <Setter Property="ContentTemplate" Value="{StaticResource Gray}" />
                    <Style.Triggers>
                        <DataTrigger Value="True" Binding="{Binding Unit.IsColor.Value}">
                            <Setter Property="ContentTemplate" Value="{StaticResource Color}" />
                        </DataTrigger>
                        <DataTrigger Value="False" Binding="{Binding Unit.IsColor.Value}">
                            <Setter Property="ContentTemplate" Value="{StaticResource Gray}" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </ContentPresenter.Style>
        </ContentPresenter>
</code>```

So in general I have two templates and when the "Unit.IsColor.Value" property changes the corresponding data template should be applied. This seems to work in the first place.

When the correct data template was applied, another property change in the view model (for a different property) which is only bound to a control inside the applied template, the complete data template will be created again.

So instead of applying the data template only one time and then changing the control inside the data template, the ContentPresenter will recreate the complete data template for every property change.

The callstack looks like this:

```<code>    mscorlib.dll!System.Activator.CreateInstance(System.Type type, bool nonPublic)  Unknown
mscorlib.dll!System.RuntimeType.CreateInstanceImpl(System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, object[] args, System.Globalization.CultureInfo culture, object[] activationAttributes, ref System.Threading.StackCrawlMark stackMark)  Unknown
mscorlib.dll!System.Activator.CreateInstance(System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, object[] args, System.Globalization.CultureInfo culture, object[] activationAttributes) Unknown
mscorlib.dll!System.Activator.CreateInstance(System.Type type, object[] args)   Unknown
System.Xaml.dll!System.Xaml.Schema.SafeReflectionInvoker.CreateInstanceCritical(System.Type type, object[] arguments)   Unknown
System.Xaml.dll!System.Xaml.Schema.XamlTypeInvoker.CreateInstance(object[] arguments)   Unknown
System.Xaml.dll!MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance(System.Xaml.XamlType xamlType, object[] args)  Unknown
System.Xaml.dll!System.Xaml.XamlObjectWriter.Logic_CreateAndAssignToParentStart(MS.Internal.Xaml.Context.ObjectWriterContext ctx)   Unknown
System.Xaml.dll!System.Xaml.XamlObjectWriter.WriteEndObject()   Unknown
PresentationFramework.dll!System.Windows.FrameworkTemplate.LoadTemplateXaml(System.Xaml.XamlReader templateReader, System.Xaml.XamlObjectWriter currentWriter)  Unknown
PresentationFramework.dll!System.Windows.FrameworkTemplate.LoadTemplateXaml(System.Xaml.XamlObjectWriter objectWriter)  Unknown
PresentationFramework.dll!System.Windows.FrameworkTemplate.LoadOptimizedTemplateContent(System.Windows.DependencyObject container, System.Windows.Markup.IComponentConnector componentConnector, System.Windows.Markup.IStyleConnector styleConnector, System.Collections.Generic.List<System.Windows.DependencyObject> affectedChildren, System.Windows.UncommonField<System.Collections.Hashtable> templatedNonFeChildrenField)   Unknown
PresentationFramework.dll!System.Windows.FrameworkTemplate.LoadContent(System.Windows.DependencyObject container, System.Collections.Generic.List<System.Windows.DependencyObject> affectedChildren)    Unknown
PresentationFramework.dll!System.Windows.StyleHelper.ApplyTemplateContent(System.Windows.UncommonField<System.Collections.Specialized.HybridDictionary[]> dataField, System.Windows.DependencyObject container, System.Windows.FrameworkElementFactory templateRoot, int lastChildIndex, System.Collections.Specialized.HybridDictionary childIndexFromChildID, System.Windows.FrameworkTemplate frameworkTemplate) Unknown
PresentationFramework.dll!System.Windows.FrameworkTemplate.ApplyTemplateContent(System.Windows.UncommonField<System.Collections.Specialized.HybridDictionary[]> templateDataField, System.Windows.FrameworkElement container)   Unknown
PresentationFramework.dll!System.Windows.FrameworkElement.ApplyTemplate()   Unknown
PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize)    Unknown
PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize)    Unknown
PresentationCore.dll!System.Windows.ContextLayoutManager.UpdateLayout() Unknown
PresentationCore.dll!System.Windows.ContextLayoutManager.UpdateLayoutCallback(object arg)   Unknown
PresentationCore.dll!System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()    Unknown
</code>```

It seems like the MeasureCore is tiggering the ApplyTemplate and so forth...

So the question is, how can I avoid that the template is recreated for every property call?

Body:
I have strange behavior with the ContentPresenter in WPF. I use the ContentPresenter control in my user control to change some child controls based on a property change in my view model. The ContentPresenter definition looks like this:

        <ContentPresenter Grid.Row="2" Content="{Binding}">
            <ContentPresenter.Resources>
                <DataTemplate x:Key="Gray" d:DataType="{x:Type vm:ResultViewModel}">
                    <util:RestrictDesiredSize KeepHeight="True">
                        <Border Padding="5,5">
                            <controls:GrayAnalysis/>
                        </Border>
                    </util:RestrictDesiredSize>
                </DataTemplate>
                <DataTemplate x:Key="Color" d:DataType="{x:Type vm:ResultViewModel}">
                    <util:RestrictDesiredSize KeepHeight="True">
                        <Border Padding="5,5">
                            <controls:ColorAnalysis/>
                        </Border>
                    </util:RestrictDesiredSize>
                </DataTemplate>
            </ContentPresenter.Resources>
            <ContentPresenter.Style>

                </Style>
            </ContentPresenter.Style>
        </ContentPresenter>

So in general I have two templates and when the "Unit.IsColor.Value" property changes the corresponding data template should be applied. This seems to work in the first place.

When the correct data template was applied, another property change in the view model (for a different property) which is only bound to a control inside the applied template, the complete data template will be created again.

So instead of applying the data template only one time and then changing the control inside the data template, the ContentPresenter will recreate the complete data template for every property change.

The callstack looks like this:

    mscorlib.dll!System.Activator.CreateInstance(System.Type type, bool nonPublic)  Unknown
mscorlib.dll!System.RuntimeType.CreateInstanceImpl(System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, object[] args, System.Globalization.CultureInfo culture, object[] activationAttributes, ref System.Threading.StackCrawlMark stackMark)  Unknown
mscorlib.dll!System.Activator.CreateInstance(System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, object[] args, System.Globalization.CultureInfo culture, object[] activationAttributes) Unknown
mscorlib.dll!System.Activator.CreateInstance(System.Type type, object[] args)   Unknown
System.Xaml.dll!System.Xaml.Schema.SafeReflectionInvoker.CreateInstanceCritical(System.Type type, object[] arguments)   Unknown
System.Xaml.dll!System.Xaml.Schema.XamlTypeInvoker.CreateInstance(object[] arguments)   Unknown
System.Xaml.dll!MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance(System.Xaml.XamlType xamlType, object[] args)  Unknown
System.Xaml.dll!System.Xaml.XamlObjectWriter.Logic_CreateAndAssignToParentStart(MS.Internal.Xaml.Context.ObjectWriterContext ctx)   Unknown
System.Xaml.dll!System.Xaml.XamlObjectWriter.WriteEndObject()   Unknown
PresentationFramework.dll!System.Windows.FrameworkTemplate.LoadTemplateXaml(System.Xaml.XamlReader templateReader, System.Xaml.XamlObjectWriter currentWriter)  Unknown
PresentationFramework.dll!System.Windows.FrameworkTemplate.LoadTemplateXaml(System.Xaml.XamlObjectWriter objectWriter)  Unknown
PresentationFramework.dll!System.Windows.FrameworkTemplate.LoadOptimizedTemplateContent(System.Windows.DependencyObject container, System.Windows.Markup.IComponentConnector componentConnector, System.Windows.Markup.IStyleConnector styleConnector, System.Collections.Generic.List<System.Windows.DependencyObject> affectedChildren, System.Windows.UncommonField<System.Collections.Hashtable> templatedNonFeChildrenField)   Unknown
PresentationFramework.dll!System.Windows.FrameworkTemplate.LoadContent(System.Windows.DependencyObject container, System.Collections.Generic.List<System.Windows.DependencyObject> affectedChildren)    Unknown
PresentationFramework.dll!System.Windows.StyleHelper.ApplyTemplateContent(System.Windows.UncommonField<System.Collections.Specialized.HybridDictionary[]> dataField, System.Windows.DependencyObject container, System.Windows.FrameworkElementFactory templateRoot, int lastChildIndex, System.Collections.Specialized.HybridDictionary childIndexFromChildID, System.Windows.FrameworkTemplate frameworkTemplate) Unknown
PresentationFramework.dll!System.Windows.FrameworkTemplate.ApplyTemplateContent(System.Windows.UncommonField<System.Collections.Specialized.HybridDictionary[]> templateDataField, System.Windows.FrameworkElement container)   Unknown
PresentationFramework.dll!System.Windows.FrameworkElement.ApplyTemplate()   Unknown
PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize)    Unknown
PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize)    Unknown
PresentationCore.dll!System.Windows.ContextLayoutManager.UpdateLayout() Unknown
PresentationCore.dll!System.Windows.ContextLayoutManager.UpdateLayoutCallback(object arg)   Unknown
PresentationCore.dll!System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()    Unknown

It seems like the MeasureCore is tiggering the ApplyTemplate and so forth...

So the question is, how can I avoid that the template is recreated for every property call?


问:
What steps does the "Deep profiling support" option in Unity internally when added in an Android build?
I am developing a VR multiplayer application that interconnects different platforms so that there can be users in non-VR mode as well. This communication is done with room matchmaking where there is a host and one or more clients for each room. For this I am using Unity 2020.3.37f1 (using Unity's own XR plugin) together with Mirror Networking version 53.0.0 and Playfab v2.9.4.
The code is fully functional for any client platform (Windows, iOS, Android/Quest...) as well as any host combination (Windows, iOS...) with the exception of Android for host which I will describe the specific problem below:

Assuming a connection between an Android host and a client on any platform, logging in, connecting, creating the room and joining is no problem, so I don't really think it's a Playfab problem, but as for the host (Android) is in the room together with the client, I noticed that, except for a few NetworkTransforms (Mirror) that are maintained with a correct latency, the rest are too slow and out of sync to the point that communication becomes unfeasible, which makes me I assume that the problem is related to the Mirror and multiplayer part but when I tried to perform some tests with "Deep Profiling Support" enabled (and consequently also the "Development Build" enabled), I realized that the resulting build worked perfectly and there was no latency bug, it's hard for me to explain why or what could be the reason why "Deep Profiling Support" affects.

The setup I have is an Oppo Find X5 Pro (Android) mobile and an iPad 9th Generation Tablet.

The first thing I tried was different combinations of the build and player settings menu to see if it was really just because of the "Deep profiling support" and after many possible combinations I saw that this latency problem only stopped occurring if the host build was compiled for Android with that option enabled. I tried in iOS and the problem does not occur in any case, I assumed that it could be a problem related to the data transmission intervals of the NetworkTransform or perhaps some overlapping of the network that when activating the "Deep Profiling Support" would cause the communication to be slower and therefore will not be saturated with an exaggerated amount of packets but after trying to make modifications in the intervals and reduce the communication through Mirror, even testing with a simple scene with a few MirrorTransforms, I saw that the same problem was still happening. Therefore, in order to understand more about what could be happening, I would like to ask if anyone knows what "Deep Profiling Support" can affect at the level of network communication or performance to take it into account and thus be able to find what exactly could be happening to me.


问:
d3 struggling to add custom ticks to area graph for chart
I cannot seem to get custom ticks added to an area graph, default however seem to work. I have attempted many different things I have found in examples online, but they either take no effect of result in the graph having no axis at all.

enter image description here

the code in question is as follows:
`
var y = d3.scaleLinear()
.domain([0, d3.max(data, function(d) { return d.age1+d.age2+d.age3+d.age4; })])
.range([ chartHeight, 0 ]);

```<code>svg.append("g").call(d3.axisLeft(y));

if(timeline){
  var x = d3
    .scaleTime()
    .domain(d3.extent(data, function(d) { return tParser(d.date);  }))
    .range([ 0, chartWidth ]);

  svg.append("g")
    .attr("transform", "translate(0," + chartHeight + ")")
    .call(d3.axisBottom(x));
}else{
  var x = d3.scaleLinear()
    .domain([d3.min(data, function(d) { return d.date; }), d3.max(data, function(d) { return d.date;        })])
    .range([ 0, chartWidth ]);

  svg.append("g")
    .attr("transform", "translate(0," + chartHeight + ")")
    .call(d3.axisBottom(x));

}`
</code>```

I have tried adding the ticks as follows:
       var x = d3         .scaleTime()         .domain(d3.extent(data, function(d) { return tParser(d.date);  }))         .ticks(5)         .range([ 0, chartWidth ]);

and this

      var x = d3         .scaleTime()         .domain(d3.extent(data, function(d) { return tParser(d.date);  }))         .range([ 0, chartWidth ]);       x.ticks(5);

I have created a stack blitz with an example of my project, should that help
https://stackblitz.com/edit/angular-ivy-mrs77c?file=src%2Fapp%2FstackedArea-chart-visualization%2FstackedArea-chart-visualization.component.ts

Body:
I cannot seem to get custom ticks added to an area graph, default however seem to work. I have attempted many different things I have found in examples online, but they either take no effect of result in the graph having no axis at all.

enter image description here

the code in question is as follows:
`
var y = d3.scaleLinear()
.domain([0, d3.max(data, function(d) { return d.age1+d.age2+d.age3+d.age4; })])
.range([ chartHeight, 0 ]);

svg.append("g").call(d3.axisLeft(y));

if(timeline){
  var x = d3
    .scaleTime()
    .domain(d3.extent(data, function(d) { return tParser(d.date);  }))
    .range([ 0, chartWidth ]);

  svg.append("g")
    .attr("transform", "translate(0," + chartHeight + ")")
    .call(d3.axisBottom(x));
}else{
  var x = d3.scaleLinear()
    .domain([d3.min(data, function(d) { return d.date; }), d3.max(data, function(d) { return d.date;        })])
    .range([ 0, chartWidth ]);

  svg.append("g")
    .attr("transform", "translate(0," + chartHeight + ")")
    .call(d3.axisBottom(x));

}`

I have tried adding the ticks as follows:
       var x = d3         .scaleTime()         .domain(d3.extent(data, function(d) { return tParser(d.date);  }))         .ticks(5)         .range([ 0, chartWidth ]);

and this

      var x = d3         .scaleTime()         .domain(d3.extent(data, function(d) { return tParser(d.date);  }))         .range([ 0, chartWidth ]);       x.ticks(5);

I have created a stack blitz with an example of my project, should that help
https://stackblitz.com/edit/angular-ivy-mrs77c?file=src%2Fapp%2FstackedArea-chart-visualization%2FstackedArea-chart-visualization.component.ts


问:
Is there a way to perform git archive with nodegit api?
I want to perform a git archive using node-git.

A feature of git-archive is that it excludes from archive the patterns set with export-ignore inside .gitattributes.

What would be a simple way to perform a git-archive operation using nodegit api?


问:
Accuracy of Model dropped gradually every loop
I have 5 different sets of data and want find evaluation metrics for every set using neural network regression. I realized that the R^2 is dropping every loop in order manner. I'm pretty sure there should be a point that I need to identify, but not sure where in my code.

My code:

```<code>for sensor, sensorlol, name in zip(sensors, sensorslol, names):
    x_train, x_test, y_train, y_test = train_test_split(sensor, reference, test_size=0.2, random_state=42)
    x_trainl, x_testl, y_trainl, y_testl = train_test_split(sensorlol, referencelol, test_size=0.2, random_state=42)

    kf=KFold(7, shuffle=True, random_state=42)
    ann=MLPRegressor(hidden_layer_sizes=int(node), activation='relu',
                     learning_rate='constant', learning_rate_init=initl, shuffle=False)
    ann.fit(x_train, y_train)
    m_predictionlol=cross_val_predict(ann, sensorlol, referencelol, cv=kf)
    R2lol=r2_score(referencelol, m_predictionlol)
    MAElol=mean_absolute_error(referencelol, m_predictionlol)
    RMSElol=mean_squared_error(referencelol, m_predictionlol)
    MBElol=np.mean(m_predictionlol-referencelol)
    r_2lol.append(R2lol)
    maelol.append(MAElol)
    rmselol.append(RMSElol)
    mbelol.append(MBElol)
    sumref=np.sum(referencelol)
    probref=referencelol/sumref
    sumtest=np.sum(m_predictionlol)
    probtest=m_predictionlol/sumtest
    KLlol=sum(rel_entr(probtest,probref))
    kllol.append(KLlol)
    del m_predictionlol, sensorlol
dataframe1=pd.DataFrame(list(zip(lst, r_2lol, maelol, rmselol, mbelol,kllol)), columns=['Sensor', 'R^2', 'MAE', 'RMSE', 'MBE','KL'])
</code>```

And results:

```<code>  Sensor       R^2       MAE      RMSE       MBE        KL
0      I  0.803568  1.776084  5.702426  0.097944  0.044695
1      H  0.739653  2.013070  7.557870  0.102656  0.053525
2      L  0.722556  2.074596  8.054198 -0.143503  0.058237
3      G  0.696291  2.193398  8.816680  0.261528  0.062377
4      J  0.677972  2.251240  9.348475 -0.000313  0.068745
</code>```

I have added random seed to reduce randomness of the model. I have deleted the model every loop and metric variables to avoid any overlay.

Body:
I have 5 different sets of data and want find evaluation metrics for every set using neural network regression. I realized that the R^2 is dropping every loop in order manner. I'm pretty sure there should be a point that I need to identify, but not sure where in my code.

My code:

for sensor, sensorlol, name in zip(sensors, sensorslol, names):
    x_train, x_test, y_train, y_test = train_test_split(sensor, reference, test_size=0.2, random_state=42)
    x_trainl, x_testl, y_trainl, y_testl = train_test_split(sensorlol, referencelol, test_size=0.2, random_state=42)

    kf=KFold(7, shuffle=True, random_state=42)
    ann=MLPRegressor(hidden_layer_sizes=int(node), activation='relu',
                     learning_rate='constant', learning_rate_init=initl, shuffle=False)
    ann.fit(x_train, y_train)
    m_predictionlol=cross_val_predict(ann, sensorlol, referencelol, cv=kf)
    R2lol=r2_score(referencelol, m_predictionlol)
    MAElol=mean_absolute_error(referencelol, m_predictionlol)
    RMSElol=mean_squared_error(referencelol, m_predictionlol)
    MBElol=np.mean(m_predictionlol-referencelol)
    r_2lol.append(R2lol)
    maelol.append(MAElol)
    rmselol.append(RMSElol)
    mbelol.append(MBElol)
    sumref=np.sum(referencelol)
    probref=referencelol/sumref
    sumtest=np.sum(m_predictionlol)
    probtest=m_predictionlol/sumtest
    KLlol=sum(rel_entr(probtest,probref))
    kllol.append(KLlol)
    del m_predictionlol, sensorlol
dataframe1=pd.DataFrame(list(zip(lst, r_2lol, maelol, rmselol, mbelol,kllol)), columns=['Sensor', 'R^2', 'MAE', 'RMSE', 'MBE','KL'])

And results:

  Sensor       R^2       MAE      RMSE       MBE        KL
0      I  0.803568  1.776084  5.702426  0.097944  0.044695
1      H  0.739653  2.013070  7.557870  0.102656  0.053525
2      L  0.722556  2.074596  8.054198 -0.143503  0.058237
3      G  0.696291  2.193398  8.816680  0.261528  0.062377
4      J  0.677972  2.251240  9.348475 -0.000313  0.068745

I have added random seed to reduce randomness of the model. I have deleted the model every loop and metric variables to avoid any overlay.


问:
unable to run javascript code in a flutter webview package of version 4.0.1
I'm using web_view package of version 4.0.1 in flutter to build andriod application. I'm facing an issue while adding javscript code to the webview controller . i need to remove the header section of the webpage . when i used this JS code in Inspect console
"document.getElementsByTagName("header")[0].style.display="none";"
it is working , but when i used this JS code in controller.runJavaScript('document.getElementsByTagName("header")[0].style.display="none";');
is not executing at all . i even tried using "controller.runJavaScriptReturningResult('document.getElementsByTagName("header")[0].style.display="none";');
but nothing seems to work. Can anyone please help me with this? Your assistance would be greatly appreciated.</p>
```<code>class TrackParcel extends StatefulWidget {
  static const routeName = "/track_parcel";
  const TrackParcel({Key? key}) : super(key: key);

  @override
  State<TrackParcel> createState() => _TrackParcelState();
}

class _TrackParcelState extends State<TrackParcel> {
  final controller = WebViewController();
  bool _isLoading = true;
  final dimensions = Dimensions.instance;

  void initateLoad() async {
    controller
      ..setJavaScriptMode(JavaScriptMode.unrestricted)
      ..runJavaScript(
          'document.getElementsByTagName("header")[0].style.display="none";')
      ..setNavigationDelegate(
        NavigationDelegate(
          onPageFinished: (String url) {
            setState(() {
              _isLoading = false;
            });
          },
          // onWebResourceError: (WebResourceError error) {},
        ),
      )
      ..loadRequest(Uri.parse("https://flutter.dev"));

    await controller.runJavaScriptReturningResult(
        'document.getElementsByTagName("header")[0].style.display="none";');
  }

  @override
  void initState() {
    initateLoad();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text("Track Parcel"),
          backgroundColor: Theme.of(context).primaryColor,
        ),
        body: Stack(
          children: [
            Padding(
                padding: EdgeInsets.symmetric(horizontal: dimensions.width10),
                child: WebViewWidget(controller: controller)),
            if (_isLoading) const Center(child: CustomLoadingSpinner())
          ],
        ));
  }
}
</code>```

Body:
I'm using web_view package of version 4.0.1 in flutter to build andriod application. I'm facing an issue while adding javscript code to the webview controller . i need to remove the header section of the webpage . when i used this JS code in Inspect console
"document.getElementsByTagName("header")[0].style.display="none";"
it is working , but when i used this JS code in controller.runJavaScript('document.getElementsByTagName("header")[0].style.display="none";');
is not executing at all . i even tried using "controller.runJavaScriptReturningResult('document.getElementsByTagName("header")[0].style.display="none";');
but nothing seems to work. Can anyone please help me with this? Your assistance would be greatly appreciated.

class TrackParcel extends StatefulWidget {
  static const routeName = "/track_parcel";
  const TrackParcel({Key? key}) : super(key: key);

  @override
  State<TrackParcel> createState() => _TrackParcelState();
}

class _TrackParcelState extends State<TrackParcel> {
  final controller = WebViewController();
  bool _isLoading = true;
  final dimensions = Dimensions.instance;

  void initateLoad() async {
    controller
      ..setJavaScriptMode(JavaScriptMode.unrestricted)
      ..runJavaScript(
          'document.getElementsByTagName("header")[0].style.display="none";')
      ..setNavigationDelegate(
        NavigationDelegate(
          onPageFinished: (String url) {
            setState(() {
              _isLoading = false;
            });
          },
          // onWebResourceError: (WebResourceError error) {},
        ),
      )
      ..loadRequest(Uri.parse("https://flutter.dev"));

    await controller.runJavaScriptReturningResult(
        'document.getElementsByTagName("header")[0].style.display="none";');
  }

  @override
  void initState() {
    initateLoad();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text("Track Parcel"),
          backgroundColor: Theme.of(context).primaryColor,
        ),
        body: Stack(
          children: [
            Padding(
                padding: EdgeInsets.symmetric(horizontal: dimensions.width10),
                child: WebViewWidget(controller: controller)),
            if (_isLoading) const Center(child: CustomLoadingSpinner())
          ],
        ));
  }
}


问:
NJsonSchema C# - Remove $ref fields and replace by the actual structure
I'm using NJsonSchema to convert a normal Json to Schema.
However, NJsonSchema returns the Schema with $ref fields, but I want to have the actual structure.

For example:

```<code>    {
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
      "Property1": {
        "$ref": "#/definitions/Property1"
      },
      "Property2": {
        "$ref": "#/definitions/Property2"
      },
      "Property3": {
        "type": "array",
        "items": {
          "$ref": "#/definitions/Property3"
        }
      },
      "Property4": {
        "type": "array",
        "items": {
          "$ref": "#/definitions/Property4"
        }
      }
    },
    "definitions": {
      "Property1": {
        "type": "object",
        "properties": {
          "Property1_1": {
            "type": "string"
          },
          "Property1_2": {
            "type": "boolean"
          },
          "Property1_3": {
            "type": "integer"
          },
          "Property1_4": {
            "type": "integer"
          }
        }
      },
      "Property2": {
        "type": "object",
        "properties": {
          "Property2_1": {
            "$ref": "#/definitions/Property2_1"
          },
          "Property2_2": {
            "$ref": "#/definitions/Property2_2"
          }
        }
      },
      "Property2_1": {
        "type": "object",
        "properties": {
          "Property2_1_1": {
            "type": "array",
            "items": {
              "$ref": "#/definitions/Property2_1_1"
            }
          },
          "Property2_1_2": {
            "type": "array",
            "items": {
              "$ref": "#/definitions/Property2_1_2"
            }
          },
          "Property2_1_3": {
            "type": "array",
            "items": {
              "$ref": "#/definitions/Property2_1_3"
            }
          },
          "Property2_1_4": {
            "type": "array",
            "items": {
              "$ref": "#/definitions/Property2_1_4"
            }
          }
        }
      },
      "Property2_1_1": {
        "type": "object",
        "properties": {
          "filename": {
            "type": "string"
          },
          "interface": {
            "type": "string"
          },
          "_Comment": {
            "type": "string"
          }
        }
      },
      "Property2_1_2": {
        "type": "object",
        "properties": {
          "filename": {
            "type": "string"
          },
          "interface": {
            "type": "string"
          },
          "_Comment": {
            "type": "string"
          }
        }
      },
      "Property2_1_3": {
        "type": "object",
        "properties": {
          "filename": {
            "type": "string"
          },
          "interface": {
            "type": "string"
          }
        }
      },
      "Property2_1_4": {
        "type": "object",
        "properties": {
          "filename": {
            "type": "string"
          },
          "interface": {
            "type": "string"
          }
        }
      },
      "Property2_2": {
        "type": "object",
        "properties": {
          "dtm_file_name": {
            "type": "string"
          },
          "dtm_file_name_ext": {
            "type": "string"
          },
          "_Comment": {
            "type": "string"
          }
        }
      },
      "Property3": {
        "type": "object",
        "properties": {
          "offset": {
            "type": "integer"
          },
          "value": {
            "type": "string"
          }
        }
      },
      "Property4": {
        "type": "object",
        "properties": {
          "attr_name": {
            "type": "string"
          },
          "offset": {
            "type": "integer"
          }
        }
      }
    }
  }
</code>```

Got the above JSON using:

```<code>JsonSchema bodySchema = JsonSchema.FromSampleJson(jsonStr);

string schemaStr = bodySchema.ToJson();
</code>```

How can I remove these references and replace to the actual structures?

Such as:

```<code>    {
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
      "Property1": {
        "type": "object",
        "properties": {
          "Property1_1": {
            "type": "string"
          },
          "Property1_2": {
            "type": "boolean"
          },
          "Property1_3": {
            "type": "integer"
          },
          "Property1_4": {
            "type": "integer"
          }
        }
      },
      "Property2": {
        "type": "object",
        "properties": {
          "Property2_1": {
            "type": "object",
            "properties": {
              "Property2_1_1": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "filename": {
                      "type": "string"
                    },
                    "interface": {
                      "type": "string"
                    },
                    "_Comment": {
                      "type": "string"
                    }
                  }
                }
              },
              "Property2_1_2": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "filename": {
                      "type": "string"
                    },
                    "interface": {
                      "type": "string"
                    },
                    "_Comment": {
                      "type": "string"
                    }
                  }
                }
              },
              "Property2_1_3": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "filename": {
                      "type": "string"
                    },
                    "interface": {
                      "type": "string"
                    }
                  }
                }
              },
              "Property2_1_4": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "filename": {
                      "type": "string"
                    },
                    "interface": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "Property2_2": {
            "type": "object",
            "properties": {
              "dtm_file_name": {
                "type": "string"
              },
              "dtm_file_name_ext": {
                "type": "string"
              },
              "_Comment": {
                "type": "string"
              }
            }
          }
        }
      },
      "Property3": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "offset": {
              "type": "integer"
            },
            "value": {
              "type": "string"
            }
          }
        }
      },
      "Property4": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "attr_name": {
              "type": "string"
            },
            "offset": {
              "type": "integer"
            }
          }
        }
      }
    }
  }
</code>```

Is there any method that does that inside NJsonSchema or some other way?

Regards,

Thiago

Body:
I'm using NJsonSchema to convert a normal Json to Schema.
However, NJsonSchema returns the Schema with $ref fields, but I want to have the actual structure.

For example:

    {
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
      "Property1": {
        "$ref": "#/definitions/Property1"
      },
      "Property2": {
        "$ref": "#/definitions/Property2"
      },
      "Property3": {
        "type": "array",
        "items": {
          "$ref": "#/definitions/Property3"
        }
      },
      "Property4": {
        "type": "array",
        "items": {
          "$ref": "#/definitions/Property4"
        }
      }
    },
    "definitions": {
      "Property1": {
        "type": "object",
        "properties": {
          "Property1_1": {
            "type": "string"
          },
          "Property1_2": {
            "type": "boolean"
          },
          "Property1_3": {
            "type": "integer"
          },
          "Property1_4": {
            "type": "integer"
          }
        }
      },
      "Property2": {
        "type": "object",
        "properties": {
          "Property2_1": {
            "$ref": "#/definitions/Property2_1"
          },
          "Property2_2": {
            "$ref": "#/definitions/Property2_2"
          }
        }
      },
      "Property2_1": {
        "type": "object",
        "properties": {
          "Property2_1_1": {
            "type": "array",
            "items": {
              "$ref": "#/definitions/Property2_1_1"
            }
          },
          "Property2_1_2": {
            "type": "array",
            "items": {
              "$ref": "#/definitions/Property2_1_2"
            }
          },
          "Property2_1_3": {
            "type": "array",
            "items": {
              "$ref": "#/definitions/Property2_1_3"
            }
          },
          "Property2_1_4": {
            "type": "array",
            "items": {
              "$ref": "#/definitions/Property2_1_4"
            }
          }
        }
      },
      "Property2_1_1": {
        "type": "object",
        "properties": {
          "filename": {
            "type": "string"
          },
          "interface": {
            "type": "string"
          },
          "_Comment": {
            "type": "string"
          }
        }
      },
      "Property2_1_2": {
        "type": "object",
        "properties": {
          "filename": {
            "type": "string"
          },
          "interface": {
            "type": "string"
          },
          "_Comment": {
            "type": "string"
          }
        }
      },
      "Property2_1_3": {
        "type": "object",
        "properties": {
          "filename": {
            "type": "string"
          },
          "interface": {
            "type": "string"
          }
        }
      },
      "Property2_1_4": {
        "type": "object",
        "properties": {
          "filename": {
            "type": "string"
          },
          "interface": {
            "type": "string"
          }
        }
      },
      "Property2_2": {
        "type": "object",
        "properties": {
          "dtm_file_name": {
            "type": "string"
          },
          "dtm_file_name_ext": {
            "type": "string"
          },
          "_Comment": {
            "type": "string"
          }
        }
      },
      "Property3": {
        "type": "object",
        "properties": {
          "offset": {
            "type": "integer"
          },
          "value": {
            "type": "string"
          }
        }
      },
      "Property4": {
        "type": "object",
        "properties": {
          "attr_name": {
            "type": "string"
          },
          "offset": {
            "type": "integer"
          }
        }
      }
    }
  }

Got the above JSON using:

JsonSchema bodySchema = JsonSchema.FromSampleJson(jsonStr);

string schemaStr = bodySchema.ToJson();

How can I remove these references and replace to the actual structures?

Such as:

    {
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
      "Property1": {
        "type": "object",
        "properties": {
          "Property1_1": {
            "type": "string"
          },
          "Property1_2": {
            "type": "boolean"
          },
          "Property1_3": {
            "type": "integer"
          },
          "Property1_4": {
            "type": "integer"
          }
        }
      },
      "Property2": {
        "type": "object",
        "properties": {
          "Property2_1": {
            "type": "object",
            "properties": {
              "Property2_1_1": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "filename": {
                      "type": "string"
                    },
                    "interface": {
                      "type": "string"
                    },
                    "_Comment": {
                      "type": "string"
                    }
                  }
                }
              },
              "Property2_1_2": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "filename": {
                      "type": "string"
                    },
                    "interface": {
                      "type": "string"
                    },
                    "_Comment": {
                      "type": "string"
                    }
                  }
                }
              },
              "Property2_1_3": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "filename": {
                      "type": "string"
                    },
                    "interface": {
                      "type": "string"
                    }
                  }
                }
              },
              "Property2_1_4": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "filename": {
                      "type": "string"
                    },
                    "interface": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "Property2_2": {
            "type": "object",
            "properties": {
              "dtm_file_name": {
                "type": "string"
              },
              "dtm_file_name_ext": {
                "type": "string"
              },
              "_Comment": {
                "type": "string"
              }
            }
          }
        }
      },
      "Property3": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "offset": {
              "type": "integer"
            },
            "value": {
              "type": "string"
            }
          }
        }
      },
      "Property4": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "attr_name": {
              "type": "string"
            },
            "offset": {
              "type": "integer"
            }
          }
        }
      }
    }
  }

Is there any method that does that inside NJsonSchema or some other way?

Regards,

Thiago


问:
Typescript: Partial not working in generic type
Partial throws an error when I have no valid property, but don't throws an error when I have at least one valid property. Why? "a" is not a valid property of User, so why I don't get an error in the first save call? Is my generic type wrong?</p>
```<code>interface User {
    firstname: string;
}

function save<T extends Partial<User>>(entity: T) {

}

// no error
save({
    firstname: 'John',
    a: 1,
})

// error
save({
    a: 1,
})

// error
let user: Partial<User> = {
    firstname: 'John',
    a: 1,
}
</code>```

Body:
Partial throws an error when I have no valid property, but don't throws an error when I have at least one valid property. Why? "a" is not a valid property of User, so why I don't get an error in the first save call? Is my generic type wrong?

interface User {
    firstname: string;
}

function save<T extends Partial<User>>(entity: T) {

}

// no error
save({
    firstname: 'John',
    a: 1,
})

// error
save({
    a: 1,
})

// error
let user: Partial<User> = {
    firstname: 'John',
    a: 1,
}


问:
MPI_Upack inside userd define operation of MPI_reduce()
I have to send a struct that contains, among other things, a dynamically allocated array of another struct.
The receiver has to merge the received message with its data and then send the result to another process.

Basically what I want to obtain is something like that.

I have implemented the following code.

```<code>#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>

typedef struct Data {
  char character;
  int frequency;
} Data;

typedef struct Dictionary {
  int charsNr;
  Data *data;
} Dictionary;

typedef struct Header {
    int id;
    int size;
    MPI_Datatype *type;
    int position;
} Header;

static const int NUM_CHARS = 5;
typedef unsigned char BYTE;

void buildMyTypr(MPI_Datatype *dictType) {
  int blockLengths[] = {1, 1};
  MPI_Datatype types[] = {MPI_CHAR, MPI_INT};
  MPI_Aint offsets[2];

  offsets[0] = offsetof(Data, character);
  offsets[1] = offsetof(Data, frequency);

  MPI_Type_create_struct(2, blockLengths, offsets, types, dictType);
  MPI_Type_commit(dictType);
}

void appendData(Dictionary *dict, Data *data) {
  dict->data = realloc(dict->data, sizeof(Data) * (dict->charsNr+1));
  dict->data[dict->charsNr] = (struct Data) {.character = data->character, .frequency = data->frequency};
  ++dict->charsNr;
}

void mergeDicts(Dictionary *dst, Dictionary *src) {
  for (int i = 0; i < src->charsNr; i++) {
    char character = src->data[i].character;
    int frequency = src->data[i].frequency;
    bool assigned = false;
    for (int j = 0; j < dst->charsNr && !assigned; j++) {
      if (dst->data[j].character == character) {
        dst->data[j].frequency += frequency;
    assigned = true;
      }
    }

    if (!assigned)
      appendData(dst, &src->data[i]);
  }
}

int getRand(const int from, const int to)
{
  int num = (rand() % (to - from + 1)) + from;
  return num;
}

void getMessageSize(int *size, int rank, int tag, MPI_Status *status) {
    MPI_Probe(rank, tag, MPI_COMM_WORLD, status);
    MPI_Get_count(status, MPI_BYTE, size);
}

BYTE* packDictionary(Header *header, Dictionary *dict) {
    header->size = sizeof(int) + (sizeof(Data) * dict->charsNr);

    BYTE *buffer = malloc(sizeof(BYTE) * (header->size));
    header->position = 0;

    MPI_Pack(&dict->charsNr, 1, MPI_INT, buffer, header->size, &header->position, MPI_COMM_WORLD);
    MPI_Pack(dict->data, dict->charsNr, *header->type, buffer, header->size, &header->position, MPI_COMM_WORLD);

    return buffer;
}

void unpackDictionary(Header *header, Dictionary *dict, BYTE *buffer) {
    MPI_Unpack(buffer, header->size, &header->position, &dict->charsNr, 1, MPI_INT, MPI_COMM_WORLD);

    dict->data = malloc(sizeof(Data) * dict->charsNr);
    MPI_Unpack(buffer, header->size, &header->position, dict->data, dict->charsNe, *header->type, MPI_COMM_WORLD);
}

void MyTypeOp(contType *in, contType *out, int *len, MPI_Datatype *typeptr)
{
  MPI_Status *status;
  Dictionary inDict = {.charsNr = 0, .data = NULL};
  Dictionary outDict = {.charsNr = 0, .data = NULL};

  int bufferSize = 0;

  // how can I get the size of the buffers?
  // in other occasion I use the getMessageSize(), but I'm not sure
  // if it can be useful here

  // how can I get the type of the message, basically the dictType?

  Header header = {.id = 0, .size = 0, .type = NULL, .position = 0};
  unpackDictionary(&header, &inDict, in);

  // I should update the header with the new size
  unpackDictionary(&header, &outDict, out);

  mergeDicts(&outDict, &inDict);

  header.size = 0;
  out = packDictionary(header, &outDict);
}

int main(int argc, char **argv)
{
  int proc_number;
  int rank;

  MPI_Comm_size(MPI_COMM_WORLD, &proc_number);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);

  Dictionary dict = {.charsNr = NUM_CHARS, .data = NULL};
  dict.data = malloc(dict.charsNr * sizeof(Data));

  // create a random dictionary
  // I use for simplicity NUM_CHARS but in real life it will be unknown
  // at the beginning and every dictionary can have a different size
  for (int i = 0; i < NUM_CHARS; i++) {
    int freq = getRand(1, 10);
    dict.data[i].frequency = freq;
    dict.data[i].character = 'a' + getRand(1, 5) + i + rank;
  }

  MPI_Datatype dictType;
  buildMyType(&dictType);

  MPI_Op MyOp;
  MPI_Op_create((MPI_User_function *) MyTypeOp, 1, &MyOp);

  MPI_Datatype contType;
  MPI_Type_contiguous(1, MPI_PACKED, &contType);
  MPI_Type_commit(&contType);

  Header header = {.id = 0, .size = 0, .type = &dictType, .position = 0};

  // when I pack the message I put everithing inside a buffer of BYTE
  BYTE *buffer = packDictionary(&header, &dict);

  BYTE *buffer_rcv = NULL;

  MPI_Reduce(&buffer,& buffer_rcv, 1, contType, MyOp, 0, MPI_COMM_WORLD);

  if(rank == 0)
    for (i = 0; i < NUM_CHARS; i++)
      printf("%c: %d\n", dict.data[i].character, dict.data[i].frequency);

  MPI_Type_free(&contType);
  MPI_Type_free(&dictType);
  MPI_Op_free(&MyOp);

  free(buffer);
  free(buffer_rcv);
  free(dict.data);

  MPI_Finalize();

  return 0;
}
</code>```

Of course this example cannot run.

Do you have any suggestion on how can I do it?

I'm writing the code in C on Linux machine.

Thanks.

Body:
I have to send a struct that contains, among other things, a dynamically allocated array of another struct.
The receiver has to merge the received message with its data and then send the result to another process.

Basically what I want to obtain is something like that.

I have implemented the following code.

#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>

typedef struct Data {
  char character;
  int frequency;
} Data;

typedef struct Dictionary {
  int charsNr;
  Data *data;
} Dictionary;

typedef struct Header {
    int id;
    int size;
    MPI_Datatype *type;
    int position;
} Header;

static const int NUM_CHARS = 5;
typedef unsigned char BYTE;

void buildMyTypr(MPI_Datatype *dictType) {
  int blockLengths[] = {1, 1};
  MPI_Datatype types[] = {MPI_CHAR, MPI_INT};
  MPI_Aint offsets[2];

  offsets[0] = offsetof(Data, character);
  offsets[1] = offsetof(Data, frequency);

  MPI_Type_create_struct(2, blockLengths, offsets, types, dictType);
  MPI_Type_commit(dictType);
}

void appendData(Dictionary *dict, Data *data) {
  dict->data = realloc(dict->data, sizeof(Data) * (dict->charsNr+1));
  dict->data[dict->charsNr] = (struct Data) {.character = data->character, .frequency = data->frequency};
  ++dict->charsNr;
}

void mergeDicts(Dictionary *dst, Dictionary *src) {
  for (int i = 0; i < src->charsNr; i++) {
    char character = src->data[i].character;
    int frequency = src->data[i].frequency;
    bool assigned = false;
    for (int j = 0; j < dst->charsNr && !assigned; j++) {
      if (dst->data[j].character == character) {
        dst->data[j].frequency += frequency;
    assigned = true;
      }
    }

    if (!assigned)
      appendData(dst, &src->data[i]);
  }
}

int getRand(const int from, const int to)
{
  int num = (rand() % (to - from + 1)) + from;
  return num;
}

void getMessageSize(int *size, int rank, int tag, MPI_Status *status) {
    MPI_Probe(rank, tag, MPI_COMM_WORLD, status);
    MPI_Get_count(status, MPI_BYTE, size);
}

BYTE* packDictionary(Header *header, Dictionary *dict) {
    header->size = sizeof(int) + (sizeof(Data) * dict->charsNr);

    BYTE *buffer = malloc(sizeof(BYTE) * (header->size));
    header->position = 0;

    MPI_Pack(&dict->charsNr, 1, MPI_INT, buffer, header->size, &header->position, MPI_COMM_WORLD);
    MPI_Pack(dict->data, dict->charsNr, *header->type, buffer, header->size, &header->position, MPI_COMM_WORLD);

    return buffer;
}

void unpackDictionary(Header *header, Dictionary *dict, BYTE *buffer) {
    MPI_Unpack(buffer, header->size, &header->position, &dict->charsNr, 1, MPI_INT, MPI_COMM_WORLD);

    dict->data = malloc(sizeof(Data) * dict->charsNr);
    MPI_Unpack(buffer, header->size, &header->position, dict->data, dict->charsNe, *header->type, MPI_COMM_WORLD);
}

void MyTypeOp(contType *in, contType *out, int *len, MPI_Datatype *typeptr)
{
  MPI_Status *status;
  Dictionary inDict = {.charsNr = 0, .data = NULL};
  Dictionary outDict = {.charsNr = 0, .data = NULL};

  int bufferSize = 0;

  // how can I get the size of the buffers?
  // in other occasion I use the getMessageSize(), but I'm not sure
  // if it can be useful here

  // how can I get the type of the message, basically the dictType?

  Header header = {.id = 0, .size = 0, .type = NULL, .position = 0};
  unpackDictionary(&header, &inDict, in);

  // I should update the header with the new size
  unpackDictionary(&header, &outDict, out);

  mergeDicts(&outDict, &inDict);

  header.size = 0;
  out = packDictionary(header, &outDict);
}

int main(int argc, char **argv)
{
  int proc_number;
  int rank;

  MPI_Comm_size(MPI_COMM_WORLD, &proc_number);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);

  Dictionary dict = {.charsNr = NUM_CHARS, .data = NULL};
  dict.data = malloc(dict.charsNr * sizeof(Data));

  // create a random dictionary
  // I use for simplicity NUM_CHARS but in real life it will be unknown
  // at the beginning and every dictionary can have a different size
  for (int i = 0; i < NUM_CHARS; i++) {
    int freq = getRand(1, 10);
    dict.data[i].frequency = freq;
    dict.data[i].character = 'a' + getRand(1, 5) + i + rank;
  }

  MPI_Datatype dictType;
  buildMyType(&dictType);

  MPI_Op MyOp;
  MPI_Op_create((MPI_User_function *) MyTypeOp, 1, &MyOp);

  MPI_Datatype contType;
  MPI_Type_contiguous(1, MPI_PACKED, &contType);
  MPI_Type_commit(&contType);

  Header header = {.id = 0, .size = 0, .type = &dictType, .position = 0};

  // when I pack the message I put everithing inside a buffer of BYTE
  BYTE *buffer = packDictionary(&header, &dict);

  BYTE *buffer_rcv = NULL;

  MPI_Reduce(&buffer,& buffer_rcv, 1, contType, MyOp, 0, MPI_COMM_WORLD);

  if(rank == 0)
    for (i = 0; i < NUM_CHARS; i++)
      printf("%c: %d\n", dict.data[i].character, dict.data[i].frequency);

  MPI_Type_free(&contType);
  MPI_Type_free(&dictType);
  MPI_Op_free(&MyOp);

  free(buffer);
  free(buffer_rcv);
  free(dict.data);

  MPI_Finalize();

  return 0;
}

Of course this example cannot run.

Do you have any suggestion on how can I do it?

I'm writing the code in C on Linux machine.

Thanks.


问:
Bootstrap Dropdown Menu - Multiple Columns Side-by-Side
Trying to create a filter on a web page that utilizes Bootstrap's drop-down menu and places the columns side-by-side, but instead it stacks them right now. The filter menu is created dynamically by looping through an array of items I want to create and. each item is a new column I want to place on my menu. I was trying to utilize the grid layout (container > row > column) with the class row-cols-# on my row element but that does not work as I thought it would.

I can force my menu to be a certain width and make the columns position correctly, but then my menu is hardcoded to a certain width on all filter menu regardless of the number of columns. Here is sample of my HTML code that is creating a rather big menu.

Wondering if my d-flex at the very end is what causes problems for my grid layout

```<code><div
  class="ms-auto py-4"
  id="PageFilter"
>
  <div class="dropdown filter">
    <button
      class="btn btn-outline-secondary d-flex align-items-center dropdown-toggle"
      type="button"
      data-bs-toggle="dropdown"
    >
      <img
        src="/static/icons/bootstrap/sliders2.svg"
        class="me-2"
        height="25"
      />
      Filter
      <span class="badge bg-danger ms-4">0</span>
    </button>
    <div class="dropdown-menu dropdown-menu-end shadow" style="">
      <form action="/ajax/page_filter/" method="GET" class="filter">
        <div class="container">
          <div class="row">
            <div class="col-sm-auto">
              <h6 class="dropdown-header">Region</h6>
              <hr class="mt-0" />
              <div
                class="overflow-y-auto filter-list"
                style="max-height: 400px"
              >
                <div class="row align-items-center mx-2">
                  <div class="form-check">
                    <input/>
                    <label class="form-check-label" for="filter-0-0">
                      ITEM 1
                    </label>
                  </div>
                </div>
                <div class="row align-items-center mx-2">
                  <div class="form-check">
                    <input/>
                    <label class="form-check-label" for="filter-0-1">
                      ITEM 2
                    </label>
                  </div>
                </div>
              </div>
            </div>
            <div class="col-sm-auto">
              <h6 class="dropdown-header">State</h6>
              <hr class="mt-0" />
              <div
                class="overflow-y-auto filter-list"
                style="max-height: 400px"
              >
                <div class="row align-items-center mx-2">
                  <div class="form-check">
                    <input/>
                    <label class="form-check-label" for="filter-1-0">
                      ITEM 1
                    </label>
                  </div>
                </div>
                <div class="row align-items-center mx-2">
                  <div class="form-check">
                    <input/>
                    <label class="form-check-label" for="filter-1-1">
                      ITEM 2
                    </label>
                  </div>
                </div>
                <div class="row align-items-center mx-2">
                  <div class="form-check">
                    <input/>
                    <label class="form-check-label" for="filter-1-2">
                      ITEM 3
                    </label>
                  </div>
                </div>
                <div class="row align-items-center mx-2">
                  <div class="form-check">
                    <input/>
                    <label class="form-check-label" for="filter-1-3">
                      ITEM 4
                    </label>
                  </div>
                </div>
                <div class="row align-items-center mx-2">
                  <div class="form-check">
                    <input/>
                    <label class="form-check-label" for="filter-1-4">
                      ITEM 5
                    </label>
                  </div>
                </div>
                <div class="row align-items-center mx-2">
                  <div class="form-check">
                    <input/>
                    <label class="form-check-label" for="filter-1-5">
                      ITEM 6
                    </label>
                  </div>
                </div>
                <div class="row align-items-center mx-2">
                  <div class="form-check">
                    <input/>
                    <label class="form-check-label" for="filter-1-6">
                      ITEM 7
                    </label>
                  </div>
                </div>
                <div class="row align-items-center mx-2">
                  <div class="form-check">
                    <input/>
                    <label class="form-check-label" for="filter-1-7">
                      ITEM 8
                    </label>
                  </div>
                </div>
              </div>
            </div>
            <div class="col-sm-auto">
              <h6 class="dropdown-header">TSC</h6>
              <hr class="mt-0" />
              <div
                class="overflow-y-auto filter-list"
                style="max-height: 400px"
              >
                <div class="row align-items-center mx-2">
                  <div class="form-check">
                    <input/>
                    <label class="form-check-label" for="filter-2-0">
                      ITEM 1
                    </label>
                  </div>
                </div>
                <div class="row align-items-center mx-2">
                  <div class="form-check">
                    <input/>
                    <label class="form-check-label" for="filter-2-1">
                      ITEM 2
                    </label>
                  </div>
                </div>
              </div>
            </div>
            <div class="d-flex justify-content-end mt-4">
              <button type="reset" class="btn btn-sm btn-warning clear-filter">
                Clear Filter
              </button>
              <button type="submit" class="btn btn-sm btn-danger ms-2">
                Submit
              </button>
            </div>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>
</code>```

UPDATE

I've included my current example here Filter Menu Help

Body:
Trying to create a filter on a web page that utilizes Bootstrap's drop-down menu and places the columns side-by-side, but instead it stacks them right now. The filter menu is created dynamically by looping through an array of items I want to create and. each item is a new column I want to place on my menu. I was trying to utilize the grid layout (container > row > column) with the class row-cols-# on my row element but that does not work as I thought it would.

I can force my menu to be a certain width and make the columns position correctly, but then my menu is hardcoded to a certain width on all filter menu regardless of the number of columns. Here is sample of my HTML code that is creating a rather big menu.

Wondering if my d-flex at the very end is what causes problems for my grid layout

    <button
      class="btn btn-outline-secondary d-flex align-items-center dropdown-toggle"
      type="button"
      data-bs-toggle="dropdown"
    >

      Filter
      0
    </button>

      <form action="/ajax/page_filter/" method="GET" class="filter">

Region

                    <input/>

                      ITEM 1

                    <input/>

                      ITEM 2

State

                    <input/>

                      ITEM 1

                    <input/>

                      ITEM 2

                    <input/>

                      ITEM 3

                    <input/>

                      ITEM 4

                    <input/>

                      ITEM 5

                    <input/>

                      ITEM 6

                    <input/>

                      ITEM 7

                    <input/>

                      ITEM 8

TSC

                    <input/>

                      ITEM 1

                    <input/>

                      ITEM 2

              <button type="reset" class="btn btn-sm btn-warning clear-filter">
                Clear Filter
              </button>
              <button type="submit" class="btn btn-sm btn-danger ms-2">
                Submit
              </button>

      </form>

UPDATE

I've included my current example here Filter Menu Help


问:
StaleElementReferenceException Selenuim Python
I am trying to extract the numbers from the below page but always showed  an exception, I tried various solutions but still get StaleElementReferenceException, here is my code..

I tried sleep and wait...., what is the problem?, please

```<code>options = Options()
options.add_argument("start-maximized")
webdriver_service = Service('C:/Users/Lenovo/PycharmProjects/pythonProject/chromedriver.exe')
driver = webdriver.Chrome(options=options, service=webdriver_service)
wait = WebDriverWait(driver, 20)

driver.get("https://ec.europa.eu/ecat/category/en/5/dishwasher-detergents")
products = []

num_pages = 7
step = 0

while (step < num_pages):

    try:
        time.sleep(2)
        elm = wait.until(EC.presence_of_all_elements_located((By.XPATH, "//*[@id='producersTableId']/tbody/tr/td[4]")))
        time.sleep(2)
        products.extend(elm)
        for i in products:
            print(i.text) # the exception appreas here
        elm = wait.until(EC.presence_of_all_elements_located((By.XPATH, "//*[@id='producersTableId']/tbody/tr/td[4]")))

        next_Butt =  wait.until(EC.element_to_be_clickable((By.XPATH, "//*[@id='producersTableId_next']/a")))
        driver.execute_script("arguments[0].click();", next_Butt)
        time.sleep(2)
        step += 1
    except exceptions.StaleElementReferenceException as e :
        print(e)
        pass
print(len(products))

</code>```

Body:
I am trying to extract the numbers from the below page but always showed  an exception, I tried various solutions but still get StaleElementReferenceException, here is my code..

I tried sleep and wait...., what is the problem?, please

options = Options()
options.add_argument("start-maximized")
webdriver_service = Service('C:/Users/Lenovo/PycharmProjects/pythonProject/chromedriver.exe')
driver = webdriver.Chrome(options=options, service=webdriver_service)
wait = WebDriverWait(driver, 20)

driver.get("https://ec.europa.eu/ecat/category/en/5/dishwasher-detergents")
products = []

num_pages = 7
step = 0

while (step < num_pages):

    try:
        time.sleep(2)
        elm = wait.until(EC.presence_of_all_elements_located((By.XPATH, "//*[@id='producersTableId']/tbody/tr/td[4]")))
        time.sleep(2)
        products.extend(elm)
        for i in products:
            print(i.text) # the exception appreas here
        elm = wait.until(EC.presence_of_all_elements_located((By.XPATH, "//*[@id='producersTableId']/tbody/tr/td[4]")))

        next_Butt =  wait.until(EC.element_to_be_clickable((By.XPATH, "//*[@id='producersTableId_next']/a")))
        driver.execute_script("arguments[0].click();", next_Butt)
        time.sleep(2)
        step += 1
    except exceptions.StaleElementReferenceException as e :
        print(e)
        pass
print(len(products))


问:
Getting Spotify-generated artist playlists using Web API
When Siri is asked "play music by ARTIST_NAME on Spotify" she starts playing music from a playlist that is generated by Spotify, with no displayed name, and the description "ARTIST_NAME songs picked just for you". I cannot find a way to find this playlist. Its name, according to the https://api.spotify.com/v1/me/player endpoint, is ARTIST_NAME, and its owner is Spotify. How can I find this playlist for a given artist using the Web API?

Ultimately, I am trying to work around the fact that if there is no available device (i.e. Spotify is idle or closed) an artist cannot be played by setting a context-uri in the https://api.spotify.com/v1/me/player/play endpoint. To work around this issue in the case of playing a playlist that the user of my program searches for, I have simply opened the URL of the first track in the album or playlist. This doesn't work in the case of artists, since the list of top tracks by an artists gives the tracks' URLs in the context of the respective tracks's album.

If there is no way to access this Siri exclusive playlist, I would appreciate feedback suggesting alternate routes. It is not sufficient to simply create a playlist, since they would be static and have to be recreated for each request.

Thank you.


问:
How to make one Javascript table popluate from multiple sets of data
I am creating a page that has 63 sets of data (states, provinces, territories) presented as an html table. The tables display 4 bits of information in columns and each table has as few as one entry or as many as 45 entries. I am currently marking this up on the page itself but with what will be hundreds of rows of data, it's making for an extremely long html page. How can I create one table in Javascript and have it populate the information from my 63 sets of data based, maybe on a unique ID or something?

Here are a sample of the tables I'm working with.

```<code><div class="hidden" id="Alabama">    <!--ALABAMA-->
                    <table class="place-table">
                            <thead>
                                    <tr>
                                         <th class="location-column">Location</th>
                                         <th class="name-column">Name</th>
                                         <th class="type-column">Type</th>
                                         <th class="rating-column">Rating</th>
                                    </tr>
                            </thead>
                    <tbody>
                      <tr>
                            <td>Eight Mile</td>
                        <td><a class="place-name-link" href="https://www.campendium.com/chickasabogue-park" target="_blank" rel="noopener">Chickasabogue Park</a></td>
                        <td>County Park</td>
                        <td class="center">3</td>
                      </tr>
                      <tr>
                            <td>Fort Payne</td>
                        <td><a class="place-name-link" href="https://www.campendium.com/desoto-state-park" target="_blank" rel="noopener">DeSoto State Park</a></td>
                        <td>Fort Payne</td>
                        <td class="center">4</td>
                      </tr>
                      <tr>
                            <td>Helflin</td>
                        <td><a class="place-name-link" href="https://www.campendium.com/pine-glen-recreation-area" target="_blank" rel="noopener">Pine Glen Recreation Area</a></td>
                        <td>National Forest</td>
                        <td class="center">3</td>
                      </tr>
                      <tr>
                            <td>Tuskaloosa</td>
                        <td><a class="place-name-link" href="https://www.allstays.com/c/Walmart/AL-Tuscaloosa-Wal-Mart-715.htm" target="_blank" rel="noopener">Walmart/Sam's Club</a></td>
                        <td>Big Box Parking Lot</td>
                        <td class="center">2</td>
                      </tr>
                      <!--<tr>
                            <td>Location</td>
                        <td>Camping place name</td>
                        <td>Camping place type</td>
                        <td class="center">Rating</td>
                      </tr>-->
                        <tbody>
                    </table>
                </div>

              <div class="hidden" id="Alberta">    <!--ALBERTA-->
                    <table class="place-table">
                            <thead>
                                    <tr>
                                         <th class="location-column">Location</th>
                                         <th class="name-column">Name</th>
                                         <th class="type-column">Type</th>
                                         <th class="rating-column">Rating</th>
                                    </tr>
                            </thead>
                            <tbody>
                                  <tr>
                                     <td>Steveville</td>
                                         <td><a class="place-name-link" href="https://www.campendium.com/steveville-bridge" target="_blank" rel="noopener">Steveville Bridge Campground</td>
                                     <td>Provincial Park</td>
                                     <td class="center">4</td>
                                  </tr>
                                  <!--<tr>
                                         <td>Location</td>
                                     <td><a class="place-name-link" href="" target="_blank" rel="noopener">Place Name</td>
                                     <td>Place Type</td>
                                     <td class="center">Rating</td>
                                  </tr>-->
                            <tbody>
                  </table>
              </div>

              <div class="hidden" id="Arizona">    <!--ARIZONA-->
                <table class="place-table">
                            <thead>
                                    <tr>
                                         <th class="location-column">Location</th>
                                         <th class="name-column">Name</th>
                                         <th class="type-column">Type</th>
                                         <th class="rating-column">Rating</th>
                                    </tr>
                            </thead>
                        <tbody>
                                <tr>
                                <tr>
                                        <td>Camp Verde</td>
                                    <td><a class="place-name-link" href="https://www.campendium.com/distant-drums-rv-resort" target="_blank" rel="noopener">Distant Drums RV Resort</td>
                                    <td>RV Park</td>
                                    <td class="center">3+</td>
                                </tr>
                                <tr>
                                        <td>Cottonwood</td>
                                    <td><a class="place-name-link" href="https://www.campendium.com/dead-horse-ranch-state-park" target="_blank" rel="noopener">Dead Horse Ranch State Park</td>
                                    <td>State Park</td>
                                    <td class="center">3</td>
                                </tr>
                                <tr>
                                        <td>Dragoon</td>
                                    <td><a class="place-name-link" href="https://www.arizonarestareas.com/az-i10-rest-area-eastbound-mile-marker-320/" target="_blank" rel="noopener">I-10 Texas Canyon</td>
                                    <td> Rest Area</td>
                                    <td class="center">2</td>
                                </tr>
                                <tr>
                                        <td>Flagstaff</td>
                                    <td><a class="place-name-link" href="https://www.campendium.com/j-h-rv-park" target="_blank" rel="noopener">J & H RV Park</td>
                                    <td>RV Park</td>
                                    <td class="center">3</td>
                                </tr>
                                <tr>
                                        <td>Kingman</td>
                                    <td><a class="place-name-link" href="https://www.campendium.com/blake-ranch-rv-park" target="_blank" rel="noopener">Blake Ranch RV Park and Horse Motel</td>
                                    <td>RV Park</td>
                                  <td class="center">2</td>
                                </tr>
                                <tr>
                                        <td>Mayer</td>
                                    <td><a class="place-name-link" href="https://www.campendium.com/bloody-basin-road-east-dispersed-camping" target="_blank" rel="noopener">Bloody Basin Road East Dispersed Camping</td>
                                    <td>BLM</td>
                                    <td class="center">4</td>
                                </tr>
                                        <td>Mesa</td>
                                    <td><a class="place-name-link" href="https://www.tripadvisor.com/ShowUserReviews-g31281-d4739035-r574036384-Bass_Pro_Shop_Outdoor_World-Mesa_Arizona.html" target="_blank" rel="noopener">Bass Pro Shop</td>
                                    <td>Parking Lot</td>
                                    <td class="center">2</td>
                                </tr>
                                <tr>
                                <tr>
                                        <td>Parker</td>
                                    <td><a class="place-name-link" href="https://www.campendium.com/shea-road" target="_blank" rel="noopener">Shea Road Dispersed Camping</td>
                                    <td>BLM</td>
                                    <td class="center">5</td>
                                </tr>
                                <tr>
                                        <td>Prescott</td>
                                    <td><a class="place-name-link" href="https://www.campendium.com/thumb-butte-loop-designated-dispersed-campsite-1" target="_blank" rel="noopener">Thumb Butte Loop Designated Dispersed Campsite</td>
                                    <td>National Forest</td>
                                    <td class="center">4</td>
                                </tr>
                                        <td>South Happy Camp Canyon, Bowie</td>
                                    <td><a class="place-name-link" href="https://www.campendium.com/indian-bread-rocks" target="_blank" rel="noopener">Indian Bread Rocks</td>
                                    <td>BLM</td>
                                    <td class="center">5+</td>
                                </tr>
                                <tr>
                                        <td>Topock</td>
                                    <td><a class="place-name-link" href="https://www.campendium.com/needle-mountain-road" target="_blank" rel="noopener">Needle Mountain Road Dispersed Camping</td>
                                    <td>BLM</td>
                                    <td class="center">3</td>
                                </tr>
                                <tr>
                                        <td>Tonopah</td>
                                    <td><a class="place-name-link" href="https://www.campendium.com/saddle-mountain" target="_blank" rel="noopener">Saddle Mountain Dispersed Camping</td>
                                    <td>BLM</td>
                                    <td class="center">4</td>
                                </tr>
                                <tr>
                                        <td>Tucson</td>
                                    <td><a class="place-name-link" href="https://www.campendium.com/diamond-j-rv-park" target="_blank" rel="noopener">Justin’s Diamond J RV Park</td>
                                    <td>RV Park</td>
                                    <td class="center">4</td>
                                </tr>
                                <tr>
                                        <td>White Hills</td>
                                    <td><a class="place-name-link" href="https://www.campendium.com/kingman-wash" target="_blank" rel="noopener">Kingman Wash Dispersed Camping</td>
                                    <td>National Recreation Area</td>
                                    <td class="center">2</td>
                                </tr>
                                <tr>
                                        <td>Wickenburg</td>
                                    <td><a class="place-name-link" href="https://www.campendium.com/vulture-peak" target="_blank" rel="noopener">Vulture Peak</td>
                                    <td>State Trust Land</td>
                                    <td class="center">4</td>
                                </tr>
                                <!--<tr>
                                        <td>Location</td>
                                    <td><a class="place-name-link" href="" target="_blank" rel="noopener">Place Name</td>
                                    <td>Place Type</td>
                                    <td class="center">Rating</td>
                                </tr>-->
                        <tbody>
                </table>
              </div>

</code>```

I understand only very rudimentary Javascript, so an actual example of code will be much more useful than an explanation of the logic behind it. Thanks in advance for any help.

I've seen examples of how to populate one table with multiple arrays, i.e., multiple rows, but I can't find an example of coding one table that will dynamically populate different arrays. If I just replicate the code to create one Javascript table 63 times, I'm not saving myself any work or space.

Body:
I am creating a page that has 63 sets of data (states, provinces, territories) presented as an html table. The tables display 4 bits of information in columns and each table has as few as one entry or as many as 45 entries. I am currently marking this up on the page itself but with what will be hundreds of rows of data, it's making for an extremely long html page. How can I create one table in Javascript and have it populate the information from my 63 sets of data based, maybe on a unique ID or something?

Here are a sample of the tables I'm working with.

                                         Location
                                         Name
                                         Type
                                         Rating

                            Eight Mile
                        Chickasabogue Park
                        County Park
                        3

                            Fort Payne
                        DeSoto State Park
                        Fort Payne
                        4

                            Helflin
                        Pine Glen Recreation Area
                        National Forest
                        3

                            Tuskaloosa
                        Walmart/Sam's Club
                        Big Box Parking Lot
                        2

                                         Location
                                         Name
                                         Type
                                         Rating

                                     Steveville
                                         Steveville Bridge Campground
                                     Provincial Park
                                     4

                                         Location
                                         Name
                                         Type
                                         Rating

                                        Camp Verde
                                    Distant Drums RV Resort
                                    RV Park
                                    3+

                                        Cottonwood
                                    Dead Horse Ranch State Park
                                    State Park
                                    3

                                        Dragoon
                                    I-10 Texas Canyon
                                     Rest Area
                                    2

                                        Flagstaff
                                    J & H RV Park
                                    RV Park
                                    3

                                        Kingman
                                    Blake Ranch RV Park and Horse Motel
                                    RV Park
                                  2

                                        Mayer
                                    Bloody Basin Road East Dispersed Camping
                                    BLM
                                    4

                                        Mesa
                                    Bass Pro Shop
                                    Parking Lot
                                    2

                                        Parker
                                    Shea Road Dispersed Camping
                                    BLM
                                    5

                                        Prescott
                                    Thumb Butte Loop Designated Dispersed Campsite
                                    National Forest
                                    4

                                        South Happy Camp Canyon, Bowie
                                    Indian Bread Rocks
                                    BLM
                                    5+

                                        Topock
                                    Needle Mountain Road Dispersed Camping
                                    BLM
                                    3

                                        Tonopah
                                    Saddle Mountain Dispersed Camping
                                    BLM
                                    4

                                        Tucson
                                    Justin’s Diamond J RV Park
                                    RV Park
                                    4

                                        White Hills
                                    Kingman Wash Dispersed Camping
                                    National Recreation Area
                                    2

                                        Wickenburg
                                    Vulture Peak
                                    State Trust Land
                                    4

I understand only very rudimentary Javascript, so an actual example of code will be much more useful than an explanation of the logic behind it. Thanks in advance for any help.

I've seen examples of how to populate one table with multiple arrays, i.e., multiple rows, but I can't find an example of coding one table that will dynamically populate different arrays. If I just replicate the code to create one Javascript table 63 times, I'm not saving myself any work or space.


问:
How can we change container registry service from Dockerhub to ECR?
I am looking for a way to move chunk of our organization's images from Dockerhub to ECR. Is there a good way to switch between container registry services?

Thanks in advnace

I have tried creating a ECR repository and get authentication token that we can use to authenticate to an Amazon ECR registry.
Use docker tag to tag new image based on source image from Dockerhub.
Use docker push to upload it to ECR.

Does this sound right, if yes can we automate this for a chunk of images?


问:
Sharing executeables from head node to compute nodes in a Unix HPC cluster
I am working with some CFD software on a Unix cluster, and the software is installed on the head node, but not as a module. Is there a way for me to share this software and its executable with the compute nodes so we can run jobs via slurm job scripts without having to reinstall this software to a different location on the head node?

So far I have been able to run a test case on the head node, so I know that the software is installed correctly and at least working on the head node. I have ssh to one of the compute nodes and searched for the executable there and not found a path where I have permission to run said executable.


问:
EF 7 readonly/hidden columns only for particular rows
I’m looking to convert an existing project to using EF 7. The current user security allows for certain fields of certain rows to be read-only or completely hidden.

For example an ‘admin’ user might be able to read/modify all data from the users table EXCEPT for other administrators. For other administrators, ‘username’ would be read-only, and ‘passwordHash’ would be completely hidden.

Is there a way to do this with EF 7? FluentAPI or something else?

From what I've been able to find with FluentAPI, filtering can be applied to read-only/hide whole rows, or read-only/hide particular columns for ALL rows. I want to read-only/hide particular columns for SOME rows.


问:
DataFrame.apply oddly returns a dataframe instead of series under certain circumstances
UPDATE: the following behaviour might have been a bug in Pandas 1.4.4 (which was the version I used up to now). Upgrading to Pandas 1.5.2 yields a Series both for test1 and test2, which is what I was expecting.

I need to handle receiving empty dataframes (besides non-empty ones) like this one:

import pandas as pd
df = pd.DataFrame({'a':[], 'b':[]})
```
<p>I derive a series from the dataframe I get (also the non-empty ones, which works well).
The <code>apply</code> function unexpectedly returns a DataFrame instead of a Series if both</p>
<ul>
<li>the input DataFrame is empty and</li>
<li>I use a function in the <code>apply</code>'s lambda.</li>
</ul>
<pre class="lang-py prettyprint-override"><code>def f(x):
    if x%2 == 0: return True
    else: return False

test1 = df.apply(lambda row: 'foo' if f(row[0]) else 'bar', axis='columns')
test2 = df.apply(lambda row: 'foo' if True else 'bar', axis='columns')
</code>```

test1 is a (empty) DataFrame while test2 a (empty) Series, which I expect it to be (with non-empty DataFrame df, always a Series is returned).

I know I could write a simple workaround, but I would really like to know what's happening here.

Body:
UPDATE: the following behaviour might have been a bug in Pandas 1.4.4 (which was the version I used up to now). Upgrading to Pandas 1.5.2 yields a Series both for test1 and test2, which is what I was expecting.

I need to handle receiving empty dataframes (besides non-empty ones) like this one:

import pandas as pd
df = pd.DataFrame({'a':[], 'b':[]})

I derive a series from the dataframe I get (also the non-empty ones, which works well).
The apply function unexpectedly returns a DataFrame instead of a Series if both

the input DataFrame is empty and

I use a function in the apply's lambda.

def f(x):
    if x%2 == 0: return True
    else: return False

test1 = df.apply(lambda row: 'foo' if f(row[0]) else 'bar', axis='columns')
test2 = df.apply(lambda row: 'foo' if True else 'bar', axis='columns')

test1 is a (empty) DataFrame while test2 a (empty) Series, which I expect it to be (with non-empty DataFrame df, always a Series is returned).

I know I could write a simple workaround, but I would really like to know what's happening here.


问:
Android Studio stuck on "Finding Available SDK Componets"
When launching android studio, it keeps trying to download this one file and never completes it. It will sit here stuck for hours. Any help or suggestions would be greatly appreciated. Screenshot attached

Tried uninstalling and reinstalling, keep getting stuck on the same screen when launching.