on-internet

Search highlights don't match the expected word. How can I fix the highlight accuracy?

I'm using PDF.js to render a PDF document from a URL in React. The PDF loads fine, but I'm facing an issue with search: When using the PDFFindController to highlight search terms, the highlights don't align correctly with the actual text—they're often offset or covering incorrect words. What I’ve tried: Adjusting currentScaleValue Tweaking textLayerMode (currently using scale) Confirmed the PDF itself is fine (rendered correctly elsewhere) useEffect(() => { const loadPDFViewer = async () => { try { const { PDFViewer, PDFLinkService, PDFFindController, EventBus } = await import('pdfjs-dist/web/

Join the discussion →

How does Python represent slices in various cases?

Consider l = [1, 2, 3, 4, 5] print(l is l[:]) t = (1, 2, 3, 4, 5) print(t is t[:]) print(t[1:] is t[1:]) print('aa'[1:] is 'aa'[1:]) print('aaa'[1:] is 'aaa'[1:]) The result is, somewhat surprisingly, False, True, False, True, False. Additionally, if I create objects of types list, tuple and str with large lengths and then create large numbers of slices [1:] of each, only with str is it efficient in terms of time and memory, even though tuples are also immutable and could, just like strings, be represented without copying the range specified by a slice, just by indexing into the contiguous mem

Join the discussion →

Exactly why does this work this way? (null coalescing operator precedence) [duplicate]

The null coalescence operator has a precedent that is different from most other comparators in PHP: Example 1: (Incorrect) $var['x'] = "5"; if ((int)$var['x']??0 < 1 ) { print "less than 1"; /* Outputs this */ } else { print "more than 1"; } This will result in "less" because the comparison seems to be between $var['x'] vs 0<1 but surely that would be $var['x']??(false) which still doesn't seem to me to warrant that if being true. Example 2: (Incorrect) $var['x'] = "5"; if ($var['x']??5 < 1 ) { print "less than 1"; /* Still outputs this */ } else { print "more than 1"; } I do understand the ex

Join the discussion →

¿Cuál es la forma correcta de manejar JSON-LD en React 19?

Estoy utilizando React 19 y necesito implementar fragmentos JSON-LD para mejorar el SEO de mi sitio web. He visto que React 19 introduce soporte para etiquetas de metadatos directamente en las Routes, lo cual parece adecuado para casos simples. Sin embargo, para JSON-LD, que requiere scripts <script type="application/ld+json">, necesito una solución más robusta. Anteriormente, react-helmet-async era la librería recomendada, pero entiendo que no es compatible con React 19. Esto me deja con react-helmet, que es una versión más antigua y me preocupa su mantenimiento a largo plazo. ¿Cuál es la mej

Join the discussion →

Audio delay after resuming screen recording with FFmpeg on Windows

In my screen recording software for Windows using Python I use FFmpeg for recording and psutil to pause and resume the process: import psutil import subprocess process = subprocess.Popen([ 'ffmpeg', '-y', '-rtbufsize', '100M', '-f', 'gdigrab', '-thread_queue_size', '1024', '-probesize', '50M', '-r', '24', '-draw_mouse', '1', '-video_size', '1920x1080', '-i', 'desktop', '-f', 'dshow', '-channel_layout', 'stereo', '-thread_queue_size', '1024', '-i', 'audio=Microphone (2- High Definition Audio Device)', # my audio device '-c:v', 'h264_nvenc', # encoding via Nvidia '-r', '24', '-preset', 'p1', '-p

Join the discussion →

Audio delay after resuming FFmpeg on Windows

I'm building a screen recording software for Windows using Python. I use FFmpeg for recording and psutil to pause and resume the process. Here is a sample of my code: import psutil import subprocess process = subprocess.Popen([ 'ffmpeg', '-y', '-rtbufsize', '100M', '-f', 'gdigrab', '-thread_queue_size', '1024', '-probesize', '50M', '-r', '24', '-draw_mouse', '1', '-video_size', '1920x1080', '-i', 'desktop', '-f', 'dshow', '-channel_layout', 'stereo', '-thread_queue_size', '1024', '-i', 'audio=Microphone (2- High Definition Audio Device)', # my audio device '-c:v', 'h264_nvenc', # encoding via

Join the discussion →

How to set a seed for gen_random_uuid()?

For testing purposes on a table like this: CREATE TABLE my_table ( id UUID DEFAULT gen_random_uuid() PRIMARY KEY, . . ...I would like to get the same id's on each test run to better compare test logs / test results. Do there exist a function that works for gen_random_uuid() the same way setseed(x) works for random() ? gen_random_uuid() returns version 4 UUIDs that does not include timestamps so I can't see why this shouldn't be possible. I guess I could always write my own my_gen_random_uuid() based on random() with some hex string trickery, but that would be much slower. Example - the dice co

Join the discussion →

Is there a way to enforce explicit returns in Rubocop?

I'm looking for a way to make Rubocop linter for Ruby enforce explicit returns from function calls. This is a house rule I want to implement since it is easier for people coming from other languages. I saw that someone had the same question earlier on the Rubocop GitHub but there was no solution provided https://github.com/rubocop/rubocop/issues/4149 Examples: # good def cond_explicit(cond) if cond return 'yes' else return 'no' end end # bad def cond_implicit(cond) if cond 'yes' else 'no' end end # good def str_explicit return 'str' end # bad def str_implicit 'str' end

Join the discussion →

¿Este diagrama de clases esta correcto?

El siguiente diagrama de clases es para un programa en C++ donde se lee una pareja de datos (x,y) en un archivo de texto donde el primer renglon en xk un numero real mayor o igual a cero, en base a esto se desea calcular lo siguiente: La cantidad de parejas de datos leídas (N) Los coeficientes de correlación rx,y y r2 Los parámetros de regresión lineal β0 y β1 Una predicción mejorada yk, donde yk = β0 + β1 xk El problema que tengo es que estoy inseguro en si las relaciones estan bien y en que si se estan llamando correctamente las clases entre si. Tambien estoy batallando en diferenciar cuando

Join the discussion →

Google が実践する最先端の SRE

はじめに こんにちは。Datadog Japan で Sales Engineer をしている 木村健人(AoTo)です。Google Cloud の公式ユーザーグループである Jagu’e’r(Japan Google Cloud Usergroup for Enterprise) では、オブザーバビリティ分科会を立ち上げ、運営を行なっています。 昨年末、Google で25年以上 SRE を推進してきたエンジニ...

Join the discussion →

__WFI() does not work as it should in STM32CubeMX

I'm programming in C on STM32F103RBT6. I'm using STM32CubeIDE. For some strange reason, the __WFI function, instead of waiting for an interrupt to occur, automatically calls itself and doesn't wait for an interrupt. I don't know what's going on. I've set breakpoints in all the functions in the interrupt file stm32f1xx_it.c, but still none of them have called. I don't know what's going on. The main.c file looks like this #include "main.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "states.h" #include "creators.h" #inc

Join the discussion →

gconf are not setting properly in Yaws

I am only using Yaws to serve dynamic content via handlers (for example, serving API responses or dynamic pages via Erlang modules). I don't need a document root at all. Here is supervisor where I am initializing Yawsusingyaws_api:embedded_start_conf/1`. I even tried to add the gconfig manually again with yaws_api:setconf(GlobalConf, [[ServerConf]]) but global config are not set. %%%------------------------------------------------------------------- %% @doc myapp top level supervisor. %% @end %%%------------------------------------------------------------------- -module(myapp_sup). -behaviour(

Join the discussion →

Picking out file names from grep results where file name contains numbers and hyphens

I have a script that runs a grep command and formats the results nicely for me, asking if I want to open any of the resulting files in an editor etc. The core of my script is a command like this: grep -HinER -B 0 -A 2 --include "*.txt" "eight" /tmp/searchTest/letters | sed -re "s/:([0-9]+:)/\n\1/" -e "s/-([0-9]+-)/\n\1/" -e "s/^[.]/\\n./" It runs the grep, outputting the file name on every line and then runs some processing to put the file names on a different line from the results. > grep -HinER -B 0 -A 2 --include "*.txt" "eight" /tmp/searchTest/letters | sed -re "s/:([0-9]+:)/\n\1/" -e "s/-

Join the discussion →

Problem with: react.production.min.js:20 Uncaught TypeError: Cannot set properties of undefined (setting 'Children')

After building the react application with vite.js, I get this error when I access the application's home page: react.production.min.js:20 Uncaught TypeError: Cannot set properties of undefined (setting 'Children') at requireReact_production_min (react.production.min.js:20:1) at requireReact (index.js:4:20) at requireUseSyncExternalStoreWithSelector_production (use-sync-external-st…production.js:12:13) at requireWithSelector (with-selector.js:4:20) at with-selector.js:7:1. When I open the application in development, the error is not present in production mode, it is present. Have you ever encou

Join the discussion →

With CASL ABAC, is it able to parse Bigint?

The object being passed as a subject is below: permissions.can("read", subject("appprofile", profile))) The profile being checked looks like this: { name: "Dave", id: 1n, <--- the bigint from Prisma } the JSON being used in createMongoAbility is like this: [ { action: "read", subject: "appprofile", conditions: { id: "1", }, } ] ... but the check fails. I'm assuming its a bigint parsing issue in CASL or am I on the wrong track?

Join the discussion →

Postgres: JSON to bytea?

I found similar questions but unanswered or didn't work for me. I am building a json object with json_build_object and I have to store the object into a column with type bytea. Using Postgres 14. Thanks in advance.

Join the discussion →

Responsive layout using CSS Grid w/ embedded YouTube video

I'm trying to create a responsive layout using CSS grid that splits the screen into two columns: left column taking up 2/3 and right column taking up 1/3 of the screen. My objective is to embed a YouTube video into the left column that scales up/down using up all the available space -- except padding -- in the left column. When viewed on a smaller screen, the columns should stack up on top of each other. Similarly, I place an image and some text in the right column which take up 1/3 of the screen. I'm also trying to get the image to scale up and down as needed. I created a public repo showing

Join the discussion →

Why does adding height: 100% cause a child to shrink, but removing it causes child to grow to fill space vertically?

I have a series of cards in a flex row. Some cards have longer titles, and therefore have a larger height. If I apply a height of 100% to all cards (using tailwind's h-full class), the smaller cards remain small. If I take that class away, the smaller cards grow to be 100% of the parent container's height, e.g. the height of the tallest card. You can see a demo here: https://codesandbox.io/p/sandbox/wonderful-ptolemy-lyh7xh <ul className="flex flex-col gap-4 items-stretch md:flex-row md:flex-wrap"> <li className="border-2 rounded-lg p-2 w-80 h-full">...</li> </ul> const { useState } = React; c

Join the discussion →

Vite is not creating CSS source maps

I am new to Vite. I need to generate CSS sourcemap files. From what I have read in the Vite documentation, Vite itself is able to generate sourcemap files, without needing gulp task or whatever. I have my vite.config.js at the root because I need to watch files in different folders, but right now I am just working with the "theme" folder. My vite.config.js file: import { defineConfig } from "vite"; import path from "path"; export default defineConfig(async () => { const glob = (await import("glob")).glob; // Define themes and their SCSS paths const themes = ["theme_one", "theme_two"]; const sc

Join the discussion →

How can I make a child element escape a parent with overflow: hidden without breaking my layout?

I’m working on a layout where the parent element has the following properties: .parent { position: relative; height: 350px; border: 1px solid #ddd; border-radius: 8px; overflow: hidden; display: flex; justify-content: flex-end; align-items: center; } The parent contains a child element (a <div> or <span>), and I want this child to visually move outside the boundaries of the parent by using negative margins or positioning. The problem is that because the parent has overflow: hidden, the child gets cut and doesn’t show outside the parent’s boundaries. I cannot remove overflow: hidden on the pare

Join the discussion →

Dahua Python SDK: P2P Connection

I have Dahua's CCTV camera and DVR in my home. I want to get its live feed and run my own computer vision algorithms on top of it. I am using Dahua's python sdk (General_NetSDK_Eng_Python_win64_IS_V3.058.0000004.0.R.241125) from their official website (Dahua Partner Alliances) to tinker with my DVR. The following code snippet from their RealPlayDemo.py file (present in their sdk's demo folder) shows how they are connecting using Ip and port: def login(self): stuInParam = NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY() stuInParam.dwSize = sizeof(NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY) stuInParam.szIP = b'

Join the discussion →

How can I handle GraphQL error status codes and pass them from the backend to the frontend in an Express app?

I am building a full-stack application using React on the frontend and Express with GraphQL on the backend. I need to handle errors in my GraphQL mutation and pass the appropriate status codes (like 409 for conflicts, 422 for validation errors, etc.) from the backend to the frontend. However, when an error occurs in the GraphQL mutation, I am unable to pass the correct HTTP status code to the frontend. Here's what I have so far: Backend (Express + GraphQL) I am using graphql-http to set up the GraphQL handler in my Express app, and I use formatError to catch GraphQL errors. Here’s how I set up

Join the discussion →

How to get a transparent background for a wordcloud in MATLAB?

I am unable to get a transparent background with this MWE (there are no errors). The procedure works fine for other types of MATLAB plotting functions. fileName = 'C-13.tex'; % Input file name text = ' this this this a is a test'; text = lower(text); words = split(text); [uniqueWords, ~, idx] = unique(words); wordCounts = accumarray(idx, 1); wordTable = table(uniqueWords, wordCounts, 'VariableNames', {'Word', 'Frequency'}); wordTable = sortrows(wordTable, 'Frequency', 'descend'); topWordCount = 75; % Keep top 75 words wordTable = wordTable(1:min(topWordCount, height(wordTable)), :); hf = figur

Join the discussion →

How do I remove the margin on my header and the div containing the search bar?

My header and the div below the header do not hug the sides of the webpage like I want them to. Despite me setting margin to 0, there is still a 10px margin. How do i fix this. I have tried setting body margin to 0 as well header position is absolute and left right top values are 0 #header{ display: grid; position: absolute; top:0; left:0; right:0; height:90px; background-color: #00719e; text-align: center; grid-template-columns: 13% 13% 13% 22% 13% 13% 13%; min-width: 1570px; margin: 0px; } #searchBox{ margin-top: 90px; height: 50px; background-color: aliceblue; margin-left: 0%; margin-right:

Join the discussion →

Extract UUencoded images from SEC EDGAR submissions

I am trying to automate the extraction of various files from SEC full text submissions on EDGAR (public company regulatory filings). With python, I can separate the various files, demarcated by DOCUMENT tags, easily enough. But I have been unable to convert and save the encoded images as jpg files. Best I can tell from SEC (https://www.sec.gov/files/edgar/pds_dissemination_spec.pdf#page=11), they're UUencoded. I've tried uu (which apparently is going away soon) and base64, and pasted it into some decoder websites, but I get errors in every case. Example full text submission: https://www.sec.go

Join the discussion →

Why does multi-thread program still need lock when running on a single-core CPU? [duplicate]

After reading Why memory reordering is not a problem on single core/processor machines?, I wrote a small multi-thread program which runs on a single-core CPU: #include <pthread.h> #include <stdio.h> #include <stdint.h> #include <inttypes.h> #include <string.h> #define THREAD_NUM 4 #define SUM_LOOP_SIZE 100000 uint64_t sum; void * thread(void *arg) { for (int i = 0; i < SUM_LOOP_SIZE; i++) { sum++; } return NULL; } int main() { pthread_t tid[THREAD_NUM]; uint64_t counter = 0; while (1) { counter++; for (int i = 0; i < THREAD_NUM; i++) { int ret = pthread_create(&tid[i], NULL, thread, NULL); if

Join the discussion →

Live activities are being registered but not appearing

Context I'm building an iOS app in which I register a live activity in a view model: @Observable class LiveActivityViewModel { private var activity: Activity<LiveActivityTimerAttributes>? // more properties func startActivity() { // .... (define some vars) // Create attributes let attributes = LiveActivityTimerAttributes() // Create initial state let state = LiveActivityTimerAttributes.ContentState( duration: offlineViewModel.state.durationSeconds, //defined earlier startDate: startDate, // defined earlier peopleOffline: offlineCountViewModel?.count ?? 0 // defined earlier ) let content = Acti

Join the discussion →

How to create multiple files with different names and content using a comma-separated list without loops?

I have a comma-separated list of file names, and I want to create multiple text files in MySQL. Each file should contain some static text. For example, if my input is: 'file1,file2,file3,file4' I want to generate: /var/www/output/file1.txt containing "SomeContent" /var/www/output/file2.txt containing "SomeContent" /var/www/output/file3.txt containing "SomeContent" /var/www/output/file4.txt containing "SomeContent" I want to achieve this without using loops. I tried using SELECT INTO OUTFILE like this: SELECT "SomeContent" INTO OUTFILE "/var/www/output/file1.txt"; SELECT "SomeContent" INTO OUTF

Join the discussion →

Cloudwatch: create log stream using wildcard name of filepath

We have a sample cloudwatch config like below for our windows-based AWS cloud EC2 instance: "logs": { "logs_collected": { "files": { "collect_list": [ { "file_path": "c:\\testfolder\\test.log", "log_group_name": "oneSpecificInstance", "log_stream_name": "{instance_id}/test.log", "timezone": "Local" } ] } } } As part of some test automation, I might generate various kinds of logs that might change over time. Given a specific log directory C:\testlog, can a specific log stream be created with the file name of any file in that folder that matches file path pattern *.log ? "logs": { "logs_collecte

Join the discussion →

Troubleshoot Chromadb configuration with semantic kernel and Docker Compose

I have semantic kernel Open AI configuration that uses chromadb. // Initialization var collectionName = "mydataMemory"; await chromaClient.CreateCollectionAsync(collectionName, cancellationToken); // Save records var chromaMemoryStore = new ChromaMemoryStore(chromaClient); var memory = new SemanticTextMemory(chromaMemoryStore, textEmbeddingGenerationService); await memory.SaveInformationAsync(collectionName, text, id, description, metadata, cancellationToken: cancellationToken); `metadata` and `description` are always empty for now. Locally when I spawn chromadb in this way: chroma run --host

Join the discussion →
Older stories