on-internet

Compare lists in one column to the first n elements of another column in Python Polars lazyframes, where n is dynamically determined from index

I'm trying to compare words present within sentences in one column, to the first n words in a wordlist (in another column), and return the words in the sentences that don't exist in that subset of the wordlist (to a new column). The "n" amount should be dynamically determined by the index of the sentence being currently compared. More specifically, n should be determined by the index position of the sentence divided by some scaling factor as follows: n = index/scaling_factor Rounded down to the nearest integer, so that it is a valid index position: n = math.floor(index/scaling_factor) In the e

Join the discussion →

Moving from legacy docker / uWSGI / Flask to new best practice

Years ago (2015-2020) I created a few hobby projects. The setup was extremely simple via: tiangolo/uwsgi-nginx-flask:latest docker image, a slim docker image with a production ready webserver simple requirements from /app/requirements.txt which were installed via pip in the Docker file a prestart.sh which did some flask database migrations if necessary It was of good performance due to having nginx. I had an ansible script which build the docker image, made a local tarbar with docke save, send it over to my VPS and ran the image at specified domain. With Traefik, I could ran dozens of projects

Join the discussion →

Why can a parameterized class be instantiated?

I have this generic class: class Box[T]: def __init__(self, val: T): self.val = val In Python < 3.12, that would be written: from typing import TypeVar, Generic T = TypeVar('T') class Box(Generic[T]): def __init__(self, val: T): self.val = val According to the docs, I can instantiate it like this: box = Box[int](42) However, I don't understand why this even works. If I print the type of Box[int]: klass = Box[int] print(type(klass)) # <class 'typing._GenericAlias'> According to the docs and this Q&A, a generic alias is supposed to represent a type annotation by storing the original type and typ

Join the discussion →

Difference between three forms of instantiating a generic class in Python

I have this generic class in Python 3.12: class Box[T]: def __init__(self, val: T): self.val = val I can instantiate it in 3 ways: box: Box[int] = Box(42) box = Box[int](42) box = Box(42) What's the difference? Do different type checkers (pyright, pyrefly, etc) interpret them differently? How about in legacy Python (<3.12), where the example would be: from typing import TypeVar, Generic T = TypeVar('T') class Box(Generic[T]): def __init__(self, val: T): self.val = val

Join the discussion →

iPhone Duo, Device Hub: how to test when set in tent mode? [closed]

Device Hub for Xcode 27.2 includes simulator for iPhone Duo running iOS 27.2. The controls for the simulator have obvious settings to open the display showing the inner screen, or closing the display to show the outer screen. It also includes controls for rotating the device. When open and showing the inner screen a rotation will change the orientation between portrait, landscape, etc. These various combinations are known as poses. However there is an additional pose Apple tells us about called Tent mode or Stand by mode (the second of the above images). In this case the phone is half opened a

Join the discussion →

iPhone Duo, Device Hub, tent mode [closed]

Device Hub for Xcode 27.2 includes simulator for iPhone Duo running iOS 27.2. The controls for the simulator have obvious settings to open the display showing the inner screen, or closing the display to show the outer screen. It also includes controls for rotating the device. When open and showing the inner screen a rotation will change the orientation between portrait, landscape, etc. These various combinations are known as poses. However there is an additional pose Apple tells us about called "Tent mode" or "Stand by mode" (the second of the above images). In this case the phone is half open

Join the discussion →

Is there a way to use lazy imports in backwards-compatible code?

I'm writing some code that I want to make use of lazy imports, which were introduced in Python 3.15. However, I want the code to run fine on Python < 3.15 too, albeit without lazy imports. Just running the following code would raise a SyntaxError on previous Python versions: lazy import numpy as np I tried using a conditional: import sys if sys.version_info >= (3, 15): lazy import numpy as np else: import numpy as np But it still raises a syntax error on Python 3.10. And it would be cumbersome anyway to have to write that in every file.

Join the discussion →

