ReactJS: Unable to show code from C file which I fetch from rawgithub

I use the following code to fetch the C language files from RawGithub it works for other languages but in C it shows the HTML of my react app

const [code, setCode] = useState("");
useEffect(() => {
    fetch(codeRawUrl, {
      headers: {
          'Content-Type': 'text/plain'
        }
      })
      .then((response) => response.text())
      .then((text) => setCode(text));
  }, [codeRawUrl]);
 <code className={`language-${language} match-braces rainbow-braces`}>
    {code}
 </code>

Code from C language file from Github Raw

Cancel Payment Button in paystack not working

I am implementing payment gateway with paystack for the first time and I really don’t want to use third party packages for paystack. It is a React Native application. I wanted to implement it using react native webview. It is working so far but I can’t seem to get the cancel button to work. This is because the button is not responding when clicked. If the button responded and invoked the paystack onClose URL https://standard.paystack.co/close, I would have simply checked for it and close the webview state.

So, how do I handle this? The button can’t be there without doing anything. Can I use javascript and hide it and create my own custom button that actually works on click?: Here is the code I have tried so far:

const { url } = value
if (!url) return;
webView.current.injectJavaScript(handleCancle)

const customUrl = url.split('?');
const getCallBackURL = customUrl[0];
const queryStr = customUrl[1]
if(getCallBackURL == callback_url){
    setPaymentState(false);
    try {
        const res = await axios.get(`${BASE_URL}/payverify/?${queryStr}`);

        if(res?.data?.status == 'success'){
            
            const  payMentData = res?.data

             navigation.navigate('ThankyouPage', {payMentData})
        }
    } catch (error) {
        
    }
}

The code that tried listening to button click but not working:

const handleCancle = `
var buttons = document.getElementsByTagName('button');

   buttons.forEach((button)=>{
    if(button.innerHTML.includes('Cancel Payment')){
        button.addEventListener("click", function() {  
            console.log('it has happened')
            var resp = {event:'cancelled'};
            window.ReactNativeWebView.postMessage(JSON.stringify(resp))
                
            });
    }
    })
    }
  `

The webview:

 {
isPaymentSuccess && paymentState &&
<WebView 
javaScriptEnabled={true}
source={{ uri: paymentData }}
style={{ marginTop: 50 }}
onNavigationStateChange={ handleNav }
cacheEnabled={false}
cacheMode={'LOAD_NO_CACHE'}
ref={webView}


onMessage={(e) => {
    console.log('pressed')
    console.log(e.nativeEvent?.data)
 }}

 />
}

The error so far: No error. No response when the cancel button is clicked!

How to overlay raster image on apple mapkit javascript (not ios, not tile overlay)

How to overlay raster image on apple mapkit javascript (not ios, not tile overlay)

I known on ios, you can do this

https://www.kodeco.com/9956648-mapkit-tutorial-overlay-views

use mapView to add a raster image overly. But on MapKit JS version, there is no ‘MapView’

object like ios version does.

MapKit JS version, only provide Tile overlay, see here

https://roblabs.com/mapkit/

This is tile overlay sample for MapKit JS version.

https://roblabs.com/projects/mapkitjs/Tile-Overlay.html

Apple document is here

https://developer.apple.com/documentation/mapkitjs/tileoverlay/2974035-mapkit_tileoverlay

I can’t find any document says you can overlay a raster image on Mapkit JS version.

Do you have some idea to work around this ?

On ios, yes, you can overlay raster image, use MapView.overlay.

But on JS version, NO??????

three xml records at once xslt mobile pagination – p.II

Back for this rather old problem about stacked paged display xml nodes on three columns.
The original question was raised up here:
three records at once xml mobile pagination on xslt
Thing is that here,
xpath predicate to limit xml nodes display
for being very glad of the way display was provided I totally forget about pagination mechanism.
I mean there were a great need for a couple of js functions (at least) to be bound over the pagination links in order for these to work.
But here is still another requirement (second one):

  • through this xml file (which I’ll show it here in a sec) there are some sub-records associated with the principal ones. And as one will display in a couple of pictures, by clicking on some small [+] sign those sub-records will expand, thus showing them accordingly. That [+] sign turned into [-] sign. And when clicked again over that [-] sign those sub-records will collapse, the displaying only showing but principal node records.
    The “pictures” are as follows:
