Posts

Showing posts from 2021

How can we use/access/read file contents of files placed in a private gitlab repository in our java code

I want to use/access/read file contents of files (excel, properties file, etc.) placed in a private gitlab repository in my java code, which would be creating a CSV file as output using the contents of the files from the private gitlab repository. from Recent Questions - Stack Overflow https://ift.tt/3HlpMry https://ift.tt/eA8V8J

How to sort array of objects based on order of another array

I have an ArrayList of Strings in a certain particular order ArrayList<String> sortedkeys And I have an unordered set of objects Set<Skugroup> unsortedSet Where SkuGroup contains a key to be used for sorting Class SkuGroup { private String sortkey; private String name; } I need to copy all the SkuGroup objects into a new array in the same order of sortedSkus, where the sortedkey value is the same as the SkuGroup->sortkey How can I accomplish this? from Recent Questions - Stack Overflow https://ift.tt/3zdhQWn https://ift.tt/eA8V8J

IntelliJ, .jar executable not behaving properly "java.lang.reflect.InvocationTargetException"

I have a JavaFX program that I need to make executable. I'm currently trying to do it with IntelliJ IDEA, it does create the .jar, but when I try to click on a clickable item that should pop a window it doesn't and instead in the console it prints this error: Screenshot of the error I get If it can be helpful this is a screenshot of the internal structure of the project + whats inside the manifest I should also specify that I imported the javaFX library in Project Structure -> Artifacts. (I already made a .jar executable for another project and worked fine there, but it didn't had any pop-up windows nor multiple .fxml / controllers... so I think that might be whats making it crash, but I'm not sure) Edit: Also I forgot to say that the problem i reported above only happens in the .jar, if i debug the program/run it through the IDE it works perfectly fine. Edit (Error code copy-pasted): Dec 30, 2021 6:51:43 PM javafx.fxml.FXMLLoader$ValueElement processValue...

how to download an audio instead of play it in crefsharp(winform)

If I open an audio link using cefsharp browser, for example: mp3 It will play it in the browser. I am wondering how to make cefsharp download it if the link is an audio. One solution is to check the link and use System.Net.WebClient to save the link to a file, but if the link isn't end with mp3,wav,...etc I still need to download it to check the file type. from Recent Questions - Stack Overflow https://ift.tt/3mKOM3v https://ift.tt/eA8V8J

Route 53 and Certificate Manager Issues

Is anyone else having issues getting a route 53 domain name certified using the certificate manager? I'm following the documentation very closely and am running into a block where I request a certificate through DNS and then create the records in route 53, but I'm stuck pending validation for days. When I click the "Create Records in Route 53 button" the records are created in route 53, but nothing else happens. Does anyone know what the issue could be? The hosted zone is firstlast.com and I'm trying to certify www.firstlast.com and firstlast.com (not actually firstlast, some other name haha). I followed this documentation: https://docs.aws.amazon.com/acm/latest/userguide/dns-validation.html I've also tried email validation but they don't give you a CNAME and it's unclear how to integrate with route 53. from Recent Questions - Stack Overflow https://ift.tt/3eE8Ksw https://ift.tt/eA8V8J

macOS disk image - create in terminal with password

macOS 12.1 here. In the man page for hdiutil there is this example for creating a disk image with a password. Creating an encrypted single-partition image without user interaction: printf pp|hdiutil create -encryption -stdinpass -size 9m sp.dmg This works. It creates a 9MB .dmg file with a password but I don't get to see what the password is. I know the "printf" is supposed to show something but I don't know what the "pp" that follows that does? from Recent Questions - Stack Overflow https://ift.tt/3EEE199 https://ift.tt/eA8V8J

How to invoke a lambda after create/update in terraform?

I'm creating/updating a lambda function using terraform and I need to run it AFTER it is created or updated. I know there is a terraform data source aws_lambda_invocation but it runs BEFORE the lambda function created/updated. Is there any way to achieve this in terraform? from Recent Questions - Stack Overflow https://ift.tt/3eCy2Hg https://ift.tt/eA8V8J

