teleren/devto huggingface dataset:
Playing with digits "Codewars"
Tags: javascript, node, algorithms, programming
Published: 2023-09-12 09:01:58

Some numbers have funny properties. For example:

89 --> 8¹ + 9² = 89 * 1

695 --> 6² + 9³ + 5⁴= 1390 = 695 * 2

46288 --> 4³ + 6⁴+ 2⁵ + 8⁶ + 8⁷ = 2360688 = 46288 * 51

Given a positive integer n written as abcd... (a, b, c, d... being digits) and a positive integer p

we want to find a positive integer k, if it exists, such that the sum of the digits of n taken to the successive powers of p is equal to k * n.
In other words:

Is there an integer k such as : (a ^ p + b ^ (p+1) + c ^(p+2) + d ^ (p+3) + ...) = n * k

If it is the case we will return k, if not return -1.

Note: n and p will always be given as strictly positive integers.

Steps.
1. Lets Convert n which is a number to an Array and to to that we have to convert to a string first.
2. Let create a variable total which will hold the sum of all numbers in the array.
3. lets create our loop which will iterate over the array we created in step 1
4. inside the array we are going to raise each number to the power of p then add it to the variable total we created in step 2
5. we will increase our p by 1 because the power goes in an increasing order.
6. now we need to find a number which when multiplied with n will give us total. the best way to do that is to divide total by n.
7. now lets do our comparison. if the dividend is an integer we will return it, else we return -1 which means no number was found.

Solution.

```js
function digPow(n, p){
    let nArr = n.toString().split("")
    let total = 0
    for (let index = 0; index < nArr.length; index++) {
        const element = nArr[index];
        total += Math.pow(parseInt(element), p)
        p++
    }
    let compare = total / n
    if(Number.isInteger(compare)){
        return compare
    }else{
        return -1
    }
}
console.log(digPow(46288, 3));
```
Grafana Consulting Services & Enterprise Support Partner
Tags: grafana, grafanaconsulting, grafanamonitoring
Published: 2023-09-12 08:50:38

InfraCloud is your trusted partner for Grafana consulting services and enterprise support. We help companies efficiently deploy, configure, and visualize complex metrics for your infrastructure and applications. With a team of certified developers and domain experts, we offer end-to-end solutions to enhance your metrics visibility, optimize infrastructure performance, and improve operational efficiency.

## Benefits of Grafana Consulting & Commercial Support:

- End-to-End Metrics Visibility
- Feature-Rich Customizable Dashboards
- Optimized Infrastructure Performance
- Monitor Infrastructure Log Analytics
- Improved Operational Efficiency
- Custom Plugins Integration

## What do we offer in Grafana Consulting Services?

Faster your Grafana adoption with the help of Grafana Experts - right from deployment to enterprise support.

**Grafana Consulting Advisory and Implementation**

With the help of Grafana, our team of architects and consultants help you to query and visualize data and logs from wherever they are stored. Helping you with expert advisory, recommendations and a roadmap to implement Grafana.

**Query, Visualize and Explore Data from Different Sources**

The Grafana experts help you connect with every possible data source (databases) such as Graphite, Prometheus, Influx DB, ElasticSearch, MySQL, PostgreSQL etc.

**Set up and Schedule Grafana Reports**

With Grafana reporting, one can pull key metrics and trends out of dashboards and distribute them to stakeholders who need them for making data-driven operational decisions in their everyday work.

**Instant Actions using Alerts**

Grafana alerting helps you to know problems in your infrastructure/applications moments after they occur. Create, manage, and take action on your alerts in a single, consolidated view, and improve your team’s ability to identify and resolve issues quickly.

**Grafana Training and Enterprise Support**

Getting started with Grafana is easy, but it’s challenging to become an expert. Training and support is a great way to expedite your team’s skill with Grafana.

## Why Choose InfraCloud for Grafana Consulting Services?

- Certified Developers with 170+ in-house engineers.
- Domain expertise from working with 100+ clients.
- First-mover advantage as a Kubernetes service provider.
- Focused training to build core knowledge and practical experience.
- CNCF Certified Provider, Silver Member, and Kubernetes Certified Service Provider.
- Scalability without the hassle of hiring or training.

