teleren/devto huggingface dataset:
.fit() LinearReggression
Tags: python, pandas, machinelearning
Published: 2023-07-07 18:24:55

LinearRegression sınıfı, doğrusal regresyon modelini uygulamak için kullanılan bir sınıftır. Bu sınıf, sklearn (scikit-learn) kütüphanesinde yer alır.

.fit() yöntemi, LinearRegression sınıfının bir yöntemidir ve bir doğrusal regresyon modelini eğitmek için kullanılır. Bu yöntem, veri kümesine (giriş ve hedef veriler) uydurmayı sağlar ve modelin içindeki katsayıları ve kesme terimini (bias) optimize eder.
```
from sklearn.linear_model import LinearRegression

# Veri kümesini tanımlama
X = [[1], [2], [3], [4]]  # Giriş verileri
y = [2, 4, 6, 8]  # Hedef veriler

# LinearRegression modelini oluşturma
model = LinearRegression()

# Modeli eğitme
model.fit(X, y)

```
Yukarıdaki örnekte, X ve y veri kümesi tanımlanır. Ardından, LinearRegression sınıfından bir model oluşturulur. fit() yöntemi, X ve y verilerini kullanarak modeli eğitir. Eğitim süreci, en küçük kareler yöntemini kullanarak giriş verileriyle hedef veriler arasında en uygun doğruyu bulmaya çalışır.

.fit() yöntemi modelin eğitildiği aşamadır ve modelin veriye uyum sağlamasını sağlar. Eğitim sonrasında, modelin eğitim verilerine en iyi uyan doğruyu temsil eden katsayıları ve kesme terimini içerir.
Which Package Managers?
Tags: discuss, webdev, codenewbie, beginners
Published: 2023-07-07 17:57:36

Hi Friends 👋🏼, 

Out of my curiosity, what are the differences between `npm`, `yarn` and `pnpm`? Which one do you use and why?

A while ago, many said that `yarn` runs faster than `npm`. But then, that's no longer the case. They both are the same -- in my opinion as a Windows user. But I'm not familiar yet with `pnpm`.
What is Doom Scrolling ?
Tags: health, discuss, socialmedia, learning
Published: 2023-07-07 17:47:43

#Problem 👀

Doomscrolling or doomsurfing is the act of spending an excessive amount of time reading large quantities of negative news online

---

#Solution 💡

Instead of just scrolling and wasting 4-5 hours daily, Can we convert this habit to watch tutorials 2-3 hours ?

Like I said the main problem of scrolling on social media is that it never ends.... while tutorials do end...

---

What changes we can bring to solve this problem comment below !!

Cheers 🍺
I finished my HTML & CSS Template No. 02 😊💜
Tags: html, css, git, github
Published: 2023-07-07 17:43:39

I'm happy to share that I finished my HTML & CSS Template No. 02 😊💜