jMeter: load file content on http request body

Image
I'm trying to inject file content into the request body: I'm using: ${__FileToString(${__eval(${bundle})},,)} I've configured the bundle variable using the directory listing plugin : When I perform the test, I'm getting: Logs is getting me: 2021-12-28 16:33:53,853 WARN o.a.j.f.FileToString: Could not read open: /patient-bundle-0193.json According to my configuration, __FileToString should read from /home/jeusdi/projects/workarea/salut/mpi/jsons/bundles/extractions/10000/bundles instead from / ... Any ideas? from Recent Questions - Stack Overflow https://ift.tt/3zdn050 https://ift.tt/3HiDICE

How can I put a Console Write Command to String [closed]

Maybe this question is silly, but I hope someone can help me out. I'm trying to get the output of this command to a string. for (int i = 48; i < 123; i++) { int keyState = GetAsyncKeyState(i); if (keyState == 32769) { Console.Write((char)i); } } The plan behind this is to get the string and do a regex. The regex should check the string and if the regex matches with the string it should execute a command. from Recent Questions - Stack Overflow https://ift.tt/3EHxqe2 https://ift.tt/eA8V8J

Why Eigen C++ with MKL doesn't use multi-threading for this large matrix multiplication?

I am doing some calculations that include QR decomposition of a large number(~40000 in each execution) of 4x4 matrix with complex double elements (chosen from a random distribution). I started with directly writing the code using Intel MKL functions. But after some research, it seems like working with Eigen will be much simpler and result in easier to maintain code. (Partly because I find it difficult to work with 2d arrays in intel MKL & care needed for memory management). Before shifting to Eigen, I started with some performance checks. I took a code(from an earlier similar question on SO) for multiplications of a 10000x100000 matrix with another 100000x1000 matrix (large size chosen to have the effect of parallelization ). I run it on a 36 core node . When I checked the stat, Eigen without Intel MKL directive (but compiled with -O3 -fopenmp) used all the cores and completed the task within ~7 sec. On the other hand with, #define EIGEN_USE_MKL_ALL #define EIGEN_VECTORIZE_SSE4_...

Is there a way to reference a parameter value within the same PSD1 file?

Let's say that I have a PSD1 file, with the following code: @{ AllNodes = @( @{ NodeName = $env:COMPUTERNAME Tags = @{ Environment = "dev" Datacenter = "east 1" } Data = @{ ConfigName = [Tags.Environment]-[Tags.Datacenter.replace(" ","-")] } }) } See how I am trying to reference the "Tags" section later on in the same file? Is there some way to do that, or do I simply need to do so within a separate PS1 file? from Recent Questions - Stack Overflow https://ift.tt/3JvDQR5 https://ift.tt/eA8V8J

Is there a way to list super primes between 1 and n in NumPy

Is there a way to list super primes (primes in a prime position wikipedia article ) between 1 and n using NumPy. from Recent Questions - Stack Overflow https://ift.tt/3JvZ01M https://ift.tt/eA8V8J

Prevent data refresh in React-Query by data hash matching

The API that I hit with React-Query returns a set of data and a hash key for this data in a form like so: { orders:[{order1},{order2},....] dataHash:number } I Use this dataHash to check if the request results are equal inside useQuery() options to make it easy for reach-query to compare big datasets on it's own like so: isDataEqual:(oldData, newData)=>oldData?.dataHash === newData.dataHash, //do not refresh page if hashes are equal The API also has a feature that allows not to send a dataset if the dataHash matches with the one in a request. In such case it only returns the following: { orders:[] //empty array here dataHash:number } But since my compare function only looks at dataHash the new data will not be used and everything will work as expected. The problem I have currently is that I cannot seem to find a built-in way in react-query to save the dataHash from the old request so that it is being passed as a parameter into the new one. Ideally I would like to see rea...

How do I split a string with two different delimiters in Ruby and convert it to two arrays?

