on-internet

Python distance between two curved lines

I have an image with two lines, the right line is supposed to be the Zero line and I want to get the distance to the left line (very precise). But somehow I'm not able to find a way to get this information. I want to get the distance between those two lines as Height Information. The right line is the ground line and the left one is the one to measure the distance from. Edit: So the Image is the result of an OpenCV addWeighted operation. Due to the Green color I tried to run it with the Numpy where() function to get at least the green lines but that was a complete fail. while x<966: y=0 while

Join the discussion →

Network communication between Windows + WSL2 + Docker

I have a web app hosted in a Docker container and exposes port 5050 that is mapped to port 80 of the container. The web app listens on 0.0.0.0:5050. The Docker engine runs on WSL2. Now when I open a browser on Windows and go to http://localhost:5050, everything works and I can see the web app. But I don't understand how the request can reach the Docker container when I navigate to localhost on Windows. Any ideas ?

Join the discussion →

Can't get personal access tokens to work with github for own repo

I've got a private repo I'm trying to push to, I'm on Centos 7. I cannot use SSH. Https says No anonymous write access. Stack overflow says to use personal access tokens. So I follow the directions, enable everysingle option under the token, and get a personal access token that looks something like: ghp_xxxxxxxxxxxxxxxxxxxxxxx I don't understand what I'm supposed to do with it though. I tried doing what one user said, and use my user name on github, with the access token as the password. Doing this: (note copy pasted ghp_xxxxxxxxxxxxxxxxxxxxxxx below, where ghp_xxxxxxxxxxxxxxxxxxxxxxx is repla

Join the discussion →

Possible conversion loss of data (warning C4244) [closed]

I am using an old compiler that made a a mistake in its warning diagnosis. typedef unsigned char uint8_t; // 8-bit byte typedef unsigned int uint32_t; // 32-bit word (change to "long" for 16-bit machines) typedef struct _sha256_ctx_t { uint8_t data[64]; uint32_t data_len; unsigned __int64 bit_len; // unsigned long long uint32_t state[8]; } sha256_ctx_t; void crypto_sha256_final(sha256_ctx_t *ctx, uint8_t *digest) { uint32_t i; i = ctx->data_len; // Append to the padding the total message's length in bits and transform. ctx->bit_len += ctx->data_len * 8; ctx->data[63] = ctx->bit_len; // LINE 15

Join the discussion →

My Java Program can't connect to the MySQL server

Yesterday I spent several hours trying to solve this problem. When I try to connect to MySQL server from my Java program I get the CommunicationsException: Communications link failure. I have encountered several questions on Stackoverflow with similar problems but none of the solutions that were provided in the answers worked for me. For instance I have read an answer which advises to replace "localhost" with "127.0.0.1" or with my private IP address in the Driver.getConnection method, but that didn't solve the problem.I have read an answer which suggested that it should be checked whether the

Join the discussion →

How to set ability conditions using TypeScript

I am following CASL's cookbook on roles with predefined permissions. I have defined my PlatformAbility as follows, in line with the cookbook instructions. import { Ability, AbilityClass, ForcedSubject } from '@casl/ability'; const platformBaseActions = ['manage', 'read', 'write'] as const; const platformSubjects = [ 'all', 'membership', 'work-order', 'equipment', 'user', ] as const; type PlatformAbilities = [ typeof platformBaseActions[number], ( | typeof platformSubjects[number] | ForcedSubject<Exclude<typeof platformSubjects[number], 'all'>> ), ]; export type PlatformAbility = Ability<Platfo

Join the discussion →

Creating a function that works like "zip"

I am trying to make a function that does something similar to "zip". My problem is that the part a = L4[l:len(L4):len(L)] doesn't work. In the case below, it should take every third element from the L4, and append it to a new list, so I ended up with [[1, 4, 7], [2, 5, 8], [3, 6, 9]], but that is not really what is happening. Also, it would be even better if I could make tuples, so it would look like [(1, 4, 7), (2, 5, 8), (3, 6, 9)], but I don't know how to do that... L = [[1,2,3], [4,5,6], [7,8,9]] L4 = [] def my_zip(L): l = 0 for i in L: if isinstance(i, list): my_zip(i) else: L4.append(i)

Join the discussion →

Argtypes: uint8_t from C to Python

I'm using ctypes to use a C library in my Python script. I have a function in C library that accepts as argtypes uint8_t and was wondering how to invoke it from Python. This is the C function I'm referring to: void indcpa_keypair(uint8_t pk[KYBER_INDCPA_PUBLICKEYBYTES], uint8_t sk[KYBER_INDCPA_SECRETKEYBYTES]) My Python script where I'm trying to use it is this: def key_generation(): out = CDLL('./PQCgenKAT_kem.so') out.pqcrystals_kyber512_ref_indcpa_keypair.argtypes = #I don't know out.pqcrystals_kyber512_ref_indcpa_keypair.restype = None pk = [] * CRYPTO_PUBLICKEYBITES sk = [] * CRYPTO_SECRE

