I created an extension but it doesn’t download the files

I have a code in a content.js and a background in a chrome extension, the code runs all fine, except the part that makes it download the information I want

part of the code that doesn’t work
content.js

function descargarArchivo(texto, nombreArchivo) {
    chrome.runtime.sendMessage({
        action: "downloadFile",
        data: texto,
        filename: nombreArchivo
    });
}

getting org.springframework.messaging.converter.MessageConversionException in chat application

I’ve made simple real time chat application however when I run the application everything seems fine.
After the typing and sending the message , it is reflecting in the console tab but not reflected in chat application also getting exception as:
org.springframework.messaging.converter.MessageConversionException:
I am unable to solve this error. Please help.

<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Real Time Chat Application</title>
<link
    href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
    rel="stylesheet"
    integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
    crossorigin="anonymous">
</head>
<body>
    <div class="container mt-4">
        <h1 class="text-center">Real-Time Chat Application</h1>
        <div id="chat" class="border rounded p-3 mb-3"
            style="height: 300px; overflow-y: auto;"></div>

        <div class="input-group mb-3">
            <input type="text" id="senderInput" class="form-control"
                placeholder="Your Name...">
        </div>

        <div class="input-group mb-3">
            <input type="text" id="messageInput" class="form-control"
                placeholder="Type Message...">
            <div id="input-group-append">
                <button id="sendMessage" class="btn btn-primary">Send</button>
            </div>
        </div>
    </div>
</body>
<script
    src="https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/stomp.js/2.3.3/stomp.min.js"></script>
<script>
    function setConnected(connected) {
        document.getElementById("sendMessage").disabled = !connected;
    }

    function connect() {
        let socket = new SockJS('/chat');
        stompClient = Stomp.over(socket);
        stompClient.connect({}, function(frame) {
            setConnected(true);
            stompClient.subscribe('topic/messages', function(message) {
                showMessage(JSON.parse(message.body));
            });
        });
    }
        
        function showMessage(message){
            let chat=document.getElementById('chat');
            let messageElement=document.createElement('div');
            messageElement.textContent=message.sender+':'+ message.content;
            messageElement.class="border-bottom mb-1";
            chat.scrollTop=chat.scrollHeight;
        }
        
        function sendMessage(){
            let sender=document.getElementById('senderInput').value;
            let content=document.getElementById('messageInput').value;
            let chatMessage={
                    sender:sender,
                    content:content
            }
            stompClient.send("/app/sendMessage",{},JSON.stringify(chatMessage));
            document.getElementById('messageInput').value='';
        }
        
        document.getElementById('sendMessage').onclick=sendMessage;
        window.onload=connect;
</script>
</html>

//Controller class code
package com.chat.main.controller;

import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import com.chat.main.model.ChatMessage;


@Controller
public class ChatController {
    @MessageMapping("/sendMessage")
    @SendTo("/topic/messages")
    public ChatMessage sendMessage(ChatMessage message) {
        return message;
    }
    
    @GetMapping("/chat")
    public String chat() {
        return "chat";
    }
}

//Websocket configuration code
package com.chat.main.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer{

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/chat")
        .setAllowedOrigins("http://localhost:8080")
        .withSockJS();
    }

    @Override
    public void configureMessageBroker(MessageBrokerRegistry registry) {
        registry.enableSimpleBroker("/topic");
        registry.setApplicationDestinationPrefixes("/app");
    }
    
}````
 [Exception][1] [1]: https://i.sstatic.net/TpsFv1dJ.png
  [Chat application][2][2]: https://i.sstatic.net/i4D42Dj8.png
[Controller] [3]: https://i.sstatic.net/cWFH5vlg.png
[Websocket Configuration][4][4]: https://i.sstatic.net/UzIro8ED.png

Why isn’t FeedMessage.decode.bind(FeedMessage) equivalent to x => FeedMessage.decode(x) in Javascript? [duplicate]

Below is a Javascript code which attempts to parse some protobuf input data.

'use strict';

import protobuf from 'protobufjs';

const proto = protobuf.loadSync('gtfs-realtime.proto');
const FeedMessage = proto.lookupType('transit_realtime.FeedMessage');

