Modify JavaScript class for all future instances

I am customizing a javascript application using the framework the application gives. I am able to modify the code of a single file.

I’ve found a bug in the application itself and I’d like to correct it from the single file I’m given. Typically, this could be achieved on a single instance with something like this:

class A {
    doathing(){
        console.log("A thing");
    }
}
let a = A();
a.doathing = () => console.log("A different thing");
...
a.doathing() // log: A different thing

But in this case I don’t have access to the instance when I need to change the behavior. I need to change the class itself so that all future instances have the new behavior. So I’m looking for something like this:

class A {
    doathing(){
        console.log("A thing");
    }
}

darkmagic(A, () = console.log("A different thing"));
...
let a = A();
...
a.doathing() // desired log message is: A different thing

Is this possible? Is there a way I could create my own class that overrides it and then ensure everywhere else in the app that uses it uses my class? Any other crazy ideas?

Why does dialog’s returnValue show old value when it is cancelled with by pressing Esc on Firefox?

Check this dialog box implementation.

const open = document.getElementById('open')
const dlg = document.getElementById('dlg')
open.addEventListener('click', function () {
  dlg.showModal()
})
dlg.addEventListener('close', function () {
  console.log('You chose:', dlg.returnValue)
})
<button id="open">Open</button>
<dialog id="dlg">
  <form method="dialog">
    <p>Are you sure?</p>
    <button value="no">No</button>
    <button value="yes">Yes</button>
  </form>
</dialog>

Follow these steps:

  1. Run the above code snippet with Firefox.
  2. Click “Open” button.
  3. Click “No” in the dialog box.
  4. The console log shows You chose: no.
  5. Click “Open” button again.
  6. Cancel the dialog box by pressing Esc.
  7. The console log shows You chose: no.

