teleren/devto huggingface dataset:
ejs ile çalışırsanız yöenlendirmede parametre
Published: 2024-02-04 22:19:49

ejs ile çalışmayın lütfen çerçek hayatta react ile json üzerinden haberleşilecek ama ejs ile çalışırken işlemi gerçekleştirdikten sonra yönlendirilen sayfaya veri aktarmak istersen render edebilirsin ama sonrasında hata alırsın bunu için çözümler.



Eğer ana sayfaya yönlendirirken bir mesaj göndermek istiyorsanız, bunu yapmanın birkaç yolu vardır. Örneğin:

- Mesajı bir **cookie** veya **session** değişkenine kaydedebilir ve ana sayfada okuyabilirsiniz. Böylece mesajı istekler arasında saklayabilirsiniz. Bu yöntem için [express-flash](^1^) gibi bir ara yazılım (middleware) kullanabilirsiniz¹².
- Mesajı ana sayfanın **URL**'sine bir **sorgu parametresi** olarak ekleyebilir ve ana sayfada bunu `req.query` ile alabilirsiniz. Böylece mesajı URL üzerinden iletebilirsiniz. Bu yöntem için şöyle yazabilirsiniz:

```javascript
res.redirect("/?message=başarılı");
```

- Mesajı ana sayfayı **render** ederken bir **şablon parametresi** olarak gönderebilir ve ana sayfada bunu `res.locals` ile erişebilirsiniz. Böylece mesajı render işlemi sırasında gönderebilirsiniz. Bu yöntem için şöyle yazabilirsiniz:

```javascript
res.render("index", {message: "başarılı"});
```

Bu yöntemlerin avantaj ve dezavantajlarını [burada](^4^) daha detaylı okuyabilirsiniz⁴. Umarım bu cevap size yardımcı olmuştur. Başka bir sorunuz varsa, lütfen bana sorun. 😊

Kaynak: Bing ile konuşma, 05.02.2024
(1) node.js - Is there a way to send message with res.redirect()? - Stack .... https://stackoverflow.com/questions/70295335/is-there-a-way-to-send-message-with-res-redirect.
(2) node.js - Is there a way to send message with res.redirect()? - Stack .... https://stackoverflow.com/questions/70295335/is-there-a-way-to-send-message-with-res-redirect.
(3) Showing a message on res.redirect in Express / Node.Js app. https://stackoverflow.com/questions/28964089/showing-a-message-on-res-redirect-in-express-node-js-app.
(4) Understanding res.redirect and res.render in Express.js: Usage and .... https://dev.to/mochafreddo/understanding-resredirect-and-resrender-in-expressjs-usage-and-security-measures-2k60.
(5) Understanding res.redirect and res.render in Express.js: Usage and .... https://dev.to/mochafreddo/understanding-resredirect-and-resrender-in-expressjs-usage-and-security-measures-2k60.
(6) Redirects With Express - Mastering JS. https://masteringjs.io/tutorials/express/redirect.
(7) Redirect with ExpressJS - Scaler Topics. https://www.scaler.com/topics/expressjs-tutorial/response-redirect/.
My Journey as a Hard of Hearing Software Engineer
Tags: learning, community
Published: 2024-02-04 22:06:13

Being a software engineer with a hearing challenge has been a rollercoaster of ups and downs, but let me tell you, the ride is worth it! Just a quick background of myself, I have a profound hearing loss in my left ear and am deaf in my right ear.

One of the biggest hurdles I faced was the constant chatter in the tech world.. M.E.E.T.I.N.G.S. I know we all have a love-hate relationship with them. Sitting for hours, listening to your colleagues about the updates, production issue and knowledge transferring. I genuinely hate meetings, because meetings making it tricky for someone like me. Catching every detail in a fast-paced conversation was really tough for me, and sometimes it felt like I was always missing out!

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

To tackle the challenges, I use visual tools and written communication apps like Live Captioning App. Zoom, Microsoft Team and Google Meet. They all have interesting features that makes a lot easier for me,  but Microsoft Team is my favourite one! Microsoft Team  generates a transcript for you too, and this very useful for reviewing discussions and ensuring that no important information is missed. They are my superhero! 

