I am storing my public web resources (CSS, JS) in the 'static' folder, with the following path: 'java/com/myapp/resources/static/**'. Here my configuration classes: SecurityConfig.java @Configuration @EnableWebSecurity public class SecurityConfig { @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { http .authorizeHttpRequests(authorize -> authorize .anyRequest().authenticated()) .formLogin(form -> form .loginPage("/login") .permitAll()); return http.build(); } @Bean public WebSecurityCustomizer webSecurityCustomizer() throws Exception { return (web) -> w
I would like to count the tokens of my OpenAI API request in R before sending it (version gpt-3.5-turbo). Since the OpenAI API has rate limits, this seems important to me. Example: The function I use to send requests: ask_chatgpt <- function(prompt) { response <- POST( url = "https://api.openai.com/v1/chat/completions", add_headers(Authorization = paste("Bearer", api_key)), content_type_json(), encode = "json", body = list( model = "gpt-3.5-turbo", messages = list(list( role = "user", content = prompt )) ) ) str_trim(content(response)$choices[[1]]$message$content) } Example api_key <- "your_op
I want to assign values of correlations from a matrix to the thickness of areas in the Igraph package using R. Here is my data require(igraph) links = (AI)# AI in a correlation matrix links= as.matrix(AI)#coersÃo do data sete em uma matrix matrixnetwork = graph.adjacency(links, mode="undirected", weighted = TRUE, add.colnames=NULL, diag=FALSE) plot(matrixnetwork) #here I change to network for igraph I try this form edge.width=strength(matrixnetwork) *2.3 #Set node thickness using strength and match within the graph edge.width=E(matrixnetwork)$weight*2.3#I set the thickness of the node using th
I would like to use PCA on the point clouds to find the lane. So the principal component analysis should work fine for this problem. So I’m not sure how to correctly use PCA with Point Clouds and ROS. Here is the code that I have created so far: #include <iostream> #include "ros/ros.h" #include "std_msgs/String.h" #include <vector> #include <sensor_msgs/LaserScan.h> #include <sensor_msgs/PointCloud2.h> #include <sensor_msgs/PointCloud.h> #include <laser_geometry/laser_geometry.h> #include <tf/transform_listener.h> #include <Eigen/Core> #include <pcl_ros/point_cloud.h> #include <pcl/point_types
How do I implement the make file to link everything together correctly? What I have: CC = g++ # Compiler flags: # -g - debugging info. # -Wall - used to turn on most compiler warnings. CFLAGS = -g -Wall # The build target TARGET = icbins # To bring exe up to date: $(TARGET): main.o m1/cell.o m1/abstractions.o m1/expression.o m1/arithmetic.o m1/logic.o m1/cell.o m1/grid.o parsing/token.o parsing/lexer.o parsing/parser.o interface/icbins.o $(CC) $(CFLAGS) -o $(TARGET) main.o m1/cell.o m1/abstractions.o m1/expression.o m1/arithmetic.o m1/logic.o m1/cell.o m1/grid.o parsing/token.o -lncurses main.
so my code is supposed to be implementing karatsuba algorithm for multiplication. this is my code #include<stdio.h> #include<string.h> #include<stdlib.h> /* karatsuba's algo: you have 2 numbers x,y you halve each of them a = 1st halve of x b = 2nd halve of x c = 1st halve of y d = 2nd halve of y n = number of digits of the biggest number if it's odd then it is decremented by 1 id n is odd then a and c take a bigger part than b and d respectively. if number of digits of both numbers are different we shift as in concat zeros to the right of the lowest by the difference of the number of digits be
I am starting to use Polars as a replacement for Pandas. I am very interested in using the show_graph() method to my team to show some of the benefits. One of the biggest benefits I can see is the use of scan_csv. However I am seeing some oddities that I cannot explain. I have the following code using the iris data set. import polars as pl x = pl.scan_csv('iris.csv') x.show_graph() x = pl.scan_csv('iris.csv').filter(pl.col('variety') == "Setosa").select("petal.length").sum() x.show_graph() I am getting random pi and sigma characters. Can anyone explain what the pi and sigma mean? In addition i
I am using Spring boot 3.0.5 along with Spring Security 6. I am facing this issue when I am trying to call an endpoint to register an account into the application: An expected CSRF token cannot be found @Configuration @EnableWebSecurity @RequiredArgsConstructor public class SecurityConfig { private final JwtAuthenticationFilter jwtAuthenticationFilter; private final AuthenticationProvider authenticationProvider; @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { return http .csrf(AbstractHttpConfigurer::disable) .authorizeHttpRequests() .requestMatchers(
I have a table with two columns which contains date and sales order. I want to create an another table using DAX which contains distinct sales orders getting data from sales order column for making some relationships with other tables. I use below DAX code, but my issue is even after filtering the data from the sheet1 table my DAX table shows all the distinct sales orders from the sales order table. I want to get distinct sales order from filtered table if there any filter for the date. Distinct Sales orders = DISTINCT(Sheet1[Sales Order])
I have a panel dataset (multiple time series indexed on IDs and time) in which I want to perform multi-step forecasts (e.g. 5-steps forecasts). An example of the dataset (pandas dataframe) is the following: IDs, time, f1, f2, ... 1 0 4.1 50 ... 1 1 3.3 44 ... 1 2 2.6 11 2 0 2.1 79 2 1 4.9 56 ... 2 2 0.1 11 ... ... ... ... ... However, i don't know how to train my models and specifically how should I split my data (train/test set). The end goal is to perform 5-steps forecasts given as inputs to the trained model x-length windows. I was thinking to split the data as follows: 80% of the IDs would
i need to show random number that change every day (24h) and keep show generated number day before that not change when user refresh page this what i have only for generate random number <script type="text/javascript"> // this gets an iterable of all elements with a class of "result" const elements = document.getElementsByClassName("result"); // you can use for..of to iterate over the elements. Don't use array methods like forEach on elements, elements is NOT an array. for( let element of elements ) element.innerText = Math.floor((Math.random() * 10000) + 99999); </script> i need the number fr
Team, I am required to use developer mode on my iPhone 16, and all the articles suggest that I need Macbook to unlock developer mode using Xcode. But I do not have access to macbook. Is there no other way I can do it just by iPhone itself. Any help will be highly appreciated.
In python, it is possible to create slots classes which do have an explicit __dict__ available. However, I am struggling to get this working with dataclasses: from dataclasses import dataclass @dataclass(slots=True) class A: __dict__: dict[str, object] A() This raises the following on the last line: TypeError: __dict__ must be set to a dictionary, not a 'mappingproxy' It is not even clear to me where this exception actually occurs since there is no further information provided. There also seems to be no information regarding this problem on google. What is the problem here? How do I create a s
I'm at a loss for understanding why I'm getting this vague ItemSpecifics error with my code. import ebaysdk import csv from ebaysdk.trading import Connection as Trading from ebaysdk.exception import ConnectionError from item_description import code_block from item_definition import myitem def addItem(): try: api = Trading(config_file='ebay.yaml') # Open our CSV file that has individual auction item details. with open("auction_data.csv") as auction_data_file: auction_item = csv.reader(auction_data_file) # Skip headers. next(auction_item, None) for row in auction_item: myitem["Item"]["Title"] =
I am trying to learn how SVD works to use it in PCA (principal component analysis), but the problem is that it seam I get wrong results, I tried using np.linalg.svd and this is my code: A = np.array([[2, 2], [1, 1]]) u, s, v = np.linalg.svd(A, full_matrices=False) print(u) print(s) print(v) And this is the result I got: [[-0.89442719 -0.4472136 ] [-0.4472136 0.89442719]] [3.16227766e+00 1.10062118e-17] [[-0.70710678 -0.70710678] [ 0.70710678 -0.70710678]] And I tried to get SVD decomposition on WolframAlpha and I got these results: The magnitude of values seems correct, but the sign is not cor
I am trying to deal with a circular import solely because of type checking, hence I was wondering if there was a TypeScript equivalent of Python's from typing import TYPE_CHECKING ?
I thought they are __and__ and __or__ but turns out they are for bitwise comparisons not logical ones. Are there such methods for the logical comparators?
How to implement drag-select (make HTML elements selectable by area mouse selecting)? I'm interested in the element selecting like it is in file explorers (of Windows, Linux) and many other sites that provide a file explorer behaviour (dropbox.com, google.drive, mega.nz, js-fileexplorer demo). I mean the selecting when you create a rectangular area by mouse move with all elements are touched by this area are "selected" (for example, an extra CSS class is added to them). How to do it? Best approach?
In RStudio, when you define vectors, data frames, lists, etc., you can see a preview of the data in the data viewer (in the upper-right corner of the picture, where you can see a num [1:4] 1 2 3 4, etc.). Is there an extension or feature in Visual Studio Code that does the same? I have not been able to find one. Searching online and among the VS Code extensions was unsuccessful. I suspect that "data viewer" may be the wrong keyword.
I found that we can build/reconstruct an external pointer from a memory address, see this example where I take a pointer from a data table object and rebuild it: # devtools::install_github("randy3k/xptr") iris_dt <- data.table::as.data.table(iris) ptr1 <- attr(iris_dt, ".internal.selfref") ptr1 #> <pointer: 0x13c00d4e0> typeof(ptr1) #> [1] "externalptr" address <- xptr::xptr_address(ptr1) address #> [1] "0x13c00d4e0" ptr2 <- xptr::new_xptr(address) identical(ptr1, ptr2) #> [1] TRUE Obviously xptr::new_xptr("0x13c00d4e0") is not stable between sessions, I am aware that the above is not allocati
I'm trying to use OpenSearch to connect to my OpenSearch domain on AWS. I set env for AWS. However, I'm encountering an authentication/authorization failure. Here's my code: public class Example { public static void main(final String[] args) throws IOException { SdkHttpClient httpClient = ApacheHttpClient.builder().build(); try { OpenSearchClient client = new OpenSearchClient( new AwsSdk2Transport( httpClient, "search-*****-3ovub4o4gncugluu6t2tquptnu.eu-central-1.es.amazonaws.com", Region.EU_CENTRAL_1, AwsSdk2TransportOptions.builder().build())); InfoResponse info = client.info(); System.out.p
Let's say I have a json data of multiple vendors in a large number of categories. I need to make post api calls for top 10 vendors of these hundreds of categories. How can I do that in a scalable manner? Each category's post api call has a specific request body. How to map the specific json to each api call's expected request body? I was thinking something like : json.stream .parallel() .map((x) -> { reqBody = jackson mapper for the request body; return reqBody; }) .forEach((body)-> make post call); I thought of polymorphism, but with large number of categories, it's difficult to have a common
I am trying to get data form Census Track data in Anaconda and jupyter-nootbook using Pandas, but I am keep getting error. My code: import pandas as pd import numpy as np import requests import geopandas as gpd year = '2021' variable = 'B09019_003E' with open (r"pathToKeyFile/census_api.txt", "r") as f: c = f.read(); url='https://api.census.gov/data/{0}/acs/acs5?get=NAME,{1}&for=tract:*&in=state:12%20county:057&key={2}'\ .format(year, variable, c) response = requests.request("GET",url) response.raise_for_status() print(response.json) temp = pd.DataFrame(response.json()[1:], columns=response.js
I am currently testing a Service performing HTTP requests with WebClient on Spring. When I'm mocking the service I get a NullPointerException on my body when I'm testing a method which performs a POST request. Here is the error : java.lang.NullPointerException: Cannot invoke "org.springframework.web.reactive.function.client.WebClient$RequestHeadersSpec.retrieve()" because the return value of "org.springframework.web.reactive.function.client.WebClient$RequestBodySpec.body(org.reactivestreams.Publisher, java.lang.Class)" is null Here is my code : import com.bluelagoon.payetonkawa.dolibarr.entiti
Best practice to manage multiple stacks with Terraform in replacement of CDK Hi all. In my previous company, we manage the AWS Resources with CDK CloudFormation. Basically, there are three AWS accounts for one project: Dev account: For development and verification purpose. Any CDK and application code changes like AWS Lambda can be deployed from developer's local machine directly. The developer can check if the AWS Resources are created with his/her changes after that deployment from AWS console. QA account: A test account before deployed to prod environment. Prod account: A production environ
I am very new to running perl scripts and I am running into problems that I suspect are due to the assignment of variables. Here is the beginning of the original script: #!/usr/bin/perl -w ##################################### # gbstrim.pl # John Garbe # June 2016 # # ##################################### =head1 NAME gbstrim.pl - - Trim padding and/or cut site residue from beginning of reads - Trim sequencing adapter from ends of reads - Trim all reads to length NOTE: this doesn't handle paired-end data =head1 SYNOPSIS gbstrim.pl --enzyme1 bamhi --enzyme2 psti --read R1 [--threads 1] [--minlen
I am trying to run the below command but I am getting an error message: [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Install-Module -Name PackageManagement,PowerShellGet -AllowClobber -Force -SkipPublisherCheck Error message: WARNING: The version '1.4.8.1' of module 'PackageManagement' is currently in use. Retry the operation after closing the applications. I am running on a windows server and on PowerShell 5.1. I've tried to remove the module and uninstall the module and I get the same error, the server has also had a reboot and there are no other users on i
How can I set a default value in a CDS view for a fiori elements app (based on annotations)? What I tried. I want to have the current date as a default value. @Consumption.filter: { defaultValue: '@Environment.systemDateTime' } and also @Consumption.filter.defaultValue: '@Environment.systemDateTime') and any other Environment date function and session. When I set in the default value a static value it work. When I use the environment thing I get also the error One parameter has an invalid value: parameter IS_EXPRESSION-DATE has the invalid value
I found these two methods to add environment variables: Add environment variables in terminal.integrated.env.osx for terminal. Add environment variables in launch.json for debugging. But no similar config options exist for VSCode Process. Some plugins often need to access specific environmental variables. In this case, I can only set up an environment variables in Terminal.App, and then open through the code command. I hope to add this environment variable in the VS Code setting file.