instruction
stringlengths
0
30k
null
I have a search box and show a filterable list of matching elements in a DIV that hovers over the other components. Once the user selects something, the DIV is hidden. This part works as supposed to. Occasionally, the user will desire to cancel the lookup process and click on a cross icon in the popout. This works as expected too. Now, I'd like to enable the user to hide the popout if they click outside of it. The approach I picked was to implement [a host listening method](https://stackoverflow.com/a/40652072/1525840) as shown below. @HostListener('click', ['$event']) onClickHost() { this.projectToggle = false; this.userToggle = false; } Well... it works as supposed to with a huge "butt". Clicking outside the listening component (which by definition is outside the popout part), gives me no action. Naturally, I understand why it won't react - the host listened to is not being clicked, du'h... The best solution I can think of is to let the parent component (the page itself containing the popouting search box) listen to its host and propagate such an event into the child. It's rather significant increment in complexity and I want to find a simpler way to detect: *click anywhere on the page outside of the DIV that poopouted*. Is it possible? If not, I'll tell the user to be happy with the cross to click. I just wish to establish that it's not my ignorance that sets the limit, not my laziness.
"Null check operator used on a null value in flutter, getx package"
|flutter|dart|
null
**Requirement**: Based on the code provided below, implement the merge sort algorithm to rearrange an array with N elements. While running the algorithm, print array A after each merge of two subarrays. Input - The first line is a positive integer N (0 \< N \< 20) - The next line contains N integers Who are the elements of the array Output - The next lines print out the configuration of array A. # Example: Input 10 800 728 703 671 628 625 518 508 392 331 Output \[ 728 800 \] 703 671 628 625 518 508 392 331 \[ 703 728 800 \] 671 628 625 518 508 392 331 703 728 800 \[ 628 671 \] 625 518 508 392 331 \[ 628 671 703 728 800 \] 625 518 508 392 331 628 671 703 728 800 \[ 518 625 \] 508 392 331 628 671 703 728 800 \[ 508 518 625 \] 392 331 628 671 703 728 800 508 518 625 \[ 331 392 \] 628 671 703 728 800 \[ 331 392 508 518 625 \] \[ 331 392 508 518 625 628 671 703 728 800 \] I'm having trouble finding a way to print out the remaining elements of the array after each merge. this is my code, hope any one can help me: ``` #include \<iostream\> using namespace std; void printArray(int arr\[\], int start, int end) { cout \<\< "\[ "; for (int i = start; i \<= end; ++i) { cout \<\< arr\[i\]; if (i \< end) { cout \<\< " "; } } cout \<\< " \] "; } void merge(int arr\[\], int left, int mid, int right) { int n1 = mid - left + 1; int n2 = right - mid; int* L = new int[n1]; int* R = new int[n2]; for (int i = 0; i < n1; ++i) L[i] = arr[left + i]; for (int j = 0; j < n2; ++j) R[j] = arr[mid + 1 + j]; int i = 0, j = 0, k = left; while (i < n1 && j < n2) { if (L[i] <= R[j]) { arr[k] = L[i]; ++i; } else { arr[k] = R[j]; ++j; } ++k; } while (i < n1) { arr[k] = L[i]; ++i; ++k; } while (j < n2) { arr[k] = R[j]; ++j; ++k; } // print the array after merge printArray(arr, left, right); cout << endl; delete[] L; delete[] R; } void mergeSort(int arr\[\], int left, int right) { if (left \< right) { int mid = left + (right - left) / 2; mergeSort(arr, left, mid); mergeSort(arr, mid + 1, right); merge(arr, left, mid, right); } } int main() { int N; cin \>\> N; int* arr = new int[N]; for (int i = 0; i < N; ++i) cin >> arr[i]; mergeSort(arr, 0, N - 1); delete[] arr; return 0; } ```
basic MergeSort exercise
|c++|sorting|mergesort|
null
``` import java.util.Random; import java.util.regex.Pattern; import java.util.regex.Matcher; String responseData = prev.getResponseDataAsString(); // log.info("the response data is : " + responseData); Pattern pattern = Pattern.compile("<option value=\"(.+?)\">(.+?)</option>"); // log.info("pattern is : " + pattern); Matcher matcher = pattern.matcher(responseData); // log.info("matcher is :" + matcher); while(matcher.find()) { log.info("the cities are : " + matcher.group(1)); String extractedCity = matcher.group(1); log.info("the extracted city is : " + extractedCity); vars.put("Depart_city" , extractedCity); }[log level output of the code](https://i.stack.imgur.com/ANKbl.png) ``` i am able to extract the data but i am unable to pick a random value from the result and store it into a jmeter variaable
{"OriginalQuestionIds":[68836551],"Voters":[{"Id":530160,"DisplayName":"Nick ODell"},{"Id":349130,"DisplayName":"Dr. Snoopy","BindingReason":{"GoldTagBadge":"keras"}}]}
If you forgot your password, save for brute forcing it, you're done for. [RAR uses AES 256 encryption][1] to encrypt archives, not to mention you can't just recover the password from information stored within the archive (since it only stores a hash to check if the password is correct), *and* the fact that every portion of a file inside a protected archive is encrypted. [1]: https://www.win-rar.com/encryption-faq.html
[After drop_na it shows 0 obs. of 68 variables] (https://i.stack.imgur.com/elrGR.png)(https://i.stack.imgur.com/txJEv.png)] [After drop_na I don't see any results in the Table except dates. This was not the case when I tried it before, I could see the values ​​in the table] +library(tidyverse) +WDI_GDP <- read_csv("C:/Users/ASYA/Desktop/P_Data_Extract_From_World_Development_Indicators/b0351889-13b3-4cbe-a5c0-a2dd9d633eab_Data.csv") +WDI_GDP <- WDI_GDP %>% + mutate(across(contains("[YR"), ~na_if(.x,"..")) %>% + mutate(across(contains("[YR"), as.numeric))) +WDI_GDP <- drop_na(WDI_GDP)
I am a grad student getting my MBA with an emphasis in finance. I am struggling to answers this question as I have no experience in coding. I am supposed to work the problem using python. Any help would be greatly appreciated! **PROBLEM** Problem Statement: We have a project with given cashflows. [-50, 20, 10, 30, 10, 15] The first element is negative and represents the initial investment required for the project. The subsequent elements represent the expected cash inflows and outflows from the project over 15 periods. We would like to calculate the Internal Rate of Return (IRR) of this project. As a reminder, the IRR is the discount rate at which the NPV of a project equals zero. Therefore, we are looking for an such that ()=0⇒−50+201++10(1+)2+30(1+)3+10(1+)4+15(1+)5=0. In this exercise, we will numerically solve this equation using Numpy. The idea is to calculate () over a grid of , e.g., [0,0.001,0.002,0.003,…,0.199,0.200] , and find a point on the grid where () is close to zero. The finer our initial grid, the closer we can get to the root of the equation above. Your task is to: Define the cash flows array. Create an array of potential discount rates ranging from 0% to 20%. Calculate the NPV for each discount rate. Identify the discount rate at which the NPV is closest to zero. This rate is the project's approximate IRR. **GUIDE** ``` Step 1: import numpy as np # Define the number of points on the grid N = 10001 # Define cashflows cash_flows = np.array([-60, 20, 10, 30, 10, 15]) # Define the array of potential discount rates r = np.linspace(0, 0.20, N) # Define an array to keep NPV values npv = np.zeros((N,)) Step 2: # Calculate NPVs for each value of the discount rate for i in range(N): # Calculate NPV for discount rate = r[i] Step 3: # Identify the discount rate at which NPV is closest to zero index = np.argmin(np.abs(npv)) Step 4: # Print the IRR Step 5: # Copy the code for N = 1001 Step 6: # Copy the code for N = 10001 ``` Thanks, Marcie I tried used ChatGPT, but I am not getting the correct code.
I implemented this function but I do not know why is it not working as I expect, I have restriction so I can not use stoll and sstream functions... ``` #include <iostream> #include <string> #include <vector> #include <climits> #include <cctype> #include <stdexcept> std::vector<long long int> NumbersInString(std::string s) { std::vector<long long int> result; long long int number = 0; bool numberIsNegative = false; bool numberIsInProgress = false; for (char c : s) { if (isdigit(c)) { int digit = c - '0'; if (number > (LLONG_MAX - digit) / 10) { throw std::range_error("Number too large"); } number = number * 10 + digit; numberIsInProgress = true; } else if (c == '-' && numberIsInProgress == false) { numberIsNegative = true; } else { if (numberIsInProgress) { if (numberIsNegative) { number = -number; numberIsNegative = false; } result.push_back(number); number = 0; numberIsInProgress = false; } } } if (numberIsInProgress) { if (numberIsNegative) { number = -number; } result.push_back(number); } return result; } int main() { std::string s; std::cout << "Enter a string:" << std::endl; std::getline(std::cin, s); std::vector<long long int> res = NumbersInString(s); std::cout << "Numbers within the string: "; for (long long int number : res) { std::cout << number << " "; } std::cout << std::endl; return 0; } ``` Here is my output: Enter a string: Rappers 2PAC and 50Cent know that the sum of the numbers 327, 39 and -4162 is -3796! They also know that 123xy is not a number, although 456 is. What can be said about 0?Numbers within the string: 2 50 327 39 -4162 But numbers like 123xy and 50Cent and 2PAC are not numbers... Here is what I expected to be: Enter a string: Rappers 2PAC and 50Cent know that the sum of the numbers 327, 39 and -4162 is -3796! They also know that 123xy is not a number, although 456 is. What can be said about 0? Numbers within the string: 327 39 -4162 −3796 456 0 And I also have to handle the numbers that are to long for type long long int but here is problem: [output for long long](https://i.stack.imgur.com/jyyX1.png) Can someone please give explanation and help in this problem?
Extracting long long int numbers from string and putting them in vector
|c++|string|vector|
null
I have a Blazor WebApp in which I load data with EF Core. Now I get the following error when displaying the data on a page because of reference loops, the data is loaded in an Syncfusion ComboBox: ``` <SfComboBox TValue="Contact" TItem="Contact" @bind-Value="item.Owner" DataSource="Contacts" Placeholder="Besitzer"> <ComboBoxFieldSettings Value="@nameof(Contact.FullName)"></ComboBoxFieldSettings> </SfComboBox> ``` The traceback: ``` Error: System.Text.Json.JsonException: A possible object cycle was detected. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 64. Consider using ReferenceHandler.Preserve on JsonSerializerOptions to support cycles. Path: $.Items.Owner.Items.Owner.Items.Owner.Items.Owner.Items.Owner.Items ... ... JsonSerializerOptions options, WriteStack& state) at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Serialize(Utf8JsonWriter writer, T& rootValue, Object rootValueBoxed) at System.Text.Json.JsonSerializer.WriteString[TValue](TValue& value, JsonTypeInfo`1 jsonTypeInfo) at System.Text.Json.JsonSerializer.Serialize[TValue](TValue value, JsonSerializerOptions options) at Syncfusion.Blazor.DropDowns.SfDropDownList`2.GetDataByValue(TValue ddlValue) at Syncfusion.Blazor.DropDowns.SfDropDownList`2.InitValueAsync() at Syncfusion.Blazor.DropDowns.SfDropDownList`2.OnAfterRenderAsync(Boolean firstRender) at Syncfusion.Blazor.DropDowns.SfComboBox`2.OnAfterRenderAsync(Boolean firstRender) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) ``` I have tried to set to Json Reference Handler but it does not work: ```csharp builder.Services.Configure<Microsoft.AspNetCore.Http.Json.JsonOptions>(options => options.SerializerOptions.ReferenceHandler = ReferenceHandler.Preserve); builder.Services.ConfigureHttpJsonOptions(jsonOptions => { jsonOptions.SerializerOptions.ReferenceHandler = ReferenceHandler.Preserve; }); ``` Classes used: public class Item { public Contact Owner { get; set; } } public class Contact { public List<Item> Items { get; set; } = new List<Item>(); }
Detecting click inside and outside of the listening component in Angular
|angular|events|
i have 1 dog page on Facebook, i usually post photo of dogs when ever i have time, so trying to write a scheduler that will take images from my system folder and upload and publish on my page. i want to post images, from my local system to 1 of my managed pages. i have page access token. and using below curl i am getting response as well. ``` curl 'https://graph.facebook.com/v19.0/page_id/photos?published=true' -H 'Cookie: ps_l=0; ps_n=0; ps_l=0; ps_n=0' -F 'access_token="my_page_access_toekn"' -F 'source=@"/C:/Users/Downloads/cute_dog.jpg"' -F 'publish="true" ``` and i am getting response back ``` { "id": "388682197392493", "post_id": "103269412609092_388682220725824" } ``` when i login from my own account, i can see the images being posted on the page. but when i login from my friend account, i don't see the image. i tried adding `publish="true` in body as well as in path param, but nothing seems working. for reference, i am following this page https://developers.facebook.com/docs/pages-api/posts what am i missing?
|machine-learning|deep-learning|computer-vision|stable-diffusion|image-generation|
I'm having some issues trying to get some content to display in an admin panel when a user is logged into it. I am using Antlers templates in Statamic with Laravel in there too and can't find a template tag that could be used for checking if the user is authenticated? I've tried looking at the Statamic documentation but couldn't find anything that I think would have helped me with this.
Is there a way of showing content in a Statamic antlers template if a user is authenticated?
|laravel|statamic|
null
## Why is not running? Basically, is not usual to use CMD and ENTRYPOINT **together**. If you do that, the cmd instructions are appended to the entrypoint as simple arguments. In your case something like this: ``` ENTRYPOINT["/entrypoint.sh", "/bin/bash", "-c", "/log-agent.sh"] ``` More details here - https://stackoverflow.com/questions/47648775/docker-entrypoint-and-cmd-together ## Explanation In docker, only one foreground process can run. Several process in just one container is not a good practice. Anyway you have these alternatives ## #1 Supervisor With supervisor, you can run several process in one container. For example: postgress + java. In your case, the supervisor config file could be like this ``` [program:java] command=/entrypoint.sh autorestart=false autostart=true process_name=java-app [program:java] command=/log-agent.sh autorestart=false autostart=true process_name=agent ``` More details here: https://stackoverflow.com/questions/70308825/how-to-package-several-services-in-one-docker-image/70326121#70326121 ## #2 Send agent to background - First the java and agent launch should be in your entrypoint.sh - The agent should be launched to the background before java Something like this ``` #launch agent nohup /log-agent.sh >/dev/null 2>&1 & #launch java app java -jar .... ``` - And your Dockerfile should end with `ENTRYPOINT ["/entrypoint.sh"]`
i have extracted some values using regex in beanshell postprocessor now i have to pick a random value and store it into a varaible?
|regex|jmeter|beanshell|
null
there is an activestorage bug for gcs when using direct upload in `activestorage/lib/active_storage/service/gcs_service.rb#headers_for_direct_upload`. it sets the content disposition metadata to inline and currently the only way to get the query params for content disposition working is to clear the content disposition metadata. here is a bushhack method for clearing it: def clear_content_disposition return unless file.service.name == :google gcs_config = Rails.application.config.active_storage.service_configurations['google'] storage = Google::Cloud::Storage.new( project_id: gcs_config['project'], credentials: gcs_config['credentials'] ) bucket = storage.bucket(gcs_config['bucket']) blob = bucket.file(file.key, skip_lookup: true) blob.content_disposition = nil end
It is a good idea to smooth scrool in $(window).load function rather than $(document).ready as scrolling in $(document).ready may cause it to scroll to wrong position due to wrong offset returned by offset function if images are not yet loaded on page. ```js $(document).ready(function () { if (window.location.hash) { scroll(0, 0); } } $(window).load(function() { if (window.location.hash) { const hash = window.location.hash; $('html, body').animate({ scrollTop : $(hash).offset().top }, 500); } }); ```
(CSS) Color pulse broken on linear gradient. How to fix "@keyframe" to pulse background of a button?
Some version of playwright(1.42) comes as to **work only with specific browser version** as you can check in the [release notes][1] in the image you have shared the version is **chromium-1105** in your local and playwright wants version **chromium-1028** So as said in the error please **run that command** and it will do the appropriate installation as per playwright vesion. Every time you updrade playwright you might have to run that command Go in your project solution directory where you can see bin folder and run the below command. If you have open **powershell prompt** then pwsh is not needed for **command prompt** pwsh is needed, also you can replace X with dotnet version like 6.0 / 7.0 / 8.0 pwsh bin/debug/netX/playwright.ps1 install [1]: https://playwright.dev/dotnet/docs/release-notes
|python|hash|substring|longest-substring|rabin-karp|
If you convert the data to vertical format and set the original column name to hue, you will get a graph that is grouped by type. df.set_index('Type', inplace=True) df = df.stack().to_frame('value').reset_index() df.rename(columns={'level_1':'Item'},inplace=True) df.head() Type Item value 0 McDonalds Single 1 1 McDonalds Double 2 2 McDonalds Many 10 3 BK Single 4 4 BK Double 8 import seaborn as sns sns.barplot(data=df, x='Type', y='value', hue='Item') [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/Hpx1y.png
I'm deleting your post because this seems like a programming-specific question, rather than a conversation starter. With more detail added, this may be better as a Question rather than a Discussions post. Please see [this page](https://stackoverflow.com/help/how-to-ask) for help on asking a question on Stack Overflow. If you are interested in starting a more general conversation about how to approach an issue or concept related to the topic of this collective, feel free to make another Discussion post. You can check the discussions guidelines at https://stackoverflow.com/help/discussions-guidelines
null
I am a grad student getting my MBA with an emphasis in finance. I am struggling to answers this question as I have no experience in coding. I am supposed to work the problem using python. Any help would be greatly appreciated! **PROBLEM** Problem Statement: We have a project with given cashflows. [-50, 20, 10, 30, 10, 15] The first element is negative and represents the initial investment required for the project. The subsequent elements represent the expected cash inflows and outflows from the project over 15 periods. We would like to calculate the Internal Rate of Return (IRR) of this project. As a reminder, the IRR is the discount rate at which the NPV of a project equals zero. Therefore, we are looking for an such that ()=0⇒−50+201++10(1+)2+30(1+)3+10(1+)4+15(1+)5=0. In this exercise, we will numerically solve this equation using Numpy. The idea is to calculate () over a grid of , e.g., [0,0.001,0.002,0.003,…,0.199,0.200] , and find a point on the grid where () is close to zero. The finer our initial grid, the closer we can get to the root of the equation above. Your task is to: Define the cash flows array. Create an array of potential discount rates ranging from 0% to 20%. Calculate the NPV for each discount rate. Identify the discount rate at which the NPV is closest to zero. This rate is the project's approximate IRR. **GUIDE** Step 1: ``` import numpy as np # Define the number of points on the grid N = 10001 # Define cashflows cash_flows = np.array([-60, 20, 10, 30, 10, 15]) # Define the array of potential discount rates r = np.linspace(0, 0.20, N) # Define an array to keep NPV values npv = np.zeros((N,)) ``` Step 2: ``` # Calculate NPVs for each value of the discount rate for i in range(N): # Calculate NPV for discount rate = r[i] ``` Step 3: ``` # Identify the discount rate at which NPV is closest to zero index = np.argmin(np.abs(npv)) ``` Step 4: ``` # Print the IRR ``` Step 5: ``` # Copy the code for N = 1001 ``` Step 6: ``` # Copy the code for N = 10001 ``` I tried used ChatGPT, but I am not getting the correct code.
I'm trying to generate Java stubs for the new 3rd party service. It worked before with no problem but recently they have added a new method `verifyDataExistence` and `wsdl2java` got failed with the following error (real names were changed): ``` Loading FrontEnd jaxws ... Loading DataBinding jaxb ... wsdl2java -verbose -b jaxb-bindings.xml -client -d src https://othercompany.com/SOAP/TheirService/Services?wsdl wsdl2java - Apache CXF 3.5.5 Jan 06, 2024 1:22:55 PM org.apache.cxf.wsdl11.WSDLServiceBuilder checkForWrapped INFO: Operation {urn:PegaRULES:SOAP:TheirService:Services}GetList cannot be unwrapped, input message must reference global element declaration with same localname as operation Jan 06, 2024 1:22:55 PM org.apache.cxf.wsdl11.WSDLServiceBuilder checkForWrapped INFO: Operation {urn:PegaRULES:SOAP:TheirService:Services}HandleInfo cannot be unwrapped, input message must reference global element declaration with same localname as operation WSDLToJava Error: Parameter: theirData already exists for method verifyDataExistence but of type com.othercompany.soap.myservice.services.VerifyDataExistenceType.TheirData instead of com.mycompany.soap.theirservice.services.VerifyDataExistenceResponseType.TheirData. Use a JAXWS/JAXB binding customization to rename the parameter. org.apache.cxf.tools.common.ToolException: Parameter: theirData already exists for method verifyDataExistence but of type com.othercompany.soap.myservice.services.VerifyDataExistenceType.TheirData instead of com.othercompany.soap.myservice.services.VerifyDataExistenceResponseType.TheirData. Use a JAXWS/JAXB binding customization to rename the parameter. at org.apache.cxf.tools.common.model.JavaMethod.addParameter(JavaMethod.java:178) at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.ParameterProcessor.addParameter(ParameterProcessor.java:130) at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.ParameterProcessor.processWrappedAbstractOutput(ParameterProcessor.java:482) at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.ParameterProcessor.processWrappedOutput(ParameterProcessor.java:360) at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.ParameterProcessor.buildParamModelsWithoutOrdering(ParameterProcessor.java:651) at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.ParameterProcessor.process(ParameterProcessor.java:88) at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.OperationProcessor.processMethod(OperationProcessor.java:141) at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.OperationProcessor.process(OperationProcessor.java:62) at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.PortTypeProcessor.process(PortTypeProcessor.java:156) at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.WSDLToJavaProcessor.wsdlDefinitionToJavaModel(WSDLToJavaProcessor.java:83) at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.WSDLToJavaProcessor.process(WSDLToJavaProcessor.java:60) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:274) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:156) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:402) at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:105) at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113) at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86) at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:184) ``` Here is wsdl: ```xml <wsdl:definitions targetNamespace="urn:PegaRULES:SOAP:TheirService:Services"> <wsdl:types> <xsd:schema> <xsd:import schemaLocation="Services.xsd1.xsd" namespace="urn:PegaRULES:SOAP:TheirService:Services" /> </xsd:schema> </wsdl:types> <wsdl:message name="GetList"> <wsdl:part name="GetListRequest" element="xsns:GetListRequest" /> </wsdl:message> <wsdl:message name="GetListResponse"> <wsdl:part name="GetListResponse" element="xsns:GetListResponse" /> </wsdl:message> <wsdl:message name="HandleInfo"> <wsdl:part name="HandleInfoRequest" element="xsns:HandleInfoRequest" /> </wsdl:message> <wsdl:message name="HandleInfoResponse"> <wsdl:part name="HandleInfoResponse" element="xsns:HandleInfoResponse" /> </wsdl:message> <wsdl:message name="VerifyDataExistence"> <wsdl:part name="VerifyDataExistence" element="xsns:VerifyDataExistence" /> </wsdl:message> <wsdl:message name="VerifyDataExistenceResponse"> <wsdl:part name="VerifyDataExistenceResponse" element="xsns:VerifyDataExistenceResponse" /> </wsdl:message> <wsdl:portType name="ServicesType"> <wsdl:operation name="GetList"> <wsdl:input name="GetListRequest" message="ns0:GetList" /> <wsdl:output name="GetListResponse" message="ns0:GetListResponse" /> </wsdl:operation> <wsdl:operation name="HandleInfo"> <wsdl:input name="HandleInfoRequest" message="ns0:HandleInfo" /> <wsdl:output name="HandleInfoResponse" message="ns0:HandleInfoResponse" /> </wsdl:operation> <wsdl:operation name="VerifyDataExistence"> <wsdl:input name="VerifyDataExistenceRequest" message="ns0:VerifyDataExistence" /> <wsdl:output name="VerifyDataExistenceResponse" message="ns0:VerifyDataExistenceResponse" /> </wsdl:operation> </wsdl:portType> <wsdl:binding name="ServicesBindingSOAP" type="ns0:ServicesType"> <soap11:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> <wsdl:operation name="GetList"> <soap11:operation soapAction="urn:PegaRULES:SOAP:TheirService:Services#GetList" style="document" /> <wsdl:input name="GetListRequest"> <soap11:body use="literal" /> </wsdl:input> <wsdl:output name="GetListResponse"> <soap11:body use="literal" /> </wsdl:output> </wsdl:operation> <wsdl:operation name="HandleInfo"> <soap11:operation soapAction="urn:PegaRULES:SOAP:TheirService:Services#HandleInfo" style="document" /> <wsdl:input name="HandleInfoRequest"> <soap11:body use="literal" /> </wsdl:input> <wsdl:output name="HandleInfoResponse"> <soap11:body use="literal" /> </wsdl:output> </wsdl:operation> <wsdl:operation name="VerifyDataExistence"> <soap11:operation soapAction="urn:PegaRULES:SOAP:TheirService:Services#VerifyDataExistence" style="document" /> <wsdl:input name="VerifyDataExistenceRequest"> <soap11:body use="literal" /> </wsdl:input> <wsdl:output name="VerifyDataExistenceResponse"> <soap11:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:binding name="ServicesBindingSOAP12" type="ns0:ServicesType"> <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> <wsdl:operation name="GetList"> <soap12:operation soapAction="urn:PegaRULES:SOAP:TheirService:Services#GetList" soapActionRequired="false" style="document" /> <wsdl:input name="GetRequest"> <soap12:body use="literal" /> </wsdl:input> <wsdl:output name="GetListResponse"> <soap12:body use="literal" /> </wsdl:output> </wsdl:operation> <wsdl:operation name="HandleInfo"> <soap12:operation soapAction="urn:PegaRULES:SOAP:TheirService:Services#HandleInfo" soapActionRequired="false" style="document" /> <wsdl:input name="HandleInfoRequest"> <soap12:body use="literal" /> </wsdl:input> <wsdl:output name="HandleInfoResponse"> <soap12:body use="literal" /> </wsdl:output> </wsdl:operation> <wsdl:operation name="VerifyDataExistence"> <soap12:operation soapAction="urn:PegaRULES:SOAP:TheirService:Services#VerifyDataExistence" soapActionRequired="false" style="document" /> <wsdl:input name="VerifyDataExistenceRequest"> <soap12:body use="literal" /> </wsdl:input> <wsdl:output name="VerifyDataExistenceResponse"> <soap12:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="ServicesService"> <wsdl:port name="ServicesPortSOAP" binding="ns0:ServicesBindingSOAP"> <soap11:address location="https://192.168.1.2:1234/one/SomeServlet/SOAP/TheirService/Services" /> </wsdl:port> <wsdl:port name="ServicesPortSOAP12" binding="ns0:ServicesBindingSOAP12"> <soap12:address location="https://192.168.1.2:1234/one/SomeServlet/SOAP/TheirService/Services" /> </wsdl:port> </wsdl:service> </wsdl:definitions> ``` and the separate schema file: ```xml <schema elementFormDefault="unqualified" targetNamespace="urn:PegaRULES:SOAP:TheirService:Services"> <complexType name="GetListRequestType"> <sequence> <element name="AppId" type="xsd:string" /> <element minOccurs="0" name="DataCode" type="xsd:string" /> <element minOccurs="0" name="DepId" type="xsd:string" /> </sequence> </complexType> <element name="GetListRequest" type="tns:GetListRequestType" /> <complexType name="GetListResponseType"> <sequence> <element name="Count" type="xsd:string" /> <element name="List"> <complexType> <sequence> <element maxOccurs="unbounded" name="Data"> <complexType> <sequence> <element name="ItemNo" type="xsd:string" /> <element name="DataCode" type="xsd:string" /> <element name="Prefix" type="xsd:string" /> <element name="Year" type="xsd:string" /> </sequence> </complexType> </element> </sequence> </complexType> </element> <element name="ErrorList"> <complexType> <sequence> <element maxOccurs="unbounded" name="Error"> <complexType> <sequence> <element name="Code" type="xsd:string" /> <element name="Desc" type="xsd:string" /> </sequence> </complexType> </element> </sequence> </complexType> </element> </sequence> </complexType> <element name="GetListResponse" type="nslt1:GetListResponseType" /> <element name="HandleInfoRequest" type="tns:HandleInfoRequestType" /> <complexType name="HandleInfoResponseType"> <sequence> <element name="TheirData"> <complexType> <sequence> <element name="DataCode" type="xsd:string" /> <element name="Prefix" type="xsd:string" /> <element name="Year" type="xsd:string" /> <element name="ItemNo" type="xsd:string" /> <element name="HandlingStatus" type="xsd:string" /> </sequence> </complexType> </element> <element minOccurs="0" name="ErrorsList"> <complexType> <sequence> <element maxOccurs="unbounded" name="Error"> <complexType> <sequence> <element name="Code" type="xsd:string" /> <element name="Desc" type="xsd:string" /> </sequence> </complexType> </element> </sequence> </complexType> </element> </sequence> </complexType> <element name="HandleInfoResponse" type="nslt1:HandleInfoResponseType" /> <complexType name="VerifyDataExistenceType"> <sequence> <element name="AppId" type="xsd:string" /> <element name="TheirData"> <complexType> <sequence> <element name="DataCode" type="xsd:string" /> <element name="Prefix" type="xsd:string" /> <element minOccurs="0" name="Year" type="xsd:string" /> <element name="ItemNo" type="xsd:string" /> </sequence> </complexType> </element> </sequence> </complexType> <element name="VerifyDataExistence" type="tns:VerifyDataExistenceType" /> <complexType name="VerifyDataExistenceResponseType"> <sequence> <element name="TheirData"> <complexType> <sequence> <element name="ItemNo" type="xsd:string" /> <element name="DataCode" type="xsd:string" /> <element name="Prefix" type="xsd:string" /> <element minOccurs="0" name="Year" type="xsd:string" /> <element name="DataExists" type="xsd:string" /> <element name="ProcessingCompleted" type="xsd:string" /> </sequence> </complexType> </element> <element minOccurs="0" name="ErrorList"> <complexType> <sequence> <element maxOccurs="unbounded" name="Error"> <complexType> <sequence> <element name="Code" type="xsd:string" /> <element name="Desc" type="xsd:string" /> </sequence> </complexType> </element> </sequence> </complexType> </element> </sequence> </complexType> <element name="VerifyDataExistenceResponse" type="nslt1:VerifyDataExistenceResponseType" /> </schema> ``` To customize the generation I already have jaxb-bindings.xml ```xml <jaxb:bindings version="2.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"> <jaxb:bindings> <jaxb:globalBindings generateElementProperty="false"/> </jaxb:bindings> </jaxb:bindings> ``` According to suggestion from the error I tried to use a JAXWS/JAXB binding customization to rename the parameter like ```xml <jaxb:bindings node="//wsdl:message[@name='verifyDataExistenceRequest']/wsdl:part[@name='theirData']"> <jaxb:property name="verifyExistenceRequestTheirData" /> </jaxb:bindings> <jaxb:bindings node="//wsdl:message[@name='verifyDataExistenceResponse']/wsdl:part[@name='theirData']"> <jaxb:property name="verifyExistenceResponseTheirData" /> </jaxb:bindings> ``` But it does not work since the definition of verifyDataExistenceRequest and verifyDataExistenceResponse types are in the separate xml scheme file `https://othercompany.com/SOAP/TheirService/Services.xsd1.xsd` Also I tried to play with `schemaLocation` attribute but it all fails. Will appreciate any ideas how to make it work. Thanks
Apache CXF is unable to handle duplicate localnames
|web-services|soap|cxf|wsdl2java|
null
I'm deleting your post because this seems like a programming-specific question, rather than a conversation starter. With more detail added, this may be better as a Question rather than a Discussions post. Please see [this page](https://stackoverflow.com/help/how-to-ask) for help on asking a question on Stack Overflow. If you are interested in starting a more general conversation about how to approach an issue or concept related to the topic of this collective, feel free to make another Discussion post. You can check the discussions guidelines at https://stackoverflow.com/help/discussions-guidelines
This is my Activity layout: <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <com.google.android.material.appbar.AppBarLayout android:id="@+id/appbar" app:layout_constraintTop_toTopOf="parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:fitsSystemWindows="true"> <com.google.android.material.appbar.MaterialToolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" /> </com.google.android.material.appbar.AppBarLayout> <androidx.fragment.app.FragmentContainerView android:id="@+id/nav_host_fragment" android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" android:layout_height="wrap_content" app:defaultNavHost="true" app:layout_constraintBottom_toTopOf="@id/adView" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@id/appbar" app:navGraph="@navigation/nav_graph" /> <com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="match_parent" android:layout_height="wrap_content" app:adUnitId="ca-app-pub-3940256099942544/9214589741" app:adSize="BANNER" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> And this is a Fragment displayed inside it: <androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" tools:context=".ScannerFragment"> <androidx.camera.view.PreviewView android:id="@+id/cameraPreview" android:layout_width="match_parent" android:layout_height="200dp"/> <androidx.recyclerview.widget.RecyclerView android:id="@+id/sale_list" android:layout_width="match_parent" android:layout_height="wrap_content"/> <View android:layout_width="match_parent" android:layout_height="0sp" android:layout_weight="1"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Total" android:textSize="24sp"/> </androidx.appcompat.widget.LinearLayoutCompat> And this is what it looks like: [![enter image description here][1]][1] Have a look at the `FragmentContainerView`: It is constraint to be below the appbar and above the adView. The fragment however clearly violates these constraints and ignores the appbar and the adView. Am I doing something wrong? Or is `ConstraintLayout` simply broken? How to achieve the layout I want? I already tried to put the `FragmentContainerView` inside a `LinearLayout` and the constraints on the `LinearLayout`, but could not witness any change. [1]: https://i.stack.imgur.com/fRDYB.png
Here method to get all linear. import bitsandbytes as bnb def find_all_linear_names(model): lora_module_names = set() for name, module in model.named_modules(): if isinstance(module, bnb.nn.Linear4bit): names = name.split(".") # model-specific lora_module_names.add(names[0] if len(names) == 1 else names[-1]) if "lm_head" in lora_module_names: # needed for 16-bit lora_module_names.remove("lm_head") return list(lora_module_names) In the futur release you can use directly `target_modules="all-linear"` in your LoraConfig
{"OriginalQuestionIds":[59232877],"Voters":[{"Id":501250,"DisplayName":"cdhowie","BindingReason":{"GoldTagBadge":"rust"}}]}
I am studying the Oss-fuzz and found the following strange behavior, which I cannot understand. I created a simple C project with the only function with 3 branches (if incoming values equal 0, 32 and whatever else). Here is the testing function: ``` 1 int func(int a) 2 { 3 FILE *fptr; 4 if ((fptr = fopen("tdata.bin","ab")) != NULL) 5 { 6 fwrite(&a, 1, 1, fptr); 7 fclose(fptr); 8 } 9 10 if (a == 0x00) 11 return 0; 12 else if (a == 0x20) 13 return 1; 14 15 printf("last line is reached!"); 16 return 2; 17 } ``` Here is the fuzzer: ``` int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { func((int)(*data)); return 0; } ``` The issue that if I run the introspector test with the following command: ``` python3 infra/helper.py introspector test02 ``` it shows me that the function coverage is only 90%. The lines 15-16 are not covered. Although the fuzzing is passing those lines. It can be seen in output console (I can see "last line is reached!") and also in the debug file "tdata.bin" I can see about 562k randomized bytes with values not equal 0 and 32. There are also two corpuses with values 0 and 32. So it seems the fuzzer is reached the lines 15-16 but for some reason does not count them in the report. Can someone explain me this strange thing?
oss-fuzz does not cover the code after if - else in C code
|code-coverage|fuzzing|libfuzzer|
null
Imagine a list with 100 items. There is a component which displays all of them. Several times per second one (random) item should be moved into a new position. The React native approach would be to rerender whole component by constructing Virtual Tree, then diff it with previous copy, then to patch DOM. The problem is that making a Virtual Tree and creating a diff takes time (about 50ms in my case). Is there a way in React to skip this creation of Virtual Tree and calculate diff? Like the following: `shouldComponentUpdate` will return `false`; then manually one `Node` will be removed from DOM, and inserted into another position. **Update** Concerning to [this video][1] there is a worst case scenario in React. When you update just one item in a 100 of them. The question is **how to update DOM the fastest possible way** (without diffing 100 items)? [This is the demo][2] for the issue, and [this is the code][3]. ![Needle in haystack problem][4] [1]: https://youtu.be/h3KksH8gfcQ?t=28m52s [2]: https://vbarbarosh.github.io/jslib_react_dragdrop_speedy/demo/demo-2-3.html [3]: https://github.com/vbarbarosh/jslib_react_dragdrop_speedy/blob/master/src/static/js/demo/demo-2-3.jsx [4]: https://static.md/1288ebef362e00dfcc3399ad85aa1152.png
Is ConstraintLayout broken?
|android|android-layout|android-constraintlayout|
I need help converting a column of 179 observations from an excel file that holds 2 variables (days and values). After i try converting the dataframe with ts(as.vector(a1dataraw['x'], the vector returns with start=1 but also end=1 when it should be 179? Can someone please identify where im going wrong? ``` r library(TSA) #Load data a1dataraw <- read.csv("assignment1data2024.csv", header=TRUE) a1dataraw #Convert to TS a1data <- NA a1data <- ts(as.vector(a1dataraw['x']), # Read correct column, which is 'x' here. start= 1) a1data ``` [![Code input](https://i.stack.imgur.com/VVfRE.png)](https://i.stack.imgur.com/VVfRE.png) [![Code output](https://i.stack.imgur.com/U4IAO.png)](https://i.stack.imgur.com/U4IAO.png) The end value is 1 when it should be 179? The csv file has 2 columns with headers Trading days and x for the observations data sample it goes up to 179 trading days: [![sample][1]][1] [1]: https://i.stack.imgur.com/mBGzd.png
The messed-up output is mainly due to not specifying the required function number AH=09h before invoking DOS to print a message, and to using DH for holding the second number while at the same time you use DX for another purpose. Remember that the 16-bit DX is composed of the two 8-bit parts DH and DL. Input of a signed single-digit decimal number - The DOS.GetCharacter function 01h first waits for the user to press a keyboard key, then it writes the corresponding character on the screen, and finally it returns to your program with the key's ASCII code in the AL register. For some special keys the function will return AL=0, that way signaling that your program should invoke the function again so as to obtain the key's scancode. If you want the user to be able to input a signed single-digit decimal number, so in the range [-9,9], you will have to take a two-step approach. If the first time that you use the function you already receive a digit [0,9] then you can just bypass the second step. If on the other hand the first character that you received happened to be a minus character then you must invoke the function a second time expecting a digit [0,9], and this time you must also negate the number. Next simplified example validates the user input: ReDo1: mov ah, 01h ; DOS.GetCharacter int 21h ; -> AL sub al, '0' cmp al, 10 jb GotIt ; Is positive [0,9] cmp al, '-' - '0' jne ReDo1 ; An invalid character detected ReDo2: mov ah, 01h ; DOS.GetCharacter int 21h ; -> AL sub al, '0' cmp al, 10 jae ReDo2 ; Not a decimal digit neg al GotIt: You don't want to repeat yourself too much ([DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself)), so you should put the above in a subroutine. mov dx, OFFSET Msg1 ; Read the first number from the user call Input ; -> AL (AH) mov bl, al mov dx, OFFSET Msg2 ; Read the second number from the user call Input ; -> AL (AH) mov bh, al ... ; IN (dx) OUT (al) MOD (ah) Input: mov ah, 09h ; DOS.PrintString int 21h ReDo1: mov ah, 01h ; DOS.GetCharacter int 21h ; -> AL sub al, '0' cmp al, 10 jb GotIt ; Is positive [0,9] cmp al, '-' - '0' jne ReDo1 ; An invalid character detected ReDo2: mov ah, 01h ; DOS.GetCharacter int 21h ; -> AL sub al, '0' cmp al, 10 jae ReDo2 ; Not a decimal digit neg al GotIt: ret Output of a signed single-digit decimal number - It is not sufficient to just add '0' and have DOS display the one character. A test for negative is in order and if required the output of a minus character: test bl, bl jns IsPositive mov dl, '-' mov ah, 02h ; DOS.PrintChar int 21h neg bl IsPositive: lea dx, [bx + '0'] ; BH and DH are un-important here mov ah, 02h ; DOS.PrintChar int 21h Displaying the final summarizing message can benefit from using a subroutine too. I did include the necessary logic to differentiate between your *PositiveMsg* and *NegativeMsg* messages, something that you forgot to do: mov dx, OFFSET Msg3 ; BL contains first number call Output ; -> (AX BL DX) mov bl, bh ; Load second number in BL mov dx, OFFSET Msg4 ; Make this a ', $' call Output ; -> (AX BL DX) ... ; IN (bl,dx) OUT () MOD (ax,bl,dx) Output: mov ah, 09h ; DOS.PrintString int 21h test bl, bl pushf ; (1) Need the test result later on jns IsPositive1 mov dl, '-' mov ah, 02h ; DOS.PrintChar int 21h neg bl IsPositive1: lea dx, [bx + '0'] ; BH and DH are not important here mov ah, 02h ; DOS.PrintChar int 21h mov dx, OFFSET PositiveMsg popf ; (1) Original BL no more available jns IsPositive2 mov dx, OFFSET NegativeMsg IsPositive2: mov ah, 09h int 21h ret ----- If ever you need to go further than a single-digit input/output, then next Q/A's go much deeper into the subject: https://stackoverflow.com/questions/72407637/inputting-multi-radix-multi-digit-signed-numbers-with-dos and https://stackoverflow.com/questions/45904075/displaying-numbers-with-dos.
@Modifying @Transactional @Query("DELETE FROM BusinessTransaction bt WHERE bt.userId.id=:id") void deleteByUserId(Long id); -->for this query i am getting "Transaction silently rolled back because it has been marked as rollback-only" this error. In this query userID is a object of User class joined and mapped with BusinessTransaction class so in where condition i am tring to fetch id of user from userId.id and it should be same as :id variable. any one please let me out of this error @Modifying @Transactional @Query("DELETE FROM BusinessTransaction bt WHERE bt.userId.id=:id") void deleteByUserId(Long id); In this query userID is a object of User class joined and mapped with BusinessTransaction class so in where condition I am trying to fetch id of user from userId.id and it should be same as :id variable. any one please let me out of this error
For anyone crossing this path in future here is my solution: **Original Problem:** I have a Django template that contains a Bootstrap Accordion, with three items. In each item I have a form. When the page is refreshed on any submit it always opened to the first Accordion item. I wanted the page to open to the accordion item that raised the 'submit' event (this is because I do some server-side form validation and want to present messages to my user when they make a bad selection). **Solution:** I was able to achieve this by adding a parameter to my template url in urls.py ('active_accordion'). I then made sure to call a form action on each of my three forms: 'action="{% url 'app:view' 'collapse???' %}"' ... where: 'collapse???' in each case matches the id of the accordion item that contains the relevant form. Example 'collapseThree' Finally I added the following script to my template to read the url and 'show' the appropriate Accordion item: <script> $(document).ready(function() { // Check if the URL contains the open_accordion parameter var urlParams = new URLSearchParams(window.location.search); if (window.location.href.indexOf("collapseOne") > -1) {$('#collapseOne').collapse('show');} if (window.location.href.indexOf("collapseTwo") > -1) {$('#collapseTwo').collapse('show');} if (window.location.href.indexOf("collapseThree") > -1) {$('#collapseThree').collapse('show');} }); </script> Hope it helps someone else. Andrew
The structure of your query is not correct. There are a lot of ways to fix this problem, but essentially you need to separate the data call from the component display instead of trying to do both all at once. This is usually done with React Hooks, and there are numerous examples out there of how to accomplish this. [Like this one](https://medium.com/nerd-for-tech/fetching-api-using-useeffect-hook-in-react-js-7b9b34e427ca). The thing to notice about that approach is that it uses the `useState` and `useEffect` hooks to separate the problem into several parts. This approach has the benefit of being reusable and scalable, as it can be easily adjusted to solve any data-fetching problem. Generally speaking, you're going to want to separate your concerns as much as you can when computer programming. If you're trying to grab state, set state, and render state all in one big chunk of code, it's probably time to slow down and re-think your approach to handle each problem one at a time.
The issue is the grouping and can be fixed by mapping on the `group=` aes. I haven't digged deeper into your code. But especially when several variables and aesthetics are involved I would recommend to map on aesthetics locally and/or to explicitly map on the `group=` aes so that bars and text or ... are dodged by the same variable. ``` r library(ggplot2) library(dplyr) library(scales) plot_geom_text_with_dodge_geom_col <- function(df) { ggplot( df |> mutate(label_pct = paste0(sumGp, "/", n)), aes(as.character(ID), pct, fill = Group, label = label_pct, group = Group) ) + geom_col(position = "dodge", col = "black") + geom_text(aes(color = grepl("0/", label_pct)), position = position_dodge(0.9), vjust = -0.5, show.legend = FALSE ) + scale_fill_manual(name = "Identity", values = c("A" = "#4A765e", "B" = "orange3")) + scale_color_manual(name = "Identity", values = c("black", "white")) + scale_y_continuous(label = scales::percent) + labs(x = "ID") + theme_bw() + theme( panel.grid = element_blank(), panel.border = element_rect(color = "black", linewidth = 1), plot.tag = element_text(face = "bold"), legend.title = element_text(face = "bold", size = 15), legend.text = element_text(size = 12), axis.title = element_text(face = "bold", size = 15), axis.text = element_text(size = 12, face = "bold"), legend.position = "top" ) } df2 <- df |> mutate(Group = case_match(Group, "A" ~ "B", "B" ~ "A")) plot_geom_text_with_dodge_geom_col(df2) ``` ![](https://i.imgur.com/V6tBOHF.png)<!-- --> **Why does this happen?** The underlying issue is the grouping or more precisely how the `group` variable is set internally by `ggplot2`. As document in several places, e.g. [in the docs](https://ggplot2.tidyverse.org/reference/aes_group_order.html) the `group` variable is set using `plyr::id()` (see [here](https://github.com/tidyverse/ggplot2/blob/a90e8ed4082100efaeee953b3974c3ba43318b52/R/grouping.R#L25)) based on all discrete variables mapped on aesthetics with the `label` aes (and the facetting) variables being the only exceptions. Additionally, it's important to note that the value set for the `group` variable also depends on the order of the aesthetics inside `aes()`. Before I go on, to show clearly what's going on I slightly changed the setup of your example, i.e. I added `label_pct` and a `color` column to the original dataset outside of your plotting function. ``` r df <- df |> dplyr::mutate( label_pct = paste0(sumGp, "/", n), color = grepl("0/", label_pct) ) plot_geom_text_with_dodge_geom_col2 <- function(df) { ggplot( df, aes(as.character(ID), pct, fill = Group, label = label_pct, # group = Group ) ) + geom_col(position = "dodge", col = "black") + geom_text(aes(color = color), position = position_dodge(0.9), vjust = -0.5, show.legend = FALSE ) + scale_fill_manual(name = "Identity", values = c("A" = "#4A765e", "B" = "orange3")) + scale_color_manual(name = "Identity", values = c("black", "red")) + scale_y_continuous(label = scales::percent) + labs(x = "ID") + theme_bw() + theme( panel.grid = element_blank(), panel.border = element_rect(color = "black", linewidth = 1), plot.tag = element_text(face = "bold"), legend.title = element_text(face = "bold", size = 15), legend.text = element_text(size = 12), axis.title = element_text(face = "bold", size = 15), axis.text = element_text(size = 12, face = "bold"), legend.position = "top" ) } df2 <- df |> mutate(Group = case_match(Group, "A" ~ "B", "B" ~ "A")) p1 <- plot_geom_text_with_dodge_geom_col2(df) p2 <- plot_geom_text_with_dodge_geom_col2(df2) ``` For the `geom_col` the `group` is set according to `ID` and `Group` aka the variables mapped on `x` and `fill`. For your example this also means that each observation gets assigned to its own group. In contrast, for the `geom_text` the `group` also accounts for the variable mapped on `color`. As a consequence, already for `df` does the `group`ing differ for the `geom_col` and the `geom_text`. This can be seen by calling `plyr::id()` and checked using e.g. `layer_data`: ``` plyr::id(df[c("ID", "Group")], drop = TRUE) #> [1] 1 2 3 4 5 6 8 7 #> attr(,"n") #> [1] 8 layer_data(p1, i = 1)[["group"]] #> [1] 1 2 3 4 5 6 8 7 plyr::id(df[c("color", "ID", "Group")], drop = TRUE) #> [1] 1 6 2 3 4 5 8 7 #> attr(,"n") #> [1] 8 layer_data(p1, i = 2)[["group"]] #> [1] 1 6 2 3 4 5 8 7 ``` This said, even for `df` are the labels assigned to the right columns only by coincidence. Now, when looking at `df2` we see that for the `geom_col` the values assigned to the `group` simply get swapped when swapping `A` and `B`. Hence, the bars are swapped too. ``` plyr::id(df2[c("ID", "Group")], drop = TRUE) #> [1] 2 1 4 3 6 5 7 8 #> attr(,"n") #> [1] 8 ``` However, this is not the case for the `geom_text` layer. Here, the values assigned to `group` are swapped for all rows except for the first two. As a result the grouping for the first two rows or labels is the same as in the case of `df` and the labels are no longer assigned or aligned to the correct bars. ``` plyr::id(df2[c("color", "ID", "Group")], drop = TRUE) #> [1] 1 6 3 2 5 4 7 8 #> attr(,"n") #> [1] 8 ```
null
I understand the OneLake should ensure a single copy of data. So, when we use Azure Synapse Data Warehouse and aggregate data into new tables, does that create a new dataset on OneLake (in a new workspace / directory / location) or does the new aggregate data reside in Synapse? Thanks!
Microsoft Fabric components and data replication
|azure-synapse|fabric|onelake|
Solver the same thing using [Bun][1]. I added an entry to script in package.json, like this: "scripts": { "compile": "bun build src/main.ts --compile --outfile out" I now run it like `bun run compile` and i can use the out file like `./out` [1]: https://bun.sh/
You have not set the `spring.security.oauth2.client.provider.keycloak` correctly: only `user-name-attribute` is present, which is not enough. As Keycloak is OIDC compliant, setting `spring.security.oauth2.client.provider.keycloak.issuer-uri=` with the **exact value of the `iss` claim in one of your tokens** should be enough (Spring will pull the rest of the conf from the `.well-known/openid-configuration`).
You can try this: ``` conda update conda conda update conda-build conda install -n base conda-libmamba-solver conda config --set solver libmamba ``` My answer is based on the issue raised [here](https://github.com/conda/conda/issues/11919).
Coroutines can be used in the main thread for network calls, but network calls may take more time because of multiple reasons, and for that time the main thread is blocked. Because the main thread is responsible for rendering the UI, it will give a bad user experience as well as it may result in ANR (Application Not Responding).
why don't you merge the two nodes ? Treat the pair as one. Distance to the merged node is distance to 3. Distance from the merged node is distance from 7. Then you add a min to the slack var of the merged node to be the transit from 3 to 7.
null
Once you are in terminal/command line, access the database/collection you want to use as follows: show dbs use <db name> show collections choose your collection and type the following to see all contents of that collection: db.collectionName.find() More info here on the [MongoDB Shell (mongosh) documentation][1]. [1]: https://www.mongodb.com/docs/mongodb-shell/
null
Once you are in terminal/command line, access the database/collection you want to use as follows: show dbs use <db name> show collections choose your collection and type the following to see all contents of that collection: db.collectionName.find() More info here on the [MongoDB Shell (mongosh) documentation][1]. [1]: https://www.mongodb.com/docs/manual/reference/method/db.collection.find/#syntax
You could try using the following formulas, this assumes there is no `Excel Constraints` as per the tags posted: [![enter image description here][1]][1] ---------- =TEXT(MAX(--TEXTAFTER(B$2:B$7,"VUAM")*($A2=A$2:A$7)),"V\U\A\M\00000") ---------- Or, using the following: =TEXT(MAX((--RIGHT(B$2:B$7,5)*($A2=A$2:A$7))),"V\U\A\M\00000") ---------- Or, you could use the following as well: [![enter image description here][2]][2] ---------- =LET( x, SORTBY(A2:B7,--RIGHT(B2:B7,5),-1), y, TAKE(x,,1), XLOOKUP(A2:A7, y, TAKE(x,,-1))) ---------- [1]: https://i.stack.imgur.com/K0j2K.png [2]: https://i.stack.imgur.com/ovCkj.png
Use these commands (in lucky case) <!-- language: shell --> git remote -v git pull git fetch upstream git checkout master git merge upstream/master --no-ff git add . git commit -m"Sync with upstream repository." git push -v
I'm deleting your post because this seems like a programming-specific question, rather than a conversation starter. With more detail added, this may be better as a Question rather than a Discussions post. Please see [this page](https://stackoverflow.com/help/how-to-ask) for help on asking a question on Stack Overflow. If you are interested in starting a more general conversation about how to approach an issue or concept related to the topic of this collective, feel free to make another Discussion post. You can check the discussions guidelines at https://stackoverflow.com/help/discussions-guidelines
null
There are two main things on keeping a forked repository always update for good. > **1. Create the branches** from the fork master and **do changes there**. So when your *Pull Request* is accepted then you can safely delete the branch as your contributed code will be then live in your master of your forked repository when you update it with the upstream. By this your master will always be in clean condition to create a new branch to do another change. > **2. Create a scheduled job** for the fork master to **do update automatically**. This can be done with *[cron][1]*. Here is for an example code if you do it in linux. $ crontab -e put this code on the `crontab file` to execute the job in hourly basis. 0 * * * * sh ~/cron.sh then create the `cron.sh` script file and a *[git interaction][2]* with *[ssh-agent][3]* and/or *[expect][4]* as below <!-- language: bash --> #!/bin/sh WORKDIR=/path/to/your/dir REPOSITORY=<name of your repo> MASTER="git@github.com:<username>/$REPOSITORY.git" UPSTREAM=git@github.com:<upstream>/<name of the repo>.git cd $WORKDIR && rm -rf $REPOSITORY eval `ssh-agent` && expect ~/.ssh/agent && ssh-add -l git clone $MASTER && cd $REPOSITORY && git checkout master git remote add upstream $UPSTREAM && git fetch --prune upstream if [ `git rev-list HEAD...upstream/master --count` -eq 0 ] then echo "all the same, do nothing" else echo "update exist, do rebase!" git reset --hard upstream/master git push origin master --force fi cd $WORKDIR && rm -rf $REPOSITORY eval `ssh-agent -k` Check your forked repository. From time to time it will always show this notification: > **This branch is even with `<upstream>`:master**. [![enter image description here][5]][5] [1]: https://en.wikipedia.org/wiki/Cron [2]: https://stackoverflow.com/a/56304600/4058484 [3]: https://www.ssh.com/ssh/agent [4]: https://stackoverflow.com/a/55779022/4058484 [5]: https://chetabahana.github.io/images/github/screencapture-github.png
Is there a way in React to update a DOM without constructing Virtual Tree?
i have 1 dog page on Facebook, i usually post photo of dogs when ever i have time, so trying to write a scheduler that will take images from my system folder and upload and publish on my page. i want to post images, from my local system to 1 of my managed pages. i have page access token. and using below curl i am getting response as well. ``` curl 'https://graph.facebook.com/v19.0/page_id/photos?published=true' -H 'Cookie: ps_l=0; ps_n=0; ps_l=0; ps_n=0' -F 'access_token="my_page_access_toekn"' -F 'source=@"/C:/Users/Downloads/cute_dog.jpg"' -F 'publish="true" ``` and i am getting response back ``` { "id": "38868xxxxx", "post_id": "10326941xxxxx_388682220xxxxx" } ``` when i login from my own account, i can see the images being posted on the page. but when i login from my friend account, i don't see the image. i tried adding `publish="true` in body as well as in path param, but nothing seems working. for reference, i am following this page https://developers.facebook.com/docs/pages-api/posts what am i missing?
In R, I am evaluating a simple statement. It should return TRUE but it returns FALSE: >a = c(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.1,1.2,1.3,1.4,1.5) >b = seq(from=0, to=1.5,by = 0.1) > a==b [1] TRUE TRUE TRUE FALSE TRUE TRUE FALSE FALSE TRUE TRUE TRUE TRUE FALSE TRUE FALSE [16] TRUE > b[3] [1] 0.2 > b[3] == 0.2 [1] TRUE #This is correct > b[4] [1] 0.3 > b[4] == 0.3 [1] FALSE #This is incorrect Why is this TRUE statement evaluating to FALSE?
Very simple true numeric statement incorrectly evaluates to false
|r|conditional-statements|
I am inspecting some code in order to prepare to do my own ocr model and everyone converting jpeg into tfrecords. Why would they do that? I found information about reducing occupied storage space, but both files occupy the same space.
Why convert jpeg into tfrecords?
|python|tensorflow|ocr|
null
<!-- language-all: sh --> > Why is PowerShell failing when redirecting the output? The reason is that `python` (which underlies `html2text`) - like many other Windows CLIs (console applications) - modifies its output behavior based on whether the output target is a *console (terminal)* or is _redirected_: * In the *former* case, such CLIs use the _Unicode_ version of the WinAPI [`WriteConsole`](https://learn.microsoft.com/en-us/windows/console/writeconsole) function, meaning that _any_ character from the global [Unicode](https://en.wikipedia.org/wiki/Unicode) alphabet is accepted. * This means that character-encoding problems do _not_ surface in this case, and the output usually _prints_ properly to the console (terminal) - that said, *exotic* Unicode characters may not print properly, necessitating switching to a different _font_. * In the *latter* case, CLIs must _encode_ their output, and are expected to respect the legacy Windows _OEM code page_ associated with the current console window, as reflected in the output from `chchp.com` and - by default - in `[Console]::OutputEncoding` inside a PowerShell session: * E.g., the OEM code page is [`437`](https://en.wikipedia.org/wiki/Code_page_437) on US-English systems, and if the text to output contains characters that cannot be represented in that code page - which (for non-[CJK](https://en.wikipedia.org/wiki/CJK_characters) locales) is a _single_-byte encoding limited to _256_ characters in total. * Notably, Python exhibits *nonstandard* behavior by default, by encoding redirected output based on the _ANSI_ code page (e.g, [`1252`](https://en.wikipedia.org/wiki/Windows-1252) on US-English systems) rather than the _OEM_ code page (both of which are determined by the system's active legacy _system locale_, aka _language for non-Unicode programs_). However, like the OEM code page (in non-CJK locales), ANSI code pages too are limited to 256 characters, and trying to encode a character outside that set results in the error you saw. * To avoid this limitation, modern CLIs increasingly encode their output using UTF-8 instead, either by default (e.g., Node.js), or on an _opt-in_ basis (e.g., Python). --- In the context of PowerShell, an external program's (stdout) output is considered _redirected_ (*not* targeting the console/terminal) in one of the following cases: * capturing external-program output in a variable (`$text = wget ...`, as in your case), or using it as part an of _expression_ (e.g., `"foo" + (wget ...)`) * _relaying_ external-program output _via the pipeline_ (e.g., `wget ... | ...`) * in _Windows PowerShell_ and [_PowerShell (Core) 7_](https://github.com/PowerShell/PowerShell/blob/master/README.md) _up to v7.3.x_: also with `>`, the [redirection operator](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Redirection); in *v7.4+*, using `>` directly on an external-program call now _passes the raw bytes through_ to the target file. That is, in all those cases _decoding_ the external program-output comes into play, into _.NET strings_, based on the encoding stored in `[Console]::OutputEncoding`. In the case at hand, this stage wasn't even reached, because Python itself wasn't able to _encode_ its output. --- The **solution** in your case is therefore two-pronged, as suggested by [zett42](https://stackoverflow.com/users/7571258/zett42): * Make sure that `html2text` outputs *UTF-8*-encoded text. * `html2text` is a Python-based script/executable, so (temporarily) set `$env:PYTHONUTF8=1` before invoking it. * Make sure that PowerShell interprets the output as UTF-8: * To that end, (temporarily) set `[Console]::OutputEncoding` to `[System.Text.UTF8Encoding]::new()` To put it all together: ``` $text = & { $prevEnv = $env:PYTHONUTF8 $env:PYTHONUTF8 = 1 $prevEnc = [Console]::OutputEncoding [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new() try { wget.exe -O - https://www.voidtools.com/forum/viewtopic.php?p=36618#p36618 | html2text } finally { $env:PYTHONUTF8 = $prevEnv [Console]::OutputEncoding = $prevEnc } } ``` Note: * When you pipe data _from PowerShell_ TO an external program, PowerShell uses the [**`$OutputEncoding`** preference variable](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Preference_Variables#outputencoding) to encode it, in which case you may have to (temporarily) change `$OutputEncoding` too; it defaults to ASCII(!) in _Windows PowerShell_, and to (BOM-less) UTF-8 in _PowerShell (Core) 7_ - which is problematic in both cases, as it doesn't match the default value of `[Console]::OutputEncoding`. For instance, to both send data as UTF-8 and to decode it as such, you can (temporarily) set: $OutputEncoding = [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new() * It is possible to configure a given system to use UTF-8 _system-wide_ by default, which would make things just work without extra effort in this case (though in _Windows PowerShell_ you may situationally still have to set `$OutputEncoding`); however, this configuration, which sets the system locale in a way that sets both the OEM and the ANSI code page to `65001` (UTF-8), has _far-reaching consequences_ that may break existing scripts - see [this answer](https://stackoverflow.com/a/57134096/45375). * [GitHub issue #7233](https://github.com/PowerShell/PowerShell/issues/7233) is a much lower-impact suggestion to make _PowerShell (Core) 7_ console windows default to UTF-8, without the need to change the system locale (active code pages).
findOneAndUpdate not updating value in mongodb?
Your code is using deprecated methods that were removed in Selenium version 4.3.0; see https://github.com/SeleniumHQ/selenium/blob/trunk/py/CHANGES. You *could* `pip install` an older version of Selenium as a workaround. But a better idea would be to change your code to replace the calls to the deprecated calls with `web.find_element(...)` calls, as described in the current [Selenium documentation][1]. It would also be a good idea to create a "requirements.txt" file for your code, and constrain the version for the Selenium python library. ------------------- I expect that the reason that your two laptops behave differently is that you have different versions of the Selenium python library installed. (If you don't constrain the required version of a library, `pip` will install the latest version by default.) [1]: https://selenium-python.readthedocs.io/locating-elements.html
Is there a way to integrate trivy to sonarqube. I'm building a docker image from jenkins pipeline and then do the trivy scan. Now I want to get that image scan result from trivy in jenkins to the sonarqube. Is it possible to do it?
Trivy report to sonarqube
|sonarqube-scan|trivy|
The closest you can get is inlining the `.rename_axis` call: ``` pd.DataFrame({"a": [1, 2], "b": [3, 4]}).rename_axis('myindex') ``` ``` a b myindex 0 1 3 1 2 4 ```
**Docker-compose.yaml:** ``` version: "3.9" services: postgres: image: postgres environment: - POSTGRES_HOST=postgres - POSTGRES_PASSWORD=password - POSTGRES_USER=Test - POSTGRES_DB=Test ports: - "5432:5432" backend: build: ./server container_name: server ports: - "3001:3001" environment: - PORT=3001 - HOST=postgres - DB_PORT=5432 - DB_USER=Test - DB_PASSWORD=password - DB_NAME=Test volumes: - ./server:/app/server - /app/server/node_modules depends_on: - postgres frontend: build: ./client container_name: client ports: - "3000:3000" environment: - NEXT_PUBLIC_API_URL=http://localhost:3001 volumes: - ./client:/app/client - /app/client/node_modules - /app/client/.next depends_on: - backend ``` **Nextjs project dockerfile:** ``` FROM node:21 WORKDIR /app/client COPY package.json ./ COPY yarn.lock ./ RUN yarn install COPY . . RUN yarn build COPY .next ./app/client/.next CMD ["yarn", "start"] ``` **Metrics Page:** ``` import { Button } from "@/components/ui/button" import { TrashIcon } from "lucide-react" import { revalidatePath } from "next/cache" import MetricForm from "../components/metric-form" async function getMetrics() { const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/metrics`, { cache: "no-cache", }) return response.json() } async function deleteMetric(metricID: FormData) { "use server" const metricId = metricID.get("metric_id") await fetch(`${process.env.NEXT_PUBLIC_API_URL}}/${metricId}`, { method: "DELETE", }) revalidatePath("/metrics") } export default async function Metrics() { const metrics = await getMetrics() return ( <main> <div className="flex flex-row justify-between my-5"> <h1 className="text-3xl text-gray-700 font-semibold">Metrics</h1> <MetricForm mode="add" buttonName="Add New Metric" title="Add New Metric" /> </div> <div> <table className="min-w-full"> <thead> <tr className="bg-gray-200"> <th>Metric ID</th> <th>Type</th> <th>Description</th> <th>Edit</th> <th>Delete</th> </tr> </thead> <tbody className="bg-white divide-y divide-gray-200"> {metrics.map((metric: any) => ( <tr key={metric.metric_id}> <td>{metric.metric_id}</td> <td>{metric.type}</td> <td>{metric.description}</td> <td> <MetricForm mode="edit" buttonName="Edit Metric" title="Edit Metric" metricData={metric} /> </td> <td> <form action={deleteMetric}> <input type="hidden" name="metric_id" value={metric.metric_id} /> <Button variant="ghost" size="sm" className="text-slate-500"> <TrashIcon size={16} /> </Button> </form> </td> </tr> ))} </tbody> </table> </div> </main> ) } ``` **ERROR:** ``` 24.93 TypeError: fetch failed 24.93 at node:internal/deps/undici/undici:13737:13 24.93 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 24.93 at async globalThis.fetch (/app/client/.next/server/chunks/735.js:1:156107) 24.93 at async ea (/app/client/.next/server/app/metrics/page.js:21:825) 24.93 at async es (/app/client/.next/server/app/metrics/page.js:21:1126) { 24.93 [cause]: Error: connect ECONNREFUSED 127.0.0.1:3001 24.93 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16) 24.93 at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) { 24.93 errno: -111, 24.93 code: 'ECONNREFUSED', 24.93 syscall: 'connect', 24.93 address: '127.0.0.1', 24.93 port: 3001 24.93 } 24.93 } 24.93 TypeError: fetch failed 24.93 at node:internal/deps/undici/undici:13737:13 24.93 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 24.93 at async globalThis.fetch (/app/client/.next/server/chunks/735.js:1:156107) 24.93 at async ea (/app/client/.next/server/app/metrics/page.js:21:825) 24.93 at async es (/app/client/.next/server/app/metrics/page.js:21:1126) { 24.93 [cause]: Error: connect ECONNREFUSED 127.0.0.1:3001 24.93 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16) 24.93 at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) { 24.93 errno: -111, 24.93 code: 'ECONNREFUSED', 24.93 syscall: 'connect', 24.93 address: '127.0.0.1', 24.93 port: 3001 24.93 } 24.93 } 24.93 24.93 Error occurred prerendering page "/metrics". Read more: https://nextjs.org/docs/messages/prerender-error 24.93 24.93 TypeError: fetch failed 24.93 at node:internal/deps/undici/undici:13737:13 24.93 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 24.93 at async globalThis.fetch (/app/client/.next/server/chunks/735.js:1:156107) 24.93 at async ea (/app/client/.next/server/app/metrics/page.js:21:825) 24.93 at async es (/app/client/.next/server/app/metrics/page.js:21:1126) ``` Hello, When I try and run ```docker-compose up``` I get the error above when ```yarn build```, I assumed with depends_on being backend, frontend won't run until backend is running. If I have the api running before running the command ```yarn build``` it builds fine without any problem. How can I fix this?
NextJS build fails: fetch fatiled ECONNREFUSED