Why does the console log show You chose: no in step 7. Shouldn’t dlg.returnValue be empty string in step 7 because the dialog box was canceled using Esc? I was expecting ‘You chose: ` in step 7.

I confirmed this with Firefox 143.

How to pass special chars to nodemailer?

I want to pass a string to nodemailer so that it results in

=C2=A0

i tried to pass in both 'Â ' (the literal chars), "xC2xA0", etc.

But they always result in =C3=A9

A longer example in case anyone can see a pattern. I pass chars that would result in:

=C2=A0=E2=80=8C=C2=A0=E2=80=8C=C2=A0=E2=80=8C=C2=A0=E2=80=8C=...

but get:

=C3=82=C2=A0=C3=A2=C2=80=C2=8C=C3=82=C2=A0=C3=A2=C2=80=C2=8C=...

i’m using only setting textEncoding: 'quoted-printable' in the options besides emails and html/text. Everything else is default.

If I pass the same string i’m sending to html on nodemailer via:

    let out = ""; // line is the string passed to nodemailer's html.
    for (let k = 0; k < line.length; k++) {
        const code = line.charCodeAt(k);
        out += "=" + code.toString(16).toUpperCase().padStart(2, "0");
    }
    console.log(out);

I do get the expected output just fine.

Roadmap to learn react native as a beginner

I’m just starting with React Native and want to build real-world apps, but I feel overwhelmed by the ecosystem (Expo vs. CLI, navigation, state management, animations, etc.).

I’ve checked the official React Native docs, which are helpful for setup, but I’m looking for a structured roadmap or learning path that tells me what core concepts and libraries I should focus on first as a beginner

What would a practical roadmap for learning React Native look like for a beginner?
Which topics should I prioritize before moving into advanced libraries (e.g., Redux, Reanimated, TypeScript)?

Jenkins Active Choice HTML parameter not updating hidden value field with dynamic JS in Groovy script

Description: I’m using the Jenkins Active Choices Plugin to build a dynamic UI with parameters for test suites and their arguments.
I have two parameters:

  1. SUITES (Active Choice Checkbox): Lets the user select one or more test suites from a list, populated by parsing the contents of a
    file.
  2. SUITES_ARGUMENTS (Active Choice HTML): For each selected suite, shows argument textboxes. These are dynamically created via Groovy.
    I want the values entered in the textboxes to be serialized (as
    “Suite:args;Suite2:args2″) and stored in the hidden parameter field
    (input[name=”value”]) so Jenkins can consume it in the pipeline.

I inject JavaScript in the HTML that listens for input changes and updates the hidden field.
However, the hidden field never updates as expected. It either remains blank, gets the wrong value, or the JS doesn’t execute at all.

My Groovy code for the parameters is:

activeChoice(
    choiceType: 'PT_CHECKBOX',
    filterLength: 1,
    filterable: false,
    name: 'SUITES',
    description: 'Test suite to execute.',
    script: groovyScript(
        script: [
            sandbox: true,
            script: """
                def procedures = 'cat /var/lib/jenkins/workspace/Atf_Tests_AAIO/procedures'.execute()
                def procedures_names = procedures.text.split('\\n').collect { line ->
                    // Split at " - Arguments" and take the first part (the test name)
                    line.split(' - Arguments')[0].trim()
                }.sort()
                return procedures_names
            """
        ]
    )
),
activeChoiceHtml(
    choiceType: 'ET_FORMATTED_HTML',
    name: 'SUITES_ARGUMENTS',
    description: 'Arguments for selected test suites',
    referencedParameters: 'SUITES',
    omitValueField: false,
    script: groovyScript(
        script: [
            sandbox: true,
            script: '''
                def selectedSuits = SUITES instanceof List ? SUITES : (SUITES ? SUITES.tokenize(",")*.trim() : [])
                def procedures = 'cat /var/lib/jenkins/workspace/Atf_Tests_AAIO/procedures'.execute()
                def procedures_names = procedures.text.readLines().findAll{ it?.trim() }.sort()

                def html = []
                html << "<div><b>Provide arguments for each selected suite that requires them:</b></div>"
                html << "<div><small>Leave empty to use default.</small></div>"

                selectedSuits.each { s ->
                    // find the line that starts exactly with the suite name
                    def line = procedures_names.find { it.trim().startsWith(s) }
                    if (line) {
                        def parts = line.split(' - Arguments: ', 2)
                        def defaultArgs = parts.size() > 1 ? parts[1].trim() : ''
                        if (defaultArgs) {
                            def argList = defaultArgs.split(',').collect { it.trim() }
                            def safeId = s.replaceAll(/[^A-Za-z0-9_\-]/, "_")
                            def suiteName = parts[0].trim()

                            html << "<div style='margin-top:6px'><strong>${suiteName} - Arguments: ${defaultArgs}</strong></div>"

                            argList.eachWithIndex { arg, idx ->
                                html << """<div style='margin-bottom:4px'>
                                        <label for='${safeId}_arg_${idx}' style='display:inline-block; width:150px;'>${arg}:</label>
                                        <input type='text' class='suite-arg' name='${suiteName}' 
                                            data-arg-idx='${idx}' placeholder='${arg}' style='width:400px; margin-bottom:2px;' /><br/>
                                        </div>"""
                            }
                        }
                    }
                }

                // JS: serialize as "Suite:args;Suite2:args2"
                html << """<script>
                (function() {
                    function updateValue() {
                        var suites = {};
                        document.querySelectorAll('.suite-arg').forEach(function(inp) {
                            var suite = (inp.getAttribute('name') || '').trim();
                            if (!suite) return;
                            var argName = inp.getAttribute('placeholder') || 'ARG';
                            var val = inp.value.trim();
                            if (!suites[suite]) suites[suite] = [];
                            suites[suite].push("-a " + argName + "=" + val);
                        });

                        var hidden = document.querySelector('input[name="value"]');
                        if (hidden) hidden.value = Object.keys(suites).map(function(suite) {
                            return suite + ":" + suites[suite].join(' ');
                        }).join(';');
                    }

                    document.querySelectorAll('.suite-arg').forEach(function(inp) {
                        inp.addEventListener('input', updateValue);
                    });
                    updateValue();
                })();
                </script>"""

                return html.join("\n")
            '''
        ]
    )
),

Problems:

  • The hidden field (input[name=”value”]) does not update when arguments are entered.
  • The JavaScript seems not to execute at all, or runs too early, or
    Jenkins does not allow script execution in this context.

Questions:

  • Is there a reliable way to have Jenkins execute custom JS in Active
    Choice HTML parameters?
  • Is there a better way to serialize and pass dynamic argument values
    to the pipeline?
  • What am I doing wrong with the plugin, or is this a limitation of
    Jenkins/Uno-Choice? Any best practices for working around this issue?

Images of the Jenkins UI:

Two SUITS selected
The script does not appear

Cybersource risk API fails with error “Authentication Failed”

I am using a javascript call through insomnia (like postman) to do a POST call to https://apitest.cybersource.com/risk/v1/decisions. Ref doc: Cybersource

const crypto = require('crypto-js');
const merchantId = insomnia.environment.get('MERCHANT_ID');
const merchantKeyId = insomnia.environment.get('VISA_KEY');
const merchantSecretKey = insomnia.environment.get('VISA_SECRET');
const requestHost = 'apitest.cybersource.com';
const requestMethod = '/risk/v1/decisions';

// Request body
const requestBody = insomnia.request.body;

// Digest
const digest = `SHA-256=${crypto.enc.Base64.stringify(crypto.SHA256(crypto.enc.Utf8.parse(requestBody)))}`;
insomnia.environment.set("bodyDigest",digest);

// Date
// const date = new Date(Date.now()).toUTCString();
var date = 'Fri, 12 Sep 2025 17:29:42 GMT';
insomnia.environment.set("date", date);

// Signature
const string = `host: ${requestHost}ndate: ${date}nrequest-target: ${requestMethod}ndigest: ${digest}nv-c-merchant-id: ${merchantId}`;
const signature = `keyid="${merchantKeyId}", algorithm="HmacSHA256", headers="host date (request-target) digest v-c-merchant-id", signature="${crypto.enc.Base64.stringify(crypto.HmacSHA256(crypto.enc.Utf8.parse(string), crypto.enc.Base64.parse(merchantSecretKey)))}"`;
insomnia.environment.set("signature", signature);

I have the following headers set as well as per cybersource documentation:

Content-Type: application/json
digest: SHA-256={{ _.bodyDigest }}
signature: {{ _.signature }}
v-c-date: {{ _.date }}
v-c-merchant-id: {{ _.MERCHANT_ID }}
Accept: application/json

But for some reason I still get the following response from cybersource:

{
    "response": {
        "rmsg": "Authentication Failed"
    }
}

Few things I tried to make it work for cybersource:

  1. I see the documentation says the header field as date but when I intercepted the call made from the live terminal, I see the header field is v-c-date. Does this make a difference? I tried both.
  2. I tried to retrace the python sdk to see if the script I use is any different but I can’t find any differences: https://github.com/CyberSource/cybersource-rest-client-python/blob/master/authenticationsdk/http/GetSignatureParameter.py#L33
  3. I used the sandbox to verify my credentials and they work in live terminal of sandbox.

Why the signature generated through the above code is different from the one in live terminal (which works)? Am I missing some data when generating the signature?

How do I predict, how window.print() will put html on a page? [closed]

I cannot figure out how my div is being translated into 8.5×11 page, by window.print(). Changing the dimensions of the print-element seems to make no difference; window.print() picked a scale and making my div wider or thinner doesn’t change it. On top of that, different pages seem to have different scales; despite having similar widths.

Things that might be helpful:

  1. My site is SharePoint under the hood; in case that is helpful.

  2. One element – width: 1101px; height:1508px gets printed on 1 page.

  3. Another element – width: 2682.5px; height: 1086px is 1 page.

  4. Helpful fact 2 and 3 have the correct widths and heights. They are both portrait; even though fact 3 looks like it should be landscape.

    My ultimate goal is to predict when my element is going over 11 inches, on a piece of paper. Auto and avoid, for break-before, break-inside and break-after, still have bizarre page breaks.

My plan is to force new pages, where I think they should be. However, I can’t do that if I don’t have a relationship between the height of my print-element and the piece of paper I want to print it on.

Buttons are flying in all directions whith motion

I have a project using react and motion.

Currently i have a component with a fixed overlay showing a bunch of ui. This UI lets the user toggle between 2 views, one vertical and one horizontal.

What’s happening:

  • When the view is toggled various parts of the overlay fly into view from the top or bottom of the screen. This happens because the page changes hight drasticly.

What do i want to happen:

  • The idea was that when changing views, the UI would stay still, fixed over the rest of the page.

I could just take out all layout animations from all motion components, but that would make the UI quite boring and it’s not my intent. I want to keep all the diferent animations but just confine them to the overlay.

I’ve tried using layoutRoot but it’s not really doing much.

Here’s a rundown of the components:

const { setComic, comic, layout, modal } = useComicReaderContext();
useEffect(() => {
    setComic(currentComic);
});
return (
    <div className="flex h-dvh w-full justify-center">
    <AnimatePresence
    initial={false}
    mode="sync"
    >
        {layout === comicLayoutModes.VERTICAL && (
            <VerticalLayout
            key={'vertical'}
            pages={currentComic.pages} //renders a bunch of images one under the other
                    />
        )}
        {layout === comicLayoutModes.SINGLE_PAGE && (
            <SinglePageLayout key={'singlePage'} /> // renders 1 image at a time.
        )}
        {modal && (
            <ComicInterface
            comic={currentComic}
            key={'UIOverlay'}
            />
            )}
        </AnimatePresence>
    </div>

and the interface itself:

const { title, author, tags, likes, price } = comic;
const { setModal, setDrawer, drawer } = useComicReaderContext();


return (
    <motion.div
    ref={overlay}
    layoutRoot
    key={'comicInterfaceOverlay'}
    className="fixed bottom-0 left-0 right-0 top-0 z-10 w-full overflow-hidden bg-black/75"
    >
        <motion.div className="mx-auto flex h-full w-full justify-between gap-2 py-2 text-white md:py-8">
            <AnimatePresence mode="sync">
                <motion.div
                transition={{ ease: 'easeInOut' }}
                        key="left col"      
                        className="flex shrink-0 flex-col justify-between pl-2 md:pl-8"
            >
                {`some buttons`}
            </motion.div>

{/* center col THISONE goes nuts when changing view*/} 
            <motion.div
            key={'centerCol'}
            onClick={(e) => onDismiss(e)}
            transition={{ ease: 'easeInOut' }}
            className="flex h-full w-full shrink flex-col items-center justify-center md:w-8/12"
            >
                    <motion.button
                initial={{ scale: 1 }}
                layout
                whileHover={{ scale: 1.05 }}
                whileTap={{ scale: 0.95 }}
                onClick={(e) => onDismiss(e)}
                className="cursor-pointer inline-flex h-20 w-[150px] items-center justify-center rounded-3xl bg-primary p-2 text-sm text-black hover:shadow-[0_0_10px_1px_rgba(250,250,250,1)] md:w-[250px] md:p-4 md:text-lg"
                >
                    Click to continue reading 
                </motion.button>
                </motion.div>
{/* right col */}
                <motion.div
                key="rightCol"
                layout
                transition={{ duration: 0.2 }}
                className={`flex flex-col justify-center gap-y-12 justify-self-end pr-2 md:pr-8`}
                >
                        <div 
                                        className="flex flex-col items-center"
                                        >
                    <div className='flex flex-col items-center w-[80px]'>
                                    <button
                        onClick={() => handleToggle()}
                        className="border-gray rounded-full w-[50px] h-[30px] p-1 border-2 bg-body cursor-pointer flex items-center" 
                        >
                                            {layout === comicLayoutModes.VERTICAL && <motion.div
                                                layout="position"
                                                layoutId='knob'
                                                layoutDependency={[layout, drawer]}
                                                className={`flex items-center justify-center rounded-full bg-primary w-[20px] h-[20px] ml-auto`}
                                                >
                                                    <GalleryVertical size={12} className='stroke-body' />
                                                </motion.div>}
                                            {layout === comicLayoutModes.SINGLE_PAGE && <motion.div
                                                layoutId='knob'
                                                layout="position"
                                                layoutDependency={[layout, drawer]}
                                                className={`flex items-center justify-center rounded-full bg-primary w-[20px] h-[20px] mr-auto`}
                                                >
                                                    <GalleryHorizontal size={12} className='stroke-body' />
                                                </motion.div>}
                                        </button>
                                        <span className='text-sm'>

                                        {layout === comicLayoutModes.VERTICAL ? "Vertical" : "Single Page"}
                                        </span>
                                    </div>


                        </div>
                    </motion.div>
                    {drawer && <Drawers open={drawer} />}
                </AnimatePresence>
            </motion.div>
        </motion.div>
    );
};

Scrolling & Map generation issue

i’m working on a client’s real estate site and it has this layout where i have a list of properties on left side and a map on right side. The map shows markers of prices on the respective property’s exact location(i have latitudes and longitudes stored in data) and whenever i hover on any property the map gets zoomed in to that respective location. On a single page we show 8 listings , the problem occurring is that whenever i scroll the list rapidly , the scrolling feels choppy , the map lags and the movement from one marker to another feels choppy as well which is spoiling user experience.

Please i need some help with this as this has been a recurring issue.

Tech stack used for client side: Astro react(jsx).

Need help and suggestions or references to solve this issue.

i have tried generating the markers and map once and just moving the map whenever a property is hovered but still feels choppy , used AI tools for help too but nothing works.

I’m expecting the list to scroll smoothly along with map generation to render smoothly even if someone scrolls rapidly through the list

If statements using other script elements functions

Somewhat a follow up to my previous question but, I’ve gotten the functions to work properly, and I have two console.log() statements in the secondary script element to test it, and it works. However, when I attempt to use this code:

<script src="https://player.twitch.tv/js/embed/v1.js"></script>
    <div id="twitchPlayer"></div>
    <script type="text/javascript">
      if(getLive() == false){
        var options = {
          width:800,
          height:450,
          channel:"rushdownresort",
          parent:["127.0.0.1"]
        }
        var player = new Twitch.Player("twitchPlayer", options);
      }
      console.log(getLive())
      console.log(getVideos())
    </script>

The embed doesn’t show until I change the comparison to !=, which is actually false, due to the channel only being live on sundays. Clearly the function isn’t returning something that works properly for a comparison in another script element, despite working within its original element.
Is this a scope issue?
By the way the end goal of this code is to display the livestream when the channel is live, and display the latest VOD when the channel is offline

Access the input element that dynamically generated either using its id or templatereference

I have to add and remove the product items by getting either the id of input element or through template reference of the input element. Since i need some other activities by accessing the input element. Please avoid adding new property in input productlists array.
Below mentioned the output

My output page

my .ts file

export class ProductsComponent implements OnInit {
  @ViewChildren('quantityreference') dynamicElements!: QueryList<ElementRef>;
  productlists = JSON.parse(`[
    {
        "productId": "T00110",
        "productName": "first",
        "productPrice": "0",
        "gst":"20"
    },
    {
      "productId": "T000",
      "productName": "Punnakuuu",
      "productPrice": "40",
      "gst":"20"
  },
    {
        "productId": "T1111",
        "productName": "Thenkaai Punnaku",
        "productPrice": "40",
        "gst":"18"
    },
    {
        "productId": "MT1",
        "productName": "Mattu Theevanam",
        "productPrice": "55",
        "gst":"18"
    },
    {
        "productId": "CP1",
        "productName": "m Punnaku",
        "productPrice": "55",
        "gst":"12"
    },
    {
      "productId": "CP2",
      "productName": "ell Punnaku",
      "productPrice": "22",
      "gst":"12"
  }]`
  );

  constructor() { }
  purchasedProudct = new Purchasedproduct("", "", 0, 0, "");
  selectedquantity: number = 0;
  @ViewChildren('quantityreference', { read: ElementRef }) products!: QueryList<ElementRef<HTMLElement>>;
  ngOnInit(): void {
  }
  increment(indexvalue: number) {
    const item = this.productlists[indexvalue];
    this.selectedquantity++;
  }
  decrement(indexvalue: number) {
    const item = this.productlists[indexvalue];
    if (this.selectedquantity > 0) {
      this.selectedquantity--;
    }
  }
}

my .html file

<ng-container *ngFor="let product of productlists; let i=index">
    <div class="products" *ngIf="product.productPrice > 0">
<h4>{{product.productName}}</h4>
<p>Rs. {{product.productPrice}}</p>
<button mat-icon-button (click)="decrement(i)" color="accent" #buttondecreament>
    <mat-icon>remove</mat-icon>
  </button>
  <mat-form-field  style="width: 50px;">
    <input matInput [(ngModel)]="selectedquantity" size="2" [id]="'quantity_input'+i" #quantityreference>
  </mat-form-field>
  <button mat-icon-button (click)="increment(i)" color="accent" #buttonincreament>
    <mat-icon>add</mat-icon>
  </button>
</div>
</ng-container>

Anyone try to solve this.

Convert .TSV to CSV, JSON or XML

On N8N, I am downloading a .TSV file from Amazon but for N8N to loop through the data, I need to convert it to an better format for looping (unless I am mistaken).

.CSV, .XML, .JSON would likely be suitable to use a loop node on.

If I am to use a code node in N8N for this, then I need it to be using JavaScript to convert.

This is the JS I used in a code node as an attempt:

const tsvToCsv = (tsvString) => {
  if (!tsvString || typeof tsvString !== 'string') {
    return '';
  }
  const lines = tsvString.split('n');
  const csvLines = lines.map(line => {
    const values = line.split('t');
    const csvValues = values.map(value => {
      // Handle values with special characters that need to be quoted
      if (value.includes(',') || value.includes('"') || value.includes('n')) {
        const escapedValue = value.replace(/"/g, '""');
        return `"${escapedValue}"`;
      }
      return value;
    });
    return csvValues.join(',');
  });
  return csvLines.join('n');
};

// Access the data directly from the first item of the previous node.
// This is where the file content is stored.
const tsvData = items[0].data;

// Convert the TSV data to CSV
const csvData = tsvToCsv(tsvData);

// Set the output for the next node in the workflow
return [{
  json: {
    csvData: csvData
  }
}];

This is the most I got from the tested code:
enter image description here

Why some changes were done in a file when file pushed into the github and what was the solution for it? [closed]

I have been working on a quiz project.There i was getting a problem like changes were done without being explicitly by me and again the right code then also i was appearing like before.So,i need a solution from an expert to overcome the situation.

I tried to push the code right code to the github and some data in the files were changing implicitly so iam expecting the right code which is in my local storage to be pushed into the github.