javascript – Best method to further execute the DRY principle and/or raise performance in my script? (client login/signup system)

Just for practice purposes, I written a basic client sided login/signup system that allows you to make an account, and then log into the account from my webpage. What it does is append to an object known as database for every new account made, and when you sign in, it loops through the database and see if your credentials match any account information.

There’s a couple of noticable problems with my script. One being that I believe that I didn’t follow the DRY principle to the fullest. I felt like I repeated myself a couple of times, and wondering if that can be avoided. The second problem is that looping through the “database” object may not be the most efficient solution, especially since the longer the table, the longer it may take. There may be a solution that is more efficient in performance that I am unaware of.

Other than that I would just like general feedback, tips, and red flags (if any) in my code. I am trying to improve myself as a JavaScript developer, and that requires feedback of my script from my peers.

TL;DR: I am a new programmer, so sorry if this is a bad question or if I have terrible code. I am still learning.

const database = ()

function usp(parent) {
  return (parent.username.value, parent.password.value)

window.onload = () => {
  const create = document.forms.createAcount;
  const log = document.forms.logIN;

  create.addEventListener('click', (e) => {
    if( == create.submit){
      const information = usp(create);
      database.push({user : information(0), pass : information(1)});

  log.addEventListener('click', (e) => {
    if ( == log.submit) {
      const information = usp(log);
      for (let x of database) {
        if (x.user == information(0) && x.pass == information(1)) {
          alert(`You successfully logged into your account! Welcome to my website ${information(0)}`)
#createAcount {
  background-color: skyblue;
#logIN {
  background-color: lightgreen;
<!DOCTYPE html>
      <link rel = "stylesheet" href = 'style.css'>
      <h1>Sign Up</h1>
      <form name = "createAcount" id = "createAcount">
        <h1>Create a Username</h1>
        <input type = 'text' placeholder="Falkyraizu"  name = 'username' maxlength=20>
        <h1>Create a password</h1>
        <input type = 'password' placeholder="password" name = 'password' maxlength=20>
        <input class = 'reset' type = 'button' value = "Reset" name = 'reset'>
        <input class = 'submit' type = 'button' value = "Submit" name = 'submit'>
      <h1>Log In</h1>
      <form name = "logIN" id = "logIN">
        <h1>What is your userName</h1>
        <input type = 'text' placeholder="Falkyraizu" name = "username" maxlength=20>
        <h1>What is your password</h1>
        <input type = 'password' placeholder="password" name = "password" maxlength=20>
        <input class = 'reset' type = 'button' value = "Reset" name = 'reset'>
        <input class = 'submit' type = 'button' value = "Submit" name = 'submit'>
      <script src = ""></script>

Side Note: If you notice something else that can be fixed such as my HTML, you can also include it in your response, however I would still like my main problems fixed (read above if you missed it). Thanks for the help!

client server – How can I standardize ping?

I hear pros playing Fortnite that have 20-50 ping complain that they cannot perform as well as pros with 0 ping due to wall taking, etc. It’s easy to think that a 20ms ping difference is negligible but it is not in competitive situations.

It seems to me that it should be possible to standardize a lobby’s ping to the current maximum player’s ping at any given moment. Obviously in a competitive game like Fortnite, the worst ping a pro player can have is generally 50-60 ping.

This solution would involve psuedo latency. For example, in competitive Fortnite, if the worst ping among the players is 50, then all players will be forced to also have 50 ping by inducing an artificial server response delay. This would allow no single player to have an advantage based on internet connection.

How could I implement a feature like this, to provide a level playing field?

client – Bitcoin Core GUI gettransaction implementation

The cli users have the option to “gettransaction txid true” in order to find valuable information about a transaction that could be theirs. This is a very powerful api call that effectively eliminates the need of an electrum server if someone wants to check his tx sent to coldstorage or a mobile wallet.

Do you think there would be any consensus in adding such a feature to the Bitcoin Core GUI? Something like Help -> Verify external txid. This would greatly increase the use of Bitcoin core for the ease of validating a transaction.

amazon web services – Use single network inerface on AWS Client VPN association

I’ve configured a Client VPN with the purpose of routing all the traffic from multiple external hosts through a static IP address that can then be whitelisted. To accomplish this I’ve run the standard setup from the AWS guides and also allocated an elastic IP address which I allocate to the network interface used by the ClientVPN Endpoint. This worked fine.

On Friday I found that there was at least another network interface created for this VPN association,(same associacion, multiple network interfaces) which I removed in order to prevent the external IP address to be randomly using it. This morning there seems to be 2 extra network interfaces, in addition to the one that I’m using with the elastic IP. I’ve read through the documentation but didn’t find a requirement to have multiple network interfaces or some sort of configuration to prevent it.

Has anyone faced the same problem or know what could be the issue?


javascript – How to iterate Client side Axios responses

I can only get the first result from axios. I’m sending payment data to a gateway. All of the payments will clear but then I only get back the results for the first payment.

This is the code I’m running:

app.get("/api/v1/gatewayService/:pId", (req, res) => {
let queryBuilder = `select * from payments where paymentdate = CURDATE() AND pid = ${req.params.pId}`;

var query = db.query(queryBuilder, (err, results) => {
  key = env.key;
  var query = db.query(queryBuilder, (err, results) => {
    for (let i = 0; i < results.length; i++) {
        .then((res) => {
        .catch((err) => console.error(err));

Here are the results:

response=3&responsetext=Duplicate transaction REFID:987654321&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=12345&type=sale&response_code=300

So I can parse this at each & and then = to get my results but the problem is that I’m sending through many different payments and can only get 1 response back to my app/terminal. If I check my gateway, I’ll see that each individual payment ran just fine, but I can’t post the proper payments without destructuring the payment ID’s for each payment.

I have tried iterating over different loops with different arrays for days now and can only ever get back the first response.

I’m using Axios and .then is where I’ve tried iterating every loop imaginable with no success.

Allow an Editor to create a new user with only the role of Client

I have a customer who had the Editor role. I created another role called Client. I want the Editor to be able to create a new user but only allow him to assign that user the “Client” role. I don’t want the Editor to be able to assign that user other roles such as “Administrator”, “Editor”, and “Subscriber”. Is there a plugin that does this? Or is there some code someone could share?

windows – SFTP-based client to auto-open files from different folder

I am working on a programming project that has multiple text-based files (.txt, .py, .sh, etc.). The files are stored on a remote server (specifically AWS EC2). I can access them with WinSCP via SFTP and edit them with Notepad++. WinSCP saves them in a temporary folder and continuously checks for changes that are uploaded to the server.

However, the files on the server are located in different folders and every time I connect I have to open them all again by navigating to those directories. I would like to ask whether there is any SFTP client on Windows or any other way to open all of them at once. Since I do not add new files, it is OK if I can find a solution that saves the session of open files and reopens that session during next connection. Or, perhaps, since the parent folder of all of their folders is the same is there a method that recursively opens all files in subfolders?