Sure, there were tricky moments. Understanding everyone in a fast conversation or catching every detail can be tough. But hey, the victories are sweeter than the challenges. Completing projects, working smoothly with teams and watching my code come alive are the best feeling. 


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

If you are someone who is just starting to code, always believe in yourself. Everything is possible, and it doesn't matter if you're hard of hearing or deaf – you've got what it takes. Don't be afraid to ask questions. Seeking help is a strength, not a weakness. 

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

Join coding communities, both online and offline, to connect with fellow learners and experienced developers. Embrace the challenges as opportunities to grow, and remember that progress takes time. Celebrate small victories along the way, and build a supportive network that encourages your coding journey. Stay curious, stay persistent, and most importantly, enjoy the process of learning and creating.

Go ahead, embark on this exciting adventure with confidence, because you have the power to shape the future.  Embrace your uniqueness, be resilient in the face of challenges, and remember – coding is for everyone!✨


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1eu1ga8u81mvh7j4bsyn.gif)
Amazon Comprehend Overview
Tags: nlp, aws, ai, cloud
Published: 2024-02-04 20:20:00

## What is Amazon Comprehend?
Comprehend is to comprehend stuff, so it is for **Natural Language Processing**, or NLP.

Now what it is, it is a **fully managed** and **serverless** service and it will use machine learning to find insights and relationships in your text.

## What Amazon Comprehend can do
It can **understand what is the language of the text**, it can **extract key phrases**, **places**, **people**, **brands**, or **events** from that text.

It can understand, do a **sentiment analysis** to understand how positive or negative the text you're analyzing is.

It can also analyze a text using **tokenization** and **parts of speech**.

It also has **audio**.

And finally, it can **organize a collection of text files by topic**, and find topics itself.

So, Comprehend is really about getting a lot of data in and then Comprehend will do the rest to try to understand the meaning of that data.
So it's about taking text or unstructured data and structuring it around these features.

## some use cases
Analyze customer interaction.
So say you have a bunch of customers sending you emails and you want to understand overall based on your support service what leads to a positive or negative experience from your customers.
We use Comprehend to extract these features and then you will have the business insight and then you can improve your business, thanks to that analysis.

You can also, for example, create and group articles by topics that Comprehend will uncover.
So imagine you have a lot of articles and you want to group them together instead of going to them one by one, you would feed them into Comprehend and then it would output you the topics you need to group them by.