I have a string "Param 1: 1, Some text: 2, Example3: 3, Example4: 4" and I'd like to convert it into an arrays: ["Param 1","Some text","Example3","Example4"] [1,2,3,4] How? from Recent Questions - Stack Overflow https://ift.tt/3JtO1pc https://ift.tt/eA8V8J

how to fix the problem of the missing color pieces in the colorbox in gnuplot

Image
I met a problem that when I draw a map using gnuplot, there would be a colorbox near the map which looks very weird. I blew up the colorbox and found that there were pieces with missing color, the picture is below. How can I fill the color for the colorbox? Here are the terminal type and the palette I used in in gnuplot. set terminal postscript portrait color enhanced 12. set palette defined (-6.0 "#1B66B1", -4.8 "#1B66B1", -4.8 "#2A85DF", -3.6 "#2A85DF", -3.6 "#5FA3E7", -2.4 "#5FA3E7", -2.4 "#95C2EF", -1.2 "#95C2EF", -1.2 "#C9E0F7", -0.120000 "#C9E0F7", 0.0 "#FFFFFF", 0.0 "#FFFFFF", 0.120000 "#F6D5CB", 1.2 "#F6D5CB", 1.2 "#EDAB96", 2.4 "#EDAB96", 2.4 "#E48062", 3.6 "#E48062", 3.6 "#DC562E", 4.8 "#DC562E", 4.8 "#AE3F1E", 6.0 "#AE3F1E") from Rece...

Execute function for every subfolder

