on-internet

PyO3 unable to find/call Python function from within a Rust application

I have the beginning of a GUI application written in Rust. I'm using the Py03 crate to run a python function inside my Rust app. I have my python function (test_func) inside a file "test_funcs.py" and this file is located in the same directory as my Rust binary. I also have a copy of this file in the root directory too. The problem is, whilst Py0 is able to find my .py file, it can't seem to find the function I'm trying to call. Here is the key bit of code: MyAppMessage::SecondButton => { Python::with_gil(|py| { let my_module = PyModule::new(py, "test_funcs").expect("Could not load Python modu

Join the discussion →

PCA Eigenface is wrong and staticy, and I don’t know what I’m doing wrong

I am trying to generate eigenfaces using principal component analysis and have gone through the following steps to do so. Am I missing something or doing something wrong? data matrix: (N, width * height) normalized matrix: data matrix - mean vector covariance matrix: (data matrix).T @ (data matrix) *results in matrix of shape (width * height, width * height) find eigenvectors of covariance matrix using np.linalg.eig function rescale the eigenvector corresponding to the largest eigenvalue to fit within 0 and 255 reshape the eigenvector to (width, height) display the eigenvector. Code is below i

Join the discussion →

How do I correctly import Bootstrap using sass and use variables across different files

I have the following project structure: /resources /components component-a.js component-a.html component-a.scss /scss bootstrap.scss variables.scss my-app.js my-app.html my-app.scss I am using the aurelia framework, but I don't think that makes much of a difference here. I am also using webpack, with these loaders style-loader, cssLoader, postcssLoader, sassLoader. Hence, my webpack config looks like this: rules: [ ... { test: /\.scss$/i, use: [ 'style-loader', cssLoader, postcssLoader, sassLoader ] }, ... ] My bootstrap.scss file looks like this (I know that @import is deprecated, but it's th

Join the discussion →

How to use multiple timer capture Interrupt in stm32