// sources is an array of Buffer containing the binary input
// const inputs = sources.map(FeedMessage.decode.bind(FeedMessage)); // this line does not work
const inputs = sources.map(x => FeedMessage.decode(x));

console.log(inputs[0].toJSON());

Why isn’t FeedMessage.decode.bind(FeedMessage) equivalent to x => FeedMessage.decode(x)?

Pixi.js wrong collision

I’m trying to create a game on pixi.js and implement custom physics for the Hero instance. I’m stuck on a jump down right now. My problem is that the collision should disappear with “state === jump”, but the Pixi.update method logically changes state === fall and when i have fall does not occur. if you remove the “if (this.#speed.speed > 0 && this.is Jump())” everything works, but I can’t figure out how to get the collision back so that the character jumps down only one platform.

I tried to enter an additional state of jumping down. I also tried using setTimeout (this leads to a memory leak) and a timer via a variable, but in this case there will be bugs when jumping in place.

I will attach a link to the github, as well as to the problematic parts of the code.
Thanks!
Github https://github.com/yanballas/contra

Code:

Hero instance

    update() {
        this.#speed.speedX = this.#movement.x * this.#speed.maxSpeed;
        this.x += this.#speed.speedX;
        
        if (this.#speed.speedY > 0 && this.isJump()) {
            console.log('down');
            this.#stateHero = $STATESCHARTER.fall
        }
        
        this.#speed.speedY += this.#gravity.gravityForce
        this.y += this.#speed.speedY
    }
    
    stay() {
        this.#stateHero = $STATESCHARTER.stay
        this.#speed.speedY = 0
    }
    
    jump() {
        if (this.#stateHero === $STATESCHARTER.jump || this.#stateHero === $STATESCHARTER.fall) return
        this.#stateHero = $STATESCHARTER.jump
        this.#speed.speedY -= this.#gravity.jumpForce
    }
    
    jumpDown() {
        console.log('jump down')
        this.#stateHero = $STATESCHARTER.jump
        console.log(this.isJump())
    }
    
    isJump() {
        return this.#stateHero === $STATESCHARTER.jump
    }

// Game instance

isCheckCollision(entity, area) {
        return entity.x < area.x + area.width &&
            entity.x + entity.width > area.x &&
            entity.y < area.y + area.height &&
            entity.y + entity.height > area.y;
    }
    
    update() {
        const previousPoint = {
            x: this.#hero.x,
            y: this.#hero.y
        }
        
        this.#hero.update()
        
        this.#platforms.forEach(platform => {
            
            if (this.#hero.isJump()) return
            
            const resultCollision = this.resultEntityCollision(this.#hero, platform, previousPoint);
            
            if (resultCollision.vertical) {
                this.#hero.stay();
            }
        })
    }
    
    resultEntityCollision(charter, platform, previousPoint) {
        const collisionResult = this.checkResultEntityCollision(charter, platform, previousPoint);
        
        if (collisionResult.vertical) {
            charter.y = previousPoint.y
        }
        
        return collisionResult
    }
    
    checkResultEntityCollision(rectangleA, rectangleB, previousPointRectangleA) {
        const collisionResult = {
            horizontal: false,
            vertical: false,
        }
        
        let isCollision = this.isCheckCollision(rectangleA, rectangleB)
        if (!isCollision) return collisionResult;
        
        rectangleA.y = previousPointRectangleA.y
        
        isCollision = this.isCheckCollision(rectangleA, rectangleB)
        if (!isCollision) {
            collisionResult.vertical = true
            return collisionResult
        }
        
        collisionResult.horizontal = true
        return collisionResult
    }

Regex to match urls is not working properly

I am really not good at writing regex so I took help from ChatGPT but whatever he is providing does not work. So I think I need an expert’s help for my case. So here I am expecting a solution from you guys.

So let me briefly explain my situation. I have a markdown js library that converts urls to html. But it doesnt support urls with format google.com and www.google.com because these two formats doesnt have the protocol. So basically, I need to identify these two url formats with regex, and then replace them with something like https://google.com and https://www.google.com so that the library can convert to html links.

The regex provided by ChatGPT is either matching the domain part of lets say [email protected] or doesnt identify nothing at all or if the url is wrapped with quotes or parentheses or brackets, it identifies them as well like "google.com". Or sometimes it matches the first part before @ in email addresses.

Here’s my code:

function matchURLs(text) {
  const regex = /b(?:(?:https?://|www.)[a-zA-Z0-9.-]+.[a-zA-Z]{2,}(?:/S*)?|(?!.*@)[a-zA-Z0-9-]+.[a-zA-Z]{2,}(?:/S*)?)b/g;
  const matches       = text.match(regex);

  if (matches?.length > 0) {
    matches.forEach(match => {

      if (!match.startsWith('http')) {
        text = text.replace(match, `https://${match}`);
      }
    });
  }

  return text;  
}

matchURLS(text)

These are the strings I’m passing to the function to match:

links like "google.com" are working
links "http://google.com" are working
links "https://google.com" are working
links "www.google.com" are working
links "http://www.google.com" are working
links "https://www.google.com" are working
email "[email protected]" are working
[email protected]
customer/[email protected]
[email protected]
this.is.a.very.long.email.address@subdomain.of.a.really.long.domain.name.com

And the output is this:

[
    "google.com",
    "http://google.com",
    "https://google.com",
    "www.google.com",
    "http://www.google.com",
    "https://www.google.com",
    "google.com",
    "exa4mple.com",
    "exa5mple.com",
    "mail.server",
    "exa7mple.com",
    "subdomain.of",
    "a.really",
    "long.domain",
    "name.com"
]

Can someone help please to improve this regex so that it only matches the urls? So the first 6 only, and must not match url in email addresses, neither email addresses.

expo-av [prepare encountered an error: Error Domain=NSOSStatus error-Domain Code=561017449″Session Activation Failed”]

I am using ‘expo-av’ in a bare react-native project to record audio. It is working fine on Android and 50% of the time on IOS.

The other 50% of the time it give the error.
prepare encountered an error: Error Domain=NSOSStatus error-Domain Code=561017449″Session Activation Failed”
error 1

error 2

I have searched long and hard so far my theory is that when some App or Service is using audio related API in the device it throws this error, but to handle this or check if the service is available or not there is not API provided by the “expo-av” library.

Can anyone give me useful insights or solutions to what is happening.

here is the recording function I am using to start the recording.

const startRecording = async () => {
    try {
      // Request microphone permissions
      if (permissionResponse.status !== 'granted') {
        console.log('Requesting permission..');
        await requestPermission();
      }

      // Prepare audio recording options
      await Audio.setAudioModeAsync({
        allowsRecordingIOS: true,
        playsInSilentModeIOS: true,
        interruptionModeIOS: InterruptionModeIOS.DoNotMix,
        interruptionModeAndroid: InterruptionModeAndroid.DoNotMix,
        playsInSilentModeIOS: true,
        staysActiveInBackground: true,
      });

      // Start recording
      const {recording} = await Audio.Recording.createAsync(
        Audio.RecordingOptionsPresets.HIGH_QUALITY,
      );
      setRecording(recording);
      setIsRecording(true);
      setIsPaused(false);
      console.log('Recording started');
    } catch (err) {
      Alert.alert('Failed to start Recording: ' + err?.message);
      console.error('Failed to start recording', err);
    }
  };

Below are the versions:
“expo”: “^52.0.0”,
“expo-av”: “~15.0.1”,
“react”: “18.3.1”,
“react-native”: “0.76.5”,

Issue with Tailwindcss intallation: “npx tailwindcss init”

npx tailwindcss init

npx: installed 1 in 1.127s
command not found: tailwindcss

I did try another command npx tailwindcss-cli@latest init -p and created tailwind.config.js folder.

But I do want to know why the npx tailwind init: not working.

Tried ChatGPT and possible solution that I could get my hand on still the problem persists.

When can using Reflect in a Proxy trap cause an infinite loop?

Following the documentation on Proxies on MDN, under the example bellow, there is this disclaimer:

If you use Reflect methods within a proxy trap, and the Reflect method
call gets intercepted by the trap again, there may be infinite
recursion.

The Proxy in the example is using Reflect in a Proxy trap, and, it works as expected, it causes no recursion.

So, in what case would the reflect call get "intercepted" and cause an infinite loop ? What should be avoided ?

const target = {
  message1: "hello",
  message2: "everyone",
};

const proxy3 = new Proxy(target, {
  get(target, prop, receiver) {
    if (prop === "message2") {
      return "world";
    }
    return Reflect.get(...arguments);
  },
});

console.log(target.message1)
console.log(target.message2)

How to create a filter panel on a HERE Map

I have created a Here Map and have placed markers based on Data I have extracted using an api. I now would like to add a panel with selectable options to provide filtering options based on my data. I’m pretty new at this so would appreciate any assistance.

I have searched online but cannot find any examples relating to HERE maps, nor have I found any help in their documentation.

Google translate API not translating to any other language after I translate to my base language English

<script type="text/javascript">
        function googleTranslateElementInit() {
            new google.translate.TranslateElement({
                pageLanguage: 'en', 
                includedLanguages: 'en,bn,hi,kn,pa,ta,te,or',
                layout: google.translate.TranslateElement.InlineLayout.SIMPLE
            }, 'google_translate_element');
        }
</script>

Above is my code. Let me write down the flow

  1. The site loads in English
  2. Change the language from English to some language. It works
  3. Change to some other , It works.
  4. Change back to English. It works.
  5. Change to some other language . It doesn’t work. The dropdown automatically gets selected to “Select Language”.

show docx file along with its edit suggestion in reactjs

I’m working on a React application that receives a DOCX file as a base64 string from the backend. When I open this file in Google Docs, it displays edit suggestions/track changes clearly (as shown in the attached image). However, when I attempt to render the same DOCX using libraries like react-doc-viewer, the edit suggestions are not visible.

What I’ve Tried:
Converted base64 to downloadable DOCX file
Used multiple React libraries for DOCX rendering
Verified the issue is specifically with rendering track changes

Specific Requirements:
Render DOCX file with full track changes/edit suggestions in React UI
Preserve the formatting and edit history shown in Google Docs

Questions:
Which React library can render DOCX track changes?
Are there any JavaScript/web techniques to parse and display edit suggestions from DOCX files?

Additional Context:
Backend provides DOCX as base64 string
Goal is to display edits inline, similar to Google Docs view

Attachments: Google doc view

Hosting website on github getting 404 error on my folder songs

I am hosting my website on GitHub but it is giving me an errorthis is the web page of the website
it is not uploading the songs folder from my project however the songs folder is pushed in the repository this is my code picture
here is the link to my repository
https://github.com/Anamf2200/Spotify_Clone.git

I added the basepath variable but it doesn’t work however the other folder like CSS is working properly

How to compile/watch TypeScript inside jasmine-browser-runner

I’m trying to set up jasmine-browser-runner for a TypeScript project.

My jasmine-config.mjs looks like this:

export default {
    srcDir: 'src',
    srcFiles: [],
    specDir: 'src',
    specFiles: [ './**/*Spec.ts' ],
    helpers: ['jasmine-ts-node-register.js'],
    enableTopLevelAwait: false,
    env: {
        stopSpecOnExpectationFailure: false,
        stopOnSpecFailure: false,
        random: true,
    },
    listenAddress: 'localhost',
    hostname: 'localhost',
    browser: { name: 'chrome' },
};

The helper jasmine-ts-node-register.js looks like this:

require('ts-node').register();

It is supposed to register ts-node, but it does not work, because require cannot be used in a browser. Running the tests with

npx jasmine-browser-runner runSpecs --config=./jasmine-config.mjs

fails with the error “No specs found”. But this is misleading, as specs are indeed found (I verified this by debugging jasmine-browser-runner), but none of them are actually called, because the helper above is called first, which aborts the tests. I changed a line in my local copy of jasmine-browser-runner that prevents Chrome from closing, and it reveals that, as expected, the require statement fails.

So, how can I set this up so that it actually works?

I could probably compile TypeScript files before calling jasmine-browser-runner, but I was hoping that I could set it up like to “watch” my files, which helps a lot when writing tests. Can I combine jasmine-browser-runner with webpack?