MAUI FilePicker.PickMultipleAsync() taking 30 seconds just to open the dialog

I have a MAUI app running on .NET 8. The app is a Windows-only app. I have Microsoft.Maui.Essentials version 8.0.100, and it appears to be the latest version for .NET 8 at the moment. It has a button for uploading files: <ImageButton Command="{Binding GetFilesCommand}" HeightRequest="90" HorizontalOptions="Start" Source="Assets/icon-add-pink.png" /> In the ViewModel, I have this line in the constructor: GetFilesCommand = new Command(async () => await GetFilesCommandAsync()); This is the command method: private async Task GetFilesCommandAsync() { try { IEnumerable<FileResult> file = await FileP

Join the discussion →

Populate columns based on letters in each position of a string in another column

I have individuals (birds) who are identified via a 3-letter system, e.g. BBO, BOB, PPG, PGP, etc. The order in the code corresponds to the position on the individual, e.g. BOB has Blue on its head, Orange on its cheek, and Blue on its neck. I want to create a data frame that takes the individual ID code and populates "head", "cheek", and "neck" columns with the colors like below: bird <- c("BOB", "OOP", "GBG") head <- c("blue", "orange", "green") cheek <- c("orange", "orange", "blue") neck <- c("blue", "purple", "green") power <- c(1, 2, 3) data <- data.frame(ID = bird, Head = head, Cheek = c

Join the discussion →

Schengen visa entry not to issuing country

My visa was approved from Sweden embassy in India. I will enter Sweden via connecting flight from Zurich. So I will have visa control or border control check at Zurich correct? 2nd Question - Since Zurich will be transit only, main entry will be in Sweden, so I hope that fulfills entry criteria for visa issuing country. 3rd Question- In original itinerary submitted for visa , we had 8 nights in Sweden and 6 nights in Finland. Now itinerary is being changed so it would be 6 nights in Sweden and 6 nights in Finland while arrival and departure will happen from Sweden. So wanted to check if it wil

Join the discussion →

Heel Nederland Leest Het Diner van Herman Koch | Campaign to promote reading in the Netherlands starts today

submitted by thymos to books 14 points | 0 comments https://www.hebban.nl/heelnederlandleest Vanaf vandaag is het boek Het diner van Herman Koch gratis verkrijgbaar in alle openbare bibliotheken in Nederland als onderdeel van de campagne Heel Nederland Leest. Today, the CPNB (Collective Promotion for the Dutch Book) has started their annual campaign to promote reading called Heel Nederland Leest, or One Book, One Country. Every year they publish one book that they distribute freely in public libraries, and this year it’s The Dinner by Herman Koch.

Join the discussion →

Python 2 vs. Python 3: what does "not backward compatible" mean exactly?

According to Wikipedia: Python 3.0 was released on 3 December 2008, and was a major revision and not completely backward-compatible with earlier versions, with some new semantics and changed syntax. What does that actually mean? Was it just the syntax which has changed, for example: print vs. print(), so that you can get an old Python 2 script running with some modifications? Or was there something deeper? Because of the usage of Unicode, etc.

Join the discussion →

How to stop a bacteriophage naturally evolving

Within my setting (suppose near-ish future), antibiotic resistant bacteria have become the new norm, with almost all currently available antibiotics being ineffective at dispatching infections. Due to this, bacteriophages are used to treat bacterial infections instead. I am curious if there is any way to prevent the bacteriophages from undergoing natural selection, or just naturally occurring mutations in general as to avoid them perhaps beginning to hunt the bacterial strains humans need to live. How could this be achieved, disregarding any technological constraints?

Join the discussion →

2026 Book Bingo midpoint!

submitted by misericordiae to books 35 points | 20 comments Hey everyone, we’re now halfway through our third annual community book bingo challenge! What is book bingo, you ask? Basically, read something for each of five squares in a line on this year’s card, and you’re done! (That’s five works total, or more if you want to.) You don’t even have read books: any type or length of literary work, including comics, audiobooks, poems, short-form nonfiction, etc., will do. There’s still plenty of time (six whole months, in fact). Plus, anything you’ve read since May is eligible, so if you haven’t jo

Join the discussion →

How to cache neighbouring variables in a 2D array?

I'm making a grid based game in c++ with SDL3. My rooms are a 2D array of Tile objects stored in an array in DungeonCrawler (think of dungeoncrawler as my game settings .cpp and .h). I have a GetNeighbour() function that returns a pointer to a tile's neigbour depending on its direction (an enum of north, south, east and west, or null if it's at the edge of the room). Instead of calling GetNeighbour() every time I need a tile to know its neighbour, I want to loop over all the tiles once and cache their neighbours so an individual tile can later easily access its neighbour. I've started the cach

Join the discussion →

Adding a Private property to CanvasRenderingContext2D

I am trying to extend CanvasRenderingContext2D to add a few more methods. I know that it’s not a simple matter of using extends because, apparently CanvasRenderingContext2D doesn’t permit normal construction. I found the technique at How to extend CanvasRenderingContext2D (in ES6-style scripts, if possible) . I have that working well enough, but I now want to add a private method. I can’t get that working at all using the normal technique. Here is an unsuccessful test script: class Context2D extends CanvasRenderingContext2D { constructor(context) { Object.setPrototypeOf(context, new.target.pro

Join the discussion →

Why does clicking the icon inside a dynamically added button not trigger my delegated click handler, while clicking the button text does?

I am building a small task list where items are added with JavaScript. Instead of adding a click listener to every button, I added one listener to the list itself. Each item has a delete button with a small icon inside it. When I click the text part of the delete button, the item is removed as expected. When I click directly on the icon inside the same button, nothing happens. There is no error in the console, and the item stays on the page. Here is a simplified version of what I have: <ul id="taskList"> <li>Buy milk <button data-action="delete">Delete <svg viewBox="0 0 10 10"><path d="M1 1 L9

Join the discussion →

How does water temperature vary with depth on a water world?

In my current project, one of the planets is a water world. I was wondering how water temperature would vary with depth. I know that, on Earth, water temperature decreases with increasing depth at a pretty constant rate (except for the surface, where local climate and water currents apply, but I'm ignoring that). On water worlds, though, I feel that water temperature would increase with depth, as all of the planet's internal heat must go through the oceans instead of having land available to conduct through. I'm not sure how quickly it would heat, though, or if my hypothesis is even correct.

Join the discussion →

Python 3.14: NameError for a self-referencing annotation, but only when it’s read in __init_subclass__

The Python 3.14 docs say annotations are now evaluated lazily, so forward references work without from __future__ import annotations. I removed that import from my mini ORM. Now defining any model that refers to itself crashes. Reading Category.__annotations__ after the class is defined works fine. class Model: registry = {} def __init_subclass__(cls, **kwargs): super().__init_subclass__(**kwargs) cls.fields = dict(cls.__annotations__) Model.registry[cls.__name__] = cls class Category(Model): name: str parent: Category | None print(Category.fields) What I expected (Python 3.14.6): {'name': <cl

Join the discussion →

Qt scale visible content globally in main()

Is there a chance to simply scale the visible content of main() globally, making it bigger? There will be ways to implement it in the DragWidget class, I assume, but is a broader question, of course... #include <QApplication> #include "dragwidget.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); DragWidget window; window.setStyleSheet("background-color:lightyellow;"); //scale content of window here ?? window.show(); return app.exec(); }

Join the discussion →

converting to php 8.5.12 on windows using firebird 2.5 but unable to load pdo_firebird

I'm trying to install a legacy system which used php 5.4 to a windows 11 64 bit environment using php 8.5.12. The system uses Apache 2.4 (32 bit) and Firebird 2.5 (which has been installed and working for about 4yrs) and have installed php 8.5.12. The fundamental system works OK showing static pages, but on starting Apache the following error is given. Unable to load dynamic library 'pdo_firebird' (tried: ext\pdo_firebird (The specified module could not be found), ext\php_pdo_firebird.dll (The specified module could not be found)) in Unknown on line 0 I have enabled extension=pdo_firebird in p

Join the discussion →

How can I prevent LaunchedEffect from cancelling an ongoing animation when StateFlow updates rapidly?

I am developing an educational Android application using Kotlin and Jetpack Compose. My application displays mathematical solutions step by step using animations. When a user taps the Next Step button multiple times quickly, the currently running animation gets cancelled, and some intermediate steps are skipped. I want every button press to be processed sequentially, regardless of how quickly the user taps. class StepViewModel : ViewModel() { private val _currentStep = MutableStateFlow(0) val currentStep = _currentStep.asStateFlow() fun nextStep() { _currentStep.value++ } } @Composable fun Ste

Join the discussion →

sphinx.ext.apidoc vs. sphinx-apidoc with custom templates

I'd like to customize the generated .rst files with sphinx.ext.apidoc. As a test, I edited the installed package files at site-packages/sphinx/templates/apidoc/*.rst.jinja, and that worked, but of course that's not the correct way to do this. I tried copying those files into my configured _templates directory, renaming the file to *_t, without success. I know I can do this with sphinx-apidoc --templatedir _templates, but that's outside the sphinx-build process per https://stackoverflow.com/a/57520238/2214933. I also know I could also create a script or add a Make target that runs sphinx-apidoc

Join the discussion →

Why does Python return True when comparing two datetime objects with different UTC timestamps?

I'm developing a Python application that stores scheduled events using timezone-aware datetime objects. I encountered an unexpected behaviour when handling Daylight Saving Time (DST). from datetime import datetime from zoneinfo import ZoneInfo tz = ZoneInfo("America/New_York") first = datetime(2024, 11, 3, 1, 30, tzinfo=tz, fold=0) second = datetime(2024, 11, 3, 1, 30, tzinfo=tz, fold=1) print("First timestamp:", first.timestamp()) print("Second timestamp:", second.timestamp()) print("Are they equal?", first == second) events = { first: "First event", second: "Second event" } print("Dictionary

Join the discussion →

Dealing with unsupported media type in HTML5 audio element?

I running into an issue whereby the audio player, is not creating an error event for media types it doesn't support. My test is providing an MP4 file containing an Apple Lossless Audio (ALE) payload as an audio source. Behaviour: Safari: Nothing logged in the console; no 'error' event or on play() promise Chrome: Nothing logged in the console; no 'error' event or on play() promise Firefox: Warnings displayed in the console; no 'error' event or on play() promise The HTML: <audio controls="" class="main-audio"> <source src="/music/myaudiofile.mp4" type="audio/x-flac"> </audio> The JS for initiat

Join the discussion →

How to distinguish Npgsql connection pool wait time from EF Core BeginTransactionAsync latency?

We are investigating high database latency in a multi-tenant application using .NET 10, Entity Framework Core, Npgsql and PostgreSQL 18. Configuration We register a singleton NpgsqlDataSource and use scoped EF Core DbContext instances. Our maximum Npgsql connection pool size is 30. builder.Services.AddSingleton<NpgsqlDataSource>( _ => new NpgsqlDataSourceBuilder(connectionString).Build()); builder.Services.AddDbContext<FacturacionDbContext>( (services, options) => options.UseNpgsql( services.GetRequiredService<NpgsqlDataSource>())); Observed behavior When running a benchmark with 250 virtual u

Join the discussion →

"We Always Leave Things Unfinished"

submitted by billionsandbillions to books 14 points | 1 comments https://bigreaderbadgrades.substack.com/p/we-always-leave-things-unfinished “William T. Vollmann is dying. In his Sacramento studio, he talks America, unfinished work, and the 3,096-page opus he finished just in time.”

Join the discussion →
Older stories