teleren/devto huggingface dataset:
bash ChatGPT
Tags: bash, chatgpt, tutorial, ai
Published: 2023-06-21 10:22:09

I often need to quickly ask ChatGPT something using a `Linux`/`GitBash` terminal, so I wrote this bash script to facilitate that. Main goal is terminal friendly output, without any additional dependency requirement for gitbash, so I used `curl`,`sed` and `fold`.

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

> write to chatgpt.sh - do not forget your key!

```bash
#!/bin/sh
curl=`cat <<EOS
curl -sS --location --insecure --request POST 'https://api.openai.com/v1/chat/completions' \
--header 'Authorization: Bearer <OPEN_AI_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
 "model": "gpt-3.5-turbo",
 "max_tokens": 2000,
 "messages": [{"role": "user", "content": "$1"}]
}'
EOS`
eval ${curl} | sed -En 's/.*"content": "(.*)"/\1/p' | sed 's/\\n/\n/g' | fold -s
```
> maybe add to `~/.bashrc` some `alias`
```bash
alias ai='sh ~/chathgpt.sh'
```

## use 
```bash
ai "write bash chatgpt call which give formated text result"
```

Happy coding!
8 Lesser-Known Redis Use Cases - Redis Cache
Tags: redis, rediscache, elastica, elasticache
Published: 2023-06-21 10:02:05

Redis cache is a caching mechanism that utilizes the Redis in-memory data store to store and retrieve frequently accessed data. It acts as a temporary storage layer between an application and its primary data source, enhancing performance by reducing the need for repetitive database or API calls. Redis cache stores data in memory, making it highly responsive and enabling quick retrieval. By caching frequently accessed data, Redis cache significantly reduces latency, improves application responsiveness, and alleviates the load on the underlying data storage system.

Redis is commonly perceived as a caching tool, but its capabilities extend far beyond that. Here are some lesser-known applications of Redis:

## 1. Message Queue
Redis functions as a message queue, allowing asynchronous communication between processes. This feature aids in decoupling components within a distributed system.

## 2. Session Store
Redis can serve as a session store, enhancing performance in web applications by minimizing database queries for each request.

## 3. Rate Limiting
Redis enables the implementation of rate limiting mechanisms to prevent abuse of APIs or other resources. For instance, you can restrict the number of requests an IP address can make within a specific time frame.

## 4. Counters
Redis can maintain counters, such as tracking the frequency of specific events. This feature proves beneficial in various scenarios, such as monitoring page views on a website.

## 5. Distributed Locks
Redis can function as a distributed lock, ensuring exclusive access to a resource by only one process at a time. This is particularly useful in distributed systems where multiple processes may attempt to access the same resource simultaneously.

## 6. Geospatial
Redis supports efficient storage and querying of geospatial data, making it valuable in applications that require geospatial indexing, such as location-based services.

## 7. Leaderboards
Redis facilitates the creation of leaderboards or rankings, commonly seen in gaming applications. It proves helpful in tracking high scores and other performance metrics.

## 8. Time-Series Data Storage and Analysis
Redis can effectively store and analyze time-series data, including server metrics and data from IoT sensors.
Khóa học SEO cộng hưởng tại IMTA
Published: 2023-06-21 09:38:48

Khóa học SEO cộng hưởng tại IMTA với hương pháp SEO trọng tâm một vài từ khóa chính sẽ kéo theo hàng loạt từ khóa phụ lên top mà bạn không cần phải tiêu tốn thêm bất cứ tài nguyên hay backlink nào.
https://imta.edu.vn/khoa-hoc-content-marketing/
Location: Tầng 4, Tòa Nhà Charmington La Pointe , Số 181 Cao Thắng nối dài, Phường 12, Quận 10, Hồ Chí Minh
Phone: 0896677499
Email: info@imta.edu.vn

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jkaudb7cxjgf01ti0ps1.jpg)
Understanding the Record Type Implementation in TypeScript
Tags: typescript
Published: 2023-06-21 09:35:08

