Can javascript have race condition?

For the following code in javascript I want to know if there are concurrent api requests to increment count is there any possibility of a race condition considering the fact that javascript is single threaded.

  app.post('/increment', async (req, res) => {
    await someAsyncFunction(); // Asynchronous operation
    count++; // Increment operation
    res.send('Count incremented');
  });

From what I understand there shouldn’t be any as once the execution resumes after await someAsyncFunction() count++ being synchronous should be executed in one stretch for a request before the execution resumes the increment for other requests. Let me know if I am wrong to understand this.

How to Buy Bitcoin on CashApp

Looking to buy Bitcoin? This article treats the topic of buying Bitcoin through CashApp. Also, how to send and receive bitcoins on the app.

Unarguably, Cash App is one of the easiest and most popular ways to transfer money to and fro. Just like Paypal, and other similar software out there, whoever you want to send money to must have the Cash App as well.

[https://shorturl.at/6aqms]

Column A Column B
Cell 1 Cell 2
Cell 3 Cell 4

Cash App image

The developers put conscious effort into making the App unique, as evident from its user interface and functionality, which sets it apart from other similar apps and software. This is an applaudable feat.

With the Cash App, you can not only send and receive money but also use the Cash App card to pay for merchandise and invest in Bitcoins through the app. This is the highlight of this article. Not too long ago, they also included the option to let users invest in the stock market and buy potential commodities with very easy steps.

CashApp is a product of Square Inc., easily one of the top-tier and prominent companies offering financial services. The parent company was founded by Mr Jack Dorsey, who is way more popular for being the brain behind Twitter.

Let’s look at the story of Cash App briefly.

The History of Cash App
———————–
In the year 2009, in St. Louis, Missouri, Mr Dorsey and his friend Mr McKelvey birthed and developed the idea of Square. His goal was to evolve Point of Sales by inventing a technology with the ability to harmonize the seller’s services and the buyer’s payment, easily, and hassle-free, all in one place.
Looking at it now, 11 years later, it’s obvious that they have been able to achieve that and even more. They are currently exploring other areas of financial services.

Mr Dorsey has always been popular for being pro-Bitcoin since its big break into the public space. And so it didn’t really take people aback when CashApp launched in the year 2013 and supported Bitcoin. After all, the owners of its parent company fully did.
Its goal was to compete with other apps offering similar services and dominate the market, including the European and Asian online banks.

Following its launch in 2013, CashApp is recorded as the payment application growing at the fastest pace, in the United States of America. In European and Asian countries, its growth is relatively much slower, but it still records positive connections nonetheless.

Why use CashApp to buy Bitcoin?
Buy bitcoin on Cash App

If you’re looking for a new bank that provides an easy, user-friendly and hitch-free way of transferring money to and fro, while letting you perform other exclusive activities like investing, then the real question should be why not use CashApp?
It doesn’t have some of the features that other similar apps share, but this simplicity makes it a good fit.

It’s up to par in the areas of speed, user-friendliness, and simplicity. The developers focused only on the really vital options to have, not burdening users with needing extra space, because of features they might never use.
Instead, they included a feature giving them an extra edge; the option to invest in Bitcoin and Stocks.

If you’d like a simple neobank for ordinary money transactions and nothing too intricate, then look no further. But if you’re going to be needing direct debits, savings and the like, then you should probably stick to your bank for the meantime, because the app is a deficit in some areas.

Ease of Operating
This can be considered CashApp’s stronghold. In the whole market of neobanking applications, there isn’t any top-level, secured application that matches the smooth ride you’ll get while operating the CashApp.
The main reason why this is so, is because the developers separated the very necessary features of a banking app, as it should be, which is to transfer and receive money electronically, and then they developed the application based on that.

Although some people may find that absurd, most especially if they have to use these different options frequently, it is certainly a good look for the greater public.

Sending Payments
On the CashApp, sending out money is super easy and doesn’t involve any extra steps. Simply input the amount you want, select the recipient from your list of contacts, making sure they also use the app, and Voila. You can as well manually input the recipient’s Cash-tag (starting with a dollar sign as prefix), their phone number or their email address.

After sending the credit, the application will notify the receiver with the note you provided during the transaction to explain why the payment was made.

The developers did not include the Bitcoin and Stock buying features in the application when they launched it. When they saw that the app was largely, positively accepted by members of the public, they included the Stock and Bitcoin investment features, and excluded the option of heavy, mandatory fees to enable users purchase, withdraw, and send out Bitcoins and also invest in certain, limited stock, with ease.

Sometimes though, even with the application’s simplicity, some end-users can find it a bit difficult to catch on to a few things, like how to buy, sell, or transfer Bitcoin on the App. In truth, none of that is a difficult process, but nonetheless we’ve made a step-by-step below for anyone experiencing problems.

Buy Bitcoin on CashApp
One thing that makes the app stand out in this area, is how easy it is to actually purchase Bitcoin. Make sure you have money in your account to cover the worth you have in mind, and tap the Bitcoin option. Literally as easy as 123.
The smoothness and speed of the process makes the app a very good recommendation for anyone new to the world of digital currencies and looking to start with BTC. This is the perfect fit for anyone looking to buy in small amounts, but for larger amounts there are other dedicated platforms that are less-expensive.

Buy Bitcoin via CashApp
Launch the app on your smart device, and select the “Investing” option in the bottom menu (with the icon of a rising curve)
When you go through with step 1, two options will show on the screen; one says ‘Buy Stocks’ and the other says ‘Bitcoin’. Tap on the Bitcoin option and it will show your in-app BTC wallet. It should be empty if you’ve never used the app to buy some.
Next, select “Buy” on the screen and select the amount of BTC you want to buy. If you want to buy a particular amount not on that list, you will have to tap on the three dots icon at the down-right corner, and enter the specific amount you want to purchase then select “Next”.
A new screen will pop up, having the important transaction information, the amount of BTC you want to buy, real-time value, commission fees, etc. If the information showing is alright, then select “Confirm”. You’re all done!
The app supports a large array of credit cards and government/bank-issued prepaid cards, but it does not support making direct deposits from the app to these cards.

Send BTC via CashApp
Following these easy steps, you can send out your in-app holdings to your personal, external address or any other.

Launch the app on your smart device, and go through the steps to get to the Bitcoin wallet screen.
Select “Withdraw”
Using your device Camera, scan the QR code of the receiving wallet or Select the option “Use wallet address”, to input one by yourself.
Confirm that you are the one making the transaction, using whatever security method you previously setup, and Voila!
Note: To be eligible for withdrawal or transfrer, you mist have a minimum of 0.001 BTC in your possession, on the in-app wallet. Within the space of 24 hours, you can only transfer BTC worth a maximum of $2000, and a maximum of $5000 within a week – 7 days – (These numbers might go up in the future).
Transfers from your in-app wallet to a different one might take up to 45 minutes to reflect.

Deposit BTC into your CashApp wallet
Launch the app on your smart device, and go through the steps to get to the Bitcoin wallet screen.
Select the option to “Deposit Bitcoin”, from those available.
Using the receipt’s device Camera, scan the QR code of your CashApp wallet, or you could copy and paste the wallet address in the wallet you want to send from. There is also an option to share the wallet address directly with the sender.
The sender confirms that they are indeed the one making the transaction, using whatever security method they previously set up, and Voila!
Note: Within a period of 1 week, you can only deposit BTC to the tune of a maximum of $10000 (This may go up in the future). These transactions could take some time to complete, especially if the network is choked with transaction activity.

The application’s platform only supports BTC for now and does not support any other coins, including Bitcoin Cash and Bitcoin SV.

Checking your Bitcoin transactions limit and growth
Like before, launch the app on your device, and go through the steps, as explained, to get to the Bitcoin wallet screen.
Go down the screen, and to the section that reads “Bitcoin Limits” (For Android), and “Limits Progress” (For iOS). Soon as you’re in there, you’ll be able to view all your transaction limitations and the progress you’ve made so far on each one.
Pros and Cons of Using CashApp to Buy Bitcoin and Sell Bitcoin
————————————————————–
Like every single “perfect” app, there are Pros and Cons of using CashApp.

Pros:

You can rest assured of security and reliability because its parent company (Square Inc), and team of developers are one to be reckoned with.
The UX design and interface are really appealing to users.
It functions with impressive simplicity and speed.
The BTC and Stock investment options are not difficult to grasp or use.
Generally, it’s a safe, easy, fast, and effective app for money transactions between people.
Cons:

The number of transacting options available to the users is very limited. Although they include the important bits, the features left out are also important to some individuals.
The app is unavailable to some regions, and some others don’t have access to the CashApp card or the option to buy BTC and Stocks, yet.your text

Yes, you can use verified Cash App accounts for Bitcoin transactions. Ensure the account is capable of handling cryptocurrency transactions.

Can you use a substitute for the keyword const?

I’m trying to make a simple counter, but its proving difficult, $ was undefined, but I used:

function jQuery($) {
  'use strict';
  $(function() {
    //code here
  });
};

While that fixed the $ problem, i can’t figure out how to make the counter. This is my code:

var counter = 0;
    
function appendNumber() {
  const newElement = document.createElement('div');
  newElement.textContent = counter;
  document.body.appendChild(newElement);
  counter++;
}

It says it’s reserved i need some other way to do const, as it says “The keyword const is reserved.”
If you find a solution to this, or a different way to do a counter, it would be much appreciated.

I tried just using a var, then using append, but it just appended x. (the var’s name)
This was some of the code I tried:

function jQuery($) {
  'use strict';
  function findAnswer() {
    x = parseInt(x);
  }
  $(function() {
    var $counter = $( ".counter" );
    if (x < 0) {
      answer = x * y;
    }
    $( ".counter" ).append("answer");
    $( ".clickme" ).on("click", function() {
      answer++;
      $( ".counter" ).append ("answer")
    });
  });
}

The parseInt was an idea I had, because is school, it had me make a calculator, using parseInt.

Decrypt cloud storage file

I am trying to decryt cloud storage files. Those files have a header that I want to skip.

For example, this file is composed of [cloud storage header + salt + content + cloud storage footer]. Lets say salt is ‘SALT’.

------WebKitFormBoundaryMpzAvNgQ8HhW5A8i
Content-Disposition: form-data; name="file"; filename="blob"
Content-Type: application/octet-stream

SALTáB†nJÎÆBÂÀ?ó“´ZM¥SJz·xM×±È(ºKéGw#²ÇœQëKBt'ø%ÄkæsUA-h]aWA¯(•Ÿ€Ø&©€
------WebKitFormBoundaryMpzAvNgQ8HhW5A8i--

My decrypt function works fine for ‘normal’ files but returns undefined for cloud storage ones. I have tried to skip/delete header but I am missing something. The footer problem I haven’t figured out how to solve it yet.

... some code...
const file = input.file;

const GCP_HEADER = await readGGCPHeader(file);
const header = await readSignatureAndHeader(file, SIGNATURE, HEADER_SIZE, GCP_HEADER);
const decRx = decodeKeys(publicKey.value, privateKey.value);
const state = initializeDecryption(header, decRx);

let buffer = [];
let index = SIGNATURE.length + HEADER_SIZE;
while (index < file.size) {
  const offset = index + CHUNK_SIZE + ABYTES_SIZE;
  const chunk = file.slice(index, offset);
  index = offset;

  // Decrypt the chunk and update the decrypted buffer
  buffer = await decryptChunk(chunk, state, buffer);

  // Define a new blob and set output element to it
  const blob = new Blob(buffer, { type: "application/octet-stream" });
  input.file = blob;
}

async function readSignatureAndHeader(file, signature, HEADER_SIZE, GCP_HEADER) {
  const fileReader = new FileReader();
  fileReader.readAsArrayBuffer(file.slice(0, signature.length + HEADER_SIZE + GCP_HEADER.length));

  const signatureAndHeader = await new Promise((resolve) => {
    fileReader.onload = () => resolve(new Uint8Array(fileReader.result));
  });

  return signatureAndHeader.slice(signature.length + GCP_HEADER.length);
}

async function readGGCPHeader(file) {
  const fileReader = new FileReader();
  fileReader.readAsArrayBuffer(file);

  const header = await new Promise((resolve) => {
    fileReader.onload = () => {
      const text = new TextDecoder().decode(fileReader.result);
      const gcpHeaderEnd = text.indexOf("SALT");
      resolve(new Uint8Array(fileReader.result.slice(0, gcpHeaderEnd)));
    };
  });

  return header;
}

I think the problem is related to how I read the headers and the salt in the readSignatureAndHeader function.

How to keep annotations within range in ApexCharts?

I’ve got a chart with a couple of annotation points in it. One of these points is within the Y-axis range, but the other is not.

Is there a way to automatically have ApexCharts include every annotation within the rendering range so that all annotations are always visible at least?

This is what my chart looks like:

import ApexCharts from "apexcharts";

var options = {
  chart: {
    type: "line",
  },
  series: [
    {
      name: "sales",
      data: [30, 40, 35, 50, 49, 60, 70, 91, 125],
    },
  ],
  xaxis: {
    categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999],
  },
  annotations: {
    points: [
      {
        x: 1993,
        y: 150,
        marker: {
          size: 4,
          fillColor: "#f00",
          strokeColor: "transparent",
        },
      },
      {
        x: 1996,
        y: 50,
        marker: {
          size: 4,
          fillColor: "#f00",
          strokeColor: "transparent",
        },
      },
    ],
  },
};

var chart = new ApexCharts(document.querySelector("#chart"), options);

chart.render();

Here is a working example of my chart and the annotations.

Adding reveal.js presentations to an existing site?

I have several reveal.js presentations, and I want to host them online so that I can access them from anywhere, rather than just on my laptop. I also host a blog site using the static engine Hugo, which serves up html pages. Hugo has the concept of “pages”: currently one page contains the blog posts, another one has a little bit about me, and another lists all the blog tags. It would be easy to add a page called “presentations”.

My presentations include text, mathematics with MathJax, and various interactive diagrams included as iframes. It would be very nice to include everything in a single html file, with reveal.js material from a CDN such as

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/reveal.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/reveal.min.css" rel="stylesheet">

I also have a few local files, such as my own theme. I don’t know whether the files above include plugins (for mathematics, menus, highlighting) or whether they have to included as well.

I appreciate that questions similar to this have been asked before, but most seem to be several years old, or involve github, which I’d rather avoid, since every time I attempt to use it I get caught up in an almighty tangle and confusion. Anyway, I don’t need version control or sharing, just an online presence.

Anyway, I’d be happy of any advice!

Twilio is sometimes turning brackets (`[`, `]`) into angle brackets (“)

I’m using the twilio api (specifically, the nestjs twilio module) and my texts have a structure like this: “[company name] some notification” with square brackets.

Sometimes the square brackets will be replaced by angle brackets. Does anyone have an idea why this might be happening?

example replacments:

“[company name] some notification” -> “[company name> some notification”

“[company name] some notification” -> “<company name> some notification”

Changes to js file not picked up for Blazor server app

I just noticed a strange behavior in Visual Studio 22 ver 17.11.5.

If I add a function to .js file, add a call to the function on a razor page and hit F5, I get an exception that the method cannot be found. This used to work just fine.

If I add a new .js file and add it to _Layout.cshtml it works for a little bit. That is, I can add new functions and they are picked up, but at some random point, changes to this new file also stops being picked up.

Anyone else seeing this?

Programatically Select eventMarker with Anychart Stock v8

How do I programmatically choose which eventMarker is selected using Anychart Stock? I have a modal that appears when you click a eventMarker to provide more info, and I want to be able to navigate between the markers using he modal rather than having to click on the graph again

(this seems to have been possible in previous versions, but I can’t seem to figure it out in v8)
see example of previous version: https://6.anychart.com/products/stock/online-demos/html-js-samples-center/selecting-event-markers/index.html#sampleView

When reviewing the documentation (https://docs.anychart.com/Stock_Charts/Event_Markers/Basics#individual_markers) I cannot find any methods that can select a specific eventMarker, only configure the behavior when eventMarkers are selected

Does the Outlet rerender with the parent component in React JS?

I have useWindowSize hook that triggers each time when the window is resized so the MainWrapper component rerenders many times. But the Outlet element is not rerendered. Is that allright?
Are there any documentation links to that?

const MainWrapper = () => {
  useWindowSize();

  return (
    <Layout className={styles.layout} hasSider>
      <Sider />
      <Layout className={styles.container}>
        <Layout.Content id="layoutContentRoot">
          <Suspense fallback={<Loading />}>
            <Outlet />
          </Suspense>
        </Layout.Content>
      </Layout>
    </Layout>
  );
};
export default MainWrapper;

How to set time zone with data-fns isSameDay function

I have a chunk of code where I need to see if two dates are on the same day. What I have found is that if one date is after 7pm, the “isSameDay” function from date-fns returns a false.

If I create two javascript date objects for the two dates I am comparing and compare the two with getDay, getMonth, and getFullYear, it fails as well.

I believe that there is some time zone issue going on and I expected date-fns functions to account for time zone – or at least allow for it. The problem is that if this is the case, I don’t see it in the documentation.

javascript library is not loaded into an angular typescript project

We are trying to build a javascript library (dwbn-event-webcomponents), that can be imported into a typescript project (angular 17) and also used standalone. It was installed via npm from git url.

In the angular project however, we get the following error:

event.module.ts:5:0-52 - Error: Module not found: Error: Can't resolve 'dwbn-event-webcomponents' in 'src/app/modules/ondemand'

The package.json of dwbn-event-webcomponents looks like this:

{
  "name": "dwbn-event-webcomponents",
  "version": "1.0.8",
  "description": "A powerfull but easy to integrate web component",
  "main": "src/js/events-webcomponents.js",
  "module": "src/js/events-webcomponents.js",
  "source": "src/js/events-webcomponents.js",
  "types": "types/event-webcomponents.d.ts",
  "type": "module",
  "keywords": [
    "events"
  ],
  "devDependencies": {
    "@inquirer/prompts": "^7.0.1",
    "clean-webpack-plugin": "^4.0.0",
    "gulp": "^5.0.0",
    "semver": "^7.6.3",
    "typescript": "^5.6.3",
    "webpack": "^5.95.0",
    "webpack-stream": "^7.0.0"
  },
  "engines": {
    "node": ">= 18"
  }
}

The files are all in the defined location and we have generated the typescript type definition file via npx tsc.

How can we resolve this error and make the library usable in a typescript project?

Conflict between fabric.js and @imgly/background-removal-node causing Sharp module errors in Next.js

I’m working on a Next.js project where I’m using both fabric.js and @imgly/background-removal-node. The @imgly/background-removal-node package depends on sharp for background removal functionality. My project works perfectly on the main branch where @imgly/background-removal-node alone is used. However, once I add fabric.js in a new branch, I start seeing errors related to sharp, specifically:

Something went wrong installing the "sharp" module
\?C:UsersUsernameDesktopmyprojectnode_modules@imglybackground-removal-nodenode_modulessharpbuildReleasesharp-win32-x64.node

Steps Taken:

Reinstalled sharp with npm install sharp.
Tried loading fabric.js dynamically to reduce conflicts.
Attempted various versions of fabric.js and sharp to check compatibility issues.

Despite these attempts, I keep getting sharp module errors as soon as fabric.js is installed. If I remove fabric.js, everything works again.

Environment:

Node.js version: 20.10.0
"next": "14.0.4",
"@types/fabric": "^5.3.0",
"fabric": "^5.3.0",
"@imgly/background-removal": "^1.4.5",
"@imgly/background-removal-node": "^1.4.5",

Question:
Has anyone encountered a similar conflict between fabric.js and sharp dependencies in Next.js? Are there any known compatibility issues or specific configurations required to get both fabric.js and @imgly/background-removal-node working together without causing sharp errors?

Any guidance or alternative approaches to prevent these conflicts would be greatly appreciated!

Node,js code not printing 24 bits colors in Git Bash terminal, But direct commands works

I’m experiencing a weird problem with printing 24-bit colors in the Git Bash terminal using Node.js. When I run a simple JavaScript script that uses ANSI codes to print 24-bit (true color) text, only the basic 16 colors are displayed. However, when I run a direct ANSI command in the Git Bash terminal, the 24-bit colors display perfectly. This problem doesn’t happen with other terminals(windows cmd in my case).

It seems that the issue might be related specifically to Node.js in Git Bash. Has anyone else encountered this, or is there a known workaround to get Node to display 24-bit colors in Git Bash?

Expanding on tests and context:
my node version is v20.10.0, my git version is 2.47.0.windows.2 and my OS is Windows.

This is a simple JavaScript code to test the colors:

console.log("x1b[38;2;255;0;0m█x1b[38;2;200;0;0m█")
process.stdout.write("x1b[38;2;255;0;0m█x1b[38;2;200;0;0m█")
process.stdout.write('x1b[0mn');

Executing through Git Bash it display only one basic color (console.log and process.stdout.write present the same result):
bash doesn’t display the full colors

If I execute the same command in a Windows cmd terminal it gives the correct colors:
cmd display the full colors

However! If I do the equivalent code directly into bash terminal, it gives the expected result:
bash displays the colors with direct code

These test imply that the code works on other terminals and that bash is capable of displaying the correct colors.
I feel that it has to have an obvious reason. But, I wasn’t able to find any mention to this specific problem.

Audio playing onload and not onclick (involves webpack)

I’m making a note sequencer web application and I am currently trying to implement the function of playing a note on pressing a button corresponding to the note. I am currently using a test sound to understand how playing audio works as this is my first time dealing with audio in HTML.

I am also using webpack, and my problem at first was getting webpack to recognize the mp3 file, but I quickly solved that by using file-loader.

Now my problem lies in the fact that the test audio I am using does not play on the click of a button, but does play perfectly fine onload of the site. There are no errors given to me by the console.

Here is script.js: (note: this may be poorly written for the meantime of me understanding this issue)

import "./style.css";
import myAudioResource from './click-234708.mp3';

const CONTROL_BAR = document.createElement("div");
CONTROL_BAR.id = "control-bar";

const MAIN_BAR = document.createElement("div");
MAIN_BAR.id = "main-bar";

const testbutton = document.createElement("button");
const testaudio = new Audio();
testaudio.src = myAudioResource;
testbutton.addEventListener('click', testaudio.play())
MAIN_BAR.appendChild(testbutton);

const SCALE_BAR = document.createElement("div");
SCALE_BAR.id = "scale-bar";

const MAIN = document.createElement("div");
MAIN.id = "main";

MAIN.appendChild(CONTROL_BAR);
MAIN.appendChild(MAIN_BAR);
MAIN.appendChild(SCALE_BAR);
document.body.appendChild(MAIN);

I want to make testaudio play on clicking testbutton, and NOT onload of the site.

Here is webpack.config.js:

const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');

module.exports = {
  mode: 'development',
  entry: "./src/script.js",
  devtool: 'inline-source-map',
  output: {
    filename: "main.js",
    path: path.resolve(__dirname, 'dist'),
    clean: true,
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: 'Leitmotif',
      filename: 'index.html',
      template: './src/template.html',
    })
  ],
  module: {
    rules: [
      {
        test: /.css$/,
        use: ['style-loader', 'css-loader'],
      },
      {
        test: /.mp3/,
        loader: 'file-loader',
      },
    ],
  },
};

I attempted some of the solutions in this forum but to no avail.

I do believe this could be a problem with the way I’ve written my program, considering I have to also ensure everything works well with webpack. I have tried different syntaxes and creating separate functions to play the audio, but all of it just ended up playing the audio on load again.

Can anyone help out here?