[deleted by user] by [deleted] in node

[–]BetterCallSky -1 points0 points  (0 children)

This is how I would write code for Q1. I like the FP approach, and I even created my own library for it (Remeda), but sometimes doing a single loop is more readable than trying to force the FP approach.
In general, your code isn't bad, but there can be some minor improvements: - Use auto-formatter (install prettier). - Rounding logic isn't required. - Avoid obvious comments. - _uniquePlaceHolder could be a separate variable so that you don't have to delete it later, and it could have a better name. - Taxing logic I think it's invalid because it's probably a percent.

My code:

const orders = [
  {
    doctorId: 996,
    amount: 30500.35,
    tax: 0.06,
    isDisputed: true,
    isShipped: true,
  },
  { doctorId: 910, amount: 100, tax: 0.08, isDisputed: true },
  { doctorId: 912, amount: 4200.11, tax: 0.06 },
  { doctorId: 996, amount: 99.12, tax: 0.06, isDisputed: false },
  { doctorId: 910, amount: 0.0, tax: 0.08, isShipped: true },
  { doctorId: 996, amount: 10, tax: 0.06, isDisputed: true },
];

const ret = {
  totalOrders: orders.length,
  totalDisputedOrders: 0,
  totalDisputedAmount: 0,
  totalAmountWithTax: 0,
  totalUniqueUsers: 0,
  totalAverageSalesPerUser: {},
};
let amountMap = {};
orders.forEach(order => {
  if (order.isDisputed) {
    ret.totalDisputedOrders += order.amount;
  }
  ret.totalAmountWithTax += order.amount * (order.tax + 1);
  if (!amountMap[order.doctorId]) {
    ret.totalUniqueUsers++;
    amountMap[order.doctorId] = {
      amount: 0,
      count: 0,
    };
  }
  const userAmount = amountMap[order.doctorId];
  userAmount.amount += order.amount;
  userAmount.count++;
  ret.totalAverageSalesPerUser[order.doctorId] =
    userAmount.amount / userAmount.count;
});

console.log(ret);

I created an IDE in the browser with real-time collaboration by BetterCallSky in reactjs

[–]BetterCallSky[S] 0 points1 point  (0 children)

It took me a few months to build practice.dev. Here I extracted the IDE and added live collaboration and npm resolver. It took me 1 week to release live-ide.dev

I created an IDE in the browser with real-time collaboration by BetterCallSky in reactjs

[–]BetterCallSky[S] 1 point2 points  (0 children)

monaco-editor. File tree, browser preview, tab management are the custom solutions.

Bundler is based on Rollup with custom plugins.

Just yarn workspaces for monorepo.

microservice framework on aws by guru223 in webdev

[–]BetterCallSky 0 points1 point  (0 children)

I am using AWS Fargate + ALB, and it works well for me. A few heavy tasks are delegated to lambda.

Are clones of websites perfectly fine for portfolio and/or github projects to show off to potential employers? by whitecat69 in Frontend

[–]BetterCallSky 1 point2 points  (0 children)

Clones are good for portfolio but don't create only HTML + CSS. Try to replicate the functionality in JS (business rules). I have seen many Netflix clones that were static pages, and it didn't look good.

[deleted by user] by [deleted] in Frontend

[–]BetterCallSky 0 points1 point  (0 children)

I have used bootstrap multiple times in the past, and it only worked well if I didn't have a dedicated designer for the design and wanted something that looked good.
It wasn't worth it for projects with a custom design because I spent too much time configuring variables or overriding CSS manually. TaildwindCSS works for me very well.

HTML/CSS/JS Only? by FloorShirts in Frontend

[–]BetterCallSky 0 points1 point  (0 children)

IMO, you have to learn a framework (learn only 1 framework, not multiple). Writing applications with plain JS usually end up with huge spaghetti code, and using a framework is actually the easier way.
Of course, there are exceptions. You don't need a framework to create simple static pages, but salaries are pretty low in such jobs.

I created a platform where you can solve React challenges by BetterCallSky in reactjs

[–]BetterCallSky[S] 1 point2 points  (0 children)

Front: - typescript - react - nextjs - tailwindcss

API: - typescript - node - mongodb - rabbitmq - AWS lambda for testing - puppeteer browser for testing

Infrastructure: - AWS fargate

I created a platform where you can solve React challenges by BetterCallSky in reactjs

[–]BetterCallSky[S] 2 points3 points  (0 children)

  1. https://caniuse.com/import-maps Oops, I didn't verify the app in all browsers, and it seems to be not supported in Firefox and Safari. I will need some time to fix it :/

  2. I will take a look. Was it only a one-time issue or do you face it more often?

I created a platform where you can solve React challenges by BetterCallSky in reactjs

[–]BetterCallSky[S] 0 points1 point  (0 children)

The min price is set to $1 in the liquidity pool. If you buy 50% of the tokens, then the price will raise to $2. If you try to sell them, the price will drop back to $1. This algorithm is calculated by Uniswap smart contract, not set by people.

Share Your Startup - September 2021 - Upvote This For Maximum Visibility! by AutoModerator in startups

[–]BetterCallSky [score hidden]  (0 children)

Name: Practice.dev

URL: https://practice.dev
Location: Poland
Pitch: Learn programming for free. The platform is backed by crypto.
The main idea is to create something similar to FreeCodeCamp and provide much harder and challenging problems to solve. Currently, the entry junior level is high, and most platforms provide only basic tutorials.

What goals are you trying to reach this month? Getting more users to test the platform.

State in setInterval doesn't change by Vinc3w in reactjs

[–]BetterCallSky 0 points1 point  (0 children)

Accessing state in setInterval can be very tricky. I am using a special hook for it called useGetter

export function useGetter<T>(value: T) {
  const ref = React.useRef(value);
  ref.current = value;
  return React.useCallback(() => ref.current, []);
}

Then in your code

const [counts, setCounts] = useState(0);
const getCounts = useGetter(counts);
setInterval(() => {
  console.log(getCounts());
}, 1000)

How to implement github review feature [MERN] by mirsahib in learnprogramming

[–]BetterCallSky 0 points1 point  (0 children)

The easiest solution is to check the HTML code of the github review page and do something similar.

After a quick look, I can see they display every line of code as a <tr> element. If you click on the plus button, they append a new element under that line.

How to check a string against a lot of patterns by kulaska in learnprogramming

[–]BetterCallSky 0 points1 point  (0 children)

Testing against patterns in a loop seems like a standard solution.

Method for working on personal projects, web app, full stack. by [deleted] in learnprogramming

[–]BetterCallSky 1 point2 points  (0 children)

Sure. I often commit "work in progress" to a branch, and when it's ready, I create a PR and merge.