php – Cómo pasar una función en bucle de JavaScript a que solo se ejecute una vez al pulsar un botón

Estoy trasteando con un programa en JavaScript que coge tus coordenadas reales y te las muestra en pantalla a la vez que las sube a una base de datos con PHP. Yo no sé mucho de JavaScript y el código está hecho ahora mismo de forma que cada x segundos te da de nuevo tus coordenadas y las sube a la base de datos. Tiene un botón de detener pero no funciona muy bien y tampoco es lo que estoy buscando.

Yo lo que quiero es que al pulsar el botón de Iniciar, te muestre una sola vez tus coordenadas y las suba una sola vez a la base de datos, pero no sé cómo hacerlo. Este es el código JavaScript en cuestión, os agradecería muchísimo que pudierais ayudarme.

    if (!"geolocation" in navigator) {
        return alert("Tu navegador no soporta el acceso a la ubicación. Intenta con otro");
    }

    const RUTA_API = "./insert.php";

    let idWatcher = null;

    const $latitud = document.querySelector("#latitud"),
        $longitud = document.querySelector("#longitud"),
        $btnIniciar = document.querySelector("#btnIniciar"),
        $btnDetener = document.querySelector("#btnDetener"),
        $log = document.querySelector("#log");


    const onUbicacionConcedida = ubicacion => {
        const coordenadas = ubicacion.coords;
        $latitud.innerText = coordenadas.latitude;
        $longitud.innerText = coordenadas.longitude;
        loguear(`${ubicacion.timestamp}: ${coordenadas.latitude},${coordenadas.longitude}`);
        enviarAServidor(ubicacion);
    }

    const enviarAServidor = ubicacion => {
        // Debemos crear otro objeto porque el que nos mandan no se puede codificar
        const otraUbicacion = {
            coordenadas: {
                latitud: ubicacion.coords.latitude,
                longitud: ubicacion.coords.longitude,
            },
            timestamp: ubicacion.timestamp,
        };
        console.log("Enviando: ", otraUbicacion);
        fetch(RUTA_API, {
            method: "POST",
            body: JSON.stringify(otraUbicacion),
        }); // No esperamos el then porque no hacemos nada cuando se termine
    };

    const loguear = texto => {
        $log.innerText += "n" + texto;
    };

    const onErrorDeUbicacion = err => {

        $latitud.innerText = "Error obteniendo ubicación: " + err.message;
        $longitud.innerText = "Error obteniendo ubicación: " + err.message;
        console.log("Error obteniendo ubicación: ", err);
    }

    const detenerWatcher = () => {
        if (idWatcher) {
            navigator.geolocation.clearWatch(idWatcher);
        }
    }

    const opcionesDeSolicitud = {
        enableHighAccuracy: true, // Alta precisión
        maximumAge: 0, // No queremos caché
        timeout: 5000 // Esperar solo 5 segundos
    };


    $btnIniciar.addEventListener("click", () => {
        detenerWatcher();
        idWatcher = navigator.geolocation.watchPosition(onUbicacionConcedida, onErrorDeUbicacion, opcionesDeSolicitud);
    });

    $btnDetener.addEventListener("click", detenerWatcher);

    $latitud.innerText = "Cargando...";
    $longitud.innerText = "Cargando...";


};
document.addEventListener("DOMContentLoaded", funcionInit);```

miner configuration – How can i solo mine with antminer? Using local bitcoin core

I am having trouble setting up mining with antminer.

I have a gpu rig which is successfully mining with 2060 rtx on bitcoin with bfgminer at a hashrate of 1.5gh/s

Obviously 1.5gh/s is nothing compared to what can be achieved with the antminer

So went and got an antminer promising speeds of dozens of th/s

I can do pooled mining with it and get the advertised speed

However i wish to have a go at setting up solo mining with my antminer

Which software would you recommend to use in conjunction with the bitcoin core client? It seems i am unable to use bfgminer with my antminer for solo mining

The information i have access to so far with google search and searching on this website is very limited or most of it is outdated

No comments on how unlikely it is i will profit. I want to get it working so please stay on topic

css – HTML sirve solo si usa otro slider-busqueda

hola buenas tengo una duda y es que tengo 2 sliders que no les puedo dar clic no pasar de imágenes hasta que le hago clic a mi barra de búsqueda y luego salgo de la misma ya funcionan perfecto los sliders alguna solución para esto?

el slider de los libros y el de abajo son destientos con distintos css y aun así ninguno sirve

cuando los superpongo con un z-index cuando uso la barra se traspasan

api – ¿Debería desarrollar una web app completamente en flask o solo usar flask para pequeños servicios?

No tengo conocimientos de buenas conductas de programación, y cuando estuve haciendo un pequeño proyecto con openCV, hice una pequeña “API” con flask si es que se le puede llamar así. Y aprovechando que flask puede devolver ‘templates’ en HTML lo estaba usando también como ‘backend’… ahora que me propongo hacerle un ‘login’, me detengo a pensar…

Me pregunto, no es este el territorio de PHP? ¿debería hacer todo esto en python con flask? o ¿solo debería usar el servicio de procesamiento de imagen de openCV en flask y utilizar otro lenguaje para backend?

La pregunta:

Es una buena práctica desarrollar un sitio web completo en flask, o lo recomendado es utilizarlo solo para API’s y servicios? Luego utilizar un backend con PHP o node js. No se si se pueda juzgar en terminos de velocidad, cantidad de peticiones que puede manejar al mismo tiempo, la modularidad y escalabilidad que tenga poner todo en un mismo código de flask, y otros detalles de producción.

web development – How do you actually design a solo web project?

thank you for reading my post.

In the last month I tried to create from scratch a forum website (Like phpBB, vBulletin Invision Community ) using PHP as backend with an MVC framework, a simple one for now so I can get a feel of MVC OOP and design patterns… all that good stuff… The thing is that the more I dive deeper the more I understand actually how hard it is.

As for myself I dream on having a backend web dev job one day, so I thought that an website like a forum board or an shop website among other smaller projects like an standalone Rest API (or I don’t know) would look great on my portfolio.

So after 30 days working on this, I’ve got really far with it, I will not go into the details but basically is usable, you can view forums the forums inside those forums (recursively), threads and the posts associated with those threads, sign up/log in system, user profiles… you get the point…

But 1 week ago I said stop, I don’t like where’s this is going, my HTML/CSS/PHP/DB schema is inconsistent, my UI looks like crap ( the UI is from scratch as well pure CSS, and at that point I didn’t had any idea about negative space, visual hierarchy, contrast, colors )

So I started my journey on trying to improve the UI, this was my first contact with the concept of User Experience, and how important actually this is, remember that I only cared about backend up until this point, now I start to see that the backend is actually a singe piece of the puzzle…

What I am trying to say is that this first try creating my project didn’t taught me that much about backend as I initially thought, but much more than that, why we need naming conventions, code formatting? Basically create a set of rules or some guidelines form the start and to stick to that the entire project, but more important that that… you need to know beforehand the features you want implement a list where you first write down what your application is supposed to do, on a very abstract level, you don’t want to lose yourself in the details at this point.

So I thought, alright… I got to know about all this important stuff the hard way, wouldn’t be nice if someone could warn me about all of these beforehand and tell me “Hey, is pretty hard to make this all by yourself, especially if you don’t have ANY idea about all this software architecture / software architecture design / web application design, you should first think about what you want to implement, then how? Scalability ? Heard of it ?, UX? UI principles? Web security? TESTING? Do you really think that you can write just what code came in your mind and then that’s all? Problem solved? Ok I get what you think: “but it works…” only for the moment, trust me…” and on and on…

Oh am I supposed to write some questions here…
So, is there something that I missed here?
Can somebody describe me how should I approach this? Some rules of thumb?

As I already said, the best option that comes in my mind is to write what functionalities your application should have? as abstract as possible, don’t drown in detail. With this information you could expand individually every concept / functionality that you wrote and based on that create your UX/UI, frontend stuff, backend stuff, database schema etc… and how should all of this snap together…

So what are your thoughts on this? Let me know.

Thank you for your time Eddy.

blockchain – If only one Bitcoin miner gets the block reward, is it worth mining only for the transaction fees as a (not-so-competitive) solo miner?

I have heard (but not that knowledgeable) about mining-pools. If a weak system joins the pool, it has a chance to get a portion of the block reward, but I assume that not all of the miners are joined to a mining pool.

If I use my average PC for Bitcoin mining, it is a very low probability that I will be the first to solve the hash problem, thus, I won’t earn the block reward most probably. I will only be rewarded with the fees with respect to the calculations I have made. So my question has two parts;

  1. I assume that the numbers showing the average revenue generated from mining includes both the transaction fees and block rewards, is that correct?
  2. If that is the case, then shouldn’t the weak miners consider a lower average revenue, until they earn the block reward with such low probabilities?

Please correct any points that I might have been wrong about. Thanks in advance.

c# – como guardar datos de archivos con un solo ID incremental

tengo una ventana que es para guardar datos en donde se ingresa el nombre de una aplicación el usuario y la contraseña y cuando presione el botón de cargar me los tiene que guardar en tres archivos uno para usuario , contraseña y otro para nombre de aplicación y tienen que estar unidos por un mismo ID incremental lo que no se es como hacer para unir todos con el ID

introducir la descripción de la imagen aquí