Calculating width and height attributes with the image plugin (tinymce)

I have a question about the standard image plugin for TinyMCE. You can read about it here: link. To describe the issue, please try the following:

  1. Open this https://codepen.io/kxfjxbja-the-vuer/pen/BaEQEwR
Code with tinymce v6.
  1. You will see an image inserted twice. One of them has the style “max-width:200px;”

  2. Right-click on the first image.

  3. Click “Image.”

  4. You will see the “Image” window with empty attributes width and height.

  5. Simply click Save.

  6. If you open the “Image” window again, you will see that the width and height attributes have been automatically calculated. Issue: they are calculated from the styles, not from the actual dimensions of the image.

  7. Do the same with the second image. You will see that the width and height are different, although it is the same image with different styles.

What I want: for the reduced image, the width and height attributes to be determined from the actual dimensions of the image, not from the styles.

Why do I need this: I want to see the images in the editor reduced. Large images are inconvenient when designing an article. So I added CSS to my website to reduce the images in the editor. But when I edit image properties, small width and height attributes are applied to it. And after publishing, they remain small, which I don’t need.

recursive function without recursive prompt

I’m trying to call recursive factorial function in javascript, but prompt keeps on going.

function recursiveFactorial() {
        var a = parseInt(prompt("Enter a Number: "));
        if (a === 0) {
            return 1;
        } else {
            facValue = (a * recursiveFactorial(a - 1));

        }
        alert("The factorial of " + a + " is: " + facValue);

}

Flatlist scroll to top onChange text in React native

There is an issue in my flatlist when typing anything in the text-input field it scrolls to the top position it should stay at the current position. my code is

         ```<FlatList
              onScroll={(e)=>{
                this.setState({scrollPosition:e.nativeEvent.contentOffset.y})
              }}
              ref={this.flatListRef}
              style={listStyles.GrayListContainer}
                data={postsList.data}
                keyExtractor={postsList.data._id}
                ListFooterComponent={
                  postsList.data.length > 0 ? (
                    <Loaders data={postsList} />
                  ) : (
                    ""
                  )
                }
                onEndReached={() => {
                  postsList?.next_page_url !== null && this.fetchMoreData();
                }}
                onEndReachedThreshold={4}
                keyboardShouldPersistTaps="handled"
                listKey={(item2, index) => "M" + index.toString()}
                removeClippedSubviews={true}
                onContentSizeChange={()=>{
                    this.flatListRef.current.scrollToOffset({offset: this.state.scrollPosition, animated: false  })
                }} />```

How to read a .bin file and display the extact content of it in a table cell?

I want to read a .bin file via file chooser and I’m using below code, which works fine.

var inp2 = document.createElement("input");
inp2.type = "file";
inp2.accept = ".bin";
inp2.setAttribute("id", "myFile");
                    
function readSingleFile(e) {
     var file = e.target.files[0];
     if (!file) {
         return;
     }
     var reader = new FileReader();
     reader.onload = function(event) {
        var fileResult = reader.result;
        binaryContent = fileResult.slice(fileResult.indexOf(",")+1);  // It is in base64 format
     };                 
     reader.readAsDataURL(file);
}

inp2.addEventListener('change', readSingleFile, false);

This is working fine and I’m able to store this binaryContent in the base64 format in the Oracle Nosql database.

But, I’m stuck at how to get back the original content of the file and display it to the users in one of the columns(cells) of a table.

I’m attaching the sample file contents for the reference.