|===========|---------------|-------------|------------|  
|   FNAME   |   Smith [+]   |  Ken   [+]  | Susan [+]  |
|===========|---------------|-------------|------------|
|   LNAME   |   Milton      |  Jackson    | Arkland    |
|===========|---------------|-------------|------------|
|    AGE    |     44        |     37      |    48      |
|===========|---------------|-------------|------------|
| ADDRESS   |5th smmr st,mntb9th Pnfeld ave 34th Mansfield st 
|===========|---------------|-------------|------------|                                        
|    CITY   |   Portland    |   Kelowna   |  Raleigh   |
|===========|---------------|-------------|------------|
|                  <<   <  1/4  >  >>                  |
|=======================================================
                 Fig. 1 First Page
           - all sub-records collapsed; one could
             notice that little [+] sign on the very 
             1'st line next over each and every name
              
|===========|---------------|-------------|------------|  
|   FNAME   |  George  [+]  |    Ron  [+] | Marie-Ann  |
|===========|---------------|-------------|------------|
|   LNAME   |    Bond       |    Davis    | Spencer    |
|===========|---------------|-------------|------------|
|    AGE    |      35       |    37       |    48      |
|===========|---------------|-------------|------------|
| ADDRESS   |5th drive, mntb|12th Greenfld ave 273 Simpson square                
|===========|---------------|-------------|------------|                                        
|    CITY   |   Albany      |    Pheonix  |  Oklahoma  |
|===========|---------------|-------------|------------|
|                  <<   <  2/4  >  >>                  |
|=======================================================
                   Fig. 2 Second Page
     - by clicking over either links (< - prev  , > - next
       << - first or >> - last) the records displaying
       will push backward or forward conesequently
       (sub-records still collapsed ...)
       
|==========|-------------|----------|-----------|------------|  
|   FNAME  |   Smith [-] |chld Name | Ken [+]   | Susan [+]  |
|==========|-------------|----------|-----------|------------|
|   LNAME  |   Milton    |  Smith   |  Jackson  |  Arkland   |
|==========|-------------|----------------------|------------|
|    AGE   |     44      |chld Sname|     37    |    48      |
|==========|-------------|----------|-----------|------------|
| ADDRESS  |5th smmr st,   Terry            Mansfield st     |
|==========|-------------|--------  |-----------|------------|                                        
|    CITY  |   Portland  |chld age  |  Kelowna  |  Raleigh   |
|==========|-------------|----------|-----------|------------|
|                       <<   <  1/4  >  >>                   |
|=============================================================               
       Fig. 3 First Page with vertically sub-records expanded
          - on the first page (Fig.1) by clicking over that
            [+] sign on top of every table's column header
            those corresponding sub-records (children stuff)
            wil get expanded (but vertically !) and be shown as such 

The xml file is this:

<persns> 
 <prsn> 
  <fname>Smith</fname> 
  <lname>Milton</lname> 
  <age>44</age> 
  <addrss>5th summer st, mntb</addrss>
  <city>Portland</city>
  <children>
    <child>
      <name>Smith</name>
      <sname>Terry</sname>
      <c_age>12</c_age>
    </child>
  </children>
 </prsn>
 <prsn> 
  <fname>Ken</fname> 
  <lname>Jackson</lname> 
  <age>37</age> 
  <addrss>19th Penfield ave, brtcl</addrss>
  <city>Kelowna</city>
 <children>
   <child>
     <name>Jackson</name>
     <sname>Grace</sname>
     <c_age>8</c_age>
    </child>
  </children>
 </prsn>
 <prsn> 
  <fname>Susan</fname> 
  <lname>Arkland</lname> 
  <age>48</age> 
  <addrss>34th Mansfield st, sgtp</addrss>
  <city>Raleigh</city>
 <children>
   <child>
     <name>Patton</name>
     <sname>Don</sname>
     <c_age>14</c_age>
    </child>
   <child>
     <name>Arkland</name>
     <sname>Rob</sname>
     <c_age>11</c_age>
    </child> 
 </children>
 </prsn>
 <prsn> 
  <fname>George</fname> 
  <lname>Bond</lname> 
  <age>35</age> 
  <addrss>5th drive, mntb</addrss>
  <city>Albany</city>
   <children>
    <child>
      <name>Bond</name>
      <sname>Areene</sname>
      <c_age>10</c_age>
    </child>
  </children>
 </prsn>
 <prsn> 
  <fname>Ron</fname> 
  <lname>Davis</lname> 
  <age>37</age> 
  <addrss>12th Greenfield ave, brtcl</addrss>
  <city>Pheonix</city>
  <children/>
 </prsn>
 <prsn> 
  <fname>Marie-Ann</fname> 
  <lname>Spencer</lname> 
  <age>48</age> 
  <addrss>273 Simpson square</addrss>
  <city>Oklahoma</city>
 <children>
   <child>
     <name>Spencer</name>
     <sname>David</sname>
     <c_age>16</c_age>
    </child>
   <child>
     <name>Spencer</name>
     <sname>Tina</sname>
     <c_age>13</c_age>
    </child> 
 </children>
 </prsn>
