on-internet

How do I document a type alias defined using `type` in Python?

Python 3.12 has the type statement. How do I document the type alias properly? I tried: type Number = int | float """Represents a scalar number that is either an integer or float""" But this doesn't seem to associate the docstring with the alias. I tried putting the docstring after the = and before the alias definition, but that generated an error.

Join the discussion →

Blank html page rendering instead of React website render

i am unable to render my React website after deploying and publishing code via github and/or netlify. It gives me a blank page instead of rendering my website. I have referred to existing answers and tried many possible solutions but it still doesn't work any help will be highly appreciated. I am trying to access my website via index.html in root folder, however, instead of url accessing my main.jsx through index.html, it is simply rendering my index.html in root. The website is published here: https://mustafafarooqusman.github.io/Murtazaportfolio-main/ (showing a blank page) My repository is

Join the discussion →

Using DRF and django-tenants together in the same project

I'm building a multi tenancy app with django-tenants and want to run my REST API in the same project as django-tenants. But if I make my API a shared tenants app, every tenant subdomain ends up having their own API. For example, all registered tenants adopt the API routes as part of their subdomain (tenant1.example.com/api, tenant2.example.com/api, etc.). I don't want my API to be underneath each tenant, I want to run it on one domain, preferably api.example.com. How do I set this up?

Join the discussion →

Fill null values with linear interpolation using DuckDB

I am trying to fill null values in a numeric table using duckdb. Let's consider the simple table df: x y 0 2.0 1 NULL 3 NULL 5 7.0 6 4.0 8 5.0 9 NULL that you can create with CREATE TABLE df (x NUMERIC, y NUMERIC) INSERT INTO df VALUES (0, 2), (1, NULL), (3, NULL), (5, 7), (6, 4), (8, 5), (9, NULL) then i would like to create a SELECT statement to retrieve: x y 0 2.0 1 3.0 3 5.0 5 7.0 6 4.0 8 5.0 9 NULL I think that a correlated subquery which finds the following and previous non-null values and then computes the interpolation should work: SELECT x, COALESCE( y, ( SELECT prev.y + ( (next.y - p

Join the discussion →

UAE tourism visa photos mixed up

My sister and I applied for a 30-day tourism visa for UAE. When we finally got the visas, our photos were mixed up (my photo is on my sister's visa and my sister's photo is on mine). All other information is correct and the passport numbers are correct. Will there be any issue? We will be leaving together at the same time.

Join the discussion →

operational error when testing my CLI app with a SQLite DB

So I wanted to add tests to my CLI app, but I am struggling to replace my db with a temporary one. So far I have used SQLModel for database access, but for the app testing I want to assert the db values using raw SQL statements. However, I get a connection error when trying to access my temporary DB. sqlite3.OperationalError: unable to open database file My plan so far is the following: In my test file I replace the sqlite uri with one directing it to a sqlite db in a temporary dictionary (using pytest tmp_path). My assumption was, that if I create that DB with SQLModel, I'd be able to access

Join the discussion →

Missing required error components, refreshing

Every time, after a pull, I run. git init git pull npm i or npm install In the first time all pages working as I wish. But when changing from one page to another in localhost - I get this error: missing required error components, refreshing... In my console, I have something like that: ⨯ Error: ENOENT: no such file or directory, open '/Users/jonasoliveira/Documents/Documentos - MacBook Pro de Jonas/next/sala-two/.next/server/pages/api/external/news-api.js' at Object.readFileUtf8 (/Users/jonasoliveira/.vscode/extensions/wallabyjs.console-ninja-1.0.266/out/buildHook/index.js:1144:66509) at Objec

Join the discussion →

How to perform read queries on read replica in postgres?

I deployed a PostgreSQL instance in k8s with a master pod and a single replica pod. I want to know how can I perform read queries on the read replica and write queries on the master? Currently, all the requests I send to the DB are served by the master (after connecting to the master). Do I need to explicitly connect to the read replica for queries to go there or is there some mechanism in Postgres which can route traffic to the read replica?

Join the discussion →

MultipartRequest with swagger_dart_code_generator