## What is the Record Type in TypeScript?
Firstly, let's talk about the Record feature in TypeScript.

You can find an explanation of the Record type at the following URL:
https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type

The Record type maps one type to another by accepting two types. 

For instance:
```
type RGBColors = Record<'red' | 'green' | 'blue', number>;
```
Here, the Record type maps the number type (the second argument) to the union of "red", "green", and "blue" (the first argument). 

The result is:
```
type RGBColors = {
  "red": number;
  "green": number;
  "blue": number;
}
```

## Understanding the Record Type Implementation in TypeScript
You can examine the implementation of the Record type at the following URL:
https://github.com/microsoft/TypeScript/blob/5d8ef4bdcb8bdbd4307c74a07b01e3bdf6e04b6a/lib/lib.es5.d.ts#L1590

```
/**
 * Construct a type with a set of properties K of type T
 */
type Record<K extends keyof any, T> = {
    [P in K]: T;
};
```
The Record type accepts two arguments:

The first argument is `K extends keyof any`, which corresponds to `"string" | "number" | "symbol"`. Hence, the first argument can be of `"string" | "number" | "symbol"` type.
The second argument, `T`, is a generic argument. It can accept all types.

Now, let's take a look into the Record type. 
The key is `[P in K]`. The `in` keyword is used to iterate over `K` to map `P`.

For example, when `K` is `"red" | "green" | "blue"`, `[P in K]` generates keys that are `"red" | "green" | "blue"`.

Let's revisit the RGBColors type from earlier:
```
type RGBColors = Record<'red' | 'green' | 'blue', number>;

// This is equivalent to the above RGBColors.
type RGBColors = {
  "red": number;
  "green": number;
  "blue": number;
}
```

With this explanation, we should now have a better understanding of the Record type in TypeScript.
What is Avro Serialization in Hadoop?
Tags: bigdata
Published: 2023-06-21 09:34:50

Avro serialization is a data serialization framework in the Apache Hadoop ecosystem. It is a compact and efficient binary serialization format that allows data to be serialized and deserialized across various programming languages. Avro provides a schema-based approach to data serialization, which means that the structure of the data is defined using schemas, enabling compatibility and interoperability between different systems.

In Avro, data is serialized into a compact binary format that is optimized for efficient storage and transmission. Avro schemas define the structure of the data, including the data types, field names, and hierarchical relationships. The schema is typically defined using JSON, which makes it easy to understand and work with.

One of the key advantages of Avro serialization is its support for schema evolution. This means that the schema can evolve over time without breaking compatibility with existing data. New fields can be added, fields can be renamed, and field types can be changed, all while maintaining compatibility with previously serialized data. This flexibility is crucial in big data environments where data schemas often need to evolve to accommodate changing business requirements.

Avro serialization also supports dynamic typing, which means that data can be serialized without specifying the schema explicitly. The schema can be included with the serialized data, allowing systems to interpret the data dynamically based on the schema provided.

In the Hadoop ecosystem, Avro is commonly used in conjunction with other components such as Apache Kafka, Apache Spark, and Apache Hive. It provides a standardized and efficient way to exchange data between different systems and applications within the Hadoop ecosystem.