<prsn> 
  <fname>David</fname> 
  <lname>Rhonson</lname> 
  <age>45</age> 
  <addrss>255 Lakeland Terrace, mi</addrss>
  <city>Livonia</city>
 <children/>
 </prsn>
<prsn> 
  <fname>Buddy</fname> 
  <lname>Clark</lname> 
  <age>53</age> 
  <addrss>Lkeshore Lane
Zion, il</addrss>
  <city>Oneonta</city>
 <children>
   <child>
     <name>Clark</name>
     <sname>Susan</sname>
     <c_age>17</c_age>
    </child>
   <child>
  </children>
 </prsn>
 <prsn> 
  <fname>Peggy</fname> 
  <lname>Johnson</lname> 
  <age>42</age> 
  <addrss>w.Devon ave.
Monroe Township, nj</addrss>
  <city>New Jersey</city>
 <children>
   <child>
     <name>Friedmann </name>
     <sname>Joseph </sname>
     <c_age>17</c_age>
    </child>
   <child>
     <name>Johnson</name>
     <sname>Denise </sname>
     <c_age>14</c_age>
    </child> 
 </children>
 </prsn>
<prsn> 
  <fname>Julie</fname> 
  <lname>Nelson</lname> 
  <age>35</age> 
  <addrss>Wagon st.
Springfield,pa</addrss>
  <city>Pennsylvania</city>
 <children>
   <child>
     <name>Nelson</name>
     <sname>Patrick</sname>
     <c_age>9</c_age>
    </child>
   <child>
  </children>
 </prsn>
</persns>

And the corresponding stylesheet is this:

<xsl:stylesheet version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>

<xsl:param name="pag" select="1"/>
<xsl:param name="frme" select="3"/>

<xsl:template match="/persns">
  <xsl:variable name="start" select="($pag - 1) * $frme + 1"/>
  <xsl:variable name="rec" select="prsn[position() ge $start and position() lt $start + $frme]"/>
  <table border="1">
   <xsl:for-each select="$rec[1]/*">
    <xsl:variable name="i" select="position()"/>
   <tr><th>
    <xsl:value-of select="name()"/>
    </th>   
   <xsl:for-each select="$rec">
    <td>
    <xsl:value-of select="*[$i]"/>
    </td>
   </xsl:for-each>
   </tr>
  </xsl:for-each>
 </table>
</xsl:template>

</xsl:stylesheet>

And the last part will be the js functions which should be bound over the pagination links/buttons for the whole process kicked off.
So, the two requirements on brief :

  • vertical expand/collapse of xml sub-records when clicked over those [+]/[-] signs
  • pagination mechanism (through some js) which allows moving backwards / forwards
    Really hope I made myself clear enough for one to Really understand my needs.
    Thank you very much and please you guys help me with all these

why am I getting an invalid token standard error?

I want to update the metadata of an NFT using metaplex js library,

I followed the docs but I keep gettin an invalid token standard error.

const new_uri = await metaplex.nfts().uploadMetadata(
    uri_obj,
) 