Join the discussion →

Is there a way to handle key not found when using operator.itemgetter without using a try-except block?

Is there any other option aside from wrapping itemgetter in a try/except block in case of a missing key? Like dict.get('bar', 'foo')? Example of usage: currentUser = { "id": 24, "name": "John Doe", "website": "http://mywebsite.com", "description": "I am an actor", "email": "[email protected]", "phone_number": "+12345678", "username": "johndoe", "birth_date": "1991-02-23", "followers": 46263, "following": 345, "like": 204, "comments": 9 } id, like, hhh = itemgetter("id","like", "hhh")(currentUser)

Join the discussion →

Polite ARIA live region for a game with high rate of messages

I'm running a little game on the web. In order for it to be optimally screen reader accessible, incoming messages, which can be about in-game actions or user text chat, have to be read automatically as soon as they arrive. Reading of messages has to be quick, but also reliable. Messages have to be read in order, and none must be prematurely interrupted or completely skipped. Otherwise, players may miss important events or information. Sometimes, messages arrive with a quite high frequency and/or in a burst. In any case, they have all to be read in order and without interruption. It may happen

Join the discussion →

Error: Refused to load the script because it violates the following Content Security Policy directive: "default-src 'none'"

I have a React + Node.js app that works fine on localhost but runs into errors when deployed to Heroku, resulting in a 404 response status. This is one of the console errors I get when loading the app on Chrome: Refused to load the script 'https://ssl.google-analytics.com/ga.js' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'script-src-elem' was not explicitly set, so 'default-src' is used as a fallback. (anonymous) @ 1:3 ... Failed to load resource: the server responded with a status of 404 (Not Found) These scripts and stylesheets are no

Join the discussion →

How to format to "dd/MM/yyyy" in Blazor Webassembly

I'm new to Blazor and I'm working on a Blazor Webassembly project where I need to format the DateTime input as "dd/MM/yyyy". I already tried this: How to format the date using local culture using the blazor <InputDate /> tag Set dd/mm/yyyy in a custom InputDate component instead of 01/01/0001 in Blazor (This actaly is intresting, but thres nothing simplier?) Is there any way to change input type="date" format? This is what I have: <InputDate @bind-Value="@Model.Date1" class="form-control"/> <InputDate @bind-Value="@Model.Date2" class="form-control"/> <InputDate @bind-Value="@Model.Date3" class

Join the discussion →

Could not find org.springframework.boot:spring-boot-starter-web:. Required by: project :

I'm new to spring and trying to use Spring Web dependency with spring boot. Here is my build.gradle plugins { id 'org.springframework.boot' version '2.6.7' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' } group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = '11' repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring- boot-starter-web' testImplementation 'org.springframework.boot:spring-boot-starter-test' } tasks.named('test') { useJUnitPlatform() } but when gradle sync, it returned errors spring-overview:test: C

Join the discussion →

Unable to access key and secrets in Azure Key Vault

I am the owner of an Azure Key Vault that I created. I created a key and a secret a day before. But today when I tried to create another key and secret, the Generate/Import button on top in the right pane is disabled and below it a following message is displayed: Firewall is turned on and your client IP address is not authorized to access this key vault. Networking section of the Key Vault has the following settings: Selected Networks and Allow trusted Microsoft services to bypass this filewall: Yes. Question: Why I am getting the above warning and how can we fix it. I was able to create a Key

Join the discussion →

A `cd` command in an executed Powershell script still affects the current session

Coming from the Unix world, scripts when executed (as opposed to sourced) are run in a subshell, and thus variable declarations and cd commands do not affect the actual current session (the one where we type our commands). For reference: # Executing a script ./myscript.ps1 # Sourcing a script . ./myscript.ps1 Very surprised (and quite frankly annoyed) to see than in Powershell, executing a script will still affect my current session regarding cd commands (but not declared variables). How can I prevent this from happening ?

Join the discussion →

I can't get binance Futures order book historical data

I'm trying to get binance Futures order history data using API. So I asked for data from binance, got the answer "Your application for historical futures order book data has been approved, please follow our Github guidance to access with your whitelisted account API key" and I have set up the API as follows. And I have modified the Enable Symbol Whitelist like this: The next step, I followed Github guidance: https://github.com/binance/binance-public-data/tree/master/Futures_Order_Book_Download which has the following sample code: """ This example python script shows how to download the Histori

Join the discussion →

Stm32CubeProgrammer not connecting (no error msg) using ST-LINK V2 dongle and Lora E5 mini board

I've tried countless settings in an attempt to program my stm32 board. The main tutorial I followed is https://wiki.seeedstudio.com/LoRa_E5_mini/. I have connected a USB st-link v2 dongle to my laptop with pins SWDIO, SWCLK, GND correctly wired to the STM32 board. For power the board is also connected to a usb port via its type c connector. Serial comms over usb work, updating the st link firmware works and stm32cube programmer finds the st link device: I now press the reset button, hold it, click on Connect, release the reset button after 3 seconds and then.. absolutly nothing happens and no