Overall, Avro serialization in Hadoop offers a flexible, efficient, and schema-based approach to data serialization. Its compatibility, schema evolution support, and interoperability make it a popular choice for handling large-scale data processing and data interchange in the Hadoop ecosystem. By obtaining a [Big Data Certification](https://www.edureka.co/big-data-hadoop-training-certification), you can advance your career in Big Data. With this course, you can demonstrate your expertise in ocial Media, Aviation, Tourism, and Finance domains using Edureka's Cloud Lab. Edureka's Online Big Data Course provides you outstanding professional training with industry-based Projects, many more fundamental concepts, and many more critical concepts among others.
Welcome Thread - v230
Tags: welcome
Published: 2023-06-21 09:30:00

---
title: Welcome Thread - v230
published: true
description: Welcome to DEV! A thread of hellos and intros.
tags: welcome, test2
published_at: 2023-06-21 09:30
---

![hello in blue and white splashing into frame on a black background](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ph4siqexooep23d5579m.gif)

---

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

3. If you are new to coding, want to help beginners in their programming journey, or just want another awesome place to connect with fellow developers, check out the [CodeNewbie Org](https://dev.to/codenewbieteam)!
How useMemo and useCallback hooks work?
Published: 2023-06-21 08:57:04

The useMemo and useCallback hooks are almost the same but designed and developed for different reasons. The implementation is the same they both expect a function and array of dependencies.

**Implementation example**
`useMemo(()=>{},[])` 
`useCallback(()=>{},[])`
The above code do look similar but serves different purposes.

**Difference between useMemo and useCallback** 

- useMemo calls it's function and return the memoized results while useCallback return it's memoized function when dependencies changes.
- useMemo only compute when there was a change in dependencies and return memoized results.

**What is Memoization?**
**Memoization** in javascript is an optimisation technique, to reduce the complexity of the application, runtime of the application, and proper utilisation of resources (Time and Memory).

By understanding how to use this two hooks properly it will help improving your applications performance.

**How does useMemo() work in react?**

`const memoizedValue = useMemo(function,dependencies)`

On an initial rendering useMemo invokes the **function**, memoize the calculated result and then returns it to the component.
If the there's no change on **dependencies** during the next rendering, then useMemo will not invoke the function, but it will returns the memoize value.

**How does useCallback() work in react?**

`const memoizedFunction = useMemo(function,dependencies)`

React useCallback Hook returns a memoized callback function. Think of memoization as caching a value so that it does not need to be recalculated. This allows us to isolate resource intensive functions so that they will not automatically run on every render, but only run when the was a change in dependencies.

**In Conclusion**

Understanding how this hooks should help developers to implement them in a correct way, to ensure applications are as optimised as possible. This will also help to avoid creating or running functions every render.
ChatGPT at Work: How to block Content Leaks 🔒
Tags: chatgpt, security, tutorial, coding
Published: 2023-06-21 09:04:34

ChatGPT is a powerful tool, but it can also **be risky** if misused in a **business environment**. Several companies have experienced **data leaks** due to careless employees.

Even with caution, ChatGPT has had data leaks in the past, so how can you **protect yourself**?

## Table of Contents:
1. Disable Training and History
2. Verify Your Shared Discussions
3. Tips for Usage


## 1. Disable Training and History
This feature was recently added, and it allows you to prevent ChatGPT from **recording your conversations** for the purpose of improving its performance.

Your new discussions will **not be saved** (the previous ones will still be retained), ensuring that no traces are left. To access this feature, go to the settings menu:
![Chatgpt Settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wk0phxkk0dx90pifreqc.png)

Now, disable the history.
![Disable Chatgpt history](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cookpypstktpji8eguqn.png)
There you go! You won't have access to your history anymore, so enable it only when you're at work (by reactivating it, your previous history will reappear).

## 2. Check your shared discussions
It is now possible to **share ChatGPT discussions** , so make sure to verify that you are not sharing any work-related discussions!
![Shared discussion panel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w57arfw8mvhy0anqc7j0.png)
This might sound funny, but mistakes can happen, so click on the trash bin icon.

## 3. Tips for Usage
We have configured everything, but it's difficult to trust 100% Chatgpt!
Here are some tips:
- Do not copy and paste confidential documents without removing sensitive data.
- Disable the history every time you're at work, don't forget!
- Your data passes through a server, even if the history is not saved, so be mindful of not using insecure Wi-Fi networks to prevent data interception.
- Pay attention to whether your company prohibits its usage.

## Conclusion
ChatGPT provides us with options to have **secure discussions**. However, it is still important to **remain vigilant**. It is a powerful tool, so don't forget to use it wisely!

Feel free to ask any questions or provide any feedback. And don't forget to **subscribe** and **like**!😊
memento pattern
Published: 2023-06-21 09:00:00

---
title: memento pattern
published: true
description: design pattern
tags: 
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c3hsyjxgvdraf6yvz1ja.jpg
series: php
---

## Elements

Is is composed by two elements. First one is an originator. Second one is memento. It separate object state from object manipulation. Memento class store the status. Originator class manipulate the status.

## Memento class

Code speak itself. This class read a content and provide same content. The content is the status of the book (libro in italian).

```php
class LibroMemento
{
    public function __construct(private string $content)
    {

    }

    public function getContent()
    {
        return $this->content;
    }
}
```

## Originator class

In this case the originator class add paragraph to the book content. It contains two special methods: save and restore. Save generate a memento object. It contains the content of the book and create a memento instance with that content. Then with restore, get the content from a memento and become that object.

```php
class Libro
{
    public function __construct(private string $content = '') {}
    public function addParagrafo(string $paragrafo)
    {
        $this->content .= "\n" . $paragrafo;
    }

    public function save()
    {
        return new LibroMemento($this->content);
    }

    public function restore(LibroMemento $libro)
    {
        $this->content = $libro->getContent();
    }

    public function __toString()
    {
        return $this->content;
    }
}
```

## Usage

In this first case, echo returns

> Ciao sono Simone
> Sono un programmatore

```php
$libro = new Libro;
$libro->addParagrafo('Ciao sono Simone');
$savepoint = $libro->save();
$libro->addParagrafo('Sono un programmatore');
echo $libro;
```

In this first case, echo returns

> Ciao sono Simone

Because `$savepoint` contains only first paragraph.

```php
$libro->restore($savepoint);
echo $libro;
```

## Conclusion

This pattern is commonly used in software of video, image, text editors and games. It separate the logic of updates from the status itself.
Clipperlink URL Shortener
Tags: link, developers
Published: 2023-06-21 08:57:05

Hi everyone. I have built a URL shortening app with the ability to manage your links, track click counts and also view some useful analytics about the performance of your link [https://clipperlink.com/](clipperlink.com).
This is my second attempt at building a SaaS as the first one didn't work out well :) so I decided to try something much more simpler. 
Let me know what you think in the comments when you check it out. I will really love some ideas on to how to improve user signups etc.
Does kong api gateway 2.1 version supports statsd plugin?
Published: 2023-06-21 08:56:48

Hi friends,
I am using kong api gateway 2.1 version (open source)
I am already enabled statsd plugin in api gateway side ,but i cant able to fetch any kind of metrics (like service metrics and log metrics)
does kong 2.1 is support statsd or not?
please tell if you have any other ways to fetch service metrics and log metrics in kong api gateway.I am waiting for your answers
how to hide header and footer when page is 404
Tags: react
Published: 2023-06-21 08:25:59

import React from "react";
import { BrowserRouter as Router } from "react-router-dom";
import { RootRoute } from "../RootRoute";
import "./auth.scss";
import "./app.scss";
import $ from "jquery";

import { Footer } from "./common/footer";
import { Header } from "./common/header";

const App = () => {
  return (
    <main className="app" data-testid="main-app">
      <Router>
        <Header />
        <RootRoute />
        <Footer />
      </Router>
    </main>
  );
};

export default App;
Return Statement in Coding Languages
Tags: tutorial, coding, programming, beginners
Published: 2023-06-21 08:24:04

This blog is for all the new comers in coding world. This article will cover the most common yet crucial part of any programing language that is **The return statement**

## What is return statement

Return state is used in functions. 

A return statement causes execution of the function to leave the current function and resume at the point in the code immediately after where the function was called. Return statements in many languages allow a function to specify a return value to be passed back to the code that called the function.

It is important to understand that a return statement is not stopping the execution of a whole code file but a certain function, because it is function scoped.


For example--

```js

function printMsg() {
return 'hi'
}

printMsg();


//output
hi
```

## Usecases

Return statement is useful in many cases. It is mostly used to get the desired output from a function. 

It can be used to get a certain value out of a function or getting modified data.

For example--

```js

function greetings(name){
return ('Hi'+name)
}

greetings('John');

}

//output
Hi John
```

In the above example the function it taking an argument and returning it with an appended string.

## Conclusion
I hope you understand the very basic usecase of return statement. Please comment if you have any query or suggestions to improve the overall content deliveriness.
Exploring the Future of Search Engines: What to Expect
Tags: searchengine, webdev
Published: 2023-06-21 08:19:32

In today's fast-paced digital world, search engines play a vital role in our daily lives. They help us find information, discover new things, and navigate the vast online world. 

But have you ever wondered what search engines will look like in the future? In this blog post, let's take a peek into what the future might hold for search engines.

## Personalized Results:
Future search engines will be smarter at understanding what we need. They will use fancy technologies like artificial intelligence and machine learning to learn from our behavior and preferences. 

This means they'll deliver search results tailored to our specific interests and also it will helps for [marketing](https://www.qined.com/t/marketing). Imagine a search engine that knows exactly what you're looking for and shows you the most relevant results. It will make your online experience quicker and more enjoyable.

## Voice and Visual Search:
The future of search engines will be more interactive and easy to use. Instead of typing, you'll be able to talk to the search engine using your natural language. 

Just say what you're looking for, and it will understand you. Not only that, but future search engines will also let you search using pictures. Imagine being able to take a photo and find information about it instantly. It will make searching more intuitive and convenient.

## Exciting Virtual Experiences:
As technology progresses, search engines will integrate augmented reality (AR) and virtual reality (VR) into their results. This means you'll be able to experience things virtually. 

For example, you could try on clothes using your phone's camera or see how furniture would look in your home before buying it. It will make shopping and other activities more fun and interactive.

The future of search engines is bright and filled with exciting possibilities. With enhanced personalization, voice and visual search options, and the integration of AR and VR, searching the web will become more intuitive and engaging.
Why Native Apps Are Dying?
Tags: nativeapps, mobileapp
Published: 2023-06-21 07:54:14

---
title: Why Native Apps Are Dying?
published: True
description: However, it's important to assess the specific requirements of your project.
tags: #NativeApps #mobileApp
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-06-21 07:51 +0000
---
While it is true that the development landscape has evolved significantly in recent years, declaring that native apps are dead would be an oversimplification. Native apps, which are specifically developed for a particular platform (e.g., iOS or Android) using platform-specific programming languages (Swift/Objective-C for iOS, Java/Kotlin for Android), still hold significant value and advantages in many scenarios. Here are a few points to consider:

<b>Performance:</b>

Native apps generally offer better performance and responsiveness compared to cross-platform or hybrid apps. They can fully leverage the native capabilities of the underlying operating system and utilize the device's hardware, resulting in a smoother user experience.

<b>Access to device features:</b>

Native apps have direct access to the device's features, such as the camera, GPS, accelerometer, and other hardware components. This enables developers to create richer and more seamless user experiences that are closely integrated with the device's capabilities.

<b>User experience:</b>

Native apps can adhere to the platform-specific design guidelines and user interface paradigms, providing a consistent and familiar experience to users. This can enhance usability, navigation, and overall user satisfaction.

<b>Performance-intensive applications:</b>

For certain types of apps that require extensive computing power or real-time processing, such as gaming or augmented reality applications, native development is often the preferred choice due to its ability to optimize performance and utilize advanced graphics libraries.

<b>Platform-specific functionalities:</b>

<a href="https://www.cmarix.com/native-app-development.html"><b>Native app development</b></a> allows you to leverage platform-specific functionalities and APIs that may not be accessible or well-supported in cross-platform development frameworks. This can be crucial when you need to implement specific platform-dependent features.

While cross-platform and hybrid app development frameworks have gained popularity due to their ability to write code once and deploy it across multiple platforms, they may not always match the performance, native feel, and access to all platform features that native apps can offer. However, it's important to assess the specific requirements of your project, including time-to-market, budget constraints, and target audience, to determine the most suitable approach for your app development.