await metaplex.nfts().update({ 
    nftOrSft: nft,
    uri:new_uri.uri
});

I created a new storage unit in airweave and got it’s url but I keep getting the error
and not just on the url but when I try to change the name for testing purposes aswell.

full error:

return resolvedError ? new ProgramError.ParsedProgramError(program, resolvedError, error.logs) : new ProgramError.UnknownProgramError(program, error);
                           ^

ParsedProgramError: The program [TokenMetadataProgram] at address [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s] raised an error of code [135] that translates to "Invalid token standard".

Source: Program > TokenMetadataProgram [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s]

Caused By: InvalidTokenStandard: Invalid token standard

Program Logs:
| Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1]
| Program log: Instruction: Token Metadata Update
| Program log: Invalid token standard
| Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 18628 of 200000 compute units
| Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: custom program error: 0x87

forEach problem: lineTo is not defined at CanvasRenderingContext2D

I tried using a forEach loop on an array of points and a canvas drawing context.
This is a simplified sample:

<html>
<head>
<<script>
function showPoints(ctx,data) {
  ctx.beginPath();
  ctx.moveTo(0,0); 
  ctx.lineTo(0,  data[0]);
  data.forEach(function(pt,i){
      lineTo(10*i, pt);
      lineTo(10*(i+1), pt);  
  },ctx);
  ctx.stroke();
}
</script> 
</head>
<body>
<canvas width="500" height="500" id="myCanvas">
<script>
  const data = [10,20,25,30,25];
  const c = document.getElementById('myCanvas');
  const ctx = c.getContext("2d");
   
  showPoints(ctx, data);
</script>
</body>
<html>

This fails with ReferenceError: lineTo is not defined at CanvasRenderingContext2D

Sure, ctx.lineTo is defined, used before and still visible directly above the forEach line.

Passing ctx as a this parameter seems ok as well, in my understanding of the error message.

Any hints what I’m doing/understanding wrong, please? (javascript is not my native language)
Sure I could replace the forEach construct, but I want to learn its usage.

Uncaught Error FirebaseError: Function CollectionReference.doc() cannot be called with an empty path

here show: var cod = document.getElementById(“codigo”).value;————- I get an error when I want to pass the cod variable of the document.getElementById — doc(cod); show error.– How do I make the query in firestore?

Uncaught Error FirebaseError: Function CollectionReference.doc() cannot be called with an empty path.
    at Br (d:Documentosapp web 2firebasejsfirestoredistprebuilt.js:184:9)
    at Xd (d:Documentosapp web 2firebasejsfirestoredistprebuilt.js:14495:19)
    at gp (d:Documentosapp web 2firebasejsfirestoredistprebuilt.js:14886:44)
    at im.doc (d:Documentosapp web 2firebasejsfirestoredistprebuilt.js:18010:79)
    at mostrarFila (d:Documentosapp web 2ventas1ventas1.js:24:44)
    at onclick (d:Documentosapp web 2ventas1ventas1.html:49:105)
Br @ d:Documentosapp web 2firebasejsfirestoredistprebuilt.js:184:9
var db = firebase.firestore();

var cod = document.getElementById("codigo").value;
//para que me muestre la tabla del tbody todas las filas con sus columanas
var tabla =document.getElementById("tabla");

function mostrarFila(){
    var docRef = db.collection("Producto").doc(cod);/* aca está el error*/

tabla.innerHTML= "";

docRef.get().then((doc) => {
    if (doc.exists) {
        console.log("Document data:", doc.data().codigo);

    } else {
        // doc.data() will be undefined in this case
        console.log("No such document!");
    }
}).catch((error) => {
    console.log("Error getting document:", error);
});
}

How to check hard drive health?

I’m facing a problem with my hard drive, and I’m not sure how to check its health. I’ve noticed that my computer is running slower than usual, and some of my files are taking longer to load. I’m worried that there might be something wrong with my hard drive, but I don’t know how to check for errors or other issues.

I’ve tried running a virus scan and cleaning up my system files, but that hasn’t seemed to help. I’ve also tried defragmenting my hard drive, but that hasn’t improved the performance either. I’m not sure what else to do to check the health of my hard drive and fix any problems that might be causing these issues.