## Ready to Get Started with Grafana?

[Schedule a call with our Grafana expert to understand how our Grafana consulting services can help you.](https://www.infracloud.io/grafana-consulting/)
Control your playbook Task execution
Tags: ansible, redhat, automation, infrastructureascode
Published: 2023-09-12 08:43:57

In Ansible, fork, serial, throttle, and async are configuration parameters that control the concurrency and parallelism of task execution


# Fork

It specifies the maximum number of parallel connections that Ansible will use when executing tasks. Increasing the fork value allows you to parallelize task execution across multiple hosts.
For example, setting fork: 3 means Ansible will execute tasks on up to 3 hosts simultaneously as shown below.

![Ansible Fork](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1z8qjgd0dtl7wi6s6v75.gif)

# Serial
The serial parameter in an Ansible playbook allows you to control the number of hosts that are targeted at a time during playbook execution. It's useful for scenarios where you want to limit the rate of change or avoid overloading hosts.

For instance, if you set serial: 3, Ansible will target and execute tasks on three hosts at a time, waiting for them to complete before moving on to the next set of hosts.

![Ansible Serial](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y8q2z271j0ldt3nlp5fn.gif)

# Throttle
The throttle parameter in an Ansible playbook allows you to control the rate at which tasks are executed. In below example for Task 2 only one machine is executed at a time.

![Ansible Throttle](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdl46i64gm4cty6xmz9e.gif)

# Async

The async parameter in an Ansible task allows you to run that task asynchronously. It means Ansible will start the task against specific set of machines and immediately move on to the next set of machines without waiting for first set to complete.

You can also use the poll parameter in conjunction with async to specify how often Ansible should check the status of the asynchronous task. In the below example poll is provided as two, so every two second the ansible will check the status of the task executed in the machines


![Ansible async](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j93l09e2oroblyj51iw9.gif)


I end this blog with a question - If you want to achieve a scenario where a machine jumps to Task 2 as soon as its Task 1 is completed, while other machines are still executing Task 1.How you structure your playbook to achieve this scenario? Please comment if you know the answer.
The best feature of Bun is not performance-related
Tags: webdev, javascript, node, bunjs
Published: 2023-09-12 08:30:31

## What is Bun?

Oh, you know what it is 😉 Let's skip this SEO filler and get straight to the point. The best feature of ***Bun*** is how it handles...

## Module resolution

Anyone who has tried using Node.js with ESM or Typescript surely knows what I'm talking about. 

- should I use ***JS*** or ***MJS*** extension?
- if so should I use `type: module` inside package.json?
- should I use `node --experimental-modules` flag while running the app?
- ok but what about TypeScript? We have `compilerOptions.module` there...
- and what If I want to mix ESM and CJS?

The list goes on and on...

In ***Bun***, you can forget about that madness.

- Want to use ESM? ***Bun handles it***
- Want to use CJS? ***Bun handles it***
- Want to use JSX/TSX out of the box? ***Bun handles it***

⭐️ ***And the most important thing:***

***You can mix ESM and CJS imports inside a single file!*** 🤯

```js
import StuffESM from "./some-esm-module";
const StuffCJS = require("./some-cjs-module.cjs");
```

This can be really handy while using some non-ESM node/express packages.

## Summary

I'm excited about the future of Bun. It has many great features that are widely discussed in the tech space right now. I'm happy that we have 3 serious runtimes (Node, Deno, Bun) because the competition between them should be beneficial to everyone. Don't want to make a switch to Bun/Deno? Thanks to that competition, Node will probably be much better in the next versions and you won't have to switch. Exciting times ahead!


⭐ If you like my posts, please follow me on Twitter:
https://twitter.com/michalkuncio
Best Soundcloud Wav Downloader Tool
Published: 2023-09-12 08:25:58

Soundcloud Music (MP3 and OGG) Downloader is a perfect tool to enjoy your favorite music. This online app utilizes the endless resources of the biggest mp3 files platform in the whole internet. The Soundcloud is full with songs and audio tracks from every music genre you can think of. Many modern and popular artists even started and even now are founding their musical careers on the Soundcloud, because it is free and popular brand itself.

How to use The Soundcloud Music downloader
This simple and totally free tool is here to help you navigate around in the massive mp3 library of Soundcloud. Therefore, we made this webpage as modern and easy to use as possible. With a simple copied Soundcloud link, you would be able to download music, favorite songs, high quality mp3 tracks and any other kind of Soundcloud media. You just need to past the correct link in this program without actually downloading any third app in your gadget and this webapp will do everything for you.

Features and Benefits
This excellent application is the fastest mp3 converter you could find in the whole internet. It lets you choose any kind of quality for your mp3 files before the download begins. This webpage is actually very beneficial because the Soundcload itself doesn’t offer us a download button on every song page, therefore with this fast and reliable downloader you can easily bypass that problem. Also, this tool even helps you download way longer mp3 files than any other website.


[Soundcloud wav downloader](https://soundcloudtomp3.splashthat.com)
[Izlesene Video indirici](https://izlesenevideoindirme.splashthat.com)
[Descargador De Vídeos De Vimeo](https://descargarvideosdevimeo.splashthat.com)
[Twitch TV Video Downloader](https://twitchclipdownloader.splashthat.com)===
[VK Video İndirici](https://vkvideoindirme.splashthat.com)
[Download Video BiliBili](https://bilibilidownload.splashthat.com)
[Descargador de videos de Dailymotion](https://dailymotionmp3.splashthat.com)
[reddit video downloader](https://reddit-video-downloader.jimdosite.com)[Today Guides](https://todayguides.net)
Frontend vs. Backend
Tags: webdev, newbie, beginners, hasanelsherbiny
Published: 2023-09-12 08:23:00

if you are new to the world of the web development ,you will have to know some important terms, two of these terms are frontend and backend.
so what are these two terms?
most of web applications are based on the model called Client Server model.

## Client Server Model
![client server model](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gem5g1pnztud16eq9080.png)

in this model your website (the application you have created) is hosted on a Computer (called server) this application is waiting for incoming requests to start to handle it, in this scenario the waiting application is called Backend (consider it as the backstage).

and the caller is called frontend which initiate the request or ask for a specific resource (exists on the server).

## sounds good but why?
why don't we place everything on the frontend and this is gonna be faster and high latency.
the problem here is:
1. difference between resources at the each caller client
What if the caller client  wants to execute a process requires high processing power and high memory requirements?
in this case our theory will fall.

2. if we placed everything at the frontend if user's device is lost or broken the stored data is lost too.
3. different client's platforms 
our application can be used be different consumers with different platforms and it can cause a change of expected behavior of our code.

ok let's do everything on the backend.
in this case will have much headache on the server requiring us to increase resources allocated to the server.

for these problems the client server model is handy and the optimal solution is to use mixture between the backend and frontend.

the backend should has the pardon of executing processes requiring high resources as mentioned before and also must be responsible for accessing the database and carrying out transactions based on each user's roles.

the frontend should expose easy to use and pretty UI to the user and any interaction between the user and the UI should be executed at frontend to reduce ovehead of the server.

## What technologies you need for the backend?
a lot of Programming languages and frameworks are there for developing backend, most common are:
1. PHP
2. Asp.net (C#-Vb.net)
3. Ruby on rails (ruby)
4. Node.Js (javascript)
5. Spring (java)
## What technologies you need for the frontend?
Mainly you need HTML , CSS and JavaScript for frontend development
but there are also a lot of frameworks facilitating the usage of CSS and JavaScript.
Opensource projects using FastAPI?
Tags: fastapi
Published: 2023-09-12 08:22:06

I am aware that there is no specific “right” answer to this question.

FastAPI does not offer any approaches or restrictions. And a young framework. In this regard, you have to independently develop approaches for development on it. And please recommend more or less working projects on FastAPI (not libraries) in order to see how people generally write in it. Various kinds of tutorials are not entirely suitable here.
I’m a RICH software engineer who Creates and Sells.
Tags: softwareengineering, freelance, contentwriting, sideprojects
Published: 2023-09-12 08:12:28


![Photo by Ian Schneider on Unsplash](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2k0q9mtuz61wtn3cp6kb.jpg)
**[Article.Preface]**
Success in the future will be determined by one’s ability to create and sell. We as software engineers are able to create digital products and sell them to our audience, Digital products can be an article like what you are reading now, a YouTube video, or anything else on the Internet. I will be sharing my experience about finding the solution to make passive income as a software engineer.

**[Article.Authrozie]**
I am a software engineer, but I’m financially illiterate,
I yearn for freedom, whether it’s financial or in terms of time.
I don’t know the secret to making money even while I sleep.
If (you can’t answer YES to at least one of these questions) then

> throw a new IrrelevantArticleException(“This article is not for you”)

**[Article.Reason]**
I’m a software engineer, always trying to keep up with new tech and programming languages. Finance topics like the stock market and crypto trading don’t really interest me, and I don’t want to work extra on weekends on another part-time project for more money.

But, is there a way to make money with my interests? BIG Yes, definitely!

Read the full version on [Medium](https://medium.com/@m-qafouri/im-a-rich-software-engineer-who-creates-and-sells-c4875e4700e2)
How to define advance types in Typescript
Tags: typescript, beginners, programming, tutorial
Published: 2023-09-12 07:55:29

Let's explore some of the advanced types that TypeScript offers and how they can be applied effectively:

- Aliases

```ts
type Student = {
  readonly id: number;
  name: string;
  retire: (date: Date) => void;
};

let student: Student = {
  id: 1,
  name: 'bayu',
  retire: (date: Date) => {
    console.log(date);
  },
};

```

- Intersection

```ts
type Draggable = {
  drag: () => void;
};
type Resizeable = {
  resize: () => void;
};
type UIWidget = Draggable & Resizeable;

let textBox: UIWidget = {
  drag: () => {},
  resize: () => {},
};

```

- Literal

```ts
type Quantity = 50 | 100;
type Metric = 'cm' | 'mm';

let quantity: Quantity = 50;
let metric: Metric = 'cm';

```

- Never

```ts
function processEvent(): never {
  while (true) {
    // read a message from a queqe
  }
}
processEvent();
console.log('Hello World');

// clg never executed

```

- Nullable

```ts
function great(name: string | null | undefined) {
  if (name) console.log(name.toUpperCase());
  else console.log('parameter is nullable');
}

great(undefined);

```

- Nullish Coaelscing

```ts
let speed: number | null = null;
let ride = {
  // speed: speed !== null ? speed : 30
  speed: speed ?? 30,
};

```

- Optional Changing

```ts
type Customer = {
  birthday?: Date;
};

function getCostumer(id: number): Customer | null | undefined {
  return id === 0 ? null : { birthday: new Date() };
}

let customer = getCostumer(1);
// optional property access operator
console.log(customer?.birthday?.getFullYear());

// optional element access operator ex: array customer
// customer?.[0]

// optional call
let log: any = null;
log?.('a');

```

- Union

```ts
function convertion(weight: number | string) {
  if (typeof weight === 'number') return weight * 2;
  else return parseInt(weight) * 2;
}

convertion(10);
convertion('10');

```

- Unknown

```ts
function render2(document: unknown) {
  // Narrowing
  if (typeof document === 'string') {
    document.toUpperCase();
  }
  //   document.fly()
  //   document.whatEverYouWant()
}

```

Advanced types in TypeScript equip you with powerful tools to handle complex scenarios, create reusable patterns, and ensure type safety in your projects. By employing union types, intersection types, conditional types, mapped types, type guards, template literal types, and even recursive types, you can elevate your code to new levels of expressiveness and maintainability.
This blog post has introduced you to the significance of advanced types, how they solve common development challenges, and how to apply them in various scenarios. Armed with this knowledge, you're ready to tackle intricate type relationships and create more resilient and adaptable TypeScript applications.
Hope this helps!
How to install Next.js in Ubuntu 22.04
Tags: nextjs, ubuntu, vscode
Published: 2023-09-12 07:50:58

Are you looking to start building web applications with Next.js on Ubuntu? You're in the right place! This tutorial will guide you through the step-by-step process of setting up and running Next.js on your Ubuntu 22.04 distribution.

Before we get started, if you're running Windows, check out the post on [How to Install Next.js in Windows Using WSL2](https://www.franciscomoretti.com/blog/how-to-install-next-js-in-windows-using-wsl2-a-step-by-step-guide). Now, let's dive into the installation process.

### Step 1: Set up NVM in Ubuntu

First things first, we need to set up Node with its version manager. Open up the Ubuntu bash tab and paste in the following commands:

```text
sudo apt update
sudo apt upgrade -y

## Install nvm and node
## nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
```

Close and reopen your terminal to start using NVM and then run the following command:

```text
nvm install --lts
```

With these commands, you'll have Node and its version manager (nvm) set up in your Ubuntu distribution.

### Step 2: Create a Next.js App

Now that we have Node set up, let's create a new Next.js application to test if everything is working correctly. To create a new application named `blog-app`, run the following command in the Ubuntu bash session:

```text
npx create-next-app@latest blog-app
```

This command will automatically install the `create-next-app` package for you. Once it's done, you should see a message confirming that the installation was successful.

![Create next app usage](https://www.franciscomoretti.com/assets/docs/2088943018.png)

### Step 3: Install VS Code (optional)

If you don't have VS Code installed yet, you can download it from the official website following the [Visual Studio Code on Linux Installation guide](https://code.visualstudio.com/docs/setup/linux#_installation). Once installed, you can proceed to the next step.

### Step 4: Open the App in VS Code

Now, let's open the `blog-app` folder in VS Code. Run the following command:

```text
code blog-app
```

This will install the VS Code remote server and open the `blog-app` folder directly in VS Code on Windows. You'll notice the `WSL:Ubuntu` label at the bottom left corner, indicating that VS Code is connected to the Ubuntu distribution.

### Step 5: Running the App

Now, it's time to run the app! Open up the VS Code terminal by pressing ``ctrl + ` ``, and install the dependencies by running:

```text
npm i
```

Once the dependencies are installed, start the server by running:

```text
npm run dev
```

Your VS Code terminal should indicate that the application is running, and you can access it at <http://localhost:3000/> on your browser.

Congratulations! You've successfully installed and run Next.js on your Ubuntu distribution.

### Conclusion

Setting up and running Next.js in Ubuntu is a straightforward process, as you've seen in this tutorial. By following these steps, you're now ready to start building your own Next.js applications in Ubuntu 22.04. Happy coding!
Abstract Factory Method
Tags: go, designpatterns
Published: 2023-09-12 07:48:23

Abstract Factory Method memungkinkan Anda untuk membuat objek-objek yang saling terkait dan bergantung satu sama lain tanpa perlu mengungkapkan detail konkretnya. Ini menciptakan antarmuka abstrak (interface atau kelas abstrak) yang mendefinisikan serangkaian metode untuk membuat objek-objek yang terkait. Kemudian, Anda dapat membuat implementasi konkret dari antarmuka ini untuk menghasilkan kelompok objek yang berbeda sesuai dengan kebutuhan.

Diagram konsep:

![Diagram UML](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d02nfifpd8e78zji6hmt.png)


Diagram implementasi:


![Diagram UML](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p7bs8s48720u76hzzu0f.png)

## Kapan?

 - Ketika kode Anda perlu bekerja dengan berbagai kelompok produk terkait, namun Anda tidak ingin kode tersebut bergantung pada kelas konkret dari produk tersebut—mereka mungkin tidak diketahui sebelumnya atau Anda hanya ingin memungkinkan perluasan di masa mendatang.
 - Anda memiliki sebuah kelas yang harus melakukan satu pekerjaan utama (tanggung jawab utama), tetapi juga melakukan pekerjaan lain yang tidak seharusnya menjadi tanggung jawabnya.

## Referensi
- https://refactoring.guru/design-patterns/abstract-factory
- https://golangbyexample.com/abstract-factory-design-pattern-go/