<95>Eù^F½^N^K:Ã<8c>k5(^G,<89>^U0 Ã<9d>I¶.hâòªÃ<96>@w=<<8c>n$9S^Vòöön<8e>²Ã<8f>íBae&ã#sâv6<8a>]¼<88>±<80>y<9f>3¬<9c>^Dø¡=^S<90>aÃ<97><97>Ã<83>Ã<86>®DÃ<92>^OÃ<9b><9a>^CÃ<99>ºf<90>ùBæöÃ<89>*<82>á£^X<8c>Ã<9c> +e<92>Ã<8e>Ã¥<84><90>®      F
^O<¡^@Ã<86>Ã<8a>Ã<8e>J^Tò9<84>T<85>¤Ã<99><9d>^VJDÃ<91>1 ^F<87> <8f>îoÃ<81>Ã<94>4-Q=ç^Hf¨¤ä2<96>­6¤ï<8b>äKzMkëYPÃ<9d><94>áaOµü+42«ë^X^PHÃ<8d>¹±<84><8d>óO<95>ã5L¼/<96>³½±Nª<93>P<8b>Ã<99><86><81><98>©ý^Ar^Záµ^Z<9a>V)Ã<93>/^[²<92>Ã<8d>YC¾^MwT^L^Sõ<97>Ã<9c>ïÃ<8c>ï'¾^LRf>2C/Ã<97>Ã<84>®<9a>Ã¥^DýdVz#tb.<8f>^E"<97><96>U^X:CI<8a>=<2Uu<86>Ã<8b>Ã<8a>^EîÃ<9d>^B^P^^G^Q^Uö{  6^_Ã<9c>ZJl^Y^CÂ¥^^6'Ã<9f>^Z<80>ïÃ<84>Ã<82>Ã<84>æ0L<8c>Ã<9b>¾Ã<96> eÃ<89>>^N[<95>¸çÃ<80>(<9f>Ã<94><8c>®B^^iÃ<93>9u,Ã<8d>^<9b>aò¸'Ã<99>^O­^S7^_s<îê¸e<9e>^Ã<97>^Tal0 Ã<85><9b><85>^X<8a>^Gý<83>%Ã<88>læNÃ<96>^Qh­Ã<97>^ZWï:M·¾<87>ñ<8c>Ã<8a>^XnÃ<9d>^ByBkY·^QÃ<94>^T¤^R:øs¨a^As<92><98>n^ZÃ<86>qÃ<90>7Ã<94>ªÃ<84><82>¤P^Uè)Ã<9d> 1¾Z¯Xíû¦:deï^@Ã<82>â%+Ã<83>¨Jfw°        ø)ähzyáù<9d>n³h^^·0zá<90>k<8a>~<9e>qÃ<96>^NíÃ<91>Ã<8b><88>ué^A]Ã<90>Ã<8f><8d>ý¼Ã<9f>Ã<9a>ì^Ã<98><88>®ë4t¸<81>@Ã¥ei      Ã<87>øÃ<91>lªq³<8b>³Ã<97>^Y^DÃ<85><99>mÃ<99>Ã<81>FÃ<9c>N<98>ð¤Ã<91>Ã<8a><96>¬Ã<9d>^_|Ã<9c>»CGÃ<8f>^L'¹<83>^Oe^X¨ä÷<8b>ªRÃ<9d><8f><83>9^D¡i®+.:NìRÃ<82>CÃ<88><87>ì(¦U^S¯<86>Ã<83>>äB^V;Ã<96><8b>H<91>,AX:ugB^FV<9d>{lÃ<89>Hò<92>Ã<9c><8c><83>,î=t2"^OUf^G^WRc÷<93><96>²jF)<8a>6^g'$Y^[<86><8a>BN    Ã<82>^PzNë¸<9f>a4Ã<8b>^F°^VÃ<87>;ì­Ã<89>·o^F^GG|PÃ<9a>^BKH§sÃ<8b>yý Ã<9a>F^X$ò^Cº°<91>íÃ<83>^Q0Ã<9c>apÃ<9d><96>mY¯~ö

How to implement excel formula intelligence/suggestion using java-script or any third party library?

I am developing excel add-in using office-js API. I want to implement excel formula intelligence functionality – when the user types formula in input box it shows suggestions of formula and parameters of formula. Is it possible to implement using java-script or any third party library?

Screenshots of functionalities that I want to implement with my input textbox.
enter image description here

enter image description here

How to Set a Permanent PATH for npm on Unix/Linux Systems

I’ve encountered an issue with npm not working properly in my Unix/Linux environment. To temporarily resolve the issue, I executed the following command in my terminal:

export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH

After setting the temporary PATH, running npm start worked fine. However, since this solution is temporary and resets after closing the terminal, I’m looking for a way to permanently set the PATH environment variable to include the necessary directories for npm to operate correctly.

How can I permanently modify the PATH environment variable to ensure npm works without needing to reset the PATH every time I open a new terminal session?

How to get values in Razor View ASP NET CORE 6

I working on Invoice Function . I create a seletec box to select the product i want to invoice.Here my razor view

IEnumerable<ProductItem> lstProduct = ViewBag.ListProduct as IEnumerable<ProductItem>

<select class="ddlProduct" name="ddlProduct">
    @foreach (var item in lstProduct)
    {
        <option value="@item.ProductItemsId"> @item.Product.ProductName</option>
    }
</select>
   <select class="ddlSize" name="ddlSize">
       @{
          
           var list = lstSize.Where(n => n.ProductItemsId == selectedProductId);
           foreach (var item in list)
           {
               <option value="@item.ProductItemsId"> @item.Size.SizeName</option>
           }
       }
   </select>
   <select class="ddlColor" name="">
       @foreach (var item in lstColor)
       {
           <option value="@item.ProductItemsId"> @item.Colors.ColorName</option>
       }
   </select> 

The website will be like this enter image description here

I want when a user changes a product, the color and size will also change accordingly the product id of that product. My design database enter image description here

So there is anyway that i can get the productItemsID and pass to Size select box and Color
to get corresponding products

I working on Invoice Function . I create a seletec box to select the product i want to invoice.Here my razor view

IEnumerable<ProductItem> lstProduct = ViewBag.ListProduct as IEnumerable<ProductItem>

<select class="ddlProduct" name="ddlProduct">
    @foreach (var item in lstProduct)
    {
        <option value="@item.ProductItemsId"> @item.Product.ProductName</option>
    }
</select>
   <select class="ddlSize" name="ddlSize">
       @{
          
           var list = lstSize.Where(n => n.ProductItemsId == selectedProductId);
           foreach (var item in list)
           {
               <option value="@item.ProductItemsId"> @item.Size.SizeName</option>
           }
       }
   </select>
   <select class="ddlColor" name="">
       @foreach (var item in lstColor)
       {
           <option value="@item.ProductItemsId"> @item.Colors.ColorName</option>
       }
   </select> 

The website will be like this

I want when a user changes a product, the color and size will also change accordingly the product id of that product. My design database
[2]: https://i.stack.imgur.com/59qTU.png

So there is anyway that i can get the productItemsID and pass to Size select box and Color
to get corresponding products

I have javascript many way but it wont work. Does anyone got solution ? I really appreciate your contribution

What is the difference between these 2 JavaScript functions using return?

So I’m learning JS, regarding functions and the use of return. Is there a functional difference between these 2 functions? They are both supposed to be BMI calculators. I’ve tested them out, and the first one works once you call the function and set a weight/height.

1.)

function bmiCalculator(weight, height){
    return bmi = Math.round(weight / Math.pow(height, 2));
} 

2.)

function bmiCalculator(weight, height){
    var bmi = Math.round(weight / Math.pow(height, 2));
    return bmi;
}

1.) works once I call function:

bmiCalculator(65, 1.8);

shows 20 on console

2.) works once I code:

var bmi = bmiCalculator(65, 1.8);
console.log(bmi);

shows 20 on console

React Suppress Warning in browser

I have similar React application code deployed in 2 places (one in a Microfrontend setup and one in a non-Microfrontend setup)

Now when running in the Microfrontend setup, I see the below warning in browser;

Warning: Cannot update a component (`ParentComponent`) while rendering a different component (`ChildComponent`). To locate the bad setState() call inside `ChildComponent`, follow the stack trace as described

But I do not see the same in the non-Microfrontend setup

Not sure what might be suppressing the message. Is it possible to suppress these warning messages via some config in the code?

ReferenceError: ReadableStream is not defined using Puppeteer’s page.pdf() on AWS

I have implemented a PDF download feature in my current project using Puppeteer. I’m hosting the project on AWS with Node 18.

Locally, it works perfectly fine, but in production when I hit the PDF download API, it returns the following error: ReferenceError: ReadableStream is not defined.

Puppeteer version is 22.3.0

Here is the Puppeteer code:

public getReportPdf = async(req: Request, res: Response) = >{
  const browser = await puppeteer.launch();
  const page = await browser.newPage();

  try {
    const {
      reportId
    } = req.params;
    const reportData = await this.reportRepo.getJobAndTemplateWithReport(reportId);
    const htmlData = await ejs.renderFile('src/helper/templates/report.ejs', {
      record: reportData[0],
      reportOverview: REPORT_OVERVIEW
    });
    const image = await getBase64Image('https://maxscaffold-front-stg.taskgrids.com/assets/images/Max-Builders-Default.png') // Need to pass here companyLogo url
    await page.setContent(htmlData);
    const pdfBuffer = await page.pdf({
      displayHeaderFooter: true,
      headerTemplate: ` < div style = "font-size: 10px; display: flex; justify-content: center; align-items: center; margin-left: 300px" > <div > Powered by < /div>
        <img style="height: 50px; width: auto; margin-left: 5px" src="data:image/png;
      base64,
      $ {
        image
      }
      "/>
        </div>`,
        format: 'A4',
        printBackground: true,
        preferCSSPageSize: true,
        scale: 0.8,
        margin: {
          top: '100px',
          bottom:'50px'
        }
      });
      await page.close();
      await browser.close();

      const savepath = `./${STORAGE_BUCKET.DEFAULT}/${reportId}_report.pdf`;

      fs.writeFile(savepath, pdfBuffer, (err) => {
        if (err) {
          console.log('err', err);
        }
      });
      setTimeout(() => {
        fs.promises.unlink(savepath);
      }, 25000);

  
      const data = process.env.NODE_URL + `api/images/${reportId}_report.pdf`;
       return generalResponse(req, res,data, successMessage.REPORT_DISPLAY_SUCCESS, true, responseFlag.SUCCESS);
    } catch (error) {
      await page.close();
      await browser.close();
      return generalResponse(req, res, error, errorMessage.SOMETHING_WRONG, false, responseFlag.ERROR);
    }
  };"

Can anyone please help me to resolve this issue?

I have tried Node version 18 locally, then it works perfectly, but I don’t know why in production it gives an error.

This is error message which I get from the server

Error message (I’m not sure which line is causing the error):

error:  ReferenceError: ReadableStream is not defined
at getReadableFromProtocolStream (/var/www/max-scaffolds/backend/node_modules/puppeteer-core/lib/cjs/puppeteer/common/util.js:241:5)
at CdpPage.createPDFStream (/var/www/max-scaffolds/backend/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Page.js:845:66)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async CdpPage.pdf (/var/www/max-scaffolds/backend/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Page.js:849:26)

How do I create a standalone app that saves inputs that can be recalled from memory after restarting the app?

How to create a standalone android application that saves inputs that can be recalled after restarting. Without using ‘import’ modules…

For example, when started the application opens in its own window, then asks…

1. Input
2. Recall

and if selecting ‘1’ I can enter any fact, using proper coding of course i.e.

bird = flying animal with feathers
pi = 3.14159
bedtime = 10.15pm

and stores the facts in it’s standalone program until opened again and then I can enter ‘2’ and ask it i.e.

"What is a bird?"
"What is pi?"
"What is my bedtime?"

and the program uses the inputs to figure out what is being asked and answers the questions.

I have tried using

```
def submit():
    data={
        }
```

and

```
open with('')
```

codes but these don’t apply to a standalone application.