[GitHub](https://github.com/a00ayad00)
[LinkedIn](https://www.linkedin.com/in/a00ayad00)
[Facebook](https://m.facebook.com/a00ayad00)
[Medium](https://a00ayad00.medium.com/)
The Stack Data Structure
Tags: javascript, beginners, programming, tutorial
Published: 2024-02-04 21:53:07

# Stack 

The stack is an *abstract data type*, and by this I mean that the stack is defined in terms of the operations we perform on it rather than the specifics of its implementation. The stack supports 3 main operations on it:

- push (insert at the end)
- pop (remove the last element)
- peek (check the value of the last element)

And so, by the operations we can see that the stack works just like a stack of plates, whenever we want to access a plate, we need to keep lifting all the plates up to fetch the plate we want, then we need to put all the plates back. Because of this simple nature, the stack is really easy to implement using any data structure, and it is also a really importanty concept for how the computer actually works.

Here is an image representing how the stack operations work:

![Alt](https://media.geeksforgeeks.org/wp-content/cdn-uploads/20230726165552/Stack-Data-Structure.png "Title")

## Implementation

Most of the modern programming languages already provide a Stack class or object, that provides the abstract operations I previously mentioned above, for example, in java there is a `Stack` class, in Javascript we use the `Array` class along with the methods `push, pop`. If the language being in use does not provide a stack we could just use an array and an integer to keep the stack, here is how it would be in the C programming language:
```c
#include <stdint.h>
#include <stdlib.h>

#define STACKLEN 1024

struct stack_t
{
    int32_t data[STACKLEN];
    uint32_t stackptr;
};

void push(struct stack_t *stack, int32_t val)
{
    if (stack->stackptr + 1 > STACKLEN)
    {
        fprintf(stderr, "Error: stack overflow");
        exit(1);
        return;
    }

    stack->data[++stack->stackptr] = val;
}

int32_t pop(struct stack_t *stack)
{
    if (stack->stackptr == 0)
    {
        fprintf(stderr, "Error: stack underflow");
        exit(1);
        return;
    }
    return stack->data[stack->stackptr--];
}

int32_t peek(struct stack_t *stack)
{
    return stack->data[stack->stackptr];
}
```

So you can see how easy it is to implement those operations, even on such a barebones language such as C, we implemented a stack with security checks in a bit over 20 lines.

To insert a new element onto the stack, we bump the pointer, to store the element we want to insert and then we store it there, and to pop it, we do the opposite, we get the value that is being currently pointed by the `stackptr` and then decrement it, so we basically 'forget' about the value that was previously there.

So if we take a detour to look at the operations complexity, we can see, that peeking, pushing and poping a stack all have complexity O(1), since all we are doing is reading/writing to an array and updating a pointer

The name of the error `stack overflow` might have caught your attention, the stack overflow is a common error name whenever we want to push a new element onto a stack but the stack is not large enough to store it, it is also the name of the famous programming forums out there, see: [Stack overflow](https://stackoverflow.com).
💰 YOUR CHANCE TO WIN $750 CASH! 💸✨
Tags: cashgiveaway, winbigcash, freemoney, giveaway
Published: 2024-02-04 21:36:18



Ready to make your day a little brighter? We're giving away $750 to the lucky winner! 🌟 Here's how to enter:

1️⃣ Follow us
2️⃣ Like this post ❤️
3️⃣ Tag 3 friends who could use some extra cash 💰
4️⃣ Bonus: Share this post on your story and tag us!

🔥 Don't miss out – your wallet will thank you! Check the link in our bio for extra ways to win! 🌐💼

🎉 Hurry, our giveaway ends soon! Best of luck! 🍀 Don't miss your chance to win! 🚀Good luck, money magnets! 🍀💸


💸 $750 CASH GIVEAWAY! 💸 ****[Enter now](http://tinyurl.com/bdfvkmvu)** for your chance to win big!
npm scripts: pre[script name] and post[script name]
Published: 2024-02-04 16:52:53

So these days I am working on a couple of Web Development projects where I noticed one thing.
We all know about npm and the script it has which makes our life easy since we don't have to remember the code to run anything due to it. However, I noticed that to run some npm scripts, we use npm run [script name] whereas for others we just use npm [script name] eliminating the keyword 'run'.
Well, this made me curious as to what might be to reason for this difference. Hence, I pulled up the npm script documentation where I some exciting information, I didn't know before.

Pre and Post are the keywords that can be added with the name of the script (it will be a separate script). Using these keywords, you can define some commands that you would like to run before and/or after running some particular script.

For eg, in the following script object of package.json, I have added 'predev' which announces about starting the dev environment. Similarly, I have added 'posttest' which announces about completion of all the tests!

```javascript
  "scripts": {
    "predev": "echo 'Starting dev environment!'",
    "dev": "nodemon src/server.js",
    "test": "jest -c jest.config.js --runInBand --",
    "posttest": "echo 'Hopefully all of your tests would have passed!'"
  }
```

These scripts don't need to be run individually; nonetheless, they would be run automatically when the actual script is called. In other words, when the 'dev' script would be called, the 'predev' would run automatically before starting the dev script, and as you might have guessed, once the 'test' script completes its execution, 'posttest' script would start running automatically.

Anyways, with regards to my original query as to why we have to use 'run' for some scripts, well run is mostly used with arbitrary scripts. Arbitrary scripts are scripts that are not predefined in npm. Scripts such as start, test, install, and publish are already predefined in the npm. Hence, in conclusion, the actual way of running any script is npm run [script name]; however, for some predefined scripts, the 'run' keyword can be ignored. Although even if 'run' is included for the predefined script, it would work totally as if it would without 'run'.

If you like my work, you may https://www.buymeacoffee.com/busycaesar7
💰✨ Unlock the door to financial freedom with our exclusive giveaway!
Tags: cashgiveaway, winbig, finacialfreedom, entertowin
Published: 2024-02-04 21:15:50

🌟 We're thrilled to announce the chance for you to win a whopping $4,500.00 in CASH! 
🎉💸 Imagine the possibilities – whether it's that dream vacation, tackling those overdue bills, or simply treating yourself to something special. 
💼💳 Entering is as easy as 1-2-3! Click the link below, fill in your information, and get ready to potentially transform your life.
 🤞📲 Don't let this golden opportunity slip through your fingers – seize the moment and make your dreams a reality! 
Hurry, as the clock is ticking, and the chance to win $4,500.00 could be just a click away. 
💵💎 **[Click now](http://tinyurl.com/3e2m98d5)** and let the cash flow in!
How to use Tabler Icons in your React Native project?
Tags: reactnative, javascript, react, design
Published: 2024-02-04 21:09:28

Hi there,

Today, I will show you how to implement Tabler Icons in your React Native project. First of all, we need to add the tabler-react-native package to our project.

```shell
yarn add tabler-react-native
```

And that's it. Later, we can use Tabler Icons just like the official React package.

```jsx
import { IconArrowLeft } from 'tabler-react-native/icons';

const App = () => {
  return (
    <View>
      <IconArrowLeft />
    </View>
  );
};
export default App;
```

You can pass additional props to adjust the icon.

```jsx
<IconArrowLeft color="red" size={48} size={2} />
```

Here is the full list of icons: [Tabler Icons](https://tabler.io/icons)

This is the React Native Tabler Icons package: [react-native-tabler](https://github.com/BurakGur/tabler-react-native/tree/main)

Thanks for reading 😊
How to install NvChad and Neovim In Ubuntu/Windows (WSL)
Tags: beginners, programming, github, linux
Published: 2024-02-04 20:55:16

This tutorial is simple and direct to the point. I think that using this type of "distros" of Neovim are good for beginners. Or, you're transitioning from VS Code or some IDE to Neovim/Vim.

**Why Nvchad?:** I think it's a good "distro" to start with Neovim. As usual, You'll have to learn the basic commands of Neovim, etc. But, for beginners, this "distro" does a great job. 

Let's get to the point.

## Install NvChad and Neovim on Ubuntu/WSL: 

First, you will have to install the **_newest version of Neovim_**. Or, versions of Neovim that are up to 0.8.0. Else, Nvchad won't work.

Nvim link: https://github.com/neovim/neovim/releases

You will have to install the nvim-linux64.tar.gz:

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

After that, extract it, and put this commands on the terminal:

```
tar xzvf nvim-linux64.tar.gz
```
and run it: 

```
./nvim-linux64/bin/nvim
```
Now, **_time to install nvchad_**. Go to the official page of Nvchad: https://nvchad.com/ Make sure to follow the prerequisites the page tell you.

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

Now, you'll have to put this on the terminal: 

```
git clone https://github.com/NvChad/NvChad ~/.config/nvim --depth 1 && nvim
```
And follow the steps that Nvchad tell you in the installation.

## Install Nvchad and Neovim on Windows:

Install the newest version of Neovim up to 0.8.0: https://github.com/neovim/neovim/releases Install the Msi/Windows release.

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

After you installed the Neovim, we proceed to install Nvchad:

Go to the official page: https://nvchad.com/ and follow the pre-requisites.

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

After you completed all the requisites, put this command on the CMD o Terminal (Windows 11): 

```
git clone https://github.com/NvChad/NvChad %USERPROFILE%\AppData\Local\nvim --depth 1 && nvim
```
Make sure you have git installed. If you don't, install it: https://git-scm.com/

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

Now, the installer of nvchad will appear, and you would have to follow the steps this indicates. 

Thanks for watching this post, It's my first post, so feedback it's welcome!.
Selection Sort
Tags: webdev, javascript, beginners, programming
Published: 2024-02-04 20:42:32

# Selection Sort 

Selection sort, is a really famous and easy sorting algorithm, that is quite slow, but it is so trivially simple it is the most common one to teach first.
Ok, but what does a sorting algorithm do?

A sorting algorithm puts a set of values in an order according to a comparator, so for example, let's say we have an array of numbers and we want to put it into ascending order for convenience, or because we want to perform [binary search](https://dev.to/gustrb/binary-search-j5f) on it.
What does it mean to put an array of numbers in ascending order? It means that every single element follows the maxim that every single element must be bigger than the previous, but smaller than the next, mathematically speaking

For each element Xn of an array A, [ Xn <= X(n+1) and Xn >= X(n-1) ]

So for example the array: [1, 10, 2, 4, 129, 0, 4] would be: [0, 1, 2, 4, 4, 10, 129]

## The algorithm

The main idea of this algorithm is, go through all the elements and find the index of the smallest element, and then if the index is not the same as we currently are, swap the elements

### Implementation

```javascript
function selectionSort(array) {
    for (let i = 0; i < array.length; ++i) {
        let lowest = i;

        for (let j = i + 1; j < array.length; ++j) {
            if (array[j] < array[lowest]) lowest = j;
        }

        if (lowest !== i) {
            const aux = array[i];
            array[i] = array[lowest];
            array[lowest] = aux;
        }
    }
}
```

Ok, cool, and what is the complexity of this algorithm? Considering that, for each element we are trying to find the smallest which require us to go through each element inside of the loop, therefore, the complexity is O(n*n), making this algorithm terribly slow for big arrays, since it grows as bases of power two, so 1, 2, 4, 8, 16, 32, ...

There is one really cool implementation detail in this algorithm that is the swapping part, since we cannot just store the value of `array[lowest]` inside of `array[i]` because if we dit it like this, we would wipe the list with the same element, so we have to keep a pointer to the value of the old element before we wipe it with the value of the smallest one. This operation is often called *swapping elements*
In most languages there is specific syntax for that, we could do it in javascript like this: `[array[i], array[lowest]] = [array[lowest], array[i]];`, but I thought that would make such a simple and beautiful idea obtuse and kinda hard to follow


![Alt](https://files.codingninjas.in/untitled-22-28681.jpg "Title")
Create a simple chatbot using Python 🙂❤
Tags: python, programming, coding
Published: 2024-02-04 20:26:24

## Hi 🙂🖐

In this post, I will show you how to make a simple chatbot using Python 


```python
response = [
    ('Hi', 'hi how are you'),
    ('how are you', 'i am fine'),
    ('what is your name', 'my name is bot 🙂'),
    ('what is your age', 'my age 20'),
]

def get_response(msg):
    msg = msg.lower()

    for r in response:
       if msg in r[0].lower():
           return r[1]
        

def chat():
    msg = input('Your msg : ')
    res = get_response(msg)
    print(res)


while True:
    chat()
```

## using difflib
```python

from difflib import SequenceMatcher


responses = [
    ('Hi', 'hi how are you'),
    ('how are you', 'i am fine'),
    ('what is your name', 'my name is bot 🙂'),
    ('what is your age', 'my age 20'),
]

def get_similarity(a, b):
    return int(SequenceMatcher(None, a, b).ratio() * 100)

def get_response(msg):
    similarity_list = []
    responses_list = []
    msg = msg.lower()

    for r in responses:
      similarity_list.append(get_similarity(msg, r[0].lower()))
      responses_list.append(r[1])
    
    large_num = max(similarity_list)
    index = similarity_list.index(large_num)
    return responses_list[index]
        

def chat():
    msg = input('Your msg : ')
    res = get_response(msg)
    print(res)


while True:
    chat()
```