โŒ

Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

Why do we call all http services 'Web Api/Web Service'?

I noticed that http services that receive and return JSON are called 'Web Api/Web Service' in many articles/book/documentation etc.

But isn't the Web (World Wide Web) about websites, html and web browsers? For example, a mobile application is not related to the web.

So why are http services that receive and return JSON called 'Web Api/Web Service'? This service does not return HTML or it's response does not rendered into user-friendly interface via browser-like applications. This API may not even be used by a website. For example, it may have been written only for another business microservice or mobile applications.

DB PostgreSQL data invisible in my website [closed]

we developing a website and I have a problem with data stored in DB PostgreSQL locally when I share the code with my team they can't see the data I uploaded to website

how can I fix that or should we use DB and website hosting like Railway ( we use the same usename;and pass of DB server and when i update the database and they pull the code it just update the schema without the data i stored -we use vs code ide,python lang and Django framework,PostgreSQL DB Github for sharing)

Correctly expanding xml namespaces without defined end character into valid URIs

As far as I know, the semantic web consists of triples of URIs. Namespace shorthands are widely used to abbreviate them in daily use. I thought, namespace shorthands would be expanded to URIs by simple concatenation, e.g. the famous dc:title in the well-known dc: namespace (which is defined as http://purl.org/dc/elements/1.1/, note that the last character is a /) would be expanded to, and hence be semantically equal to http://purl.org/dc/elements/1.1/title.

Then I came over some namespace definitions which lack a sensible separation character at their end. Some examples from http://live.dbpedia.org/sparql?nsdecl

and some from the Most common RDF namespaces list:

How to expand such namespaces into valid linked data URIs?

The W3C Recommendation Namespaces in XML defines:

An expanded name is a pair consisting of a namespace name and a local name.

And Fredrik Lundh writes on effbot.org:

In an Element tree, qualified names are stored as universal names in Clarkโ€™s notation, which combines the URI and the local part into a single string, given as โ€˜{uri}localโ€™.

This may be suitable for a wide range of use cases, but it doesnโ€™t conform to the idea that linked data constists of URIs, which cannot start with a {.

I would have thought that xsd:element should not be expanded to http://www.w3.org/2001/XMLSchemaelement in linked data (nor to {http://www.w3.org/2001/XMLSchema}element), should it? How must this be implemented correctly?

Rust return a result from a function

I'm quite new at using Rust. I'm trying to play around with Rust, Actix, and Azure Cosmosdb. At the moment I'm simply trying to connect to the cosmosdb and returning a result. I'm at the point where I'm happy with any result at all. At the moment I have some code in a function that should just return a string with the cosmos collection name. I can not wrap my head around how to return the string as a result. I need to return the result as it is an async function. If someone can please point me in the right way I would be very grateful. cosmos code is coming from azure_data_cosmos::prelude::*; Code below:

    async fn datastuff() -> Result<String, String> {

    let primary_key = std::env::var("COSMOSDB_READKEY").expect("Set env variable COSMOS_PRIMARY_KEY first!");
    let account = std::env::var("COSMOSDB_ACCOUNT").expect("Set env variable COSMOS_ACCOUNT first!");

    let database_name = "azdeployer";
    let collection_name = "resourcetemplates";

    // First, create an authorization token. There are two types of tokens: primary and resource constrained.
    // Please check the Azure documentation or the examples folder on how to create and use token-based permissions.
    let authorization_token = AuthorizationToken::primary_key(&primary_key)?;

    // Next we will create a Cosmos client.
    let client = CosmosClient::new(account, authorization_token);

    // We know the database so we can obtain a database client.
    let database = client.database_client(database_name);
    // We know the collection so we can obtain a collection client.
    let collection = database.collection_client(collection_name);
    //let cosmos_collection_client: CollectionClient = cosmos::cosmosclient::create_collection_client().expect("prutser");
    //let document_client: DocumentClient = cosmos_collection_client.document_client("resourceGroups@2022-09-01", "resourcegroup");
    let documents1 = collection.list_documents();
    let documents = collection.collection_name();
    let result: String = documents.to_string();
    Ok(result)

The error I'm getting is:

error[E0277]: `?` couldn't convert the error
to `std::string::String`   --> src\main.rs:17:76    | 17 |     let
authorization_token = AuthorizationToken::primary_key(&primary_key)?; 
|                                                                     
^ the trait `std::convert::From<azure_core::error::Error>` is not
implemented for `std::string::String`    |    = note: the question
mark operation (`?`) implicitly performs a conversion on the error
value using the `From` trait    = help: the following other types
implement trait `std::convert::From<T>`:
             <std::string::String as std::convert::From<char>>
             <std::string::String as std::convert::From<bytestring::ByteString>>
             <std::string::String as std::convert::From<Box<str>>>
             <std::string::String as std::convert::From<uuid::Uuid>>
             <std::string::String as std::convert::From<Cow<'a, str>>>
             <std::string::String as std::convert::From<url::Url>>
             <std::string::String as std::convert::From<&str>>
             <std::string::String as std::convert::From<&mut str>>
             <std::string::String as std::convert::From<&std::string::String>>    = note: required for
`Result<std::string::String, std::string::String>` to implement
`FromResidual<Result<Infallible, azure_core::error::Error>>`

Some errors have detailed explanations: E0277, E0425. For more
information about an error, try `rustc --explain E0277`.

Why does my navbar dropdown menu won't stay open?

My bootstrap navbar dropdown menu is disapearing, I can see the animation when I open/close it, but then it disappears. I can't figure out why.

I'm working in a school project, my classmates used JS to add some more fields to the navbar, I don't think this causes the problem, but i'm adding it just in case, here's the full page :

<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <link rel="icon" href="../files/logoSite.png">
    <link rel="stylesheet" href="../../View/CSS/navbar.css">
</head>
<body>
<?php
session_start();
include_once("../../Model/Utilisateur/User.php");
include_once("../../Model/Utilisateur/UsersModel.php");
if(isset($_POST['Deconnexion'])){
    session_unset();
    session_destroy();
    header("Location: ../../Controller/Accueil/HomePageController.php");
}

$userLoggedIn = isset($_SESSION['user_id']);
$res = GetRole($_SESSION['user_id'])[0]["idRole"];
echo ("<p id='currentRole' type='hidden' style= 'display :none;'>".json_encode($res)."</p>");

?>

<nav class="navbar navbar-expand-sm bg-dark-subtle">
    <a class="navbar-brand " id="backHome" href="../../Controller/Accueil/HomePageController.php" >
        <img src="../../View/files/logoSite.png" width="200px" height="133px">
    </a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarNav">
        <ul id="navbar" class="navbar-nav">
            <li class="nav-item">
            </li>
            <?php if ($userLoggedIn): ?>
            <li class="nav-item mt-auto">
                <a class="nav-link fw-bold" href="../../Controller/Tournoi/ControllerMatchPlayer.php">Les matchs</a>
            </li>
            <?php endif; ?>
        </ul>
    </div>
    <div class="p-xl-4">
        <ul class="navbar-nav">
            <?php if (!$userLoggedIn): ?>
                <li class="nav-item p-xl-1">
                    <button name="Connexion" id="Connexion" class="btn btn-primary" >Connexion</button>
                </li>
                <li class="nav-item p-xl-1">
                    <a href="../../Controller/Connexion/RegisterController.php" class="btn btn-primary">Inscription</a>
                </li>
            <?php else: ?>
                <li class="nav-item p-xl-1">
                    <form method="post">
                        <input name="Deconnexion" type="submit" value="Deconnexion" class="btn btn-danger">
                    </form>
                </li>
                <li class="nav-item p-xl-1">
                    <a href="../../Controller/Connexion/RegisterController.php" class="btn btn-primary">Inscription</a>
                </li>
            <?php endif; ?>
        </ul>
    </div>
</nav>
<script>
    
    
    
    const backHome = document.querySelector("#backHome");
    const goConn = document.querySelector("#Connexion")
    backHome.addEventListener("click",function (){
        window.location.replace("../../Controller/Accueil/HomepageController.php");
    });
    <?php if (!$userLoggedIn): ?>
        goConn.addEventListener("click", function (){
            window.location.replace("../../Controller/Connexion/ConnectionController.php");
        });
    <?php endif; ?>

    function toggleButtonState() {
        
        console.log(document.getElementById('userState').outerText);
        if (document.getElementById('userState').outerText = "null") {
            //gestion du bouton de connexion
            goConn.setAttribute("disabled",true);
            goConn.classList.remove("btn-primary");
            goConn.classList.add("btn-secondary");
        }
        else {
            //gestion du bouton de dรฉconnexion
            goDeco.setAttribute("disabled", true);
            goConn.classList.remove("btn-secondary");
            goConn.classList.add("btn-primary");
        }
    }
    let role = document.querySelector("#currentRole").innerText;
    const navbar = document.querySelector("#navbar");
    role = JSON.parse(role);
    if (role == 0 ){

        let li = document.createElement("li");
        li.setAttribute("class","nav-item mt-auto");
        let menu = document.createElement("a");
        menu.setAttribute("class","nav-link fw-bold");
        menu.innerText = "Vรฉrifier Joueur";
        menu.setAttribute("href","../../Controller/Utilisateurs/valideInscriptionController.php");
        li.appendChild(menu);
        navbar.appendChild(li);

        li = document.createElement("li");
        li.setAttribute("class","nav-item mt-auto");
        menu = document.createElement("a");
        menu.setAttribute("class","nav-link fw-bold");
        menu.innerText = "Modifier joueur";
        menu.setAttribute("href","../../Controller/Utilisateurs/ModificationController.php");
        li.appendChild(menu);
        navbar.appendChild(li);

        li = document.createElement("li");
        li.setAttribute("class","nav-item mt-auto");
        menu = document.createElement("a");
        menu.setAttribute("class","nav-link fw-bold");
        menu.innerText = "Gรฉrer Contribution";
        menu.setAttribute("href","../../Controller/Utilisateurs/ContributionConsultController.php");
        li.appendChild(menu);
        navbar.appendChild(li);

        li = document.createElement("li");
        li.setAttribute("class","nav-item mt-auto");
        menu = document.createElement("a");
        menu.setAttribute("class","nav-link fw-bold");
        menu.innerText = "Gรฉrer Parcours";
        menu.setAttribute("href","../../Controller/Parcours/ParcoursController.php");
        li.appendChild(menu);
        navbar.appendChild(li);

        li = document.createElement("li");
        li.setAttribute("class","nav-item mt-auto");
        menu = document.createElement("a");
        menu.setAttribute("class","nav-link fw-bold");
        menu.innerText = "Mail";
        menu.setAttribute("href","../../Controller/Mail/ControllerMailing.php");
        li.appendChild(menu);
        navbar.appendChild(li);
        
        li = document.createElement("li");
        li.setAttribute("class","nav-item mt-auto");
        menu = document.createElement("a");
        menu.setAttribute("class","nav-link fw-bold");
        menu.innerText = "Modifier les rencontres";
        menu.setAttribute("href","../../Controller/Tournoi/ControllerMatch.php");
        li.appendChild(menu);
        navbar.appendChild(li);

        li = document.createElement("li");
        li.setAttribute("class","nav-item mt-auto");
        menu = document.createElement("a");
        menu.setAttribute("class","nav-link fw-bold");
        menu.innerText = "Les Equipes";
        menu.setAttribute("href","../../Controller/Equipe/teamsController.php");
        li.appendChild(menu);
        navbar.appendChild(li);

        li = document.createElement("li");
        li.setAttribute("class","nav-item mt-auto");
        menu = document.createElement("a");
        menu.setAttribute("class","nav-link fw-bold");
        menu.innerText = "Crรฉer Tournoi";
        menu.setAttribute("href","../../Controller/Tournoi/tournamentController.php");
        li.appendChild(menu);
        navbar.appendChild(li);
        
        li = document.createElement("li");
        li.setAttribute("class","nav-item mt-auto");
        menu = document.createElement("a");
        menu.setAttribute("class","nav-link fw-bold");
        menu.innerText = "Modifier Tournoi";
        menu.setAttribute("href","../../Controller/Tournoi/tournamentModificationController.php");
        li.appendChild(menu);
        navbar.appendChild(li);

        li = document.createElement("li");
        li.setAttribute("class","nav-item mt-auto");
        menu = document.createElement("a");
        menu.setAttribute("class","nav-link fw-bold");
        menu.innerText = "Modifier Equipes sur les tournois";
        menu.setAttribute("href","../../Controller/Tournoi/verifyTeamTournamentController.php");
        li.appendChild(menu);
        navbar.appendChild(li);
        
        li = document.createElement("li");
        li.setAttribute("class","nav-item mt-auto");
        menu = document.createElement("a");
        menu.setAttribute("class","nav-link fw-bold");
        menu.innerText = "Inscrire รฉquipe au tournoi";
        menu.setAttribute("href","../../Controller/Tournoi/addTeamTournamentController.php");
        li.appendChild(menu);
        navbar.appendChild(li);

        li = document.createElement("li");
        li.setAttribute("class","nav-item mt-auto");
        menu = document.createElement("a");
        menu.setAttribute("class","nav-link fw-bold");
        menu.innerText = "Classement";
        menu.setAttribute("href","../../Controller/Classement/ClassementController.php");
        li.appendChild(menu);
        navbar.appendChild(li);
    }
    else if (role == "1"){

        let li = document.createElement("li");
        li.setAttribute("class","nav-item mt-auto");
        let menu = document.createElement("a");

        li = document.createElement("li");
        li.setAttribute("class","nav-item mt-auto");
        menu = document.createElement("a");
        menu.setAttribute("class","nav-link fw-bold");
        menu.innerText = "Modifier mes infos";
        menu.setAttribute("href","../../Controller/Utilisateurs/updateDataController.php");
        li.appendChild(menu);
        navbar.appendChild(li);
        
        li = document.createElement("li");
        li.setAttribute("class","nav-item mt-auto");
        menu = document.createElement("a");
        menu.setAttribute("class","nav-link fw-bold");
        menu.innerText = "Mes Equipes";
        menu.setAttribute("href","../../Controller/Equipe/myTeamController.php");
        li.appendChild(menu);
        navbar.appendChild(li);

        li = document.createElement("li");
        li.setAttribute("class","nav-item mt-auto");
        menu = document.createElement("a");
        menu.setAttribute("class","nav-link fw-bold");
        menu.innerText = "Inscrire รฉquipe au tournoi";
        menu.setAttribute("href","../../Controller/Tournoi/addTeamTournamentController.php");
        li.appendChild(menu);
        navbar.appendChild(li);
    }
</script>

<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>

</body>
</html>

I tried playing around with bootstrap classes and to add a css file with #navbarNav{z-index:10} (nothing is higher than that) for it to overlap (if that's the problem).

Is there a way to solve this problem , Type '{ children: Element; }' has no properties in common with type 'IntrinsicAttributes'.?

I create a file called ThemeContext:

import { createContext, useState } from "react";
import PropTypes from "prop-types";
import { DARK_THEME, LIGHT_THEME } from "../constants/themeConstants";

interface ThemeContextType {
  theme: string;
  toggleTheme: () => void;
}

export const ThemeContext = createContext<ThemeContextType>({
  theme: LIGHT_THEME,
  toggleTheme: () => {}
});

export const ThemeProvider: React.FC<{}> = ({ children }: any) => {
  const [theme, setTheme] = useState<string>(
    window.localStorage.getItem("themeMode") || LIGHT_THEME
  );

  window.localStorage.setItem("themeMode", theme);

  const toggleTheme = () => {
    setTheme((prevTheme) =>
      prevTheme === LIGHT_THEME ? DARK_THEME : LIGHT_THEME
    );
    window.localStorage.setItem("themeMode", theme);
  };

  return (
    <ThemeContext.Provider
      value={{
        theme,
        toggleTheme,
      }}
    >
      {children}
    </ThemeContext.Provider>
  );
};

ThemeProvider.propTypes = {
  children: PropTypes.node.isRequired,
};

and this is where I am using the theme provider :

import "./App.scss";
import { ThemeProvider } from "./context/ThemeContext";

import Admin from "./routes/admin/Admin";
import Global from "./routes/global/Global";

function App() {
  return (
    <div className="App">
      <Global />
      
      <ThemeProvider>
        <Admin></Admin>
     
      </ThemeProvider>
        
     
    </div>
  );
}

export default App;

but I got an error which is this: Type '{ children: Element; }' has no properties in common with type 'IntrinsicAttributes'.ts(2559) (alias) module ThemeProvider (alias) const ThemeProvider: React.FC<{}> import ThemeProvider

I tried to understand the issue but it seems like the ThemeProvider doesn' accept any element wrapped by it. I hope someone help me

Flutter build web in release mode

Is is possible to build flutter web in release mode? The only commmand I found to run on web was either :

flutter run -d chrome

but it's in debug

or I use : flutter run -d web-server --web-port 5000 --web-hostname localhost

to run a local webserver to avoid having to use a new chrome everytime I debug anything.

My problem is the following and pretty simple : I have code that crashes in release mode when webApp is built and deployed on github pages, but the stack is impossible to understand, also this very code doesn't crash when I test it in debug mode ( again the error stack looks like this ):

main.dart.js:4315 Uncaught TypeError: n.gawc is not a function
    at main.dart.js:22638:13
    at aAA.a (main.dart.js:5512:62)
    at aAA.$2 (main.dart.js:39196:14)
    at Object.E (main.dart.js:5498:10)
    at Object.QE (main.dart.js:22648:10)

the javascript is obfuscated so I don't know at which point it's hapenning, and if I want to test anything I need to build for web and upload on github pages, then wait 1 hour for it to be live to be able to see my prints in the console which are placed completely blind.

Is it possible to build for web in release mode locally?

Thank you for your time.

How does one host a web server that has an SSL certificate signed by a free provider like Cloudflare, without having an index.html

All I want is a javascript program running that has a domain name to itself. I want a client to be able to send a simple HTTPS request to this server, which can then interpret it and send commands out to other devices over the network using HTTP. I have all the juicy communication stuff prepared

send requests recieve requests

The problem arises when I directly reference the 'receive requests' server, the browsers don't like it being over HTTP so I must use HTTPS, but the certificate I have (self-signed) doesn't sit well with basically any of the security checks built into the browser. To get it signed by the authority, I must have a domain name rather than an IP. Which brings us back to the original problem, how can I host this second script with a domain name and its own URL, without dealing with any if that HTML stuff?

I tried hooking the browser up to my raspberry pi server directly over HTTPS but it decided to give a 'hey use HTTPS' error. So I generated a self-signed certificate but it complained that it wasn't signed by an authority it trusts. So I'll get my own domain running this script with a certificate and just force it to accept HTTP to the pi itself, but how do I do that without having a webpage running as well?

Why can't open the website when living abroad out of Vietnam?

I am interested at stocks in vietnam market, live abroad out of Vietnam,almost everytime can't open the HoChiMinh Stock Exchange website with browser,so i want to check what is happening in my PC:

 curl -I -v  https://www.hsx.vn
*   Trying 103.147.36.10:443...
* Connected to www.hsx.vn (103.147.36.10) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: C=VN; ST=Ho Chi Minh; L=Ho Chi Minh; O=HOCHIMINH STOCK EXCHANGE; CN=*.hsx.vn
*  start date: Oct  2 08:02:02 2023 GMT
*  expire date: Oct 19 10:11:04 2024 GMT
*  subjectAltName: host "www.hsx.vn" matched cert's "*.hsx.vn"
*  issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign RSA OV SSL CA 2018
*  SSL certificate verify ok.
> HEAD / HTTP/1.1
> Host: www.hsx.vn
> User-Agent: curl/7.74.0
> Accept: */*

Then the cursor stuck here ,the command--curl -I -v https://www.hsx.vn can't run to completion,it only output part of info as above,why?

The Most-Anticipated Movies of 2024

Get ready for a ton of sequels, threequels and prequels coming to the big screen in 2024, including some movies that were delayed due to the Hollywood strikes. Although the actors and writers strikes may have pushed back production and release dates for some films, moviegoers will still have plenty of choices in the coming [โ€ฆ]

set-cookie header not working

I'm developing a small site w/ Go and I'm trying to set a cookie from my server.

I'm running the server on localhost, with 127.0.0.1 aliased to subdomain-dev.domain.com on port 5080.

My When I receive the response for my POST to subdomain-dev.domain.com:5080/login I can see the set-cookie header. The response looks like this:

HTTP/1.1 307 Temporary Redirect
Location: /
Set-Cookie: myappcookie=encryptedvalue==; Path=/; Expires=Fri, 13 Sep 2013 21:12:12 UTC; Max-Age=900; HttpOnly; Secure
Content-Type: text/plain; charset=utf-8
Content-Length: 0
Date: Fri, 13 Sep 2013 20:57:12 GMT

Why isn't Chrome or Firefox recording this? In Chrome it doesn't show up in the Resources tab. In FF I can't see it either. And in neither do I see it in future Request headers.

How to fix the empty space between Logo and Navigation Menu?

This is the Live Demo of my header section, what can I do to fix the empty space between the logo and navigation menu?

I want both the image and .nav to come close towards each other, not one to lean towards the other, so that the empty space outside both is same.

.nav {
  display         : flex;
  align-items     : center;
  justify-content : space-between;
  margin          : 10px 100px;
  }
ul {
  display    : flex;
  list-style : none;
  }
ul li {
  padding : 8px 12px;
  }
.nav .logo {
  width   : 120px;
}
<div class="nav">
  <img class="logo" src="https://santabanta.co.in/wp-content/uploads/2023/11/vbes-2-1.png" alt="">
  <ul>
    <li><a href="">Classes & Services</a></li>
    <li><a href="">Pricing</a></li>
    <li><a href="">Kids & Family</a></li>
    <li><a href="">Workshop</a></li>
    <li><a href="">Training</a></li>
  </ul>
</div>
โŒ
โŒ