**--> Proj name:**
Kasper - Free One-Page Creative Template From [Graphberry.com ↗](https://www.graphberry.com/item/kasper-one-page-psd-template)

[--> Source code ↗](https://github.com/mohamed-hgag/HTML-And-CSS-Template-02)

[--> Visit the site ↗](https://mohamed-hgag.github.io/HTML-And-CSS-Template-02/)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ksp13gt71urx38nzhzcf.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k4wg5lmi0ygpgqm78wap.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k3kukuto7tm2a4afsl4n.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g3h17wp28h9i0z00ifgv.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3670jpr5sdxgknd9ag1m.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o16vbhdm58a597rwalld.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/60mh9cg0zcq8z4ffyiuk.jpg)
Study Smarter Now - Enhance Your Learning with AI
Tags: gpt3, chatgpt, ai, startup
Published: 2023-07-07 17:39:20

I am delighted to introduce you to [Study Smarter Now](https://studysmarternow.com/), my innovative AI-driven platform that is set to revolutionize the way students study. By using the advanced capabilities of OpenAI's GPT-3 Turbo and the forthcoming GPT-4, Study Smarter Now offers students the opportunity to upload their textbooks or homework and receive comprehensive AI-generated study notes. Moreover, students can engage with an AI bot for further insights and guidance.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/skddxc0tf2wpe5zacyag.jpg)

**Why Choose Study Smarter Now?**
Study Smarter Now is a resource designed for all learners seeking to upgrade their study techniques and maximize their academic performance. Whether you're in high school or college, the platform is designed to assist you in studying more effectively. Powered by cutting-edge AI technology, it generates accurate and relevant study notes based on your materials and serves as an AI companion for further discussions.

**Technologies Behind the Platform**
Study Smarter Now is built using some of the most advanced web technologies. For the AI component, I've used [OpenAI's](https://openai.com/) GPT-3 Turbo, and I'm already working on upgrading it to GPT-4 as soon as it's released. The front-end user interface is designed with [React](https://react.dev/), while [Flask](https://flask.palletsprojects.com/en/2.3.x/) powers the backend. Deployment is handled by [Vercel](https://vercel.com/) and [Google App Engine](https://cloud.google.com/appengine), with [Supabase](https://supabase.com/) taking care of the scalable database requirements. I've chosen these technologies to provide the fastest, most efficient, and user-friendly experience for all users.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lh9l319pyel8eoxj6wzu.jpg)

**Discover Study Smarter Now Today!**
If you're interested in learning more about Study Smarter Now, visit the website at https://studysmarternow.com/, or watch my introductory video on [YouTube](https://www.youtube.com/watch?v=NJLIsOivKDA&t=2s).

Don't forget to follow the updates on Twitter at @betterMateusz.

I look forward to welcoming you to the platform and am excited to help you enhance your study habits with Study Smarter Now!

**Exciting Features:**

Interactive AI bot for textbook discussions
Comprehensive, easy-to-understand AI-generated study notes
Effective study strategies powered by AI
Try it for FREE now!
We are currently in the beta testing phase. Register for an account and take full advantage of the platform at no cost!
Get Started!

Your input is crucial! I welcome your feedback on the overall user experience, the effectiveness of the AI-generated study notes, interactions with the AI bot, and any other suggestions for improvements. Together, we can redefine the studying experience with Study Smarter Now!
Servers: Explained to a Five Year-Old
Tags: servers, webdev, programming
Published: 2023-07-07 17:07:45

Are you ready to learn about how servers work and what they do?  Let's dive into this blog post together!

## So, what exactly is a server?

A server is like a big computer that helps other computers talk to each other and share information. Imagine a librarian at a library - the librarian helps you find the books you need, and the server helps computers find the information they need.

## How do clients and servers interact with each other?

In the digital world, a client is a device like a computer, tablet, or even a smartphone that asks the servers to share the information or files the user needs.

The server listens to the requests from all the clients and tries its best to give them what they want. It's like a friendly helper who is always ready to provide the right information or file to the person who asks for it.

For example, when you send an email, your email client is the client that sends a request to an email server, which processes the request and sends the email to the recipient.

## How would you explain what a "server" is to a 5 year-old?

Imagine you're in a restaurant full of magical chefs and waiters. The restaurant has a special room called the kitchen, where all the waiters and waitresses get the food from. This room is like the heart of the restaurant, where all the yummy dishes are prepared and stored.

When you want to order your favorite meal, you write down your request on a magic paper and give it to a waiter. The waiter takes your paper to the kitchen, where the chefs prepare your meal with love and care. Once your meal is ready, the waiter brings it back to your table, and you can enjoy the delicious food you asked for.

In the digital world, the server is just like that special kitchen in the restaurant. It's where all the digital information is stored and managed. When you want to watch a fun video or play an exciting game, your device (like a magic menu tablet) sends a message to the server, asking for what you want. The server then prepares and sends the information or files back to your device, just like the waiter bringing your favorite meal to the table.
Base Backup & Point-in-Time Recovery: PostgreSQL
Tags: apacheage, postgressql, database, datascience
Published: 2023-07-07 17:02:13

Logical and physical backups are the two forms of online database backups available in PostgreSQL. Physical backups require taking a picture of the physical files that make up the database, whereas logical backups entail producing a backup by exporting the logical structure and data of the database.


Logical backups can be time-consuming, especially for large databases, despite having benefits such offering a flexible way to extract and edit data. On the other hand, huge databases can be backed up and restored more quickly and effectively with physical backups.

**Base Backup:** A base backup is the technical term for the creation of a physical backup in PostgreSQL. The steps below make up the normal process for making a basic backup:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6muv774v1sqj03dbzmwy.png)

Use the pg_backup_start command (or, in previous versions, pg_start_backup).
Making use of the preferred archiving command, take a snapshot of the database cluster.
Use the pg_backup_stop command (or, in earlier versions, pg_stop_backup).
The pg_backup_start command switches to the current Write-Ahead Log (WAL) segment file and creates a checkpoint to prepare the database for the backup procedure. Additionally, it generates a backup_label file that includes crucial details about the base backup, like the location of the checkpoint.

By switching the WAL segment file, writing a backup end XLOG record, resetting the full-page write mode, and generating a backup history file, the pg_backup_stop command ends the backup operation. The contents of the backup_label file and extra data are contained in the backup history file.

With the help of a base backup and the archive logs produced by continuous archiving, you can restore a database cluster to any point in time using the PostgreSQL functionality known as Point-in-Time Recovery (PITR). This capability can be used to fix serious errors or return the database to a specific state.

PostgreSQL determines the beginning point for the recovery procedure by reading the checkpoint location from the backup_label file. It reads the archive logs from the archival path supplied in the archive_command option and replays the WAL data from those logs.

A timeline history file is created in the pg_xlog (or pg_wal in version 10 or later) subfolder once the recovery operation is finished. The LSN (Log Sequence Number) where the WAL segment switches occurred, the timeline change's cause, and the timelineId of the restored database cluster are all recorded in this file. The timeline history file, which offers a history of recovered clusters, is crucial for later PITR procedures.
How to format currency with Intl.NumberFormat
Tags: javascript, intl, i18n
Published: 2023-07-07 16:51:33

---
title: How to format currency with Intl.NumberFormat
published: true
description: How to format currency using built-in browser API.
tags: javascript, Intl, i18n
---

Displaying currency formatted depending on user language/region is not uncommon task in web development.

It can be easily achieved with usage of `Intl`, which is a namespace in browser API and part of *ECMAScript Internationalization API*. 

> The Intl namespace object contains several constructors as well as functionality common to the internationalization constructors and other language sensitive functions. Collectively, they comprise the ECMAScript Internationalization API, which provides language sensitive string comparison, number formatting, date and time formatting, and more. <cite>[MDN Intl page]
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl)</cite>


## Code
This is ready to use code that display `amount` of `currency` formatted for given `locale`. These data are usually taken from API or application state or in case of locale from browser API.
```
function formatCurrency(locale,amount,currency){
const formatter = new Intl.NumberFormat(locale,
 {
   style:'currency',
   currency: currency
 });

 return formatter.format(amount);
}
```
And this is all that you need. Simple function that can be used in any framework, no npm packages needed, no dictionaries with currency symbols etc.
There other options that can be set to customize how currency is presented, all of them well described [on MDN as well](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#parameters). Interactive examples are there as well so I will not rewrite them here.

## Let the browser worry
Even if your application is not localized or uses only single currency it is convenient to let the browser worry about how currency should be displayed: 
* what is currency symbol ?
* should symbol be placed before or after amount?
* use spaces or comma for separating thousands and decimal separator.

Other thing is that using standardized formatting assures that screen readers and other assistive technologies will read that data correctly.
Write Ahead Logging: PostgreSQL
Tags: apacheage, postgressql, database, datascience
Published: 2023-07-07 16:49:38

In the event of system failures, the Write Ahead Logging(WAL) protocol assures durability and data recovery. These are the few topics discussed in WAL.

**Insertion Operations:** Data entered into the database is susceptible to loss in the event of system failures without WAL. 

**Database recovery and insertion operations:** PostgreSQL uses the WAL method to write all modifications as historical information into a transaction log. When a transaction commits or aborts, XLOG records, or WAL data, are written to the in-memory WAL buffer and then flushed to the WAL segment file. Replaying XLOG records from the REDO point, or the location at the most recent checkpoint, is a step in the recovery process.

**Full-Page Writes:** PostgreSQL allows full-page writes to address failures where the page data on the storage is corrupted. Following a checkpoint, a backup block (full-page image) containing the whole page is written as an XLOG record during the first change of each page.

**WAL, Backup, and Replication:** While WAL protects against process or operating system failures, file-system or media failures require extra safeguards like online backups and synchronous replication.

WAL segment files, which are generally typically 16 MB in size, are used to separate the transaction log in PostgreSQL. A timelineId and LSN (Log Sequence Number) information are included in the naming convention for WAL segment files.

A WAL segment file is internally divided into pages, with the first page containing a header and all subsequent pages containing XLOG records in descending order.
The fastest and simplest way to bring your KOA app to the cloud.
Tags: cloudcomputing, webdev, tutorial
Published: 2023-07-07 16:44:58

TL;DR: Ready to migrate your KOA application to AWS, GCP, or Azure? Simplify the process by automating resource provisioning which is ready to scale up or down to zero as required by usage.

Let's take a look at an example of a KOA service that creates secure download URLs for images stored in a bucket like S3 or Blob Storage:

```javascript
import Koa from "koa";
import Router from "koa-router";
import { http, bucket } from "@nitric/sdk";

export const imgBucket = bucket("images").for("reading", "writing");

const app = new Koa();
const router = new Router();

router.get("/download/:id", async (ctx) => {
  try {
    const { id } = ctx.params;
    const img = imgBucket.file(`images/${id}/photo.png`);

    ctx.body = {
      url: await img.getDownloadUrl(),
    };
  } catch (err) {
    ctx.throw(500, "Error getting file URL");
  }
});

app.use(router.routes());

http(app, () => {
  console.log(`Application started`);
});
```

[Link to full project](https://github.com/nitrictech/example-apps/tree/main/nitric-koa).

This code sets up an HTTP server that handles requests for downloading images. It listens for a GET request to "/download/:id" and retrieves the corresponding image file from the "images" bucket. It then generates a download URL for the image and sends it back as the response.

To automate the deployment into the cloud we'll introduce the Nitric SDK. The only difference between your existing KOA app and this version is how the server is started. Instead of using the traditional approach, such as `app.listen(port)`, we use the http import from the Nitric SDK.

```javascript
http(app, () => {
  console.log(`Application started`);
});
```

This modification allows [Nitric](https://nitric.io) to wire up your API Gateway in AWS, GCP, or Azure automatically. Additionally, the Nitric SDK provides access to cloud storage functionality, allowing you to interact with resources like buckets seamlessly.

To begin your deployment install the [Nitric CLI](https://nitric.io/docs/guides/getting-started/installation), which containerizes and deploys your solution using traditional IaC tools like Pulumi and Terraform to create the necessary infrastructure.
Develop .NET Core 3.1 Inside a Container
Tags: csharp, docker, dotnet
Published: 2023-07-07 16:42:44

Distros like Ubuntu 22.04 only supports OpenSSL 3, so users can only install .NET 6 SDK, it does not support .NET Core 3.1 or 2. Fortunately, Microsoft officially provides image files for development, and we don't even need to write Dockerfile to set up the environment.

## Setup Environment

Here are the instructions to start a container named `dotnet31` locally using `devcontainers/dotnet:dev-3.1`:
```
$ mkdir -p dev-container/dotnet31
$ cd dev-container
$ docker pull mcr.microsoft.com/devcontainers/dotnet:dev-3.1
$ docker run -it --name dotnet31 --volume ./dotnet31:/workspace:cached --network host mcr.microsoft.com/devcontainers/dotnet:dev-3.1 sleep infinity
```

Notice that we use `--network host`, that makes the container share the host’s networking namespace. So be careful to do any network change inside the container. You can omit the option if you don't need to access localhost from the container.

Next, enter the container to test whether the program can be compiled and executed:
```
$ docker exec -it dotnet31 bash
```

Inside the container:
```
# dotnet --list-sdks
3.1.425 [/usr/share/dotnet/sdk]
# mkdir /workspace/test && cd /workspace/test
# dotnet new console
# dotnet run
Hello World!
```

Then use your favorite IDE or editor to enter the container development, I personally use VS Code's [Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers).

## Other settings

Notice that you may need to manual use `--environment=Development` to tell the compiler using development settings.
```
# dotnet run --environment=Development
```

You may also need to set up Entity Framework.
```
# dotnet tool install --global dotnet-ef --version 3.1.3
```

Finally, you can also install other packages.
```
# sudo passwd root
# sudo apt install neofetch
```

Hope this to be helpful for who annoyed at developing old .NET projects in new Ubuntu host systems.
Javascript Polyfill Reduce #2
Tags: javascript, programming, webdev, react
Published: 2023-07-07 16:26:36

Array.prototype.reduce() is a handy method to process arrays.

```
Example

[1, 2, 3].myReduce((prev, curr) => prev + curr, 0); // 6
[1, 2, 3].myReduce((prev, curr) => prev + curr, 4); // 10
```

Note

- Do not use native Array.prototype.reduce() in your code
- your function is only tested against valid array (no array-like objects)

**Solution**

```
if (!Array.prototype.concat.myReduce) {
  Array.prototype.myReduce = function (callback, initialValue) {
    let index = 0;
    if (!initialValue) {
      index++;
      initialValue = this[0];
    }
    let acc = initialValue;
    for (let i = index; i < this.length; i++) {
      acc = callback(acc, this[i], i, this);
    }
    return acc;
  };
}

```

- We iterate through the array and call the callback function on each iteration, passing in the accumulator, current element, index and original array.
- The initialValue is used as the first accumulator value if provided, otherwise the first element of the array is used.
Time Warp
Tags: devjournal
Published: 2023-07-07 16:06:59

It has been quite a while since I last worked on my game, Project YOMI. It's been an even longer while since I last wrote here. I ask you, dear reader, that you forgive me for my absence, as I have been a bit preoccupied with a very important life event--my wedding! This past weekend, after six years of dating and two years of engagement, my wife and I got married at sunset at an Oregon winery. It was a wonderful weekend of celebration, connecting with friends and family, and joy.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/caudtpkr45pl89m0yc6v.jpeg)

A wedding, like other major life events, has a bit of a time dilation effect. Each day leading up to it seemed to pass by quicker than the day before. So, despite my promise to myself to make at least one contribution to this project each day, it was more important to me to spend time helping with the planning and preparation of the wedding. Now though, with that incredible weekend behind us, and looking ahead to future plans and goals, I am ready to resume this work. 

The time away from the project has allowed me some time to reflect on my approach and my vision. Here are some notes and reminders to myself as I dive back in to this game:

- Finish the design.
- Done is better than perfect.
- Don't get caught up in pre-optimizing.
- Lastly, start thinking of a title... 'YOMI' is copyrighted.
Critter Corner v4
Tags: discuss, watercooler, aww, codenewbie
Published: 2023-07-07 15:48:00

Hello, wonderful DEV community! Welcome back to our biweekly Critter Corner where we encourage you to share photos of all of the furry friends that cheer up your day!

By sharing snapshots of your cherished animal friends, you not only make [Sloan](https://dev.to/sloan) incredibly happy but also help create a more vibrant and inclusive community for everyone. We can't wait to see what furry, feathery, and scaly adventures await us! 📸🐶🐦🦎

And hey, if you do happen to know any sloths looking for a job, please do send them our way. Sloan is patiently waiting to make some new friends who can match their unique pace and personality.

Share your beloved animal friend's photo in the comments below and let's make DEV a welcoming haven for all creatures great and small!
A basic question about use of typescript with Vue.js
Tags: vue, typescript
Published: 2023-07-07 15:40:52

Hi,

I'll start to an internship, and the company said me to learn some basics about vue.js and typescript beforehand but I couldn't understand one thing about this. Doesn't vue.js use javascript? What's purpose of mentioning to typescript in here? 

I googled about it and as I understand typescript is generally used for data manipulation in background but not for the whole Vue.js. I previously use Angular-CLI before so I have some experience with typescript but I couldn't wrap my head around about this. Can you help me out please?

(they also use pinia and quasar dev)