I have a folder named students_projects that contains 10 subfolders. Each subfolder has project1.c and project2.c, each one prints a value. I made a bash script function that check those numbers and save them to a txt file. I tested it with 2 .c files named project1 and project2 in Desktop and not in the folder. I made sure that i worked fine but when i went to run it for all the subfolders it keeps saving the values that are in desktop files. My function: function test () { gcc project1.c p1=$(./a.out) if (( $p1 == 20 )); then v1=30 else v1=0 fi gcc project2.c p2=$(./a.out) if (($p2 == 10 )); then v2=70 else v2=0 fi sum=$(( $v1 + $v2 )) on="cut -d' ' -f1 report.txt" onoma=$(eval "$on") temp="cut -d' ' -f2 report.txt" am=$(eval "$temp") printf "$onoma $am project1: $v1 project2: $v2 total_grade: $sum\n" >> grades.txt } Then i do for FILE in students_projects/*...

Expand row from grid to use free space left by a max-height row

Given a grid body and these 3 panes: ┌───┬───┐ │ │ B │ │ A ├───┤ │ │ C │ └───┴───┘ I'm trying to have A and B/C columns to be 50% 50% viewport width ; A to be 100% viewport height, B 60vh and C 40vh. But also C to be max-height of its max-content , and so B to take the remaining place left by C if C's max-content is lower than 40vh. All panes have overflow-y: auto and A & B always have scrollable content. So starting with this body { display: grid; grid-template-columns: 50% 50%; grid-template-rows: 60% 40%; } .a { grid-row: 1 / 3; } which work appart for the C's max-height part, I tried to replace grid-template-rows with 60% minmax(40%, max-content) , or even to use fixed height (say 16em ) instead of max-content minmax(60%, calc(100% - 16em)) minmax(40%, 16em) , but I'm definitely missing something here. from Recent Questions - Stack Overflow https://ift.tt/33YrbG1 https://ift.tt/eA8V8J

I am only able to control the first out of four 8x8 led matrices powered by Max7219

I have 4 8x8 led matrices that are serial connected and I communicate with the using the SPI protocol. And after rewriting a few libraries ( python implementation , rust implementation , c implementation ), because it just does not work on my system and my code works at least a bit I am only able to control the first out of the four connected displays. Here is my code to display a target like image on the first display: Matrix Object: #![allow(dead_code)] use spidev::Spidev; use std::io::prelude::*; // Maximum number of displays connected in series supported const MAX_DISPLAYS: u8 = 8; // Digits per addr const MAX_DIGITS: u8 = 8; // Possible command register values on the addr chip. #[derive(Clone, Copy)] pub enum Command { Noop = 0x00, Digit0 = 0x01, Digit1 = 0x02, Digit2 = 0x03, Digit3 = 0x04, Digit4 = 0x05, Digit5 = 0x06, Digit6 = 0x07, Digit7 = 0x08, DecodeMode = 0x09, Intensity = 0x0A, ScanLimit = 0x0B, Power = 0x0C, D...

Apply for loop or sapply on multiple columns in R

I have data like wherein A* represents the place with time format (01:01) as column names and the row names like 1C or 9D represent the individual ID. structure(list(V1 = c("1C", "9D", "9F", "9H", "9S", "9T", "9Y" ), `A*01:01` = c(NA, NA, "1", NA, NA, NA, NA), `A*02:01` = c(NA, NA, "1", NA, NA, NA, NA), `A*02:02` = c(NA, NA, "1", NA, NA, NA, NA), `A*02:03` = c(NA, NA, "1", NA, NA, NA, NA), `A*02:05` = c(NA, NA, NA, NA, NA, NA, "1"), `A*02:06` = c(NA, NA, NA, NA, NA, NA, "1"), `A*03:01` = c(NA, NA, "1", NA, NA, NA, NA), `A*11:01` = c(NA, NA, NA, NA, NA, NA, "1"), `A*11:02` = c(NA, NA, NA, NA, NA, NA, "1"), `A*23:01` = c(NA, NA, NA, NA, "1", NA, NA), `A*23:02` = c(NA, NA, NA, NA, "1", NA, NA), `A*24:02` = c(NA, NA, NA, NA, "1", NA, NA), `A*24:03` = c(NA, NA, NA, NA, "1", NA, NA), `A...

Pyinstaller and pygubu's calendar frame cause a problem

I made a pygubu python application, and decided I wanted to freeze it, after troubleshooting some simple problems, I ran into something I couldn't fix: Traceback (most recent call last): File "main.py", line 138, in <module> File "pygubu\__init__.py", line 30, in __init__ File "main.py", line 38, in _create_ui File "pygubu\builder\__init__.py", line 166, in get_object File "pygubu\builder\__init__.py", line 215, in _realize File "pygubu\builder\__init__.py", line 215, in _realize File "pygubu\builder\__init__.py", line 225, in _realize Exception: Class "pygubu.builder.widgets.calendarframe" not mapped [13108] Failed to execute script 'main' due to unhandled exception! I even imported a bunch of pyugubu modules to try to fix this, and it still didn't work: from pygubu import builder from pygubu.builder import ttkstdwidgets from pygubu.builder import widgets from pygubu....

Setting tabBarAppearance makes it so UITabBarItem doesn't respect `imageInsets`

When I set the UITabBar's appearance, it makes it so the UITabBarItem's imageInsets and titlePositionAdjustment aren't respected anymore on iOS 15. Removing the line [UITabBar appearance].standardAppearance = tabBarAppearance; makes it so the image and label lineup but the background color can't be set. Has anyone run into something like this and solved it? Code: UITabBarAppearance *tabBarAppearance = [[UITabBarAppearance alloc] init]; [tabBarAppearance configureWithOpaqueBackground]; [UITabBar appearance].standardAppearance = tabBarAppearance; [UITabBar appearance].scrollEdgeAppearance = tabBarAppearance; static let tabBarImageInsets: UIEdgeInsets = UIEdgeInsets(top: 4.0, left: 0, bottom: -4.0, right: 0) static let titlePositionAdjustmentValue: UIOffset = UIOffset(horizontal: 0.0, vertical: -8.0) tabBarItem.imageInsets = tabBarImageInsets tabBarItem.titlePositionAdjustment = titlePositionAdjustmentValue Images: Tab Bar with appearance and misaligned label Tab ...

Google Chrome Error Message: "Uncaught (in promise) DOMException: play()"

In Google Chrome, I get this error: Uncaught (in promise) DOMException: play() My php code: <a href="javascript:void(0);" onclick="aj('player')"></a> My js code: case "player": var request = new XMLHttpRequest(); var fileId = info.match(/\/view\/([a-zA-Z0-9]+)/g)[0].substr(6), request.onload = successListener; function successListener() { var data = JSON.parse(this.responseText); var player = '<iframe width="668" height="100" autoplay="true" frameBorder="0" src="https://'music.com/getEmbedPlayer/'+ fileId +'?width=668&autoplay=true&date='+ data.uploadDate +'"></iframe>'; from Recent Questions - Stack Overflow https://ift.tt/311Wyym https://ift.tt/eA8V8J

Exclude null values from GraphQL query

Image
Disclaimer, I am still a noob in GraphQL. Apologies for the long post, but I need to give as much information as possible to explain my issue. I am currently trying to query my Neo4j using GraphQL and then tabulate the data using ReTool . I managed to do most of the work but when I query the database, I also get the null values. You can access the sandbox below to test yourself a probable solution. https://codesandbox.io/s/great-marco-coy3k The query I am using is the following: query { people{ child{ firstname{ name } middlename{ name } lastname{ name } phone{ name } email{ name } dob{ name } eid{ name } } } } As you can see, I get back a mixture of null and none-null values. What I would like to get back is the children that has data in them and ignore the null ones. The reason for that is when I try to populate my table, t...

How are nodes and edges connected in GraphQL?

Image
I am using https://arrows.app/ to create a basic network: And the resulting GraphQL it creates is: type Person { Name: Dante Alighieri wroteBook: Book @relationship(type: "WROTE", direction: OUT) } type Book { Title: The Inferno personWrote: Person @relationship(type: "WROTE", direction: IN) personReviewed: Person @relationship(type: "REVIEWED", direction: IN) personRead: Person @relationship(type: "READ", direction: IN) } type Person { Name: Harold Bloom reviewedBook: Book @relationship(type: "REVIEWED", direction: OUT) reviewedBook: Book @relationship(type: "REVIEWED", direction: OUT) } ... How do we know in GraphQL that these two relationships are 'linked'? type Person { Name: Dante Alighieri wroteBook: Book @relationship(type: "WROTE", direction: OUT) } type Book { Title: The Inferno personWrote: Person @relationship(type: "WROTE", direction: IN) } Does sequent...

AttributeError: can't set attribute when trying to increment X value of a circle in sympy[2] I want 3Pattern

I want 3Pattern ①②➂ https://docs.sympy.org/latest/modules/geometry/points.html#sympy.geometry.point.Point2D.x AttributeError: can't set attribute when trying to increment X value of a circle in sympy from sympy import Point, Circle def myPointSubs(PT,x,y): return PT.translate(x=-PT.x+x,y=-PT.y+y) test_center=Point (1,2) test_circle=Circle(myPointSubs(test_center,2,test_center.y), 1) # test_circle=Circle(myPointSubs(test_center,2,), 1) #① I want Circle(Point2D(2,2), 1) # test_circle=Circle(myPointSubs(test_center,,1), 1) #② I want Circle(Point2D(1,1), 1) # test_circle=Circle(myPointSubs(test_center,, ), 1) #➂ I want Circle(Point2D(1,2), 1) print("#",test_circle) # Circle(Point2D(2, 2), 1) test_circle=Circle(myPointSubs(test_center,2,), 1) TypeError: myPointSubs() missing 1 required positional argument: 'y' (2021-12-28) from sympy import Point def change(pt,x=None,y=None): return pt.func(pt.x if x is None else x, pt.y if y is None else y) print("...

AfxBeginThread no work when attatch it in VC6 [closed]

I have a problem about thread. I develop a dll and try useing AfxbeginThread in VC6. AfxBeginThread(ReciveImg, (LPVOID)this,THREAD_PRIORITY_NORMAL,0,0,NULL); and ReciveImg function ReciveImg() { while(1) { //Recive image... } } but ReciveImg fucntion no work when I attached a process. Anybody can help me? Thank you. from Recent Questions - Stack Overflow https://ift.tt/3EuoVD3 https://ift.tt/eA8V8J

Why application crashes when using express-rate-limit?

Image
I'm using express-rate-limit package version 6.0.1 to limit hits of request an I also had used express-rate-limit documentation found on https://www.npmjs.com/package/express-rate-limit However when I use this in my app, my application crashes. I"m not understanding what is going on here. I have search allot for a conclusion but without any results. Can someone give me an idea of what I'm doing wrong??? ... //Load env vars dotenv.config({ path: "./config/config.env" }); //Connect to database connectDB(); const app = express(); //Set Static folder app.use(express.static(path.join(__dirname, "public"))); // Body Parser app.use(express.json()); // Cookie parser app.use(cookieParser()); //Dev logging middleware if (process.env.NODE_ENV === "development") { app.use(morgan("dev")); } // File uploading app.use(fileUpload()); // Sanitize data app.use(mongoSanitize()); // Set security headers app.use(helmet()); // Prevent XSS a...

SwiftUI: Filtered list indices are not corresponding to new list

I have a Country model and then a JSON list of countries. I have creating the list by using a ForEach . If the search box is empty, the value of filteredCountries is just the whole list, otherwise the list only contains countries that include whats in the search box. The problem is that when the list is filtered and I click to favorite an item, the wrong country is favorited. The indices don't match the filtered items, they still go in sequential order: 0,1,2,3 etc. Country import Foundation struct Country: Codable, Identifiable { var id: String {image} let display_name: String let searchable_names: [String] let image: String var favorite: Bool var extended: Bool } ContentView var filteredCountries : [Country] { if (searchText.isEmpty) { return countries; } else { return countries.filter { $0.display_name.contains(searchText) } } } NavigationView { ScrollView { ForEach(Array...

Template function with template argument parametrized over int

Without using the features of C++11 and higher (I will accept them but would prefer C++98), I have to write a template function with argument T which is an STL container of int s. It receives such a container along with another int which it tries to search for, Right now I have this but it doesn't compile: template <template<int> class T> T::iterator easyfind(T &container, int val) { T::iterator it = container.begin(); for ( ; it != container.end(); it++) if (val == *it) break ; return (it); } I wonder if I can somehow force the T parameter to always be a class template that is parametrized over integers... I tried writing T<int> but it still doesn't compile. from Recent Questions - Stack Overflow https://ift.tt/343GFZx https://ift.tt/eA8V8J

Using buttons in Bottom navigation crashes app

App Crashes when using button , link and . isGone function. It was working before but error occurred when switched to bottom navigation and fragments. Could anyone explain what is happening. Error: E/AndroidRuntime: FATAL EXCEPTION: main Process: com.dmat.zerowaste, PID: 14673 java.lang.NullPointerException at com.dmat.zerowaste.OrganicWasteFragment.onCreate(OrganicWasteFragment.kt:41) at androidx.fragment.app.Fragment.performCreate(Fragment.java:2949) at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:475) at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:278) at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2189) at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2100) at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2002) at andr...

Automatically update local Git repository

I want to clone a GitHub repository that's not mine, and keep this local cloned repository always up to date, that is, whenever a new commit is made upstream, my local repository is also updated automatically. My use case is CI/CD, I need to clone repositories several times in my jobs, if I had a local GitHub cache it'd be way faster. Is this possible? from Recent Questions - Stack Overflow https://ift.tt/3EC8Nzj https://ift.tt/eA8V8J

parallelStream for time consuming methods [closed]

I have something like this: // sequential version for(var t: tasks){ // run() is a time consuming method (approx. 20-30 seconds) t.run(); } I have approx. 1000 (independent) tasks and the above needs approx. 1000 x 25 seconds. The run() -method is only CPU intensive (there are no I/O Operations involved). I switched to parallelStream: // parallel version tasks.parallelStream().forEach(Task:run); and measured that with parallelStream each task.run() needs approx. 15-20 seconds. So it's definitely a little faster than using the sequential version. Can I use parallelStream (with its fork-join) for such long running operations (each task.run() needs approx. 15-20 seconds) or would it be better to use executorServices with custom thread pools (for example, because of system stability, performance, etc.)? What I want to know if there is any harm when using parallelStream (fork-join) for such long running tasks. I have thought that fork-join should only be used for...

How to convert XML to String with JAXB and spring-boot?

Image
When I run a mvn spring-boot:run on the folder that has the pom.xml file the application starts and serializes a POJO into a XML correctly, but when I do it by going to the target folder and starting it by using java -jar in the jar file I get javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath caused by .java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory . In my maven I have the following JAXB dependencies: <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.1</version> </dependency> <dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-runtime</artifactId> <version>2.3.1</version> <scope>runtime</scope> </dependency> Here's the method that serializes a POJO into XML: private static final Pattern REMOVE_HEA...

Xgboost multiclass classification map the probabilities to the labels

I am using the xgboost multiclass classifier as outlined in the example below. For each row in the X_test dataframe the model outputs a list with the list elements being the probability corresponding to each category 'a','b','c' or 'd' e.g. [0.44767836 0.2043365 0.15775423 0.19023092] . How can I tell which element in the list corresponds to which class / cateogry (a,b,c or d)? My goal is to create 4 extra columns on the dataframe a,b,c,d with the matching probability as the row value in each column. import numpy as np import pandas as pd import xgboost as xgb import random from sklearn import preprocessing from sklearn.model_selection import train_test_split #Create Example Data np.random.seed(312) data = np.random.random((10000, 3)) y = [random.choice('abcd') for _ in range(data.shape[0])] features = ["x1", "x2", "x3"] df = pd.DataFrame(data=data, columns=features) df['y']=y #Encode target variable lab...

Performance of rand() in CUDA host function [closed]

Why is this function that uses rand() slow and what approach would have better performance when used in .cu file? In my case I would like to replace one function that reads strings from file and fills an array(data) to other function which generate strings and fills the same array. Then this array transfers from host to device. Would like to replace this function that reads file and fills array: char* get_data(char* file_name) { FILE* f; if (!(f = fopen(file_name, "r"))) { printf("Error opening file %s", file_name); exit(1); } char* data = (char*)malloc(sizeof(char) * count * str_length); if (data == NULL) { perror("Error allocating memory for list of Strings.\n"); exit(1); } int index = 0; char buf[50]; while (1) { if (fgets(buf, str_length + 1, f) == NULL) break; buf[strlen(buf) - 1] = '\0'; memcpy(&data[index], buf, str_length); index += str_length - 1...

Magento 2.3.7 Problem Forgot Password letters and numbers don't displayed on the page

When the client forgot your password the form is incorrect in the page the letters and numbers of recaptcha are not displayed in the page and the client don't get reset our password.How can I solve this problem? enter image description here from Recent Questions - Stack Overflow https://ift.tt/32l83Sr https://ift.tt/eA8V8J

executing "service libvirtd start" from ubuntu:20.04 container in docker results in libvirtd: unrecognized service [duplicate]

Steps taken: Created a Dockerfile: FROM ubuntu:20.04 ENV TZ=Europe/Amsterdam RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN apt-get update -y RUN apt-get install -y build-essential RUN apt-get install -y qemu-kvm libvirt-daemon-system libvirt-dev COPY startup.sh / ENTRYPOINT ["/startup.sh"] Created startup.sh: #!/bin/bash set -eou pipefail chown root:kvm /dev/kvm service libvirtd start service virtlogd start exec "$@" Then make it executable and create a docker image build: chmod +x startup.sh docker build -t win10-vm:latest -f Dockerfile . And last running a container from the image: docker run --privileged -it --name temp-container1 --device=/dev/kvm --device=/dev/net/tun -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cap-add=NET_ADMIN --cap-add=SYS_ADMIN win10-vm:latest bash Unfortunately when getting to the rule >> service libvirtd start in startup.sh then I'm getting the following error: libvirtd: un...

Need help understanding IDAT header in Png image file

Image
I am trying to make an simple-png image file from scratch, using hex editor. Bytes before the highlighted region are for PNG file header and IHDR. Which states that I am trying to make an 10 x 10 Png file Greyscale color space 1 bit depth (bi-level) Deflate Compression? Adaptive Filtering? No interlace The bytes highlighted are a placeholder for the future length of the IDAT field. Question:- Now I am unsure on what ( or How? ) am I supposed to put the image data in the IDAT field? I am aware of Pixel values of an image being an matrix of MxN dimensions. Being displayed somewhat like: [ (255, 255, 255), (255, 255, 255) ... (255, 255, 255)] [ (255, 255, 255), (255, 255, 255) ... (255, 255, 255)] [ (255, 255, 255), (255, 255, 255) ... (255, 255, 255)] [ (255, 255, 255), (255, 255, 255) ... (255, 255, 255)] The Pixel values of an White RGB image, where top left tuple is the color value of pixel at (0, 0) and bottom right being the one for (m-1, n-1) . Now how am I sup...

Numpy array indexing: view or copy - depends on scope?

Consider the following array manipulations: import numpy as np def f(x): x += 1 x = np.zeros(1) f(x) # changes `x` f(x[0]) # doesn't change `x` x[0] += 1 # changes `x` Why does x[0] behave differently depending on whether += 1 happens inside or outside the function f ? Can I pass a part of the array to the function, such that the function modifies the original array? Edit: If we considered = instead of += , it seems that we would maintain the core of the question while getting rid of some irrelevant complexity. from Recent Questions - Stack Overflow https://ift.tt/3H6HyP2 https://ift.tt/eA8V8J

routing with webpack encore, symfony5

I am developing with symfony 5.3 and webpack encore and I need to call symfony routes from js code. In order to integrate symfony routes to javascript, I am following Symfony 4 - Webpack-encore use FosJsRouting : Routing is not defined . With this bundle I should write $.ajax({ url: Routing.generate("route_of_symfony"), ....... I am installing jsrouting-bundle with symfony 5 but I am getting some errors: Problem 1 - Root composer.json requires friendsofsymfony/jsrouting-bundle ^3.0 -> satisfiable by friendsofsymfony/jsrouting-bundle[3.0.0]. - friendsofsymfony/jsrouting-bundle 3.0.0 requires symfony/framework-bundle ^5.4|^6.0 -> found symfony/framework-bundle[v5.4.0, v5.4.1, v6.0.0, v6.0.1] but it conflicts with your root composer.json require (5.3.*). I asked and got this answer https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/issues/422#issuecomment-999818579 where it is not compatible with 5.3 is there some workarround o other way to get routes fro...

Why the CLR keeps checking static members for type constructor invocation even after the constructor invoked?

I understand that when a type declares an explicit static constructor, the just-in-time (JIT) compiler adds a check to each static method and instance constructor of the type to make sure that the static constructor was previously called. This behaviour I can imagine it as the following code (correct me please if I’m wrong with this conclusion): class ExplicitConstructor { private static string myVar; // Force “precise” initialization static ExplicitConstructor() { myVar = "hello, world";} /* CLR: if the type constructor didn't invoked then add a call to the type constructor */ public static string MyProperty { get { return myVar; } } /* CLR: if the type constructor didn't invoked then add a call to the type constructor */ public ExplicitConstructor() { Console.WriteLine("In instance ctor")...

Can i send variable in php to anoter page?

This is my code but it doesn't work (error 500) while ($dbarr = mysqli_fetch_array($result)) { echo $dbarr['qno']; echo '<a href=show_detail.php?item=' . $dbarr[qno] . '>' . $dbarr[ans] . '</a>'; echo $dbarr['qname'],"</a>&nbsp;"; echo $dbarr['qcount'] . "<br>\n"; } from Recent Questions - Stack Overflow https://ift.tt/3yHn78w https://ift.tt/eA8V8J