I am using swagger_dart_code_generator for my Flutter app to generate code based on an openapi.json. It does its job for application/json requests, however it does not work with multipart/form-data. I am sure that the api works, I tried it from the swagger web ui. In case it helps, here are the relevant parts of the openapi.json: "post": { "operationId": "ImageListApiView_post_images_post", "requestBody": { "content": { "multipart/form-data": { "schema": { "$ref": "#/components/schemas/ImageMetaForm" } } }, "required": true }, /* ... */ }, "ImageMetaForm": { "properties": { "file": { "descript

Join the discussion →

Computer Virus Spread Simulation - How to make each trial have random outputs?

This code is used to simulate the virus spread in the network of 20 computers with the probability of 0.1 ~ 10%. It initially starts with only 1 computer being infected and each day has a chance that it spreads to other computers in the network. The output for each trial should be: time to remove the virus from the network, probability that each computer gets infected at least once, and the expected number of computers that get infected each trial. Logically each trial should have a random for each of the outputs listed. My problem is that each trial produces the same output, and I don't under

Join the discussion →

Error when running OTEL collector with Jaeger in Docker containers

I'm trying to run jaeger and an OTEL collector as docker containers. Unfortunately I run into the following error message: otel-collector | Error: failed to get config: cannot unmarshal the configuration: 1 error(s) decoding: error decoding 'exporters': unknown type: "jaeger" for id: "jaeger" (valid values: [logging otlp otlphttp file kafka prometheus debug opencensus prometheusremotewrite zipkin]) My docker compose file looks as follows: version: '3' services: otel-collector: container_name: otel-collector image: otel/opentelemetry-collector command: ["--config=/etc/otel-collector-config.yaml

Join the discussion →

How to improve form provider performance in React Hook Form

Since the react hook form provider is based on context Api, for large nested forms it can cause performance issues due to multiple re-renders during state updates. I came across this section in the documentation: https://react-hook-form.com/advanced-usage#FormProviderPerformance, which basically uses react memo to stop additional re-renders unless the property isDirty changes. I added the above implementation to my code and it has helped speed up the form performance a little but I now realize that my validations are not working since my memo does not check for updates to the formState. https:

Join the discussion →

Add numpy random values to a Polars dataframe using a column as input to numpy.random?

Let's say I have a dataframe that has a column named mean that I want to use as an input to a random number generator. Coming from R, this is relatively easy to do in a pipeline: library(dplyr) tibble(alpha = rnorm(1000), beta = rnorm(1000)) %>% mutate(mean = alpha + beta) %>% bind_cols(random_output = rnorm(n = nrow(.), mean = .$mean, sd = 1)) #> # A tibble: 1,000 × 4 #> alpha beta mean random_output #> <dbl> <dbl> <dbl> <dbl> #> 1 0.231 -0.243 -0.0125 0.551 #> 2 0.213 0.647 0.861 0.668 #> 3 0.824 -0.353 0.471 0.852 #> 4 0.665 -0.916 -0.252 -1.81 #> 5 -0.850 0.384 -0.465 -3.90 #> 6 0.721 0.67

Join the discussion →

How do I fix this foreach loop variable syntax error?

I am trying to use foreach in SystemVerilog. What I am doing wrong here? `define size 3:0 //variable module tb; reg [7:0] temp; initial begin temp = 8'd25; $display("%d", temp[`size]); foreach ((temp[`size])[i]) $display("%d", temp[i]); (temp[`size])[i] = 1'b0; end endmodule

Join the discussion →

Zero-copy reference a slice of bytes by a step

I have a large Vec<u8> representing the raw pixel values of a gray image. Since the pixel format is actually 16-bit width, two u8 makes one pixel. Now I'd like to use the image as if it was 8-bit width, so I only take the higher 8-bit part of a pixel. As an instance, given a raw vec v = vec![0,1,2,3,4,5], how can I view it by a step 2 to a reference view : &[u8] (without the need to copy them into a new Vec, for performance), such that view can be used equivalent to &[0,2,4]. Thanks very much.

Join the discussion →

How to use * wildcard character in robots.txt files?

My website is crawled high frequently. I have robots.txt is below: User-agent: * Allow: .htm$ Disallow: /*?* Disallow: /mls.php?* but 'Googlebot 2' doesn't obey the robots rules. The following is a log snappet: 2023-11-03 06:46:47.856 PDT GET 200 6.62KB 433 ms Googlebot 2 https://vanfangchan.com/mls.php?mls=1355081&lang=zh_s Does my robots.txt is right, and anyone know that 'Googlebot 2' is owned by Google?

Join the discussion →

Extracting lots of data from SQL Server into parquet file efficiently?

I have data in SQL Server and I need to save it in parquet format. Right now I'm using pyodbc and pyarrow libraries for this. As there are serveral million rows, I'm doing it by using queries within a for loop that retrieves chunks of data using a where clause on the SQL server that search for periods in YYYYMM format like 201501, 201502, ..., 202310 and then grouping them together by year and saving it as parquet like example_2023.parquet. The code is: conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};' 'SERVER=SERVER;' 'DATABASE=DATABASE;' 'UID=USER;' 'PWD=PASS') cursor = conn.cu

Join the discussion →

fatal: unable to access OpenSSL/3.1.2: error:0A000152:SSL routines::unsafe legacy renegotiation disabled

I am trying to clone a repo from DevOps using Git Bash, with the git clone command I'm getting the error message: fatal: unable to access OpenSSL/3.1.2: error:0A000152:SSL routines::unsafe legacy renegotiation disabled I was trying to clone a DevOps Repo, I was expecting the repo to be cloned on to my local drive so I could make changes

Join the discussion →

How to resolve IMPORTRANGE access permission issue in Google Sheets

I am encountering an issue in Google Sheets while utilizing the IMPORTRANGE function across two sheets, both of which I am the owner of. Whenever I attempt to import data, I am greeted with the error message: "You don't have permissions to access that spreadsheet." Here's the formula I am using: =importrange("URL_of_the_sheet","A2:A980") I have verified that I am logged into the correct Google account, and have tried refreshing the browser and the sheets, re-adding the IMPORTRANGE formula, and even creating new sheets to test the function. Despite these efforts, the error persists. Is there a

Join the discussion →

How to handle values greater than 255 as returned by toupper() in recent macOS with UTF-8 locales

The problem, the code below is trying to address, is on how to effectively detect that an UTF-8 based locale might be in use so that all code points above 127 are not queried for ctype attributes, as we are dealing with plain (not wide) chars. At least in macOS 14, when using an UTF-8 based locale. the following program will show 2 problematic code points that eventhough are valid for an unsigned char, are getting as a response from toupper() values that are not able to fit on that type: #include <langinfo.h> #include <ctype.h> #include <locale.h> #include <stdlib.h> #include <string.h> #inclu

Join the discussion →

Why does [[no_unique_address]] interfere with base classes in MSVC?

The following program returns 1 on all compilers except MSVC, where it returns 2: struct E1 { }; struct E2 { }; struct #ifdef _MSC_VER __declspec(empty_bases) // This doesn't make any difference #endif S : E1 { char c; [[no_unique_address]] #ifdef _MSC_VER [[msvc::no_unique_address]] #endif E2 e; }; int main() { return sizeof(S); } Why is this? Shouldn't no_unique_address cause e and c to overlap?

Join the discussion →

I can't get an output with space characters

I have a cryptography project and want to decrypt sentences using python. I wrote this code but can't get an output, where the words have spaces between them. def vigenere_decrypt(key: str, text: str) -> str: decrypted_text = "" encrypted_text = text.replace(" ", "") key_length = len(key) for i, char in enumerate(encrypted_text): #ex. 0 y, 1 a... key_char = key[i % key_length] # ex. key = KEY, text = MESSAGE => KEYKEYK shifted_char = (ord(char) - (ord(key_char))) % 26 for c in text: if c in text == " ": decrypted_char = " " else: decrypted_char = chr((shifted_char) + ord('a')) decrypted_text +

Join the discussion →

How to establish a WebSocket connection with MT5 server for real-time symbol pricing?

I am exploring the potential of creating a real-time data streaming application that involves integration with the MT5 server. The application aims to fetch real-time symbol pricing and trade profit data. Currently, I have managed to connect to the MT5 server through a traditional Web API provided by MetaQuotes. However, this doesn't provide real-time data fetching capabilities that are critical to my project. I've also tried using some pre-existing codes (https://www.mql5.com/en/code/169) to establish connection for single instruments, but they lack the feature of real-time trade profit fetch

Join the discussion →

Convert to Vec to i32 [duplicate]

I was trying to create a function that trasform a Vec to i32 fn vec_to_int(digits: Vec<i32>) -> i32 { let n = &digits.iter().fold(0, |acc, digit| acc * 10 + digit); println!("Vec:{:?} to: {}",digits,n); *n } the results of this function was just as expected Vec:[3, 4, 2] to: 342 Vec:[4, 6, 5] to: 465 Vec:[9] to: 9 Vec:[9, 9, 9, 9, 9, 9, 9] to: 9999999 but when i try using the vec[9, 9, 9, 9, 9, 9, 9, 9, 9, 1] the result was Vec:[9, 9, 9, 9, 9, 9, 9, 9, 9, 1] to: 1410065399 why this happen and what i can do to improve the code? I know that i could just parse the Vec to a string than parse to a

Join the discussion →

How to get page title in Nuxt 3?

I am struggling to find a way to get page title in Nuxt 3 and reuse it in layout. I am pretty sure there is a way to do it through some meta object but I just can not find it. I tried to do it through route meta /layouts/default.vue <template> <h1> {{ route.meta.title }} </h1> </template> <script setup> const route = useRoute(); </script> But now when I have to set title I need to do it twice so this method works /pages/catalog.vue <script setup> definePageMeta({ title: 'Catalog Page', }); useHead({ title: 'Catalog Page', }); </script> Seems realy hacky so I open to ideas here

Join the discussion →

Toast notification disappears after few seconds, how to hold until taking any action on display?

I'm trying to make a small PowerShell program to display a toast notification after log on. I'd like the custom toast notification will stay there until user closes it. But but it disappears quickly. (about 5 seconds) How can I do that ? Script: Import-Module BurntToast $button = New-BTButton -Dismiss -Content "OK" New-BurntToastNotification -Text 'Yoooo, this is a toast notification... from PowerShell!' -Button $button

Join the discussion →

How to access form data in a post request when using React (TypeScript)?

I wanted to create a simple signup page using React in TypeScript. My goal was to create two input fields on a signup page asking for a first and last name, and once the form was submitted, it would redirect the user to a page called "complete" that would display their first and last name. I was able to do this using the get method, as I was able to use url parameters as displayed below. Signup page: import React, { useState, useRef } from 'react'; export default function SignUpPage() { return ( <> <form autoComplete="off" action="/complete" method="get"> <label htmlFor="firstNameInputField">F

Join the discussion →

CommunityToolkit.MVVM send message identified by token to specific view model

I need a help with CommunityToolkit.MVVM to utilize messenger for communication between view models. The issue I have is that that at the same time user can open the same view twice (because it's a desktop app) so simple implementation of messenger doesn't work for me - I need to register my view model with some token to so it only listens for specific view model (I have trouble finding any example in documentation). Thank you for any help in advance. I tried to simplify the code to include only needed parts of it. UserListView.xaml <UserControl x:Class="ProjectIdeas.Core.Users.View.UsersListV

Join the discussion →

Shuffle map stage failure with indeterminate output: eliminate the indeterminacy by checkpointing the RDD before repartition

I'm running into an issue with a Spark job that fails roughly every 2nd time with the following error message: org.apache.spark.SparkException: Job aborted due to stage failure: A shuffle map stage with indeterminate output was failed and retried. However, Spark cannot rollback the ResultStage XYZ to re-process the input data, and has to fail this job. Please eliminate the indeterminacy by checkpointing the RDD before repartition and try again. This happens on Databricks 13.3 LTS (based on Apache Spark 3.4.1). I started out by step-wise eliminating calls to repartition(...) until there was non

Join the discussion →

FastAPI TestClient overriding lifespan function

In a more complicated setup using the python dependency injector framework I use the lifespan function for the FastAPI app object to correctly wire everything. When testing I'd like to replace some of the objects with different versions (fakes), and the natural way to accomplish that seems to me like I should override or mock the lifespan function of the app object. However I can't seem to figure out if/how I can do that. MRE follows import pytest from contextlib import asynccontextmanager from fastapi.testclient import TestClient from fastapi import FastAPI, Response, status greeting = None @

Join the discussion →
Older stories