ı have two capture interrupts from tim1ch1 and tim4ch1, when ı worked with only tim1 ch1, ı could use if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1) but what if ı want to use tim4ch1 interrupts at the same time. Can ı use below format? is it correct or not? Can you warn me about it. I will not be able to try it as software that so ı want to ask professions about these kind of topics. void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) { if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1) { if (htim->Instance == htim1.Instance) { // to do sth } else if (htim->Instance == htim4.Instance) { // to

Join the discussion →

Integration testing in React

You can view my app in my repository, make sure you're on the tests/vitest branch. The Problem I am trying to incorporate integration tests for my components. The thing is, in my app I always check if a user is authenticated. This happens in a component called AuthContext.tsx and it uses /auth/re and /auth/refresh-token to verify if a user is authenticated (if he has a valid token cookie). Now, I understood that in react-testing-library there is no way to use cookies, and there is no need to. I am very confused. Should I simulate exactly how my app works? Or just manipulate my components (i.e

Join the discussion →

Error producing message Local Value serialization error in Kafka

Hi I am working in Kafka and .Net. I am trying to produce message as below. I have created configuration for schema registry and producer as below. I am using certificates to connect to schema registry var schemaRegistryConfig = new SchemaRegistryConfig { Url = "", SslKeystoreLocation = Path.Combine(Directory.GetCurrentDirectory(), @"Certs/decodedca.p12"), SslKeystorePassword = "", EnableSslCertificateVerification = false }; var producerConfig = new ProducerConfig { BootstrapServers = "3", SaslMechanism = SaslMechanism.ScramSha512, SaslUsername = "", SaslPassword = "", SecurityProtocol = Secur

Join the discussion →

How to make an image with %2F in the url appear when shared, after including it in html meta og:image tag?

I have an image stored in Firebase Storage. I used the link for my website's meta og:image tag, but it doesn't appear on the preview for WhatsApp or Facebook. It seems like the %2F characters are being replaced with %252F. How can I get around this issue without changing the name of the image? This image works (doesn't have %2F). This image doesn't work (has %2F).

Join the discussion →

Java vs. Kotlin for Android development [closed]

Which language should I consider for Android development, Java or Kotlin? I understand the main point of Kotlin is that it can handle null safety, while Java can't, but I am confused about which language I should use for Android dev.

Join the discussion →

java vs kotlin android development [closed]

plz someone tell me which language should i consider for Android development, java or kotlin. Till now i understand main point about kotlin that it can handle null safety but java can't, but i am confused which language should i use for Android dev, i already completed my java and kotlin. plz someone help me and also suggest me sources where i can learn without wandering on internet and also share your opinion if you have to start over, what you do first? sorry for grammar mistakes i am expecting genuine answer about language which i use as a android dev java or kotlin. devs can help me in cle

Join the discussion →

TypeError: 'coroutine' object does not support the asynchronous context manager protocol

Trying to make an invite manager I get: async with cursor.execute("SELECT id, uses FROM invites WHERE guild_id = ?", (member.guild.id,)) as cursor: RuntimeWarning: Enable tracemalloc to get the object allocation traceback Ignoring exception in on_member_join Traceback (most recent call last): File "C:\Users\Zacha\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 378, in _run_event await coro(*args, **kwargs) File "D:\Projects\SkriptsNet-Bot\modules\invites.py", line 48, in on_member_join async with cursor.execute("SELECT id, uses FROM invites WHERE guild_id = ?

Join the discussion →

SwiftUI Formatting TextField for credit card input "xxxx-xxxx-xxxx-xxxx"

I want to write a custom TextField on SwiftUI to have an input with credit card format like this "xxxx-xxxx-xxxx-xxxx", I was looking at this answers https://stackoverflow.com/a/48252437, but I'm struggling with UIViewRepresentable, when I want to past the numbers into the original text, it doesn't seems to update it with the format. The textField will show you 12345, but I need 1234 5 struct ContentView: View { @State var cardNumber: String = "12345" // <-- It won't be formatted until I type another one number var body: some View { VStack { CreditCardTextField(number: $cardNumber) .frame(heig

Join the discussion →

How to modify a regular expression to validate a text box with letters and numbers only, excluding certain characters like !@#$%^&*+=

Regular Expression for text box validation. I need to validate textbox. conditions like below can enter numbers and letters. need to avoid these characters !@#$%^&*+= Currently i am using below regular expression. but it is not working. <input type="text" pattern="^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$" /> can u help me to find correct regular expression

Join the discussion →

How to Draw most simple 3D objects in .Net Maui

I want to port an old app to run on .net maui to be cross-plattform. In the UI, I need also an 3d View, where I draw some lines and surfaces in 3d space. Only User interaction here is rotate and translate view as well as zoom. The data itself is result of simulation, no imported 3d moddel. Model is updated with very low update rate (30s). I didn't find such features in .net maui: are there cross plattform packages for that? If Not, is there another cross plattform ui approach other than maui for this scope? Backend will be C#

Join the discussion →

How can i fix white-space between picture and progress bard on large screens using Bootstrap Grid systen?

let first show you the idea in this picture: Picture (1) in this picture we see that the progress bars are under the picture in md/lg screens, and the text is on its right. and in picture(2) the text gose second and the progress bars gose last in small screen size: what i tried to do is this code: <!DOCTYPE html> <html lang="fr"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Mon cv - </title> <link rel="stylesheet" href="style.css"> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="styl

Join the discussion →

Getting [Errno 1] Operation is not permitted error when trying to write to /storage/emulated/0 with Kivy and Python on Android

I have been around the mulberry bush for a few weeks now trying to implement the writing of a file on an android phone. My development setup is on a Windows PC with Anaconda and Pycharm. I am using kivy and buildozer to create the android app. My test app is simply trying to write a file (test.txt) to the root directory of the SD card on the phone. The directory is: /storage/emulated/0 The error I am getting is: [Errno 1] Operation is not permitted: '/storage/emulated/0/test.txt' I ask for permissions in the code, but the permissions are not prompted at application startup or installation. Her

Join the discussion →

Database Returns Instead of Data

Whenever I collect data from my database, it is stored as <sqlite3.Row object at 0x0000019494A725F0> instead of being the actual data within the database. I've tried multiple methods that worked for other people but doesn't for me(such as .fetchall()). I'm currently using Flask and I think that might have something to do with the error. This is my current python code: @app.route('/signup', methods=["GET", "POST"]) def add_data(): p = request.form['password'] p2 = request.form['password_c'] if p == p2: db = get_db() e = request.form['email'] e2 = db.execute('SELECT Email FROM Users').fetchall()

Join the discussion →

DuckDuckGo search error when using FastAPI's pip version

I've been trying to get images from duckduckgo using: from duckduckgo_search import DDGS from fastcore.all import * ddgs = DDGS() def search_images(term, max_images=30): print(f"Searching for '{term}'") keywords = 'stop sign' return L(ddgs.images((keywords, term, max_results=max_images)).itemgot('image')) but it gives an error: Cell In[30], line 8 return L(ddgs.images((keywords, term, max_results=max_images)).itemgot('image')) ^ SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='? Did some looking up and seems there's some issue with the pip version of fastbook-0.0.16.tar.

Join the discussion →

fast check if the difference between two int32_t is 1 or 0

A straight forward way would be uint32_t diff = abs(num1 - num2); bool isZeroOrOne = (diff == 0 || diff == 1); or to simply check for all possible cases: int32_t diff = num1 - num2; bool isZeroOrOne = (diff == 0 || diff == 1 || diff == -1); Is there a more optimized way?

Join the discussion →

Is it possible to modify Valgrind to detect uninitialized value errors during ALU operations?

Currently, Valgrind only uses uninitialized variables error when a conditional jump or move, use of an uninitialized pointer, etc., is done. I want to detect the use of uninitialized value error also when some ALU operation is performed over that value. int add(int a, int b){ return a+b; } int main(){ int a = 10; int b ; int t = add(a,b); return 0; } I am trying to figure out where to change the Valgrind source code. I am looking in mc_translate.c but cannot find the exact change. What and where should I change?

Join the discussion →

Impeller Rendering Engine Causing Massive Latency and Memory Consumption

I'm working on a Flutter project (sdk: '>=3.0.1 <4.0.0') for iOS (platform :ios, '13.0') and right after upgrading Flutter this morning I noticed that the iPhone simulator (Xcode 14.3) was using between 3-5gb of memory and my entire system was unusable as long as the simulator was running. I have a 32GB Mac and when the simulator was onscreen (when minimized the system was performant and seemed fine) and running, my entire system was experiencing massive latency, lags, and performance issues. Scrolling through source, doing any kind of debugging, or really anything at all was extremely difficu

Join the discussion →

Difficulty in trying to implement a type-safe `at` for length-indexed vectors

I have just learnt about the DataKinds extension, type-level literals, and found out that type-levels natural numbers can be compared using constraints provided in the Data.Type.Ord such as (>), and manipulated using type-level operations provided in GHC.TypeNats such as (+). With these in mind, I came across the idea of implementing a safe version of !! for length-indexed vectors. The idea is simple: you pass in an ix :: Natural as the index, and a vec :: Vec len a with length len and type a, and you get the element at index ix. The compiler should detect and shout at you for any illegal ix (

Join the discussion →

Can't install onnxruntime

I want to install the onnxruntime pip library but i have this output: pip install onnxruntime ERROR: Could not find a version that satisfies the requirement onnxruntime (from versions: none) ERROR: No matching distribution found for onnxruntime Also: pip install onnxruntime-gpu ERROR: Could not find a version that satisfies the requirement onnxruntime-gpu (from versions: none) ERROR: No matching distribution found for onnxruntime-gpu links: onnxruntime-gpu at PyPI onnxruntime at PyPI onnxruntime at Github My python version is 3.9 My OS is Windows 11 (I already have the VSC Built Tools) My pip

Join the discussion →

Impulse response function (IRF) for VECM

I need help with irf plots. I am working with R and hope You can help me here. My VECM model consist of three endogenous variables and two exogenous variables. When I transform VECM to VAR using vec2var function and try to plot impulse response functions it shows only endogenous variables, because vec2var takes cointegration test results and cointegration was tested between three I(1) variables. So is it possible to plot IRF with those exogenous variables or not really? I tried to use VARXirf, but it doesn't work for me. My data: structure(list(date = structure(c(1546214400, 1548892800, 155131

Join the discussion →

Showing Memory utilization in Grafana dashboard

I have configured node exporter, grafana and prometheus through docker compose. I want to show Memory usage in the dashboard. I want to match the value shown with what is shown in the Ubuntu System monitor. Below are my queries: This is the transform: If I turn of the transform by clicking button, panel gets rendered like this: The value of 8.4 GB is correct one as my Ubuntu System Monitor shows the same. My concern is why it is not showing any gauge representing 8.4 GiB of memory is used (the same way it shows thick red gauge for Total Memory when I click that button). Update It started showi

Join the discussion →

OpenSSL Wrong version number on Ubuntu nginx

I'm setting my nginx to listen to port 8080 here's my config file and it works on when I'm accessing with http e.g http://myweb.com:8080/api/. server { listen 8080; location / { proxy_pass http://localhost:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_ssl_server_name on; } } However when I try to access it with https on Insomnia it returns SSL connect error. When I try curl https://myweb.com:8080 --verbose It returns something like this: * Trying {myipadress}:8080... * Connected to myweb.com (ipaddress) port 8080 (#0) * ALPN: offers h2,http/1.1 * TLSv1.3 (OU

Join the discussion →

How did it get converted into 1 line of code from 3 lines? Remapping uv and fixing aspect ratio in shaders

How would you get from this vec2 uv = fragCoord/iResolution.xy; // <0, 1> uv -= 0.5; // <-0.5,0.5> uv.x *= iResolution.x/iResolution.y; // fix aspect ratio to this? vec2 uv = (fragCoord - .5 * iResolution.xy) / iResolution.y; // Condense 3 lines down to a single line! Well, I tried breaking it down into components ((fragCoord.x-0.5) / iResolution.x) * (iResolution.x / iResolution.y) ((fragCoord.y-0.5) / iResolution.y)

Join the discussion →

REST API did not process the context query parameter correctly- Wordpress

While working on my wordpress theme, inside my Site Health Status I am facing an error of The REST API is one way that WordPress and other applications communicate with the server. For example, the block editor screen relies on the REST API to display and save your posts and pages. The REST API did not process the context query parameter correctly. Currently I am using Wp- version 6.2. I have tried all possible methods to the best of my knowledge. I am not able to understand what it is going wrong. Any help would be appreciated.

Join the discussion →

Is there a way to open ssh terminal when we are inside Devcontainer in vscode?

I am connecting to ssh machine in which I have installed Docker. From the ssh machine I will use Devcontainer. I am using Devcontainer most of the time. Some time I need to run commands from terminal in ssh. During that time i am doing 'Reopen folder in ssh' and run commands in terminal. Is there a way that I can open one terminal in SSH and one in Devcontainer at the same time?

Join the discussion →

.Renviron in project folder

If I put the .Renviron file into my project folder, does that get read and override an .Renviron file (and any environment variables)? Or do I need to put the .Renviron file into the home folder? I looked and didn't see this asked anywhere else. Sorry if this is a dupe. thanks.

Join the discussion →
Older stories