If anyone has any advice or suggestions on how to check the health of a Hard Drive or troubleshoot performance issues, I would greatly appreciate it. I need to get my computer running smoothly again, and I don’t want to risk losing any important data if my hard drive is failing.

React typing effect on 3 containers with strings

I’m trying to create a typing effect in React on 3 containers that are lined up and holding strings within them. The effect should start from the leftmost container after it finishes typing its string, it starts the container that comes after it, and so on.

I started with an idea where I store all the strings in an array and initialize a new array called currentText with a new letter every second but I probably just made things more complicated for myself.

Perhaps there is a simpler solution?

My complicated and not working solution looks like this:

    const [text, setText] = useState([]);
    const [currentIndex, setCurrentIndex] = useState(0);
    const [currentText, setCurrentText] = useState([]);


    // Setting Text Content For Typing
    useEffect(() => {
        if(log && log.length > 0 && text.length == 0){
            log.map((item, key) => {
                let time = item['time'];
                let message = item['message'];
                let event = item['eventid'];
                setText((prev) => [...prev, time, message, event]);
            });
        }
    }, [log, text]);


    useEffect(() => {
            if(currentText?.length < text?.length){
                const interval = setInterval(()=> {

                    // Setting Current index
                    if(currentText?.length !== 0 && currentIndex !== currentText?.length -1) {
                        setCurrentIndex(currentText?.length -1);
                    }
                    
                    // Check if the last index string completed
                    if(currentText[currentIndex]?.length !== text[currentIndex]?.length){
                        let temp = currentText;
                        let lastText = temp[currentIndex];
                        if(lastText) lastText = lastText + text[currentIndex].charAt(lastText?.length -1);
                        else lastText = text[currentIndex].charAt(0);
                        temp[currentIndex] = lastText;
                        setCurrentText(temp);
                    }
                    // If completed open new array element to contain new string
                    else{
                        setCurrentText((prev) => [...prev, ['']]);
                    }
            }, 1000);
            return () => clearInterval(interval);
            }

    }, [currentText, text, currentIndex]);


return (
    <>
       {
          currentText && currentText.length > 0 && 
                    currentText.map((item, key) => {
                            <div key={key} className={classes.row}>
                                <span className={classes.time}>{currentText[key]}</span>
                                <span className={classes.message}>{key % 1 ? currentText[key] : currentText[key+1]}</span>
                                <span className={classes.event}>{key % 2 ? currentText[key] : currentText[key+2]}</span>
                            </div>
                        })
        }

Will chat Gpt finish web developers? [closed]

So I learned advanced HTML and CSS and now moving towards javascript I’m afraid that after learning js it will waste my time as chat gpt will take over so should I advance towards python for Artificial Intelligence as the future there is more promising? Kindly motivate me for front-end web development as I am lost

I think I am wasting time learning HTML, CSS, and js

Auto-append a Staff Notice when a member is part of a group

I’ve tried using JS to auto-append a staff notice to an auto-generated account if it is a member of the group “autogenerated” but I’m not sure where I’m going wrong.

<script>
   window.onload = function() {
     const { groupMembers } = await discourse.groups.getMembers({
       group_name: 'autogenerated'
     });

     if (groupMembers.includes(helper.getModel().user_id)) {
       return helper.h('div.post-notices', [
         helper.rawHtml(iconHTML('shield-alt')),
         helper.h('p', 'This account is auto-generated and should be considered as a bot. The account is not monitored by Staff.')
       ]);
     }
   }
 </script>

I’ve put the code in the “Head” part of our component, however, it’s not running. I’m not sure if it isn’t calling the function correctly, or if my IF statement suddenly isn’t being met.

firebase authentication persistence in electron

I’m trying to sign in a user with signInWithEmailAndPassword() but after signing the user and moving to another BrowserWindow object and initializing the auth object again with the same firebase app .. the auth.currentUser property shows as null.

I tried using the onAuthStateChanged observer as following :

onAuthStateChanged(auth,(user) => {
    console.log(user)
})

and I also tried setting the persistence using setPersistence :

onAuthStateChanged(auth,(user) => {
  setPersistence(auth,browserLocalPersistence).then(console.log(user))
})

both ended up giving me a null user