Join the discussion →

How to get multiple values by index in an ojAlgo-array?

Let's say I have an ojAlgo-array defined like this ArrayAnyD<Double> regularArray = ArrayAnyD.PRIMITIVE64.make(10); regularArray.loopAll((final long[] ref) -> regularArray.set(ref, ref[0]*ref[0])); which just contains the squares of the numbers from 0 to 9, and some indexes: long[] idxs = {1, 3, 4, 7, 9} Now, I'd like to do something akin to slicedArray = regularArray[idxs] which should give me another Array containing 1.0, 9.0, 16.0, 49.0, 81.0. How would I do that with ojAlgo? regularArray.get(idxs) only gives me the first value. regularArray.sliceSet(idxs, 0) returns all values from the fir

Join the discussion →

JPA insert query spring boot

I have class City which is: @Entity @Table(name="city",schema="rezervisi") public class City { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Getter @Setter private int id; @Getter @Setter @NotBlank(message = "Name is mandatory") private String name; } Now I want to override save method in which I send object city. How can I do it if i want to send whole object and not @Params separately. And also since ID is generated how I handle it through parameter here? Code for repository class is: public interface CityRepo extends JpaRepository<City,Integer> { @Query(value="select id, name fro

Join the discussion →

How does Visual Studio Code remember trusted workspaces?

I would like to know how Visual Studio Code remembers which folders, repositories and workspaces are "trusted". That is, where is the information stored? In my personal case, I want to know for Linux and Mac installations, but others may be interested in where it's stored in Windows too.

Join the discussion →

Uncaught TypeError: Cannot read properties of undefined (reading 'maps')

I'm trying to display map from google map on file html.twig, but this errors it displayed to me Uncaught TypeError: Cannot read properties of undefined (reading 'maps') my twig : let map, google; let markers = []; var infowindow = new google.maps.InfoWindow(); function initMap() { const haightAshbury = { lat: 36.77355514795189, lng: 9.088027850665279 }; map = new google.maps.Map(document.getElementById("map"), { zoom: 10, center: haightAshbury, draggable: true }); map.addListener("click", (event) => { addMarker(event.latLng); }); } function addMarker(location) { deleteMarkers(); const marker =

Join the discussion →

WARN: Unable to locate 'report-task.txt' in the workspace

My stage sonarqube always fails to run the job, I've made sure the server is correct. Console output Started by user Jesaya Fernando Napitupulu Obtained Jenkinsfile from git http://10.8.60.132/jesaya/simple-webapp.git [Pipeline] Start of Pipeline [Pipeline] podTemplate [Pipeline] { [Pipeline] node Created Pod: kubernetes jenkins/xjoj-61-kw27q-npzb8-x2q9c [Normal][jenkins/xjoj-61-kw27q-npzb8-x2q9c][Scheduled] Successfully assigned jenkins/xjoj-61-kw27q-npzb8-x2q9c to microk8s-worker [Normal][jenkins/xjoj-61-kw27q-npzb8-x2q9c][Pulled] Container image "docker.io/library/openjdk:11.0.14.1-jre" alr

Join the discussion →

How can we validate a Postgres database backup is not corrupted?

Is there a efficient way to check if the Postgres backups (for managed services like RDS and Cloudsql) are not corrupted? Currently one of the ways we are implementing this check is in the following way: spin up a new DB from the backup and run a vacuum if the vacuum runs successful we are considering the backup is not corrupted delete the test DB Does this sound like a valid approach and any better solution to this? PS: GCP has this open source tool to test on their end, but did not understand how we can implement or use it on a managed PG instance. https://github.com/google/pg_page_verificat

Join the discussion →

How do I use asyncio.Lock to stop a function from running more than once concurrently?

Looking into asyncio.Lock to stop a function from running at the same time as another. But am a little confused. Essentially what I need is for a cache update function to be locked if multiple requests are made to it at the same time (By the same user), or within close proximity of each other. This will prevent the external api from rate limiting this users token. app.ctx.cache = {} # {userToken: {user_information...} app.route(user_information, "/api/user_information") async def user_information(request): token = request.get("user_token") cooldown = 5 last_update = datetime.utcnow() - timedel

Join the discussion →

How to securely manage environment variables for AWS Elastic Beanstalk using Terraform?

We are managing an elastic beanstalk application via terraform, and are unsure of the best way to handle sensitive environment variables for our application. Currently, we are storing these sensitive values in an AWS Secrets Manager secret. During the terraform apply step, we use an aws_secrets_manager_secret data source to load the secret. We then iterate over the key/value pairs in the secret, and create setting blocks within our aws_elastic_beanstalk_environment resource. There are a couple of concerns we have with this approach: We have to mark our sensitive values as nonsensitive, because

Join the discussion →
Older stories